documentation.d.ts 3.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Represens a plane by the equation ax + by + cz + d = 0
  1909. */
  1910. export class Plane {
  1911. private static _TmpMatrix;
  1912. /**
  1913. * Normal of the plane (a,b,c)
  1914. */
  1915. normal: Vector3;
  1916. /**
  1917. * d component of the plane
  1918. */
  1919. d: number;
  1920. /**
  1921. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1922. * @param a a component of the plane
  1923. * @param b b component of the plane
  1924. * @param c c component of the plane
  1925. * @param d d component of the plane
  1926. */
  1927. constructor(a: number, b: number, c: number, d: number);
  1928. /**
  1929. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1930. */
  1931. asArray(): number[];
  1932. /**
  1933. * @returns a new plane copied from the current Plane.
  1934. */
  1935. clone(): Plane;
  1936. /**
  1937. * @returns the string "Plane".
  1938. */
  1939. getClassName(): string;
  1940. /**
  1941. * @returns the Plane hash code.
  1942. */
  1943. getHashCode(): number;
  1944. /**
  1945. * Normalize the current Plane in place.
  1946. * @returns the updated Plane.
  1947. */
  1948. normalize(): Plane;
  1949. /**
  1950. * Applies a transformation the plane and returns the result
  1951. * @param transformation the transformation matrix to be applied to the plane
  1952. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1953. */
  1954. transform(transformation: DeepImmutable<Matrix>): Plane;
  1955. /**
  1956. * Compute the dot product between the point and the plane normal
  1957. * @param point point to calculate the dot product with
  1958. * @returns the dot product (float) of the point coordinates and the plane normal.
  1959. */
  1960. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1961. /**
  1962. * Updates the current Plane from the plane defined by the three given points.
  1963. * @param point1 one of the points used to contruct the plane
  1964. * @param point2 one of the points used to contruct the plane
  1965. * @param point3 one of the points used to contruct the plane
  1966. * @returns the updated Plane.
  1967. */
  1968. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1969. /**
  1970. * Checks if the plane is facing a given direction
  1971. * @param direction the direction to check if the plane is facing
  1972. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1973. * @returns True is the vector "direction" is the same side than the plane normal.
  1974. */
  1975. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1976. /**
  1977. * Calculates the distance to a point
  1978. * @param point point to calculate distance to
  1979. * @returns the signed distance (float) from the given point to the Plane.
  1980. */
  1981. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1982. /**
  1983. * Creates a plane from an array
  1984. * @param array the array to create a plane from
  1985. * @returns a new Plane from the given array.
  1986. */
  1987. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1988. /**
  1989. * Creates a plane from three points
  1990. * @param point1 point used to create the plane
  1991. * @param point2 point used to create the plane
  1992. * @param point3 point used to create the plane
  1993. * @returns a new Plane defined by the three given points.
  1994. */
  1995. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1996. /**
  1997. * Creates a plane from an origin point and a normal
  1998. * @param origin origin of the plane to be constructed
  1999. * @param normal normal of the plane to be constructed
  2000. * @returns a new Plane the normal vector to this plane at the given origin point.
  2001. * Note : the vector "normal" is updated because normalized.
  2002. */
  2003. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Calculates the distance from a plane and a point
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @param point point to calculate distance to
  2009. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2010. */
  2011. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2012. }
  2013. }
  2014. declare module BABYLON {
  2015. /**
  2016. * Class representing a vector containing 2 coordinates
  2017. */
  2018. export class Vector2 {
  2019. /** defines the first coordinate */
  2020. x: number;
  2021. /** defines the second coordinate */
  2022. y: number;
  2023. /**
  2024. * Creates a new Vector2 from the given x and y coordinates
  2025. * @param x defines the first coordinate
  2026. * @param y defines the second coordinate
  2027. */
  2028. constructor(
  2029. /** defines the first coordinate */
  2030. x?: number,
  2031. /** defines the second coordinate */
  2032. y?: number);
  2033. /**
  2034. * Gets a string with the Vector2 coordinates
  2035. * @returns a string with the Vector2 coordinates
  2036. */
  2037. toString(): string;
  2038. /**
  2039. * Gets class name
  2040. * @returns the string "Vector2"
  2041. */
  2042. getClassName(): string;
  2043. /**
  2044. * Gets current vector hash code
  2045. * @returns the Vector2 hash code as a number
  2046. */
  2047. getHashCode(): number;
  2048. /**
  2049. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2050. * @param array defines the source array
  2051. * @param index defines the offset in source array
  2052. * @returns the current Vector2
  2053. */
  2054. toArray(array: FloatArray, index?: number): Vector2;
  2055. /**
  2056. * Copy the current vector to an array
  2057. * @returns a new array with 2 elements: the Vector2 coordinates.
  2058. */
  2059. asArray(): number[];
  2060. /**
  2061. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2062. * @param source defines the source Vector2
  2063. * @returns the current updated Vector2
  2064. */
  2065. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2066. /**
  2067. * Sets the Vector2 coordinates with the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns the current updated Vector2
  2071. */
  2072. copyFromFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Sets the Vector2 coordinates with the given floats
  2075. * @param x defines the first coordinate
  2076. * @param y defines the second coordinate
  2077. * @returns the current updated Vector2
  2078. */
  2079. set(x: number, y: number): Vector2;
  2080. /**
  2081. * Add another vector with the current one
  2082. * @param otherVector defines the other vector
  2083. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2084. */
  2085. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2086. /**
  2087. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2088. * @param otherVector defines the other vector
  2089. * @param result defines the target vector
  2090. * @returns the unmodified current Vector2
  2091. */
  2092. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2093. /**
  2094. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2095. * @param otherVector defines the other vector
  2096. * @returns the current updated Vector2
  2097. */
  2098. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2099. /**
  2100. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2101. * @param otherVector defines the other vector
  2102. * @returns a new Vector2
  2103. */
  2104. addVector3(otherVector: Vector3): Vector2;
  2105. /**
  2106. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2107. * @param otherVector defines the other vector
  2108. * @returns a new Vector2
  2109. */
  2110. subtract(otherVector: Vector2): Vector2;
  2111. /**
  2112. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2113. * @param otherVector defines the other vector
  2114. * @param result defines the target vector
  2115. * @returns the unmodified current Vector2
  2116. */
  2117. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2118. /**
  2119. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2120. * @param otherVector defines the other vector
  2121. * @returns the current updated Vector2
  2122. */
  2123. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2124. /**
  2125. * Multiplies in place the current Vector2 coordinates by the given ones
  2126. * @param otherVector defines the other vector
  2127. * @returns the current updated Vector2
  2128. */
  2129. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @returns a new Vector2
  2134. */
  2135. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2136. /**
  2137. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2138. * @param otherVector defines the other vector
  2139. * @param result defines the target vector
  2140. * @returns the unmodified current Vector2
  2141. */
  2142. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2143. /**
  2144. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2145. * @param x defines the first coordinate
  2146. * @param y defines the second coordinate
  2147. * @returns a new Vector2
  2148. */
  2149. multiplyByFloats(x: number, y: number): Vector2;
  2150. /**
  2151. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. divide(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Divides the current Vector2 coordinates by the given ones
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Gets a new Vector2 with current Vector2 negated coordinates
  2171. * @returns a new Vector2
  2172. */
  2173. negate(): Vector2;
  2174. /**
  2175. * Negate this vector in place
  2176. * @returns this
  2177. */
  2178. negateInPlace(): Vector2;
  2179. /**
  2180. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2181. * @param result defines the Vector3 object where to store the result
  2182. * @returns the current Vector2
  2183. */
  2184. negateToRef(result: Vector2): Vector2;
  2185. /**
  2186. * Multiply the Vector2 coordinates by scale
  2187. * @param scale defines the scaling factor
  2188. * @returns the current updated Vector2
  2189. */
  2190. scaleInPlace(scale: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2193. * @param scale defines the scaling factor
  2194. * @returns a new Vector2
  2195. */
  2196. scale(scale: number): Vector2;
  2197. /**
  2198. * Scale the current Vector2 values by a factor to a given Vector2
  2199. * @param scale defines the scale factor
  2200. * @param result defines the Vector2 object where to store the result
  2201. * @returns the unmodified current Vector2
  2202. */
  2203. scaleToRef(scale: number, result: Vector2): Vector2;
  2204. /**
  2205. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2206. * @param scale defines the scale factor
  2207. * @param result defines the Vector2 object where to store the result
  2208. * @returns the unmodified current Vector2
  2209. */
  2210. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2211. /**
  2212. * Gets a boolean if two vectors are equals
  2213. * @param otherVector defines the other vector
  2214. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2215. */
  2216. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2217. /**
  2218. * Gets a boolean if two vectors are equals (using an epsilon value)
  2219. * @param otherVector defines the other vector
  2220. * @param epsilon defines the minimal distance to consider equality
  2221. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2222. */
  2223. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2224. /**
  2225. * Gets a new Vector2 from current Vector2 floored values
  2226. * @returns a new Vector2
  2227. */
  2228. floor(): Vector2;
  2229. /**
  2230. * Gets a new Vector2 from current Vector2 floored values
  2231. * @returns a new Vector2
  2232. */
  2233. fract(): Vector2;
  2234. /**
  2235. * Gets the length of the vector
  2236. * @returns the vector length (float)
  2237. */
  2238. length(): number;
  2239. /**
  2240. * Gets the vector squared length
  2241. * @returns the vector squared length (float)
  2242. */
  2243. lengthSquared(): number;
  2244. /**
  2245. * Normalize the vector
  2246. * @returns the current updated Vector2
  2247. */
  2248. normalize(): Vector2;
  2249. /**
  2250. * Gets a new Vector2 copied from the Vector2
  2251. * @returns a new Vector2
  2252. */
  2253. clone(): Vector2;
  2254. /**
  2255. * Gets a new Vector2(0, 0)
  2256. * @returns a new Vector2
  2257. */
  2258. static Zero(): Vector2;
  2259. /**
  2260. * Gets a new Vector2(1, 1)
  2261. * @returns a new Vector2
  2262. */
  2263. static One(): Vector2;
  2264. /**
  2265. * Gets a new Vector2 set from the given index element of the given array
  2266. * @param array defines the data source
  2267. * @param offset defines the offset in the data source
  2268. * @returns a new Vector2
  2269. */
  2270. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2271. /**
  2272. * Sets "result" from the given index element of the given array
  2273. * @param array defines the data source
  2274. * @param offset defines the offset in the data source
  2275. * @param result defines the target vector
  2276. */
  2277. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2278. /**
  2279. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2280. * @param value1 defines 1st point of control
  2281. * @param value2 defines 2nd point of control
  2282. * @param value3 defines 3rd point of control
  2283. * @param value4 defines 4th point of control
  2284. * @param amount defines the interpolation factor
  2285. * @returns a new Vector2
  2286. */
  2287. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2288. /**
  2289. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2290. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2291. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2292. * @param value defines the value to clamp
  2293. * @param min defines the lower limit
  2294. * @param max defines the upper limit
  2295. * @returns a new Vector2
  2296. */
  2297. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2298. /**
  2299. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2300. * @param value1 defines the 1st control point
  2301. * @param tangent1 defines the outgoing tangent
  2302. * @param value2 defines the 2nd control point
  2303. * @param tangent2 defines the incoming tangent
  2304. * @param amount defines the interpolation factor
  2305. * @returns a new Vector2
  2306. */
  2307. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2308. /**
  2309. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2310. * @param start defines the start vector
  2311. * @param end defines the end vector
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Gets the dot product of the vector "left" and the vector "right"
  2318. * @param left defines first vector
  2319. * @param right defines second vector
  2320. * @returns the dot product (float)
  2321. */
  2322. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2323. /**
  2324. * Returns a new Vector2 equal to the normalized given vector
  2325. * @param vector defines the vector to normalize
  2326. * @returns a new Vector2
  2327. */
  2328. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2329. /**
  2330. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2331. * @param left defines 1st vector
  2332. * @param right defines 2nd vector
  2333. * @returns a new Vector2
  2334. */
  2335. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2336. /**
  2337. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2338. * @param left defines 1st vector
  2339. * @param right defines 2nd vector
  2340. * @returns a new Vector2
  2341. */
  2342. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2345. * @param vector defines the vector to transform
  2346. * @param transformation defines the matrix to apply
  2347. * @returns a new Vector2
  2348. */
  2349. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2350. /**
  2351. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2352. * @param vector defines the vector to transform
  2353. * @param transformation defines the matrix to apply
  2354. * @param result defines the target vector
  2355. */
  2356. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2357. /**
  2358. * Determines if a given vector is included in a triangle
  2359. * @param p defines the vector to test
  2360. * @param p0 defines 1st triangle point
  2361. * @param p1 defines 2nd triangle point
  2362. * @param p2 defines 3rd triangle point
  2363. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2364. */
  2365. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2366. /**
  2367. * Gets the distance between the vectors "value1" and "value2"
  2368. * @param value1 defines first vector
  2369. * @param value2 defines second vector
  2370. * @returns the distance between vectors
  2371. */
  2372. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2373. /**
  2374. * Returns the squared distance between the vectors "value1" and "value2"
  2375. * @param value1 defines first vector
  2376. * @param value2 defines second vector
  2377. * @returns the squared distance between vectors
  2378. */
  2379. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2380. /**
  2381. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2382. * @param value1 defines first vector
  2383. * @param value2 defines second vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2389. * @param p defines the middle point
  2390. * @param segA defines one point of the segment
  2391. * @param segB defines the other point of the segment
  2392. * @returns the shortest distance
  2393. */
  2394. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2395. }
  2396. /**
  2397. * Class used to store (x,y,z) vector representation
  2398. * A Vector3 is the main object used in 3D geometry
  2399. * It can represent etiher the coordinates of a point the space, either a direction
  2400. * Reminder: js uses a left handed forward facing system
  2401. */
  2402. export class Vector3 {
  2403. /**
  2404. * Defines the first coordinates (on X axis)
  2405. */
  2406. x: number;
  2407. /**
  2408. * Defines the second coordinates (on Y axis)
  2409. */
  2410. y: number;
  2411. /**
  2412. * Defines the third coordinates (on Z axis)
  2413. */
  2414. z: number;
  2415. private static _UpReadOnly;
  2416. private static _ZeroReadOnly;
  2417. /**
  2418. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2419. * @param x defines the first coordinates (on X axis)
  2420. * @param y defines the second coordinates (on Y axis)
  2421. * @param z defines the third coordinates (on Z axis)
  2422. */
  2423. constructor(
  2424. /**
  2425. * Defines the first coordinates (on X axis)
  2426. */
  2427. x?: number,
  2428. /**
  2429. * Defines the second coordinates (on Y axis)
  2430. */
  2431. y?: number,
  2432. /**
  2433. * Defines the third coordinates (on Z axis)
  2434. */
  2435. z?: number);
  2436. /**
  2437. * Creates a string representation of the Vector3
  2438. * @returns a string with the Vector3 coordinates.
  2439. */
  2440. toString(): string;
  2441. /**
  2442. * Gets the class name
  2443. * @returns the string "Vector3"
  2444. */
  2445. getClassName(): string;
  2446. /**
  2447. * Creates the Vector3 hash code
  2448. * @returns a number which tends to be unique between Vector3 instances
  2449. */
  2450. getHashCode(): number;
  2451. /**
  2452. * Creates an array containing three elements : the coordinates of the Vector3
  2453. * @returns a new array of numbers
  2454. */
  2455. asArray(): number[];
  2456. /**
  2457. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2458. * @param array defines the destination array
  2459. * @param index defines the offset in the destination array
  2460. * @returns the current Vector3
  2461. */
  2462. toArray(array: FloatArray, index?: number): Vector3;
  2463. /**
  2464. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2465. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2466. */
  2467. toQuaternion(): Quaternion;
  2468. /**
  2469. * Adds the given vector to the current Vector3
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2474. /**
  2475. * Adds the given coordinates to the current Vector3
  2476. * @param x defines the x coordinate of the operand
  2477. * @param y defines the y coordinate of the operand
  2478. * @param z defines the z coordinate of the operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2482. /**
  2483. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2484. * @param otherVector defines the second operand
  2485. * @returns the resulting Vector3
  2486. */
  2487. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2488. /**
  2489. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2490. * @param otherVector defines the second operand
  2491. * @param result defines the Vector3 object where to store the result
  2492. * @returns the current Vector3
  2493. */
  2494. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2495. /**
  2496. * Subtract the given vector from the current Vector3
  2497. * @param otherVector defines the second operand
  2498. * @returns the current updated Vector3
  2499. */
  2500. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2503. * @param otherVector defines the second operand
  2504. * @returns the resulting Vector3
  2505. */
  2506. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2509. * @param otherVector defines the second operand
  2510. * @param result defines the Vector3 object where to store the result
  2511. * @returns the current Vector3
  2512. */
  2513. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2514. /**
  2515. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2516. * @param x defines the x coordinate of the operand
  2517. * @param y defines the y coordinate of the operand
  2518. * @param z defines the z coordinate of the operand
  2519. * @returns the resulting Vector3
  2520. */
  2521. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2522. /**
  2523. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2531. /**
  2532. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2533. * @returns a new Vector3
  2534. */
  2535. negate(): Vector3;
  2536. /**
  2537. * Negate this vector in place
  2538. * @returns this
  2539. */
  2540. negateInPlace(): Vector3;
  2541. /**
  2542. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2543. * @param result defines the Vector3 object where to store the result
  2544. * @returns the current Vector3
  2545. */
  2546. negateToRef(result: Vector3): Vector3;
  2547. /**
  2548. * Multiplies the Vector3 coordinates by the float "scale"
  2549. * @param scale defines the multiplier factor
  2550. * @returns the current updated Vector3
  2551. */
  2552. scaleInPlace(scale: number): Vector3;
  2553. /**
  2554. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2555. * @param scale defines the multiplier factor
  2556. * @returns a new Vector3
  2557. */
  2558. scale(scale: number): Vector3;
  2559. /**
  2560. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2561. * @param scale defines the multiplier factor
  2562. * @param result defines the Vector3 object where to store the result
  2563. * @returns the current Vector3
  2564. */
  2565. scaleToRef(scale: number, result: Vector3): Vector3;
  2566. /**
  2567. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2568. * @param scale defines the scale factor
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the unmodified current Vector3
  2571. */
  2572. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2573. /**
  2574. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2575. * @param origin defines the origin of the projection ray
  2576. * @param plane defines the plane to project to
  2577. * @returns the projected vector3
  2578. */
  2579. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2580. /**
  2581. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2582. * @param origin defines the origin of the projection ray
  2583. * @param plane defines the plane to project to
  2584. * @param result defines the Vector3 where to store the result
  2585. */
  2586. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2587. /**
  2588. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2589. * @param otherVector defines the second operand
  2590. * @returns true if both vectors are equals
  2591. */
  2592. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2593. /**
  2594. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2595. * @param otherVector defines the second operand
  2596. * @param epsilon defines the minimal distance to define values as equals
  2597. * @returns true if both vectors are distant less than epsilon
  2598. */
  2599. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2600. /**
  2601. * Returns true if the current Vector3 coordinates equals the given floats
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @returns true if both vectors are equals
  2606. */
  2607. equalsToFloats(x: number, y: number, z: number): boolean;
  2608. /**
  2609. * Multiplies the current Vector3 coordinates by the given ones
  2610. * @param otherVector defines the second operand
  2611. * @returns the current updated Vector3
  2612. */
  2613. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2614. /**
  2615. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2616. * @param otherVector defines the second operand
  2617. * @returns the new Vector3
  2618. */
  2619. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2620. /**
  2621. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2622. * @param otherVector defines the second operand
  2623. * @param result defines the Vector3 object where to store the result
  2624. * @returns the current Vector3
  2625. */
  2626. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2627. /**
  2628. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2629. * @param x defines the x coordinate of the operand
  2630. * @param y defines the y coordinate of the operand
  2631. * @param z defines the z coordinate of the operand
  2632. * @returns the new Vector3
  2633. */
  2634. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2637. * @param otherVector defines the second operand
  2638. * @returns the new Vector3
  2639. */
  2640. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2643. * @param otherVector defines the second operand
  2644. * @param result defines the Vector3 object where to store the result
  2645. * @returns the current Vector3
  2646. */
  2647. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2648. /**
  2649. * Divides the current Vector3 coordinates by the given ones.
  2650. * @param otherVector defines the second operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. divideInPlace(otherVector: Vector3): Vector3;
  2654. /**
  2655. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2656. * @param other defines the second operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2660. /**
  2661. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2662. * @param other defines the second operand
  2663. * @returns the current updated Vector3
  2664. */
  2665. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2666. /**
  2667. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2668. * @param x defines the x coordinate of the operand
  2669. * @param y defines the y coordinate of the operand
  2670. * @param z defines the z coordinate of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2684. * Check if is non uniform within a certain amount of decimal places to account for this
  2685. * @param epsilon the amount the values can differ
  2686. * @returns if the the vector is non uniform to a certain number of decimal places
  2687. */
  2688. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2689. /**
  2690. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2691. */
  2692. get isNonUniform(): boolean;
  2693. /**
  2694. * Gets a new Vector3 from current Vector3 floored values
  2695. * @returns a new Vector3
  2696. */
  2697. floor(): Vector3;
  2698. /**
  2699. * Gets a new Vector3 from current Vector3 floored values
  2700. * @returns a new Vector3
  2701. */
  2702. fract(): Vector3;
  2703. /**
  2704. * Gets the length of the Vector3
  2705. * @returns the length of the Vector3
  2706. */
  2707. length(): number;
  2708. /**
  2709. * Gets the squared length of the Vector3
  2710. * @returns squared length of the Vector3
  2711. */
  2712. lengthSquared(): number;
  2713. /**
  2714. * Normalize the current Vector3.
  2715. * Please note that this is an in place operation.
  2716. * @returns the current updated Vector3
  2717. */
  2718. normalize(): Vector3;
  2719. /**
  2720. * Reorders the x y z properties of the vector in place
  2721. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2722. * @returns the current updated vector
  2723. */
  2724. reorderInPlace(order: string): this;
  2725. /**
  2726. * Rotates the vector around 0,0,0 by a quaternion
  2727. * @param quaternion the rotation quaternion
  2728. * @param result vector to store the result
  2729. * @returns the resulting vector
  2730. */
  2731. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2732. /**
  2733. * Rotates a vector around a given point
  2734. * @param quaternion the rotation quaternion
  2735. * @param point the point to rotate around
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2740. /**
  2741. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2742. * The cross product is then orthogonal to both current and "other"
  2743. * @param other defines the right operand
  2744. * @returns the cross product
  2745. */
  2746. cross(other: Vector3): Vector3;
  2747. /**
  2748. * Normalize the current Vector3 with the given input length.
  2749. * Please note that this is an in place operation.
  2750. * @param len the length of the vector
  2751. * @returns the current updated Vector3
  2752. */
  2753. normalizeFromLength(len: number): Vector3;
  2754. /**
  2755. * Normalize the current Vector3 to a new vector
  2756. * @returns the new Vector3
  2757. */
  2758. normalizeToNew(): Vector3;
  2759. /**
  2760. * Normalize the current Vector3 to the reference
  2761. * @param reference define the Vector3 to update
  2762. * @returns the updated Vector3
  2763. */
  2764. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2765. /**
  2766. * Creates a new Vector3 copied from the current Vector3
  2767. * @returns the new Vector3
  2768. */
  2769. clone(): Vector3;
  2770. /**
  2771. * Copies the given vector coordinates to the current Vector3 ones
  2772. * @param source defines the source Vector3
  2773. * @returns the current updated Vector3
  2774. */
  2775. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Copies the given floats to the current Vector3 coordinates
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. set(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given float to the current Vector3 coordinates
  2794. * @param v defines the x, y and z coordinates of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. setAll(v: number): Vector3;
  2798. /**
  2799. * Get the clip factor between two vectors
  2800. * @param vector0 defines the first operand
  2801. * @param vector1 defines the second operand
  2802. * @param axis defines the axis to use
  2803. * @param size defines the size along the axis
  2804. * @returns the clip factor
  2805. */
  2806. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2807. /**
  2808. * Get angle between two vectors
  2809. * @param vector0 angle between vector0 and vector1
  2810. * @param vector1 angle between vector0 and vector1
  2811. * @param normal direction of the normal
  2812. * @return the angle between vector0 and vector1
  2813. */
  2814. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2815. /**
  2816. * Returns a new Vector3 set from the index "offset" of the given array
  2817. * @param array defines the source array
  2818. * @param offset defines the offset in the source array
  2819. * @returns the new Vector3
  2820. */
  2821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2822. /**
  2823. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2824. * @param array defines the source array
  2825. * @param offset defines the offset in the source array
  2826. * @returns the new Vector3
  2827. * @deprecated Please use FromArray instead.
  2828. */
  2829. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @param result defines the Vector3 where to store the result
  2835. */
  2836. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2837. /**
  2838. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2839. * @param array defines the source array
  2840. * @param offset defines the offset in the source array
  2841. * @param result defines the Vector3 where to store the result
  2842. * @deprecated Please use FromArrayToRef instead.
  2843. */
  2844. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the given floats.
  2847. * @param x defines the x coordinate of the source
  2848. * @param y defines the y coordinate of the source
  2849. * @param z defines the z coordinate of the source
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2853. /**
  2854. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2855. * @returns a new empty Vector3
  2856. */
  2857. static Zero(): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2860. * @returns a new unit Vector3
  2861. */
  2862. static One(): Vector3;
  2863. /**
  2864. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2865. * @returns a new up Vector3
  2866. */
  2867. static Up(): Vector3;
  2868. /**
  2869. * Gets a up Vector3 that must not be updated
  2870. */
  2871. static get UpReadOnly(): DeepImmutable<Vector3>;
  2872. /**
  2873. * Gets a zero Vector3 that must not be updated
  2874. */
  2875. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2876. /**
  2877. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2878. * @returns a new down Vector3
  2879. */
  2880. static Down(): Vector3;
  2881. /**
  2882. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2883. * @param rightHandedSystem is the scene right-handed (negative z)
  2884. * @returns a new forward Vector3
  2885. */
  2886. static Forward(rightHandedSystem?: boolean): Vector3;
  2887. /**
  2888. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2889. * @param rightHandedSystem is the scene right-handed (negative-z)
  2890. * @returns a new forward Vector3
  2891. */
  2892. static Backward(rightHandedSystem?: boolean): Vector3;
  2893. /**
  2894. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2895. * @returns a new right Vector3
  2896. */
  2897. static Right(): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2900. * @returns a new left Vector3
  2901. */
  2902. static Left(): Vector3;
  2903. /**
  2904. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2905. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2906. * @param vector defines the Vector3 to transform
  2907. * @param transformation defines the transformation matrix
  2908. * @returns the transformed Vector3
  2909. */
  2910. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2911. /**
  2912. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2921. * This method computes tranformed coordinates only, not transformed direction vectors
  2922. * @param x define the x coordinate of the source vector
  2923. * @param y define the y coordinate of the source vector
  2924. * @param z define the z coordinate of the source vector
  2925. * @param transformation defines the transformation matrix
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2931. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2932. * @param vector defines the Vector3 to transform
  2933. * @param transformation defines the transformation matrix
  2934. * @returns the new Vector3
  2935. */
  2936. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2937. /**
  2938. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param x define the x coordinate of the source vector
  2949. * @param y define the y coordinate of the source vector
  2950. * @param z define the z coordinate of the source vector
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2957. * @param value1 defines the first control point
  2958. * @param value2 defines the second control point
  2959. * @param value3 defines the third control point
  2960. * @param value4 defines the fourth control point
  2961. * @param amount defines the amount on the spline to use
  2962. * @returns the new Vector3
  2963. */
  2964. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2967. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2968. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2969. * @param value defines the current value
  2970. * @param min defines the lower range value
  2971. * @param max defines the upper range value
  2972. * @returns the new Vector3
  2973. */
  2974. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2975. /**
  2976. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2977. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2978. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2979. * @param value defines the current value
  2980. * @param min defines the lower range value
  2981. * @param max defines the upper range value
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2985. /**
  2986. * Checks if a given vector is inside a specific range
  2987. * @param v defines the vector to test
  2988. * @param min defines the minimum range
  2989. * @param max defines the maximum range
  2990. */
  2991. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2992. /**
  2993. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2994. * @param value1 defines the first control point
  2995. * @param tangent1 defines the first tangent vector
  2996. * @param value2 defines the second control point
  2997. * @param tangent2 defines the second tangent vector
  2998. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2999. * @returns the new Vector3
  3000. */
  3001. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3004. * @param start defines the start value
  3005. * @param end defines the end value
  3006. * @param amount max defines amount between both (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3018. /**
  3019. * Returns the dot product (float) between the vectors "left" and "right"
  3020. * @param left defines the left operand
  3021. * @param right defines the right operand
  3022. * @returns the dot product
  3023. */
  3024. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3025. /**
  3026. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3027. * The cross product is then orthogonal to both "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the cross product
  3031. */
  3032. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Sets the given vector "result" with the cross product of "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 as the normalization of the given vector
  3043. * @param vector defines the Vector3 to normalize
  3044. * @returns the new Vector3
  3045. */
  3046. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3047. /**
  3048. * Sets the given vector "result" with the normalization of the given first vector
  3049. * @param vector defines the Vector3 to normalize
  3050. * @param result defines the Vector3 where to store the result
  3051. */
  3052. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3053. /**
  3054. * Project a Vector3 onto screen space
  3055. * @param vector defines the Vector3 to project
  3056. * @param world defines the world matrix to use
  3057. * @param transform defines the transform (view x projection) matrix to use
  3058. * @param viewport defines the screen viewport to use
  3059. * @returns the new Vector3
  3060. */
  3061. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3062. /** @hidden */
  3063. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3064. /**
  3065. * Unproject from screen space to object space
  3066. * @param source defines the screen space Vector3 to use
  3067. * @param viewportWidth defines the current width of the viewport
  3068. * @param viewportHeight defines the current height of the viewport
  3069. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3070. * @param transform defines the transform (view x projection) matrix to use
  3071. * @returns the new Vector3
  3072. */
  3073. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3074. /**
  3075. * Unproject from screen space to object space
  3076. * @param source defines the screen space Vector3 to use
  3077. * @param viewportWidth defines the current width of the viewport
  3078. * @param viewportHeight defines the current height of the viewport
  3079. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3080. * @param view defines the view matrix to use
  3081. * @param projection defines the projection matrix to use
  3082. * @returns the new Vector3
  3083. */
  3084. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3085. /**
  3086. * Unproject from screen space to object space
  3087. * @param source defines the screen space Vector3 to use
  3088. * @param viewportWidth defines the current width of the viewport
  3089. * @param viewportHeight defines the current height of the viewport
  3090. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3091. * @param view defines the view matrix to use
  3092. * @param projection defines the projection matrix to use
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3096. /**
  3097. * Unproject from screen space to object space
  3098. * @param sourceX defines the screen space x coordinate to use
  3099. * @param sourceY defines the screen space y coordinate to use
  3100. * @param sourceZ defines the screen space z coordinate to use
  3101. * @param viewportWidth defines the current width of the viewport
  3102. * @param viewportHeight defines the current height of the viewport
  3103. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3104. * @param view defines the view matrix to use
  3105. * @param projection defines the projection matrix to use
  3106. * @param result defines the Vector3 where to store the result
  3107. */
  3108. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3109. /**
  3110. * Gets the minimal coordinate values between two Vector3
  3111. * @param left defines the first operand
  3112. * @param right defines the second operand
  3113. * @returns the new Vector3
  3114. */
  3115. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Gets the maximal coordinate values between two Vector3
  3118. * @param left defines the first operand
  3119. * @param right defines the second operand
  3120. * @returns the new Vector3
  3121. */
  3122. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Returns the distance between the vectors "value1" and "value2"
  3125. * @param value1 defines the first operand
  3126. * @param value2 defines the second operand
  3127. * @returns the distance
  3128. */
  3129. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3130. /**
  3131. * Returns the squared distance between the vectors "value1" and "value2"
  3132. * @param value1 defines the first operand
  3133. * @param value2 defines the second operand
  3134. * @returns the squared distance
  3135. */
  3136. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 located at the center between "value1" and "value2"
  3139. * @param value1 defines the first operand
  3140. * @param value2 defines the second operand
  3141. * @returns the new Vector3
  3142. */
  3143. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3144. /**
  3145. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3146. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3147. * to something in order to rotate it from its local system to the given target system
  3148. * Note: axis1, axis2 and axis3 are normalized during this operation
  3149. * @param axis1 defines the first axis
  3150. * @param axis2 defines the second axis
  3151. * @param axis3 defines the third axis
  3152. * @returns a new Vector3
  3153. */
  3154. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3155. /**
  3156. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @param ref defines the Vector3 where to store the result
  3161. */
  3162. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3163. }
  3164. /**
  3165. * Vector4 class created for EulerAngle class conversion to Quaternion
  3166. */
  3167. export class Vector4 {
  3168. /** x value of the vector */
  3169. x: number;
  3170. /** y value of the vector */
  3171. y: number;
  3172. /** z value of the vector */
  3173. z: number;
  3174. /** w value of the vector */
  3175. w: number;
  3176. /**
  3177. * Creates a Vector4 object from the given floats.
  3178. * @param x x value of the vector
  3179. * @param y y value of the vector
  3180. * @param z z value of the vector
  3181. * @param w w value of the vector
  3182. */
  3183. constructor(
  3184. /** x value of the vector */
  3185. x: number,
  3186. /** y value of the vector */
  3187. y: number,
  3188. /** z value of the vector */
  3189. z: number,
  3190. /** w value of the vector */
  3191. w: number);
  3192. /**
  3193. * Returns the string with the Vector4 coordinates.
  3194. * @returns a string containing all the vector values
  3195. */
  3196. toString(): string;
  3197. /**
  3198. * Returns the string "Vector4".
  3199. * @returns "Vector4"
  3200. */
  3201. getClassName(): string;
  3202. /**
  3203. * Returns the Vector4 hash code.
  3204. * @returns a unique hash code
  3205. */
  3206. getHashCode(): number;
  3207. /**
  3208. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3209. * @returns the resulting array
  3210. */
  3211. asArray(): number[];
  3212. /**
  3213. * Populates the given array from the given index with the Vector4 coordinates.
  3214. * @param array array to populate
  3215. * @param index index of the array to start at (default: 0)
  3216. * @returns the Vector4.
  3217. */
  3218. toArray(array: FloatArray, index?: number): Vector4;
  3219. /**
  3220. * Adds the given vector to the current Vector4.
  3221. * @param otherVector the vector to add
  3222. * @returns the updated Vector4.
  3223. */
  3224. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3225. /**
  3226. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3227. * @param otherVector the vector to add
  3228. * @returns the resulting vector
  3229. */
  3230. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3233. * @param otherVector the vector to add
  3234. * @param result the vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Subtract in place the given vector from the current Vector4.
  3240. * @param otherVector the vector to subtract
  3241. * @returns the updated Vector4.
  3242. */
  3243. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3246. * @param otherVector the vector to add
  3247. * @returns the new vector with the result
  3248. */
  3249. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3252. * @param otherVector the vector to subtract
  3253. * @param result the vector to store the result
  3254. * @returns the current Vector4.
  3255. */
  3256. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3257. /**
  3258. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3259. */
  3260. /**
  3261. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3262. * @param x value to subtract
  3263. * @param y value to subtract
  3264. * @param z value to subtract
  3265. * @param w value to subtract
  3266. * @returns new vector containing the result
  3267. */
  3268. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3269. /**
  3270. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3271. * @param x value to subtract
  3272. * @param y value to subtract
  3273. * @param z value to subtract
  3274. * @param w value to subtract
  3275. * @param result the vector to store the result in
  3276. * @returns the current Vector4.
  3277. */
  3278. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3279. /**
  3280. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3281. * @returns a new vector with the negated values
  3282. */
  3283. negate(): Vector4;
  3284. /**
  3285. * Negate this vector in place
  3286. * @returns this
  3287. */
  3288. negateInPlace(): Vector4;
  3289. /**
  3290. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3291. * @param result defines the Vector3 object where to store the result
  3292. * @returns the current Vector4
  3293. */
  3294. negateToRef(result: Vector4): Vector4;
  3295. /**
  3296. * Multiplies the current Vector4 coordinates by scale (float).
  3297. * @param scale the number to scale with
  3298. * @returns the updated Vector4.
  3299. */
  3300. scaleInPlace(scale: number): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3303. * @param scale the number to scale with
  3304. * @returns a new vector with the result
  3305. */
  3306. scale(scale: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3309. * @param scale the number to scale with
  3310. * @param result a vector to store the result in
  3311. * @returns the current Vector4.
  3312. */
  3313. scaleToRef(scale: number, result: Vector4): Vector4;
  3314. /**
  3315. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3316. * @param scale defines the scale factor
  3317. * @param result defines the Vector4 object where to store the result
  3318. * @returns the unmodified current Vector4
  3319. */
  3320. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3321. /**
  3322. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3323. * @param otherVector the vector to compare against
  3324. * @returns true if they are equal
  3325. */
  3326. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3327. /**
  3328. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3329. * @param otherVector vector to compare against
  3330. * @param epsilon (Default: very small number)
  3331. * @returns true if they are equal
  3332. */
  3333. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3334. /**
  3335. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3336. * @param x x value to compare against
  3337. * @param y y value to compare against
  3338. * @param z z value to compare against
  3339. * @param w w value to compare against
  3340. * @returns true if equal
  3341. */
  3342. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3343. /**
  3344. * Multiplies in place the current Vector4 by the given one.
  3345. * @param otherVector vector to multiple with
  3346. * @returns the updated Vector4.
  3347. */
  3348. multiplyInPlace(otherVector: Vector4): Vector4;
  3349. /**
  3350. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3351. * @param otherVector vector to multiple with
  3352. * @returns resulting new vector
  3353. */
  3354. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3355. /**
  3356. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3357. * @param otherVector vector to multiple with
  3358. * @param result vector to store the result
  3359. * @returns the current Vector4.
  3360. */
  3361. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3364. * @param x x value multiply with
  3365. * @param y y value multiply with
  3366. * @param z z value multiply with
  3367. * @param w w value multiply with
  3368. * @returns resulting new vector
  3369. */
  3370. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3371. /**
  3372. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3373. * @param otherVector vector to devide with
  3374. * @returns resulting new vector
  3375. */
  3376. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3379. * @param otherVector vector to devide with
  3380. * @param result vector to store the result
  3381. * @returns the current Vector4.
  3382. */
  3383. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3384. /**
  3385. * Divides the current Vector3 coordinates by the given ones.
  3386. * @param otherVector vector to devide with
  3387. * @returns the updated Vector3.
  3388. */
  3389. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3392. * @param other defines the second operand
  3393. * @returns the current updated Vector4
  3394. */
  3395. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3398. * @param other defines the second operand
  3399. * @returns the current updated Vector4
  3400. */
  3401. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Gets a new Vector4 from current Vector4 floored values
  3404. * @returns a new Vector4
  3405. */
  3406. floor(): Vector4;
  3407. /**
  3408. * Gets a new Vector4 from current Vector3 floored values
  3409. * @returns a new Vector4
  3410. */
  3411. fract(): Vector4;
  3412. /**
  3413. * Returns the Vector4 length (float).
  3414. * @returns the length
  3415. */
  3416. length(): number;
  3417. /**
  3418. * Returns the Vector4 squared length (float).
  3419. * @returns the length squared
  3420. */
  3421. lengthSquared(): number;
  3422. /**
  3423. * Normalizes in place the Vector4.
  3424. * @returns the updated Vector4.
  3425. */
  3426. normalize(): Vector4;
  3427. /**
  3428. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3429. * @returns this converted to a new vector3
  3430. */
  3431. toVector3(): Vector3;
  3432. /**
  3433. * Returns a new Vector4 copied from the current one.
  3434. * @returns the new cloned vector
  3435. */
  3436. clone(): Vector4;
  3437. /**
  3438. * Updates the current Vector4 with the given one coordinates.
  3439. * @param source the source vector to copy from
  3440. * @returns the updated Vector4.
  3441. */
  3442. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Updates the current Vector4 coordinates with the given floats.
  3445. * @param x float to copy from
  3446. * @param y float to copy from
  3447. * @param z float to copy from
  3448. * @param w float to copy from
  3449. * @returns the updated Vector4.
  3450. */
  3451. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3452. /**
  3453. * Updates the current Vector4 coordinates with the given floats.
  3454. * @param x float to set from
  3455. * @param y float to set from
  3456. * @param z float to set from
  3457. * @param w float to set from
  3458. * @returns the updated Vector4.
  3459. */
  3460. set(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Copies the given float to the current Vector3 coordinates
  3463. * @param v defines the x, y, z and w coordinates of the operand
  3464. * @returns the current updated Vector3
  3465. */
  3466. setAll(v: number): Vector4;
  3467. /**
  3468. * Returns a new Vector4 set from the starting index of the given array.
  3469. * @param array the array to pull values from
  3470. * @param offset the offset into the array to start at
  3471. * @returns the new vector
  3472. */
  3473. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3474. /**
  3475. * Updates the given vector "result" from the starting index of the given array.
  3476. * @param array the array to pull values from
  3477. * @param offset the offset into the array to start at
  3478. * @param result the vector to store the result in
  3479. */
  3480. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3481. /**
  3482. * Updates the given vector "result" from the starting index of the given Float32Array.
  3483. * @param array the array to pull values from
  3484. * @param offset the offset into the array to start at
  3485. * @param result the vector to store the result in
  3486. */
  3487. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3488. /**
  3489. * Updates the given vector "result" coordinates from the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @param result the vector to the floats in
  3495. */
  3496. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3497. /**
  3498. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3499. * @returns the new vector
  3500. */
  3501. static Zero(): Vector4;
  3502. /**
  3503. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3504. * @returns the new vector
  3505. */
  3506. static One(): Vector4;
  3507. /**
  3508. * Returns a new normalized Vector4 from the given one.
  3509. * @param vector the vector to normalize
  3510. * @returns the vector
  3511. */
  3512. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3513. /**
  3514. * Updates the given vector "result" from the normalization of the given one.
  3515. * @param vector the vector to normalize
  3516. * @param result the vector to store the result in
  3517. */
  3518. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3519. /**
  3520. * Returns a vector with the minimum values from the left and right vectors
  3521. * @param left left vector to minimize
  3522. * @param right right vector to minimize
  3523. * @returns a new vector with the minimum of the left and right vector values
  3524. */
  3525. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3526. /**
  3527. * Returns a vector with the maximum values from the left and right vectors
  3528. * @param left left vector to maximize
  3529. * @param right right vector to maximize
  3530. * @returns a new vector with the maximum of the left and right vector values
  3531. */
  3532. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Returns the distance (float) between the vectors "value1" and "value2".
  3535. * @param value1 value to calulate the distance between
  3536. * @param value2 value to calulate the distance between
  3537. * @return the distance between the two vectors
  3538. */
  3539. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3540. /**
  3541. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3542. * @param value1 value to calulate the distance between
  3543. * @param value2 value to calulate the distance between
  3544. * @return the distance between the two vectors squared
  3545. */
  3546. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3547. /**
  3548. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3549. * @param value1 value to calulate the center between
  3550. * @param value2 value to calulate the center between
  3551. * @return the center between the two vectors
  3552. */
  3553. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3554. /**
  3555. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3556. * This methods computes transformed normalized direction vectors only.
  3557. * @param vector the vector to transform
  3558. * @param transformation the transformation matrix to apply
  3559. * @returns the new vector
  3560. */
  3561. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3562. /**
  3563. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @param result the vector to store the result in
  3568. */
  3569. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param x value to transform
  3574. * @param y value to transform
  3575. * @param z value to transform
  3576. * @param w value to transform
  3577. * @param transformation the transformation matrix to apply
  3578. * @param result the vector to store the results in
  3579. */
  3580. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3581. /**
  3582. * Creates a new Vector4 from a Vector3
  3583. * @param source defines the source data
  3584. * @param w defines the 4th component (default is 0)
  3585. * @returns a new Vector4
  3586. */
  3587. static FromVector3(source: Vector3, w?: number): Vector4;
  3588. }
  3589. /**
  3590. * Class used to store quaternion data
  3591. * @see https://en.wikipedia.org/wiki/Quaternion
  3592. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3593. */
  3594. export class Quaternion {
  3595. /** defines the first component (0 by default) */
  3596. x: number;
  3597. /** defines the second component (0 by default) */
  3598. y: number;
  3599. /** defines the third component (0 by default) */
  3600. z: number;
  3601. /** defines the fourth component (1.0 by default) */
  3602. w: number;
  3603. /**
  3604. * Creates a new Quaternion from the given floats
  3605. * @param x defines the first component (0 by default)
  3606. * @param y defines the second component (0 by default)
  3607. * @param z defines the third component (0 by default)
  3608. * @param w defines the fourth component (1.0 by default)
  3609. */
  3610. constructor(
  3611. /** defines the first component (0 by default) */
  3612. x?: number,
  3613. /** defines the second component (0 by default) */
  3614. y?: number,
  3615. /** defines the third component (0 by default) */
  3616. z?: number,
  3617. /** defines the fourth component (1.0 by default) */
  3618. w?: number);
  3619. /**
  3620. * Gets a string representation for the current quaternion
  3621. * @returns a string with the Quaternion coordinates
  3622. */
  3623. toString(): string;
  3624. /**
  3625. * Gets the class name of the quaternion
  3626. * @returns the string "Quaternion"
  3627. */
  3628. getClassName(): string;
  3629. /**
  3630. * Gets a hash code for this quaternion
  3631. * @returns the quaternion hash code
  3632. */
  3633. getHashCode(): number;
  3634. /**
  3635. * Copy the quaternion to an array
  3636. * @returns a new array populated with 4 elements from the quaternion coordinates
  3637. */
  3638. asArray(): number[];
  3639. /**
  3640. * Check if two quaternions are equals
  3641. * @param otherQuaternion defines the second operand
  3642. * @return true if the current quaternion and the given one coordinates are strictly equals
  3643. */
  3644. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3645. /**
  3646. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3647. * @param otherQuaternion defines the other quaternion
  3648. * @param epsilon defines the minimal distance to consider equality
  3649. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3650. */
  3651. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3652. /**
  3653. * Clone the current quaternion
  3654. * @returns a new quaternion copied from the current one
  3655. */
  3656. clone(): Quaternion;
  3657. /**
  3658. * Copy a quaternion to the current one
  3659. * @param other defines the other quaternion
  3660. * @returns the updated current quaternion
  3661. */
  3662. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Updates the current quaternion with the given float coordinates
  3665. * @param x defines the x coordinate
  3666. * @param y defines the y coordinate
  3667. * @param z defines the z coordinate
  3668. * @param w defines the w coordinate
  3669. * @returns the updated current quaternion
  3670. */
  3671. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3672. /**
  3673. * Updates the current quaternion from the given float coordinates
  3674. * @param x defines the x coordinate
  3675. * @param y defines the y coordinate
  3676. * @param z defines the z coordinate
  3677. * @param w defines the w coordinate
  3678. * @returns the updated current quaternion
  3679. */
  3680. set(x: number, y: number, z: number, w: number): Quaternion;
  3681. /**
  3682. * Adds two quaternions
  3683. * @param other defines the second operand
  3684. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3685. */
  3686. add(other: DeepImmutable<Quaternion>): Quaternion;
  3687. /**
  3688. * Add a quaternion to the current one
  3689. * @param other defines the quaternion to add
  3690. * @returns the current quaternion
  3691. */
  3692. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3693. /**
  3694. * Subtract two quaternions
  3695. * @param other defines the second operand
  3696. * @returns a new quaternion as the subtraction result of the given one from the current one
  3697. */
  3698. subtract(other: Quaternion): Quaternion;
  3699. /**
  3700. * Multiplies the current quaternion by a scale factor
  3701. * @param value defines the scale factor
  3702. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3703. */
  3704. scale(value: number): Quaternion;
  3705. /**
  3706. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3707. * @param scale defines the scale factor
  3708. * @param result defines the Quaternion object where to store the result
  3709. * @returns the unmodified current quaternion
  3710. */
  3711. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3712. /**
  3713. * Multiplies in place the current quaternion by a scale factor
  3714. * @param value defines the scale factor
  3715. * @returns the current modified quaternion
  3716. */
  3717. scaleInPlace(value: number): Quaternion;
  3718. /**
  3719. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3720. * @param scale defines the scale factor
  3721. * @param result defines the Quaternion object where to store the result
  3722. * @returns the unmodified current quaternion
  3723. */
  3724. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3725. /**
  3726. * Multiplies two quaternions
  3727. * @param q1 defines the second operand
  3728. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3729. */
  3730. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3733. * @param q1 defines the second operand
  3734. * @param result defines the target quaternion
  3735. * @returns the current quaternion
  3736. */
  3737. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3738. /**
  3739. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @returns the currentupdated quaternion
  3742. */
  3743. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3744. /**
  3745. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3746. * @param ref defines the target quaternion
  3747. * @returns the current quaternion
  3748. */
  3749. conjugateToRef(ref: Quaternion): Quaternion;
  3750. /**
  3751. * Conjugates in place (1-q) the current quaternion
  3752. * @returns the current updated quaternion
  3753. */
  3754. conjugateInPlace(): Quaternion;
  3755. /**
  3756. * Conjugates in place (1-q) the current quaternion
  3757. * @returns a new quaternion
  3758. */
  3759. conjugate(): Quaternion;
  3760. /**
  3761. * Gets length of current quaternion
  3762. * @returns the quaternion length (float)
  3763. */
  3764. length(): number;
  3765. /**
  3766. * Normalize in place the current quaternion
  3767. * @returns the current updated quaternion
  3768. */
  3769. normalize(): Quaternion;
  3770. /**
  3771. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3772. * @param order is a reserved parameter and is ignore for now
  3773. * @returns a new Vector3 containing the Euler angles
  3774. */
  3775. toEulerAngles(order?: string): Vector3;
  3776. /**
  3777. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3778. * @param result defines the vector which will be filled with the Euler angles
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns the current unchanged quaternion
  3781. */
  3782. toEulerAnglesToRef(result: Vector3): Quaternion;
  3783. /**
  3784. * Updates the given rotation matrix with the current quaternion values
  3785. * @param result defines the target matrix
  3786. * @returns the current unchanged quaternion
  3787. */
  3788. toRotationMatrix(result: Matrix): Quaternion;
  3789. /**
  3790. * Updates the current quaternion from the given rotation matrix values
  3791. * @param matrix defines the source matrix
  3792. * @returns the current updated quaternion
  3793. */
  3794. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3795. /**
  3796. * Creates a new quaternion from a rotation matrix
  3797. * @param matrix defines the source matrix
  3798. * @returns a new quaternion created from the given rotation matrix values
  3799. */
  3800. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3801. /**
  3802. * Updates the given quaternion with the given rotation matrix values
  3803. * @param matrix defines the source matrix
  3804. * @param result defines the target quaternion
  3805. */
  3806. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3807. /**
  3808. * Returns the dot product (float) between the quaternions "left" and "right"
  3809. * @param left defines the left operand
  3810. * @param right defines the right operand
  3811. * @returns the dot product
  3812. */
  3813. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3814. /**
  3815. * Checks if the two quaternions are close to each other
  3816. * @param quat0 defines the first quaternion to check
  3817. * @param quat1 defines the second quaternion to check
  3818. * @returns true if the two quaternions are close to each other
  3819. */
  3820. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3821. /**
  3822. * Creates an empty quaternion
  3823. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3824. */
  3825. static Zero(): Quaternion;
  3826. /**
  3827. * Inverse a given quaternion
  3828. * @param q defines the source quaternion
  3829. * @returns a new quaternion as the inverted current quaternion
  3830. */
  3831. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Inverse a given quaternion
  3834. * @param q defines the source quaternion
  3835. * @param result the quaternion the result will be stored in
  3836. * @returns the result quaternion
  3837. */
  3838. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3839. /**
  3840. * Creates an identity quaternion
  3841. * @returns the identity quaternion
  3842. */
  3843. static Identity(): Quaternion;
  3844. /**
  3845. * Gets a boolean indicating if the given quaternion is identity
  3846. * @param quaternion defines the quaternion to check
  3847. * @returns true if the quaternion is identity
  3848. */
  3849. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3850. /**
  3851. * Creates a quaternion from a rotation around an axis
  3852. * @param axis defines the axis to use
  3853. * @param angle defines the angle to use
  3854. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3855. */
  3856. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3857. /**
  3858. * Creates a rotation around an axis and stores it into the given quaternion
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @param result defines the target quaternion
  3862. * @returns the target quaternion
  3863. */
  3864. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3865. /**
  3866. * Creates a new quaternion from data stored into an array
  3867. * @param array defines the data source
  3868. * @param offset defines the offset in the source array where the data starts
  3869. * @returns a new quaternion
  3870. */
  3871. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3872. /**
  3873. * Updates the given quaternion "result" from the starting index of the given array.
  3874. * @param array the array to pull values from
  3875. * @param offset the offset into the array to start at
  3876. * @param result the quaternion to store the result in
  3877. */
  3878. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3879. /**
  3880. * Create a quaternion from Euler rotation angles
  3881. * @param x Pitch
  3882. * @param y Yaw
  3883. * @param z Roll
  3884. * @returns the new Quaternion
  3885. */
  3886. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3887. /**
  3888. * Updates a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @param result the quaternion to store the result
  3893. * @returns the updated quaternion
  3894. */
  3895. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3896. /**
  3897. * Create a quaternion from Euler rotation vector
  3898. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3899. * @returns the new Quaternion
  3900. */
  3901. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3902. /**
  3903. * Updates a quaternion from Euler rotation vector
  3904. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3905. * @param result the quaternion to store the result
  3906. * @returns the updated quaternion
  3907. */
  3908. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3911. * @param yaw defines the rotation around Y axis
  3912. * @param pitch defines the rotation around X axis
  3913. * @param roll defines the rotation around Z axis
  3914. * @returns the new quaternion
  3915. */
  3916. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3917. /**
  3918. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @param result defines the target quaternion
  3923. */
  3924. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3925. /**
  3926. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3927. * @param alpha defines the rotation around first axis
  3928. * @param beta defines the rotation around second axis
  3929. * @param gamma defines the rotation around third axis
  3930. * @returns the new quaternion
  3931. */
  3932. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @param result defines the target quaternion
  3939. */
  3940. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3941. /**
  3942. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3943. * @param axis1 defines the first axis
  3944. * @param axis2 defines the second axis
  3945. * @param axis3 defines the third axis
  3946. * @returns the new quaternion
  3947. */
  3948. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3949. /**
  3950. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @param ref defines the target quaternion
  3955. */
  3956. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3957. /**
  3958. * Interpolates between two quaternions
  3959. * @param left defines first quaternion
  3960. * @param right defines second quaternion
  3961. * @param amount defines the gradient to use
  3962. * @returns the new interpolated quaternion
  3963. */
  3964. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3965. /**
  3966. * Interpolates between two quaternions and stores it into a target quaternion
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @param result defines the target quaternion
  3971. */
  3972. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3973. /**
  3974. * Interpolate between two quaternions using Hermite interpolation
  3975. * @param value1 defines first quaternion
  3976. * @param tangent1 defines the incoming tangent
  3977. * @param value2 defines second quaternion
  3978. * @param tangent2 defines the outgoing tangent
  3979. * @param amount defines the target quaternion
  3980. * @returns the new interpolated quaternion
  3981. */
  3982. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3983. }
  3984. /**
  3985. * Class used to store matrix data (4x4)
  3986. */
  3987. export class Matrix {
  3988. private static _updateFlagSeed;
  3989. private static _identityReadOnly;
  3990. private _isIdentity;
  3991. private _isIdentityDirty;
  3992. private _isIdentity3x2;
  3993. private _isIdentity3x2Dirty;
  3994. /**
  3995. * Gets the update flag of the matrix which is an unique number for the matrix.
  3996. * It will be incremented every time the matrix data change.
  3997. * You can use it to speed the comparison between two versions of the same matrix.
  3998. */
  3999. updateFlag: number;
  4000. private readonly _m;
  4001. /**
  4002. * Gets the internal data of the matrix
  4003. */
  4004. get m(): DeepImmutable<Float32Array>;
  4005. /** @hidden */
  4006. _markAsUpdated(): void;
  4007. /** @hidden */
  4008. private _updateIdentityStatus;
  4009. /**
  4010. * Creates an empty matrix (filled with zeros)
  4011. */
  4012. constructor();
  4013. /**
  4014. * Check if the current matrix is identity
  4015. * @returns true is the matrix is the identity matrix
  4016. */
  4017. isIdentity(): boolean;
  4018. /**
  4019. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4020. * @returns true is the matrix is the identity matrix
  4021. */
  4022. isIdentityAs3x2(): boolean;
  4023. /**
  4024. * Gets the determinant of the matrix
  4025. * @returns the matrix determinant
  4026. */
  4027. determinant(): number;
  4028. /**
  4029. * Returns the matrix as a Float32Array
  4030. * @returns the matrix underlying array
  4031. */
  4032. toArray(): DeepImmutable<Float32Array>;
  4033. /**
  4034. * Returns the matrix as a Float32Array
  4035. * @returns the matrix underlying array.
  4036. */
  4037. asArray(): DeepImmutable<Float32Array>;
  4038. /**
  4039. * Inverts the current matrix in place
  4040. * @returns the current inverted matrix
  4041. */
  4042. invert(): Matrix;
  4043. /**
  4044. * Sets all the matrix elements to zero
  4045. * @returns the current matrix
  4046. */
  4047. reset(): Matrix;
  4048. /**
  4049. * Adds the current matrix with a second one
  4050. * @param other defines the matrix to add
  4051. * @returns a new matrix as the addition of the current matrix and the given one
  4052. */
  4053. add(other: DeepImmutable<Matrix>): Matrix;
  4054. /**
  4055. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4056. * @param other defines the matrix to add
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4061. /**
  4062. * Adds in place the given matrix to the current matrix
  4063. * @param other defines the second operand
  4064. * @returns the current updated matrix
  4065. */
  4066. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4067. /**
  4068. * Sets the given matrix to the current inverted Matrix
  4069. * @param other defines the target matrix
  4070. * @returns the unmodified current matrix
  4071. */
  4072. invertToRef(other: Matrix): Matrix;
  4073. /**
  4074. * add a value at the specified position in the current Matrix
  4075. * @param index the index of the value within the matrix. between 0 and 15.
  4076. * @param value the value to be added
  4077. * @returns the current updated matrix
  4078. */
  4079. addAtIndex(index: number, value: number): Matrix;
  4080. /**
  4081. * mutiply the specified position in the current Matrix by a value
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. multiplyAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * Inserts the translation vector (using 3 floats) in the current matrix
  4089. * @param x defines the 1st component of the translation
  4090. * @param y defines the 2nd component of the translation
  4091. * @param z defines the 3rd component of the translation
  4092. * @returns the current updated matrix
  4093. */
  4094. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4095. /**
  4096. * Adds the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Inserts the translation vector in the current matrix
  4105. * @param vector3 defines the translation to insert
  4106. * @returns the current updated matrix
  4107. */
  4108. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4109. /**
  4110. * Gets the translation value of the current matrix
  4111. * @returns a new Vector3 as the extracted translation from the matrix
  4112. */
  4113. getTranslation(): Vector3;
  4114. /**
  4115. * Fill a Vector3 with the extracted translation from the matrix
  4116. * @param result defines the Vector3 where to store the translation
  4117. * @returns the current matrix
  4118. */
  4119. getTranslationToRef(result: Vector3): Matrix;
  4120. /**
  4121. * Remove rotation and scaling part from the matrix
  4122. * @returns the updated matrix
  4123. */
  4124. removeRotationAndScaling(): Matrix;
  4125. /**
  4126. * Multiply two matrices
  4127. * @param other defines the second operand
  4128. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4129. */
  4130. multiply(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Copy the current matrix from the given one
  4133. * @param other defines the source matrix
  4134. * @returns the current updated matrix
  4135. */
  4136. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4137. /**
  4138. * Populates the given array from the starting index with the current matrix values
  4139. * @param array defines the target array
  4140. * @param offset defines the offset in the target array where to start storing values
  4141. * @returns the current matrix
  4142. */
  4143. copyToArray(array: Float32Array, offset?: number): Matrix;
  4144. /**
  4145. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4146. * @param other defines the second operand
  4147. * @param result defines the matrix where to store the multiplication
  4148. * @returns the current matrix
  4149. */
  4150. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4151. /**
  4152. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the array where to store the multiplication
  4155. * @param offset defines the offset in the target array where to start storing values
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4159. /**
  4160. * Check equality between this matrix and a second one
  4161. * @param value defines the second matrix to compare
  4162. * @returns true is the current matrix and the given one values are strictly equal
  4163. */
  4164. equals(value: DeepImmutable<Matrix>): boolean;
  4165. /**
  4166. * Clone the current matrix
  4167. * @returns a new matrix from the current matrix
  4168. */
  4169. clone(): Matrix;
  4170. /**
  4171. * Returns the name of the current matrix class
  4172. * @returns the string "Matrix"
  4173. */
  4174. getClassName(): string;
  4175. /**
  4176. * Gets the hash code of the current matrix
  4177. * @returns the hash code
  4178. */
  4179. getHashCode(): number;
  4180. /**
  4181. * Decomposes the current Matrix into a translation, rotation and scaling components
  4182. * @param scale defines the scale vector3 given as a reference to update
  4183. * @param rotation defines the rotation quaternion given as a reference to update
  4184. * @param translation defines the translation vector3 given as a reference to update
  4185. * @returns true if operation was successful
  4186. */
  4187. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4188. /**
  4189. * Gets specific row of the matrix
  4190. * @param index defines the number of the row to get
  4191. * @returns the index-th row of the current matrix as a new Vector4
  4192. */
  4193. getRow(index: number): Nullable<Vector4>;
  4194. /**
  4195. * Sets the index-th row of the current matrix to the vector4 values
  4196. * @param index defines the number of the row to set
  4197. * @param row defines the target vector4
  4198. * @returns the updated current matrix
  4199. */
  4200. setRow(index: number, row: Vector4): Matrix;
  4201. /**
  4202. * Compute the transpose of the matrix
  4203. * @returns the new transposed matrix
  4204. */
  4205. transpose(): Matrix;
  4206. /**
  4207. * Compute the transpose of the matrix and store it in a given matrix
  4208. * @param result defines the target matrix
  4209. * @returns the current matrix
  4210. */
  4211. transposeToRef(result: Matrix): Matrix;
  4212. /**
  4213. * Sets the index-th row of the current matrix with the given 4 x float values
  4214. * @param index defines the row index
  4215. * @param x defines the x component to set
  4216. * @param y defines the y component to set
  4217. * @param z defines the z component to set
  4218. * @param w defines the w component to set
  4219. * @returns the updated current matrix
  4220. */
  4221. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4222. /**
  4223. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4224. * @param scale defines the scale factor
  4225. * @returns a new matrix
  4226. */
  4227. scale(scale: number): Matrix;
  4228. /**
  4229. * Scale the current matrix values by a factor to a given result matrix
  4230. * @param scale defines the scale factor
  4231. * @param result defines the matrix to store the result
  4232. * @returns the current matrix
  4233. */
  4234. scaleToRef(scale: number, result: Matrix): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor and add the result to a given matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the Matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4244. * @param ref matrix to store the result
  4245. */
  4246. toNormalMatrix(ref: Matrix): void;
  4247. /**
  4248. * Gets only rotation part of the current matrix
  4249. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4250. */
  4251. getRotationMatrix(): Matrix;
  4252. /**
  4253. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4254. * @param result defines the target matrix to store data to
  4255. * @returns the current matrix
  4256. */
  4257. getRotationMatrixToRef(result: Matrix): Matrix;
  4258. /**
  4259. * Toggles model matrix from being right handed to left handed in place and vice versa
  4260. */
  4261. toggleModelMatrixHandInPlace(): void;
  4262. /**
  4263. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4264. */
  4265. toggleProjectionMatrixHandInPlace(): void;
  4266. /**
  4267. * Creates a matrix from an array
  4268. * @param array defines the source array
  4269. * @param offset defines an offset in the source array
  4270. * @returns a new Matrix set from the starting index of the given array
  4271. */
  4272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4273. /**
  4274. * Copy the content of an array into a given matrix
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @param result defines the target matrix
  4278. */
  4279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4280. /**
  4281. * Stores an array into a matrix after having multiplied each component by a given factor
  4282. * @param array defines the source array
  4283. * @param offset defines the offset in the source array
  4284. * @param scale defines the scaling factor
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4288. /**
  4289. * Gets an identity matrix that must not be updated
  4290. */
  4291. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4292. /**
  4293. * Stores a list of values (16) inside a given matrix
  4294. * @param initialM11 defines 1st value of 1st row
  4295. * @param initialM12 defines 2nd value of 1st row
  4296. * @param initialM13 defines 3rd value of 1st row
  4297. * @param initialM14 defines 4th value of 1st row
  4298. * @param initialM21 defines 1st value of 2nd row
  4299. * @param initialM22 defines 2nd value of 2nd row
  4300. * @param initialM23 defines 3rd value of 2nd row
  4301. * @param initialM24 defines 4th value of 2nd row
  4302. * @param initialM31 defines 1st value of 3rd row
  4303. * @param initialM32 defines 2nd value of 3rd row
  4304. * @param initialM33 defines 3rd value of 3rd row
  4305. * @param initialM34 defines 4th value of 3rd row
  4306. * @param initialM41 defines 1st value of 4th row
  4307. * @param initialM42 defines 2nd value of 4th row
  4308. * @param initialM43 defines 3rd value of 4th row
  4309. * @param initialM44 defines 4th value of 4th row
  4310. * @param result defines the target matrix
  4311. */
  4312. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4313. /**
  4314. * Creates new matrix from a list of values (16)
  4315. * @param initialM11 defines 1st value of 1st row
  4316. * @param initialM12 defines 2nd value of 1st row
  4317. * @param initialM13 defines 3rd value of 1st row
  4318. * @param initialM14 defines 4th value of 1st row
  4319. * @param initialM21 defines 1st value of 2nd row
  4320. * @param initialM22 defines 2nd value of 2nd row
  4321. * @param initialM23 defines 3rd value of 2nd row
  4322. * @param initialM24 defines 4th value of 2nd row
  4323. * @param initialM31 defines 1st value of 3rd row
  4324. * @param initialM32 defines 2nd value of 3rd row
  4325. * @param initialM33 defines 3rd value of 3rd row
  4326. * @param initialM34 defines 4th value of 3rd row
  4327. * @param initialM41 defines 1st value of 4th row
  4328. * @param initialM42 defines 2nd value of 4th row
  4329. * @param initialM43 defines 3rd value of 4th row
  4330. * @param initialM44 defines 4th value of 4th row
  4331. * @returns the new matrix
  4332. */
  4333. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4334. /**
  4335. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4336. * @param scale defines the scale vector3
  4337. * @param rotation defines the rotation quaternion
  4338. * @param translation defines the translation vector3
  4339. * @returns a new matrix
  4340. */
  4341. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4342. /**
  4343. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @param result defines the target matrix
  4348. */
  4349. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4350. /**
  4351. * Creates a new identity matrix
  4352. * @returns a new identity matrix
  4353. */
  4354. static Identity(): Matrix;
  4355. /**
  4356. * Creates a new identity matrix and stores the result in a given matrix
  4357. * @param result defines the target matrix
  4358. */
  4359. static IdentityToRef(result: Matrix): void;
  4360. /**
  4361. * Creates a new zero matrix
  4362. * @returns a new zero matrix
  4363. */
  4364. static Zero(): Matrix;
  4365. /**
  4366. * Creates a new rotation matrix for "angle" radians around the X axis
  4367. * @param angle defines the angle (in radians) to use
  4368. * @return the new matrix
  4369. */
  4370. static RotationX(angle: number): Matrix;
  4371. /**
  4372. * Creates a new matrix as the invert of a given matrix
  4373. * @param source defines the source matrix
  4374. * @returns the new matrix
  4375. */
  4376. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4377. /**
  4378. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4379. * @param angle defines the angle (in radians) to use
  4380. * @param result defines the target matrix
  4381. */
  4382. static RotationXToRef(angle: number, result: Matrix): void;
  4383. /**
  4384. * Creates a new rotation matrix for "angle" radians around the Y axis
  4385. * @param angle defines the angle (in radians) to use
  4386. * @return the new matrix
  4387. */
  4388. static RotationY(angle: number): Matrix;
  4389. /**
  4390. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4391. * @param angle defines the angle (in radians) to use
  4392. * @param result defines the target matrix
  4393. */
  4394. static RotationYToRef(angle: number, result: Matrix): void;
  4395. /**
  4396. * Creates a new rotation matrix for "angle" radians around the Z axis
  4397. * @param angle defines the angle (in radians) to use
  4398. * @return the new matrix
  4399. */
  4400. static RotationZ(angle: number): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4403. * @param angle defines the angle (in radians) to use
  4404. * @param result defines the target matrix
  4405. */
  4406. static RotationZToRef(angle: number, result: Matrix): void;
  4407. /**
  4408. * Creates a new rotation matrix for "angle" radians around the given axis
  4409. * @param axis defines the axis to use
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @param result defines the target matrix
  4419. */
  4420. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4421. /**
  4422. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4423. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4424. * @param from defines the vector to align
  4425. * @param to defines the vector to align to
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Creates a rotation matrix
  4431. * @param yaw defines the yaw angle in radians (Y axis)
  4432. * @param pitch defines the pitch angle in radians (X axis)
  4433. * @param roll defines the roll angle in radians (X axis)
  4434. * @returns the new rotation matrix
  4435. */
  4436. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4437. /**
  4438. * Creates a rotation matrix and stores it in a given matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @param result defines the target matrix
  4443. */
  4444. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4445. /**
  4446. * Creates a scaling matrix
  4447. * @param x defines the scale factor on X axis
  4448. * @param y defines the scale factor on Y axis
  4449. * @param z defines the scale factor on Z axis
  4450. * @returns the new matrix
  4451. */
  4452. static Scaling(x: number, y: number, z: number): Matrix;
  4453. /**
  4454. * Creates a scaling matrix and stores it in a given matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @param result defines the target matrix
  4459. */
  4460. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4461. /**
  4462. * Creates a translation matrix
  4463. * @param x defines the translation on X axis
  4464. * @param y defines the translation on Y axis
  4465. * @param z defines the translationon Z axis
  4466. * @returns the new matrix
  4467. */
  4468. static Translation(x: number, y: number, z: number): Matrix;
  4469. /**
  4470. * Creates a translation matrix and stores it in a given matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @param result defines the target matrix
  4475. */
  4476. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4477. /**
  4478. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4479. * @param startValue defines the start value
  4480. * @param endValue defines the end value
  4481. * @param gradient defines the gradient factor
  4482. * @returns the new matrix
  4483. */
  4484. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4485. /**
  4486. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @param result defines the Matrix object where to store data
  4491. */
  4492. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4493. /**
  4494. * Builds a new matrix whose values are computed by:
  4495. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4496. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4497. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4498. * @param startValue defines the first matrix
  4499. * @param endValue defines the second matrix
  4500. * @param gradient defines the gradient between the two matrices
  4501. * @returns the new matrix
  4502. */
  4503. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4504. /**
  4505. * Update a matrix to values which are computed by:
  4506. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4507. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4508. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4509. * @param startValue defines the first matrix
  4510. * @param endValue defines the second matrix
  4511. * @param gradient defines the gradient between the two matrices
  4512. * @param result defines the target matrix
  4513. */
  4514. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4515. /**
  4516. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4517. * This function works in left handed mode
  4518. * @param eye defines the final position of the entity
  4519. * @param target defines where the entity should look at
  4520. * @param up defines the up vector for the entity
  4521. * @returns the new matrix
  4522. */
  4523. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4524. /**
  4525. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4526. * This function works in left handed mode
  4527. * @param eye defines the final position of the entity
  4528. * @param target defines where the entity should look at
  4529. * @param up defines the up vector for the entity
  4530. * @param result defines the target matrix
  4531. */
  4532. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4535. * This function works in right handed mode
  4536. * @param eye defines the final position of the entity
  4537. * @param target defines where the entity should look at
  4538. * @param up defines the up vector for the entity
  4539. * @returns the new matrix
  4540. */
  4541. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4542. /**
  4543. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4544. * This function works in right handed mode
  4545. * @param eye defines the final position of the entity
  4546. * @param target defines where the entity should look at
  4547. * @param up defines the up vector for the entity
  4548. * @param result defines the target matrix
  4549. */
  4550. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Create a left-handed orthographic projection matrix
  4553. * @param width defines the viewport width
  4554. * @param height defines the viewport height
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a left-handed orthographic projection matrix
  4558. */
  4559. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Store a left-handed orthographic projection to a given matrix
  4562. * @param width defines the viewport width
  4563. * @param height defines the viewport height
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. */
  4568. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4569. /**
  4570. * Create a left-handed orthographic projection matrix
  4571. * @param left defines the viewport left coordinate
  4572. * @param right defines the viewport right coordinate
  4573. * @param bottom defines the viewport bottom coordinate
  4574. * @param top defines the viewport top coordinate
  4575. * @param znear defines the near clip plane
  4576. * @param zfar defines the far clip plane
  4577. * @returns a new matrix as a left-handed orthographic projection matrix
  4578. */
  4579. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4580. /**
  4581. * Stores a left-handed orthographic projection into a given matrix
  4582. * @param left defines the viewport left coordinate
  4583. * @param right defines the viewport right coordinate
  4584. * @param bottom defines the viewport bottom coordinate
  4585. * @param top defines the viewport top coordinate
  4586. * @param znear defines the near clip plane
  4587. * @param zfar defines the far clip plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4591. /**
  4592. * Creates a right-handed orthographic projection matrix
  4593. * @param left defines the viewport left coordinate
  4594. * @param right defines the viewport right coordinate
  4595. * @param bottom defines the viewport bottom coordinate
  4596. * @param top defines the viewport top coordinate
  4597. * @param znear defines the near clip plane
  4598. * @param zfar defines the far clip plane
  4599. * @returns a new matrix as a right-handed orthographic projection matrix
  4600. */
  4601. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4602. /**
  4603. * Stores a right-handed orthographic projection into a given matrix
  4604. * @param left defines the viewport left coordinate
  4605. * @param right defines the viewport right coordinate
  4606. * @param bottom defines the viewport bottom coordinate
  4607. * @param top defines the viewport top coordinate
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Creates a left-handed perspective projection matrix
  4615. * @param width defines the viewport width
  4616. * @param height defines the viewport height
  4617. * @param znear defines the near clip plane
  4618. * @param zfar defines the far clip plane
  4619. * @returns a new matrix as a left-handed perspective projection matrix
  4620. */
  4621. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4622. /**
  4623. * Creates a left-handed perspective projection matrix
  4624. * @param fov defines the horizontal field of view
  4625. * @param aspect defines the aspect ratio
  4626. * @param znear defines the near clip plane
  4627. * @param zfar defines the far clip plane
  4628. * @returns a new matrix as a left-handed perspective projection matrix
  4629. */
  4630. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4631. /**
  4632. * Stores a left-handed perspective projection into a given matrix
  4633. * @param fov defines the horizontal field of view
  4634. * @param aspect defines the aspect ratio
  4635. * @param znear defines the near clip plane
  4636. * @param zfar defines the far clip plane
  4637. * @param result defines the target matrix
  4638. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4639. */
  4640. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4641. /**
  4642. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4643. * @param fov defines the horizontal field of view
  4644. * @param aspect defines the aspect ratio
  4645. * @param znear defines the near clip plane
  4646. * @param zfar not used as infinity is used as far clip
  4647. * @param result defines the target matrix
  4648. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4649. */
  4650. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4651. /**
  4652. * Creates a right-handed perspective projection matrix
  4653. * @param fov defines the horizontal field of view
  4654. * @param aspect defines the aspect ratio
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a right-handed perspective projection matrix
  4658. */
  4659. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Stores a right-handed perspective projection into a given matrix
  4662. * @param fov defines the horizontal field of view
  4663. * @param aspect defines the aspect ratio
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4668. */
  4669. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4670. /**
  4671. * Stores a right-handed perspective projection into a given matrix
  4672. * @param fov defines the horizontal field of view
  4673. * @param aspect defines the aspect ratio
  4674. * @param znear defines the near clip plane
  4675. * @param zfar not used as infinity is used as far clip
  4676. * @param result defines the target matrix
  4677. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4678. */
  4679. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4680. /**
  4681. * Stores a perspective projection for WebVR info a given matrix
  4682. * @param fov defines the field of view
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @param result defines the target matrix
  4686. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4687. */
  4688. static PerspectiveFovWebVRToRef(fov: {
  4689. upDegrees: number;
  4690. downDegrees: number;
  4691. leftDegrees: number;
  4692. rightDegrees: number;
  4693. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4694. /**
  4695. * Computes a complete transformation matrix
  4696. * @param viewport defines the viewport to use
  4697. * @param world defines the world matrix
  4698. * @param view defines the view matrix
  4699. * @param projection defines the projection matrix
  4700. * @param zmin defines the near clip plane
  4701. * @param zmax defines the far clip plane
  4702. * @returns the transformation matrix
  4703. */
  4704. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4705. /**
  4706. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4707. * @param matrix defines the matrix to use
  4708. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4709. */
  4710. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4711. /**
  4712. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4713. * @param matrix defines the matrix to use
  4714. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4715. */
  4716. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4717. /**
  4718. * Compute the transpose of a given matrix
  4719. * @param matrix defines the matrix to transpose
  4720. * @returns the new matrix
  4721. */
  4722. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4723. /**
  4724. * Compute the transpose of a matrix and store it in a target matrix
  4725. * @param matrix defines the matrix to transpose
  4726. * @param result defines the target matrix
  4727. */
  4728. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4729. /**
  4730. * Computes a reflection matrix from a plane
  4731. * @param plane defines the reflection plane
  4732. * @returns a new matrix
  4733. */
  4734. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4735. /**
  4736. * Computes a reflection matrix from a plane
  4737. * @param plane defines the reflection plane
  4738. * @param result defines the target matrix
  4739. */
  4740. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4741. /**
  4742. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4743. * @param xaxis defines the value of the 1st axis
  4744. * @param yaxis defines the value of the 2nd axis
  4745. * @param zaxis defines the value of the 3rd axis
  4746. * @param result defines the target matrix
  4747. */
  4748. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4749. /**
  4750. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4751. * @param quat defines the quaternion to use
  4752. * @param result defines the target matrix
  4753. */
  4754. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4755. }
  4756. /**
  4757. * @hidden
  4758. */
  4759. export class TmpVectors {
  4760. static Vector2: Vector2[];
  4761. static Vector3: Vector3[];
  4762. static Vector4: Vector4[];
  4763. static Quaternion: Quaternion[];
  4764. static Matrix: Matrix[];
  4765. }
  4766. }
  4767. declare module BABYLON {
  4768. /**
  4769. * Defines potential orientation for back face culling
  4770. */
  4771. export enum Orientation {
  4772. /**
  4773. * Clockwise
  4774. */
  4775. CW = 0,
  4776. /** Counter clockwise */
  4777. CCW = 1
  4778. }
  4779. /** Class used to represent a Bezier curve */
  4780. export class BezierCurve {
  4781. /**
  4782. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4783. * @param t defines the time
  4784. * @param x1 defines the left coordinate on X axis
  4785. * @param y1 defines the left coordinate on Y axis
  4786. * @param x2 defines the right coordinate on X axis
  4787. * @param y2 defines the right coordinate on Y axis
  4788. * @returns the interpolated value
  4789. */
  4790. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4791. }
  4792. /**
  4793. * Defines angle representation
  4794. */
  4795. export class Angle {
  4796. private _radians;
  4797. /**
  4798. * Creates an Angle object of "radians" radians (float).
  4799. * @param radians the angle in radians
  4800. */
  4801. constructor(radians: number);
  4802. /**
  4803. * Get value in degrees
  4804. * @returns the Angle value in degrees (float)
  4805. */
  4806. degrees(): number;
  4807. /**
  4808. * Get value in radians
  4809. * @returns the Angle value in radians (float)
  4810. */
  4811. radians(): number;
  4812. /**
  4813. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4814. * @param a defines first vector
  4815. * @param b defines second vector
  4816. * @returns a new Angle
  4817. */
  4818. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4819. /**
  4820. * Gets a new Angle object from the given float in radians
  4821. * @param radians defines the angle value in radians
  4822. * @returns a new Angle
  4823. */
  4824. static FromRadians(radians: number): Angle;
  4825. /**
  4826. * Gets a new Angle object from the given float in degrees
  4827. * @param degrees defines the angle value in degrees
  4828. * @returns a new Angle
  4829. */
  4830. static FromDegrees(degrees: number): Angle;
  4831. }
  4832. /**
  4833. * This represents an arc in a 2d space.
  4834. */
  4835. export class Arc2 {
  4836. /** Defines the start point of the arc */
  4837. startPoint: Vector2;
  4838. /** Defines the mid point of the arc */
  4839. midPoint: Vector2;
  4840. /** Defines the end point of the arc */
  4841. endPoint: Vector2;
  4842. /**
  4843. * Defines the center point of the arc.
  4844. */
  4845. centerPoint: Vector2;
  4846. /**
  4847. * Defines the radius of the arc.
  4848. */
  4849. radius: number;
  4850. /**
  4851. * Defines the angle of the arc (from mid point to end point).
  4852. */
  4853. angle: Angle;
  4854. /**
  4855. * Defines the start angle of the arc (from start point to middle point).
  4856. */
  4857. startAngle: Angle;
  4858. /**
  4859. * Defines the orientation of the arc (clock wise/counter clock wise).
  4860. */
  4861. orientation: Orientation;
  4862. /**
  4863. * Creates an Arc object from the three given points : start, middle and end.
  4864. * @param startPoint Defines the start point of the arc
  4865. * @param midPoint Defines the midlle point of the arc
  4866. * @param endPoint Defines the end point of the arc
  4867. */
  4868. constructor(
  4869. /** Defines the start point of the arc */
  4870. startPoint: Vector2,
  4871. /** Defines the mid point of the arc */
  4872. midPoint: Vector2,
  4873. /** Defines the end point of the arc */
  4874. endPoint: Vector2);
  4875. }
  4876. /**
  4877. * Represents a 2D path made up of multiple 2D points
  4878. */
  4879. export class Path2 {
  4880. private _points;
  4881. private _length;
  4882. /**
  4883. * If the path start and end point are the same
  4884. */
  4885. closed: boolean;
  4886. /**
  4887. * Creates a Path2 object from the starting 2D coordinates x and y.
  4888. * @param x the starting points x value
  4889. * @param y the starting points y value
  4890. */
  4891. constructor(x: number, y: number);
  4892. /**
  4893. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4894. * @param x the added points x value
  4895. * @param y the added points y value
  4896. * @returns the updated Path2.
  4897. */
  4898. addLineTo(x: number, y: number): Path2;
  4899. /**
  4900. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4901. * @param midX middle point x value
  4902. * @param midY middle point y value
  4903. * @param endX end point x value
  4904. * @param endY end point y value
  4905. * @param numberOfSegments (default: 36)
  4906. * @returns the updated Path2.
  4907. */
  4908. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4909. /**
  4910. * Closes the Path2.
  4911. * @returns the Path2.
  4912. */
  4913. close(): Path2;
  4914. /**
  4915. * Gets the sum of the distance between each sequential point in the path
  4916. * @returns the Path2 total length (float).
  4917. */
  4918. length(): number;
  4919. /**
  4920. * Gets the points which construct the path
  4921. * @returns the Path2 internal array of points.
  4922. */
  4923. getPoints(): Vector2[];
  4924. /**
  4925. * Retreives the point at the distance aways from the starting point
  4926. * @param normalizedLengthPosition the length along the path to retreive the point from
  4927. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4928. */
  4929. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4930. /**
  4931. * Creates a new path starting from an x and y position
  4932. * @param x starting x value
  4933. * @param y starting y value
  4934. * @returns a new Path2 starting at the coordinates (x, y).
  4935. */
  4936. static StartingAt(x: number, y: number): Path2;
  4937. }
  4938. /**
  4939. * Represents a 3D path made up of multiple 3D points
  4940. */
  4941. export class Path3D {
  4942. /**
  4943. * an array of Vector3, the curve axis of the Path3D
  4944. */
  4945. path: Vector3[];
  4946. private _curve;
  4947. private _distances;
  4948. private _tangents;
  4949. private _normals;
  4950. private _binormals;
  4951. private _raw;
  4952. private _alignTangentsWithPath;
  4953. private readonly _pointAtData;
  4954. /**
  4955. * new Path3D(path, normal, raw)
  4956. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4957. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4958. * @param path an array of Vector3, the curve axis of the Path3D
  4959. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4960. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4961. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4962. */
  4963. constructor(
  4964. /**
  4965. * an array of Vector3, the curve axis of the Path3D
  4966. */
  4967. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4968. /**
  4969. * Returns the Path3D array of successive Vector3 designing its curve.
  4970. * @returns the Path3D array of successive Vector3 designing its curve.
  4971. */
  4972. getCurve(): Vector3[];
  4973. /**
  4974. * Returns the Path3D array of successive Vector3 designing its curve.
  4975. * @returns the Path3D array of successive Vector3 designing its curve.
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the path.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns an array populated with tangent vectors on each Path3D curve point.
  4984. * @returns an array populated with tangent vectors on each Path3D curve point.
  4985. */
  4986. getTangents(): Vector3[];
  4987. /**
  4988. * Returns an array populated with normal vectors on each Path3D curve point.
  4989. * @returns an array populated with normal vectors on each Path3D curve point.
  4990. */
  4991. getNormals(): Vector3[];
  4992. /**
  4993. * Returns an array populated with binormal vectors on each Path3D curve point.
  4994. * @returns an array populated with binormal vectors on each Path3D curve point.
  4995. */
  4996. getBinormals(): Vector3[];
  4997. /**
  4998. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4999. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5000. */
  5001. getDistances(): number[];
  5002. /**
  5003. * Returns an interpolated point along this path
  5004. * @param position the position of the point along this path, from 0.0 to 1.0
  5005. * @returns a new Vector3 as the point
  5006. */
  5007. getPointAt(position: number): Vector3;
  5008. /**
  5009. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5010. * @param position the position of the point along this path, from 0.0 to 1.0
  5011. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5012. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5013. */
  5014. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5019. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5020. */
  5021. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5026. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5027. */
  5028. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5033. */
  5034. getDistanceAt(position: number): number;
  5035. /**
  5036. * Returns the array index of the previous point of an interpolated point along this path
  5037. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5038. * @returns the array index
  5039. */
  5040. getPreviousPointIndexAt(position: number): number;
  5041. /**
  5042. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5043. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5044. * @returns the sub position
  5045. */
  5046. getSubPositionAt(position: number): number;
  5047. /**
  5048. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5049. * @param target the vector of which to get the closest position to
  5050. * @returns the position of the closest virtual point on this path to the target vector
  5051. */
  5052. getClosestPositionTo(target: Vector3): number;
  5053. /**
  5054. * Returns a sub path (slice) of this path
  5055. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5056. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5057. * @returns a sub path (slice) of this path
  5058. */
  5059. slice(start?: number, end?: number): Path3D;
  5060. /**
  5061. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5062. * @param path path which all values are copied into the curves points
  5063. * @param firstNormal which should be projected onto the curve
  5064. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5065. * @returns the same object updated.
  5066. */
  5067. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5068. private _compute;
  5069. private _getFirstNonNullVector;
  5070. private _getLastNonNullVector;
  5071. private _normalVector;
  5072. /**
  5073. * Updates the point at data for an interpolated point along this curve
  5074. * @param position the position of the point along this curve, from 0.0 to 1.0
  5075. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5076. * @returns the (updated) point at data
  5077. */
  5078. private _updatePointAtData;
  5079. /**
  5080. * Updates the point at data from the specified parameters
  5081. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5082. * @param point the interpolated point
  5083. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5084. */
  5085. private _setPointAtData;
  5086. /**
  5087. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5088. */
  5089. private _updateInterpolationMatrix;
  5090. }
  5091. /**
  5092. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5093. * A Curve3 is designed from a series of successive Vector3.
  5094. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5095. */
  5096. export class Curve3 {
  5097. private _points;
  5098. private _length;
  5099. /**
  5100. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5101. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5102. * @param v1 (Vector3) the control point
  5103. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5104. * @param nbPoints (integer) the wanted number of points in the curve
  5105. * @returns the created Curve3
  5106. */
  5107. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5108. /**
  5109. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5110. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5111. * @param v1 (Vector3) the first control point
  5112. * @param v2 (Vector3) the second control point
  5113. * @param v3 (Vector3) the end point of the Cubic Bezier
  5114. * @param nbPoints (integer) the wanted number of points in the curve
  5115. * @returns the created Curve3
  5116. */
  5117. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5118. /**
  5119. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5120. * @param p1 (Vector3) the origin point of the Hermite Spline
  5121. * @param t1 (Vector3) the tangent vector at the origin point
  5122. * @param p2 (Vector3) the end point of the Hermite Spline
  5123. * @param t2 (Vector3) the tangent vector at the end point
  5124. * @param nbPoints (integer) the wanted number of points in the curve
  5125. * @returns the created Curve3
  5126. */
  5127. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5128. /**
  5129. * Returns a Curve3 object along a CatmullRom Spline curve :
  5130. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5131. * @param nbPoints (integer) the wanted number of points between each curve control points
  5132. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5136. /**
  5137. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5138. * A Curve3 is designed from a series of successive Vector3.
  5139. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5140. * @param points points which make up the curve
  5141. */
  5142. constructor(points: Vector3[]);
  5143. /**
  5144. * @returns the Curve3 stored array of successive Vector3
  5145. */
  5146. getPoints(): Vector3[];
  5147. /**
  5148. * @returns the computed length (float) of the curve.
  5149. */
  5150. length(): number;
  5151. /**
  5152. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5153. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5154. * curveA and curveB keep unchanged.
  5155. * @param curve the curve to continue from this curve
  5156. * @returns the newly constructed curve
  5157. */
  5158. continue(curve: DeepImmutable<Curve3>): Curve3;
  5159. private _computeLength;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * This represents the main contract an easing function should follow.
  5165. * Easing functions are used throughout the animation system.
  5166. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5167. */
  5168. export interface IEasingFunction {
  5169. /**
  5170. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5171. * of the easing function.
  5172. * The link below provides some of the most common examples of easing functions.
  5173. * @see https://easings.net/
  5174. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5175. * @returns the corresponding value on the curve defined by the easing function
  5176. */
  5177. ease(gradient: number): number;
  5178. }
  5179. /**
  5180. * Base class used for every default easing function.
  5181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5182. */
  5183. export class EasingFunction implements IEasingFunction {
  5184. /**
  5185. * Interpolation follows the mathematical formula associated with the easing function.
  5186. */
  5187. static readonly EASINGMODE_EASEIN: number;
  5188. /**
  5189. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5190. */
  5191. static readonly EASINGMODE_EASEOUT: number;
  5192. /**
  5193. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5194. */
  5195. static readonly EASINGMODE_EASEINOUT: number;
  5196. private _easingMode;
  5197. /**
  5198. * Sets the easing mode of the current function.
  5199. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5200. */
  5201. setEasingMode(easingMode: number): void;
  5202. /**
  5203. * Gets the current easing mode.
  5204. * @returns the easing mode
  5205. */
  5206. getEasingMode(): number;
  5207. /**
  5208. * @hidden
  5209. */
  5210. easeInCore(gradient: number): number;
  5211. /**
  5212. * Given an input gradient between 0 and 1, this returns the corresponding value
  5213. * of the easing function.
  5214. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5215. * @returns the corresponding value on the curve defined by the easing function
  5216. */
  5217. ease(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a circle shape (see link below).
  5221. * @see https://easings.net/#easeInCirc
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class CircleEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a ease back shape (see link below).
  5230. * @see https://easings.net/#easeInBack
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BackEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the amplitude of the function */
  5235. amplitude: number;
  5236. /**
  5237. * Instantiates a back ease easing
  5238. * @see https://easings.net/#easeInBack
  5239. * @param amplitude Defines the amplitude of the function
  5240. */
  5241. constructor(
  5242. /** Defines the amplitude of the function */
  5243. amplitude?: number);
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a bouncing shape (see link below).
  5249. * @see https://easings.net/#easeInBounce
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class BounceEase extends EasingFunction implements IEasingFunction {
  5253. /** Defines the number of bounces */
  5254. bounces: number;
  5255. /** Defines the amplitude of the bounce */
  5256. bounciness: number;
  5257. /**
  5258. * Instantiates a bounce easing
  5259. * @see https://easings.net/#easeInBounce
  5260. * @param bounces Defines the number of bounces
  5261. * @param bounciness Defines the amplitude of the bounce
  5262. */
  5263. constructor(
  5264. /** Defines the number of bounces */
  5265. bounces?: number,
  5266. /** Defines the amplitude of the bounce */
  5267. bounciness?: number);
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a power of 3 shape (see link below).
  5273. * @see https://easings.net/#easeInCubic
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class CubicEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with an elastic shape (see link below).
  5282. * @see https://easings.net/#easeInElastic
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the number of oscillations*/
  5287. oscillations: number;
  5288. /** Defines the amplitude of the oscillations*/
  5289. springiness: number;
  5290. /**
  5291. * Instantiates an elastic easing function
  5292. * @see https://easings.net/#easeInElastic
  5293. * @param oscillations Defines the number of oscillations
  5294. * @param springiness Defines the amplitude of the oscillations
  5295. */
  5296. constructor(
  5297. /** Defines the number of oscillations*/
  5298. oscillations?: number,
  5299. /** Defines the amplitude of the oscillations*/
  5300. springiness?: number);
  5301. /** @hidden */
  5302. easeInCore(gradient: number): number;
  5303. }
  5304. /**
  5305. * Easing function with an exponential shape (see link below).
  5306. * @see https://easings.net/#easeInExpo
  5307. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5308. */
  5309. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5310. /** Defines the exponent of the function */
  5311. exponent: number;
  5312. /**
  5313. * Instantiates an exponential easing function
  5314. * @see https://easings.net/#easeInExpo
  5315. * @param exponent Defines the exponent of the function
  5316. */
  5317. constructor(
  5318. /** Defines the exponent of the function */
  5319. exponent?: number);
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a power shape (see link below).
  5325. * @see https://easings.net/#easeInQuad
  5326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class PowerEase extends EasingFunction implements IEasingFunction {
  5329. /** Defines the power of the function */
  5330. power: number;
  5331. /**
  5332. * Instantiates an power base easing function
  5333. * @see https://easings.net/#easeInQuad
  5334. * @param power Defines the power of the function
  5335. */
  5336. constructor(
  5337. /** Defines the power of the function */
  5338. power?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with a power of 2 shape (see link below).
  5344. * @see https://easings.net/#easeInQuad
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a power of 4 shape (see link below).
  5353. * @see https://easings.net/#easeInQuart
  5354. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5357. /** @hidden */
  5358. easeInCore(gradient: number): number;
  5359. }
  5360. /**
  5361. * Easing function with a power of 5 shape (see link below).
  5362. * @see https://easings.net/#easeInQuint
  5363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5364. */
  5365. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a sin shape (see link below).
  5371. * @see https://easings.net/#easeInSine
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class SineEase extends EasingFunction implements IEasingFunction {
  5375. /** @hidden */
  5376. easeInCore(gradient: number): number;
  5377. }
  5378. /**
  5379. * Easing function with a bezier shape (see link below).
  5380. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5382. */
  5383. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5384. /** Defines the x component of the start tangent in the bezier curve */
  5385. x1: number;
  5386. /** Defines the y component of the start tangent in the bezier curve */
  5387. y1: number;
  5388. /** Defines the x component of the end tangent in the bezier curve */
  5389. x2: number;
  5390. /** Defines the y component of the end tangent in the bezier curve */
  5391. y2: number;
  5392. /**
  5393. * Instantiates a bezier function
  5394. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5395. * @param x1 Defines the x component of the start tangent in the bezier curve
  5396. * @param y1 Defines the y component of the start tangent in the bezier curve
  5397. * @param x2 Defines the x component of the end tangent in the bezier curve
  5398. * @param y2 Defines the y component of the end tangent in the bezier curve
  5399. */
  5400. constructor(
  5401. /** Defines the x component of the start tangent in the bezier curve */
  5402. x1?: number,
  5403. /** Defines the y component of the start tangent in the bezier curve */
  5404. y1?: number,
  5405. /** Defines the x component of the end tangent in the bezier curve */
  5406. x2?: number,
  5407. /** Defines the y component of the end tangent in the bezier curve */
  5408. y2?: number);
  5409. /** @hidden */
  5410. easeInCore(gradient: number): number;
  5411. }
  5412. }
  5413. declare module BABYLON {
  5414. /**
  5415. * Class used to hold a RBG color
  5416. */
  5417. export class Color3 {
  5418. /**
  5419. * Defines the red component (between 0 and 1, default is 0)
  5420. */
  5421. r: number;
  5422. /**
  5423. * Defines the green component (between 0 and 1, default is 0)
  5424. */
  5425. g: number;
  5426. /**
  5427. * Defines the blue component (between 0 and 1, default is 0)
  5428. */
  5429. b: number;
  5430. /**
  5431. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5432. * @param r defines the red component (between 0 and 1, default is 0)
  5433. * @param g defines the green component (between 0 and 1, default is 0)
  5434. * @param b defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. constructor(
  5437. /**
  5438. * Defines the red component (between 0 and 1, default is 0)
  5439. */
  5440. r?: number,
  5441. /**
  5442. * Defines the green component (between 0 and 1, default is 0)
  5443. */
  5444. g?: number,
  5445. /**
  5446. * Defines the blue component (between 0 and 1, default is 0)
  5447. */
  5448. b?: number);
  5449. /**
  5450. * Creates a string with the Color3 current values
  5451. * @returns the string representation of the Color3 object
  5452. */
  5453. toString(): string;
  5454. /**
  5455. * Returns the string "Color3"
  5456. * @returns "Color3"
  5457. */
  5458. getClassName(): string;
  5459. /**
  5460. * Compute the Color3 hash code
  5461. * @returns an unique number that can be used to hash Color3 objects
  5462. */
  5463. getHashCode(): number;
  5464. /**
  5465. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5466. * @param array defines the array where to store the r,g,b components
  5467. * @param index defines an optional index in the target array to define where to start storing values
  5468. * @returns the current Color3 object
  5469. */
  5470. toArray(array: FloatArray, index?: number): Color3;
  5471. /**
  5472. * Returns a new Color4 object from the current Color3 and the given alpha
  5473. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5474. * @returns a new Color4 object
  5475. */
  5476. toColor4(alpha?: number): Color4;
  5477. /**
  5478. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5479. * @returns the new array
  5480. */
  5481. asArray(): number[];
  5482. /**
  5483. * Returns the luminance value
  5484. * @returns a float value
  5485. */
  5486. toLuminance(): number;
  5487. /**
  5488. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5489. * @param otherColor defines the second operand
  5490. * @returns the new Color3 object
  5491. */
  5492. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5493. /**
  5494. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5495. * @param otherColor defines the second operand
  5496. * @param result defines the Color3 object where to store the result
  5497. * @returns the current Color3
  5498. */
  5499. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5500. /**
  5501. * Determines equality between Color3 objects
  5502. * @param otherColor defines the second operand
  5503. * @returns true if the rgb values are equal to the given ones
  5504. */
  5505. equals(otherColor: DeepImmutable<Color3>): boolean;
  5506. /**
  5507. * Determines equality between the current Color3 object and a set of r,b,g values
  5508. * @param r defines the red component to check
  5509. * @param g defines the green component to check
  5510. * @param b defines the blue component to check
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equalsFloats(r: number, g: number, b: number): boolean;
  5514. /**
  5515. * Multiplies in place each rgb value by scale
  5516. * @param scale defines the scaling factor
  5517. * @returns the updated Color3
  5518. */
  5519. scale(scale: number): Color3;
  5520. /**
  5521. * Multiplies the rgb values by scale and stores the result into "result"
  5522. * @param scale defines the scaling factor
  5523. * @param result defines the Color3 object where to store the result
  5524. * @returns the unmodified current Color3
  5525. */
  5526. scaleToRef(scale: number, result: Color3): Color3;
  5527. /**
  5528. * Scale the current Color3 values by a factor and add the result to a given Color3
  5529. * @param scale defines the scale factor
  5530. * @param result defines color to store the result into
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Clamps the rgb values by the min and max values and stores the result into "result"
  5536. * @param min defines minimum clamping value (default is 0)
  5537. * @param max defines maximum clamping value (default is 1)
  5538. * @param result defines color to store the result into
  5539. * @returns the original Color3
  5540. */
  5541. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5542. /**
  5543. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5544. * @param otherColor defines the second operand
  5545. * @returns the new Color3
  5546. */
  5547. add(otherColor: DeepImmutable<Color3>): Color3;
  5548. /**
  5549. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5550. * @param otherColor defines the second operand
  5551. * @param result defines Color3 object to store the result into
  5552. * @returns the unmodified current Color3
  5553. */
  5554. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5555. /**
  5556. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5557. * @param otherColor defines the second operand
  5558. * @returns the new Color3
  5559. */
  5560. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5561. /**
  5562. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5563. * @param otherColor defines the second operand
  5564. * @param result defines Color3 object to store the result into
  5565. * @returns the unmodified current Color3
  5566. */
  5567. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5568. /**
  5569. * Copy the current object
  5570. * @returns a new Color3 copied the current one
  5571. */
  5572. clone(): Color3;
  5573. /**
  5574. * Copies the rgb values from the source in the current Color3
  5575. * @param source defines the source Color3 object
  5576. * @returns the updated Color3 object
  5577. */
  5578. copyFrom(source: DeepImmutable<Color3>): Color3;
  5579. /**
  5580. * Updates the Color3 rgb values from the given floats
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @returns the current Color3 object
  5585. */
  5586. copyFromFloats(r: number, g: number, b: number): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. set(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Compute the Color3 hexadecimal code as a string
  5597. * @returns a string containing the hexadecimal representation of the Color3 object
  5598. */
  5599. toHexString(): string;
  5600. /**
  5601. * Computes a new Color3 converted from the current one to linear space
  5602. * @returns a new Color3 object
  5603. */
  5604. toLinearSpace(): Color3;
  5605. /**
  5606. * Converts current color in rgb space to HSV values
  5607. * @returns a new color3 representing the HSV values
  5608. */
  5609. toHSV(): Color3;
  5610. /**
  5611. * Converts current color in rgb space to HSV values
  5612. * @param result defines the Color3 where to store the HSV values
  5613. */
  5614. toHSVToRef(result: Color3): void;
  5615. /**
  5616. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5617. * @param convertedColor defines the Color3 object where to store the linear space version
  5618. * @returns the unmodified Color3
  5619. */
  5620. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5621. /**
  5622. * Computes a new Color3 converted from the current one to gamma space
  5623. * @returns a new Color3 object
  5624. */
  5625. toGammaSpace(): Color3;
  5626. /**
  5627. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5628. * @param convertedColor defines the Color3 object where to store the gamma space version
  5629. * @returns the unmodified Color3
  5630. */
  5631. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5632. private static _BlackReadOnly;
  5633. /**
  5634. * Convert Hue, saturation and value to a Color3 (RGB)
  5635. * @param hue defines the hue
  5636. * @param saturation defines the saturation
  5637. * @param value defines the value
  5638. * @param result defines the Color3 where to store the RGB values
  5639. */
  5640. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5641. /**
  5642. * Creates a new Color3 from the string containing valid hexadecimal values
  5643. * @param hex defines a string containing valid hexadecimal values
  5644. * @returns a new Color3 object
  5645. */
  5646. static FromHexString(hex: string): Color3;
  5647. /**
  5648. * Creates a new Color3 from the starting index of the given array
  5649. * @param array defines the source array
  5650. * @param offset defines an offset in the source array
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5654. /**
  5655. * Creates a new Color3 from integer values (< 256)
  5656. * @param r defines the red component to read from (value between 0 and 255)
  5657. * @param g defines the green component to read from (value between 0 and 255)
  5658. * @param b defines the blue component to read from (value between 0 and 255)
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromInts(r: number, g: number, b: number): Color3;
  5662. /**
  5663. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5664. * @param start defines the start Color3 value
  5665. * @param end defines the end Color3 value
  5666. * @param amount defines the gradient value between start and end
  5667. * @returns a new Color3 object
  5668. */
  5669. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param left defines the start value
  5673. * @param right defines the end value
  5674. * @param amount defines the gradient factor
  5675. * @param result defines the Color3 object where to store the result
  5676. */
  5677. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5678. /**
  5679. * Returns a Color3 value containing a red color
  5680. * @returns a new Color3 object
  5681. */
  5682. static Red(): Color3;
  5683. /**
  5684. * Returns a Color3 value containing a green color
  5685. * @returns a new Color3 object
  5686. */
  5687. static Green(): Color3;
  5688. /**
  5689. * Returns a Color3 value containing a blue color
  5690. * @returns a new Color3 object
  5691. */
  5692. static Blue(): Color3;
  5693. /**
  5694. * Returns a Color3 value containing a black color
  5695. * @returns a new Color3 object
  5696. */
  5697. static Black(): Color3;
  5698. /**
  5699. * Gets a Color3 value containing a black color that must not be updated
  5700. */
  5701. static get BlackReadOnly(): DeepImmutable<Color3>;
  5702. /**
  5703. * Returns a Color3 value containing a white color
  5704. * @returns a new Color3 object
  5705. */
  5706. static White(): Color3;
  5707. /**
  5708. * Returns a Color3 value containing a purple color
  5709. * @returns a new Color3 object
  5710. */
  5711. static Purple(): Color3;
  5712. /**
  5713. * Returns a Color3 value containing a magenta color
  5714. * @returns a new Color3 object
  5715. */
  5716. static Magenta(): Color3;
  5717. /**
  5718. * Returns a Color3 value containing a yellow color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Yellow(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a gray color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Gray(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a teal color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Teal(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a random color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Random(): Color3;
  5737. }
  5738. /**
  5739. * Class used to hold a RBGA color
  5740. */
  5741. export class Color4 {
  5742. /**
  5743. * Defines the red component (between 0 and 1, default is 0)
  5744. */
  5745. r: number;
  5746. /**
  5747. * Defines the green component (between 0 and 1, default is 0)
  5748. */
  5749. g: number;
  5750. /**
  5751. * Defines the blue component (between 0 and 1, default is 0)
  5752. */
  5753. b: number;
  5754. /**
  5755. * Defines the alpha component (between 0 and 1, default is 1)
  5756. */
  5757. a: number;
  5758. /**
  5759. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5760. * @param r defines the red component (between 0 and 1, default is 0)
  5761. * @param g defines the green component (between 0 and 1, default is 0)
  5762. * @param b defines the blue component (between 0 and 1, default is 0)
  5763. * @param a defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. constructor(
  5766. /**
  5767. * Defines the red component (between 0 and 1, default is 0)
  5768. */
  5769. r?: number,
  5770. /**
  5771. * Defines the green component (between 0 and 1, default is 0)
  5772. */
  5773. g?: number,
  5774. /**
  5775. * Defines the blue component (between 0 and 1, default is 0)
  5776. */
  5777. b?: number,
  5778. /**
  5779. * Defines the alpha component (between 0 and 1, default is 1)
  5780. */
  5781. a?: number);
  5782. /**
  5783. * Adds in place the given Color4 values to the current Color4 object
  5784. * @param right defines the second operand
  5785. * @returns the current updated Color4 object
  5786. */
  5787. addInPlace(right: DeepImmutable<Color4>): Color4;
  5788. /**
  5789. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5790. * @returns the new array
  5791. */
  5792. asArray(): number[];
  5793. /**
  5794. * Stores from the starting index in the given array the Color4 successive values
  5795. * @param array defines the array where to store the r,g,b components
  5796. * @param index defines an optional index in the target array to define where to start storing values
  5797. * @returns the current Color4 object
  5798. */
  5799. toArray(array: number[], index?: number): Color4;
  5800. /**
  5801. * Determines equality between Color4 objects
  5802. * @param otherColor defines the second operand
  5803. * @returns true if the rgba values are equal to the given ones
  5804. */
  5805. equals(otherColor: DeepImmutable<Color4>): boolean;
  5806. /**
  5807. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5808. * @param right defines the second operand
  5809. * @returns a new Color4 object
  5810. */
  5811. add(right: DeepImmutable<Color4>): Color4;
  5812. /**
  5813. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5814. * @param right defines the second operand
  5815. * @returns a new Color4 object
  5816. */
  5817. subtract(right: DeepImmutable<Color4>): Color4;
  5818. /**
  5819. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5820. * @param right defines the second operand
  5821. * @param result defines the Color4 object where to store the result
  5822. * @returns the current Color4 object
  5823. */
  5824. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5825. /**
  5826. * Creates a new Color4 with the current Color4 values multiplied by scale
  5827. * @param scale defines the scaling factor to apply
  5828. * @returns a new Color4 object
  5829. */
  5830. scale(scale: number): Color4;
  5831. /**
  5832. * Multiplies the current Color4 values by scale and stores the result in "result"
  5833. * @param scale defines the scaling factor to apply
  5834. * @param result defines the Color4 object where to store the result
  5835. * @returns the current unmodified Color4
  5836. */
  5837. scaleToRef(scale: number, result: Color4): Color4;
  5838. /**
  5839. * Scale the current Color4 values by a factor and add the result to a given Color4
  5840. * @param scale defines the scale factor
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the unmodified current Color4
  5843. */
  5844. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Clamps the rgb values by the min and max values and stores the result into "result"
  5847. * @param min defines minimum clamping value (default is 0)
  5848. * @param max defines maximum clamping value (default is 1)
  5849. * @param result defines color to store the result into.
  5850. * @returns the cuurent Color4
  5851. */
  5852. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5853. /**
  5854. * Multipy an Color4 value by another and return a new Color4 object
  5855. * @param color defines the Color4 value to multiply by
  5856. * @returns a new Color4 object
  5857. */
  5858. multiply(color: Color4): Color4;
  5859. /**
  5860. * Multipy a Color4 value by another and push the result in a reference value
  5861. * @param color defines the Color4 value to multiply by
  5862. * @param result defines the Color4 to fill the result in
  5863. * @returns the result Color4
  5864. */
  5865. multiplyToRef(color: Color4, result: Color4): Color4;
  5866. /**
  5867. * Creates a string with the Color4 current values
  5868. * @returns the string representation of the Color4 object
  5869. */
  5870. toString(): string;
  5871. /**
  5872. * Returns the string "Color4"
  5873. * @returns "Color4"
  5874. */
  5875. getClassName(): string;
  5876. /**
  5877. * Compute the Color4 hash code
  5878. * @returns an unique number that can be used to hash Color4 objects
  5879. */
  5880. getHashCode(): number;
  5881. /**
  5882. * Creates a new Color4 copied from the current one
  5883. * @returns a new Color4 object
  5884. */
  5885. clone(): Color4;
  5886. /**
  5887. * Copies the given Color4 values into the current one
  5888. * @param source defines the source Color4 object
  5889. * @returns the current updated Color4 object
  5890. */
  5891. copyFrom(source: Color4): Color4;
  5892. /**
  5893. * Copies the given float values into the current one
  5894. * @param r defines the red component to read from
  5895. * @param g defines the green component to read from
  5896. * @param b defines the blue component to read from
  5897. * @param a defines the alpha component to read from
  5898. * @returns the current updated Color4 object
  5899. */
  5900. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5901. /**
  5902. * Copies the given float values into the current one
  5903. * @param r defines the red component to read from
  5904. * @param g defines the green component to read from
  5905. * @param b defines the blue component to read from
  5906. * @param a defines the alpha component to read from
  5907. * @returns the current updated Color4 object
  5908. */
  5909. set(r: number, g: number, b: number, a: number): Color4;
  5910. /**
  5911. * Compute the Color4 hexadecimal code as a string
  5912. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5913. * @returns a string containing the hexadecimal representation of the Color4 object
  5914. */
  5915. toHexString(returnAsColor3?: boolean): string;
  5916. /**
  5917. * Computes a new Color4 converted from the current one to linear space
  5918. * @returns a new Color4 object
  5919. */
  5920. toLinearSpace(): Color4;
  5921. /**
  5922. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5923. * @param convertedColor defines the Color4 object where to store the linear space version
  5924. * @returns the unmodified Color4
  5925. */
  5926. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5927. /**
  5928. * Computes a new Color4 converted from the current one to gamma space
  5929. * @returns a new Color4 object
  5930. */
  5931. toGammaSpace(): Color4;
  5932. /**
  5933. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5934. * @param convertedColor defines the Color4 object where to store the gamma space version
  5935. * @returns the unmodified Color4
  5936. */
  5937. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5938. /**
  5939. * Creates a new Color4 from the string containing valid hexadecimal values
  5940. * @param hex defines a string containing valid hexadecimal values
  5941. * @returns a new Color4 object
  5942. */
  5943. static FromHexString(hex: string): Color4;
  5944. /**
  5945. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5946. * @param left defines the start value
  5947. * @param right defines the end value
  5948. * @param amount defines the gradient factor
  5949. * @returns a new Color4 object
  5950. */
  5951. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5952. /**
  5953. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @param result defines the Color4 object where to store data
  5958. */
  5959. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5960. /**
  5961. * Creates a new Color4 from a Color3 and an alpha value
  5962. * @param color3 defines the source Color3 to read from
  5963. * @param alpha defines the alpha component (1.0 by default)
  5964. * @returns a new Color4 object
  5965. */
  5966. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5967. /**
  5968. * Creates a new Color4 from the starting index element of the given array
  5969. * @param array defines the source array to read from
  5970. * @param offset defines the offset in the source array
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5974. /**
  5975. * Creates a new Color3 from integer values (< 256)
  5976. * @param r defines the red component to read from (value between 0 and 255)
  5977. * @param g defines the green component to read from (value between 0 and 255)
  5978. * @param b defines the blue component to read from (value between 0 and 255)
  5979. * @param a defines the alpha component to read from (value between 0 and 255)
  5980. * @returns a new Color3 object
  5981. */
  5982. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5983. /**
  5984. * Check the content of a given array and convert it to an array containing RGBA data
  5985. * If the original array was already containing count * 4 values then it is returned directly
  5986. * @param colors defines the array to check
  5987. * @param count defines the number of RGBA data to expect
  5988. * @returns an array containing count * 4 values (RGBA)
  5989. */
  5990. static CheckColors4(colors: number[], count: number): number[];
  5991. }
  5992. /**
  5993. * @hidden
  5994. */
  5995. export class TmpColors {
  5996. static Color3: Color3[];
  5997. static Color4: Color4[];
  5998. }
  5999. }
  6000. declare module BABYLON {
  6001. /**
  6002. * Defines an interface which represents an animation key frame
  6003. */
  6004. export interface IAnimationKey {
  6005. /**
  6006. * Frame of the key frame
  6007. */
  6008. frame: number;
  6009. /**
  6010. * Value at the specifies key frame
  6011. */
  6012. value: any;
  6013. /**
  6014. * The input tangent for the cubic hermite spline
  6015. */
  6016. inTangent?: any;
  6017. /**
  6018. * The output tangent for the cubic hermite spline
  6019. */
  6020. outTangent?: any;
  6021. /**
  6022. * The animation interpolation type
  6023. */
  6024. interpolation?: AnimationKeyInterpolation;
  6025. }
  6026. /**
  6027. * Enum for the animation key frame interpolation type
  6028. */
  6029. export enum AnimationKeyInterpolation {
  6030. /**
  6031. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6032. */
  6033. STEP = 1
  6034. }
  6035. }
  6036. declare module BABYLON {
  6037. /**
  6038. * Represents the range of an animation
  6039. */
  6040. export class AnimationRange {
  6041. /**The name of the animation range**/
  6042. name: string;
  6043. /**The starting frame of the animation */
  6044. from: number;
  6045. /**The ending frame of the animation*/
  6046. to: number;
  6047. /**
  6048. * Initializes the range of an animation
  6049. * @param name The name of the animation range
  6050. * @param from The starting frame of the animation
  6051. * @param to The ending frame of the animation
  6052. */
  6053. constructor(
  6054. /**The name of the animation range**/
  6055. name: string,
  6056. /**The starting frame of the animation */
  6057. from: number,
  6058. /**The ending frame of the animation*/
  6059. to: number);
  6060. /**
  6061. * Makes a copy of the animation range
  6062. * @returns A copy of the animation range
  6063. */
  6064. clone(): AnimationRange;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * Composed of a frame, and an action function
  6070. */
  6071. export class AnimationEvent {
  6072. /** The frame for which the event is triggered **/
  6073. frame: number;
  6074. /** The event to perform when triggered **/
  6075. action: (currentFrame: number) => void;
  6076. /** Specifies if the event should be triggered only once**/
  6077. onlyOnce?: boolean | undefined;
  6078. /**
  6079. * Specifies if the animation event is done
  6080. */
  6081. isDone: boolean;
  6082. /**
  6083. * Initializes the animation event
  6084. * @param frame The frame for which the event is triggered
  6085. * @param action The event to perform when triggered
  6086. * @param onlyOnce Specifies if the event should be triggered only once
  6087. */
  6088. constructor(
  6089. /** The frame for which the event is triggered **/
  6090. frame: number,
  6091. /** The event to perform when triggered **/
  6092. action: (currentFrame: number) => void,
  6093. /** Specifies if the event should be triggered only once**/
  6094. onlyOnce?: boolean | undefined);
  6095. /** @hidden */
  6096. _clone(): AnimationEvent;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * Interface used to define a behavior
  6102. */
  6103. export interface Behavior<T> {
  6104. /** gets or sets behavior's name */
  6105. name: string;
  6106. /**
  6107. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6108. */
  6109. init(): void;
  6110. /**
  6111. * Called when the behavior is attached to a target
  6112. * @param target defines the target where the behavior is attached to
  6113. */
  6114. attach(target: T): void;
  6115. /**
  6116. * Called when the behavior is detached from its target
  6117. */
  6118. detach(): void;
  6119. }
  6120. /**
  6121. * Interface implemented by classes supporting behaviors
  6122. */
  6123. export interface IBehaviorAware<T> {
  6124. /**
  6125. * Attach a behavior
  6126. * @param behavior defines the behavior to attach
  6127. * @returns the current host
  6128. */
  6129. addBehavior(behavior: Behavior<T>): T;
  6130. /**
  6131. * Remove a behavior from the current object
  6132. * @param behavior defines the behavior to detach
  6133. * @returns the current host
  6134. */
  6135. removeBehavior(behavior: Behavior<T>): T;
  6136. /**
  6137. * Gets a behavior using its name to search
  6138. * @param name defines the name to search
  6139. * @returns the behavior or null if not found
  6140. */
  6141. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * Defines an array and its length.
  6147. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6148. */
  6149. export interface ISmartArrayLike<T> {
  6150. /**
  6151. * The data of the array.
  6152. */
  6153. data: Array<T>;
  6154. /**
  6155. * The active length of the array.
  6156. */
  6157. length: number;
  6158. }
  6159. /**
  6160. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6161. */
  6162. export class SmartArray<T> implements ISmartArrayLike<T> {
  6163. /**
  6164. * The full set of data from the array.
  6165. */
  6166. data: Array<T>;
  6167. /**
  6168. * The active length of the array.
  6169. */
  6170. length: number;
  6171. protected _id: number;
  6172. /**
  6173. * Instantiates a Smart Array.
  6174. * @param capacity defines the default capacity of the array.
  6175. */
  6176. constructor(capacity: number);
  6177. /**
  6178. * Pushes a value at the end of the active data.
  6179. * @param value defines the object to push in the array.
  6180. */
  6181. push(value: T): void;
  6182. /**
  6183. * Iterates over the active data and apply the lambda to them.
  6184. * @param func defines the action to apply on each value.
  6185. */
  6186. forEach(func: (content: T) => void): void;
  6187. /**
  6188. * Sorts the full sets of data.
  6189. * @param compareFn defines the comparison function to apply.
  6190. */
  6191. sort(compareFn: (a: T, b: T) => number): void;
  6192. /**
  6193. * Resets the active data to an empty array.
  6194. */
  6195. reset(): void;
  6196. /**
  6197. * Releases all the data from the array as well as the array.
  6198. */
  6199. dispose(): void;
  6200. /**
  6201. * Concats the active data with a given array.
  6202. * @param array defines the data to concatenate with.
  6203. */
  6204. concat(array: any): void;
  6205. /**
  6206. * Returns the position of a value in the active data.
  6207. * @param value defines the value to find the index for
  6208. * @returns the index if found in the active data otherwise -1
  6209. */
  6210. indexOf(value: T): number;
  6211. /**
  6212. * Returns whether an element is part of the active data.
  6213. * @param value defines the value to look for
  6214. * @returns true if found in the active data otherwise false
  6215. */
  6216. contains(value: T): boolean;
  6217. private static _GlobalId;
  6218. }
  6219. /**
  6220. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6221. * The data in this array can only be present once
  6222. */
  6223. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6224. private _duplicateId;
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6228. * @param value defines the object to push in the array.
  6229. */
  6230. push(value: T): void;
  6231. /**
  6232. * Pushes a value at the end of the active data.
  6233. * If the data is already present, it won t be added again
  6234. * @param value defines the object to push in the array.
  6235. * @returns true if added false if it was already present
  6236. */
  6237. pushNoDuplicate(value: T): boolean;
  6238. /**
  6239. * Resets the active data to an empty array.
  6240. */
  6241. reset(): void;
  6242. /**
  6243. * Concats the active data with a given array.
  6244. * This ensures no dupplicate will be present in the result.
  6245. * @param array defines the data to concatenate with.
  6246. */
  6247. concatWithNoDuplicate(array: any): void;
  6248. }
  6249. }
  6250. declare module BABYLON {
  6251. /**
  6252. * @ignore
  6253. * This is a list of all the different input types that are available in the application.
  6254. * Fo instance: ArcRotateCameraGamepadInput...
  6255. */
  6256. export var CameraInputTypes: {};
  6257. /**
  6258. * This is the contract to implement in order to create a new input class.
  6259. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6260. */
  6261. export interface ICameraInput<TCamera extends Camera> {
  6262. /**
  6263. * Defines the camera the input is attached to.
  6264. */
  6265. camera: Nullable<TCamera>;
  6266. /**
  6267. * Gets the class name of the current intput.
  6268. * @returns the class name
  6269. */
  6270. getClassName(): string;
  6271. /**
  6272. * Get the friendly name associated with the input class.
  6273. * @returns the input friendly name
  6274. */
  6275. getSimpleName(): string;
  6276. /**
  6277. * Attach the input controls to a specific dom element to get the input from.
  6278. * @param element Defines the element the controls should be listened from
  6279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6280. */
  6281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6282. /**
  6283. * Detach the current controls from the specified dom element.
  6284. * @param element Defines the element to stop listening the inputs from
  6285. */
  6286. detachControl(element: Nullable<HTMLElement>): void;
  6287. /**
  6288. * Update the current camera state depending on the inputs that have been used this frame.
  6289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6290. */
  6291. checkInputs?: () => void;
  6292. }
  6293. /**
  6294. * Represents a map of input types to input instance or input index to input instance.
  6295. */
  6296. export interface CameraInputsMap<TCamera extends Camera> {
  6297. /**
  6298. * Accessor to the input by input type.
  6299. */
  6300. [name: string]: ICameraInput<TCamera>;
  6301. /**
  6302. * Accessor to the input by input index.
  6303. */
  6304. [idx: number]: ICameraInput<TCamera>;
  6305. }
  6306. /**
  6307. * This represents the input manager used within a camera.
  6308. * It helps dealing with all the different kind of input attached to a camera.
  6309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6310. */
  6311. export class CameraInputsManager<TCamera extends Camera> {
  6312. /**
  6313. * Defines the list of inputs attahed to the camera.
  6314. */
  6315. attached: CameraInputsMap<TCamera>;
  6316. /**
  6317. * Defines the dom element the camera is collecting inputs from.
  6318. * This is null if the controls have not been attached.
  6319. */
  6320. attachedElement: Nullable<HTMLElement>;
  6321. /**
  6322. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6323. */
  6324. noPreventDefault: boolean;
  6325. /**
  6326. * Defined the camera the input manager belongs to.
  6327. */
  6328. camera: TCamera;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs: () => void;
  6334. /**
  6335. * Instantiate a new Camera Input Manager.
  6336. * @param camera Defines the camera the input manager blongs to
  6337. */
  6338. constructor(camera: TCamera);
  6339. /**
  6340. * Add an input method to a camera
  6341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6342. * @param input camera input method
  6343. */
  6344. add(input: ICameraInput<TCamera>): void;
  6345. /**
  6346. * Remove a specific input method from a camera
  6347. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6348. * @param inputToRemove camera input method
  6349. */
  6350. remove(inputToRemove: ICameraInput<TCamera>): void;
  6351. /**
  6352. * Remove a specific input type from a camera
  6353. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6354. * @param inputType the type of the input to remove
  6355. */
  6356. removeByType(inputType: string): void;
  6357. private _addCheckInputs;
  6358. /**
  6359. * Attach the input controls to the currently attached dom element to listen the events from.
  6360. * @param input Defines the input to attach
  6361. */
  6362. attachInput(input: ICameraInput<TCamera>): void;
  6363. /**
  6364. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6365. * @param element Defines the dom element to collect the events from
  6366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6367. */
  6368. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6369. /**
  6370. * Detach the current manager inputs controls from a specific dom element.
  6371. * @param element Defines the dom element to collect the events from
  6372. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6373. */
  6374. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6375. /**
  6376. * Rebuild the dynamic inputCheck function from the current list of
  6377. * defined inputs in the manager.
  6378. */
  6379. rebuildInputCheck(): void;
  6380. /**
  6381. * Remove all attached input methods from a camera
  6382. */
  6383. clear(): void;
  6384. /**
  6385. * Serialize the current input manager attached to a camera.
  6386. * This ensures than once parsed,
  6387. * the input associated to the camera will be identical to the current ones
  6388. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6389. */
  6390. serialize(serializedCamera: any): void;
  6391. /**
  6392. * Parses an input manager serialized JSON to restore the previous list of inputs
  6393. * and states associated to a camera.
  6394. * @param parsedCamera Defines the JSON to parse
  6395. */
  6396. parse(parsedCamera: any): void;
  6397. }
  6398. }
  6399. declare module BABYLON {
  6400. /**
  6401. * Class used to store data that will be store in GPU memory
  6402. */
  6403. export class Buffer {
  6404. private _engine;
  6405. private _buffer;
  6406. /** @hidden */
  6407. _data: Nullable<DataArray>;
  6408. private _updatable;
  6409. private _instanced;
  6410. private _divisor;
  6411. /**
  6412. * Gets the byte stride.
  6413. */
  6414. readonly byteStride: number;
  6415. /**
  6416. * Constructor
  6417. * @param engine the engine
  6418. * @param data the data to use for this buffer
  6419. * @param updatable whether the data is updatable
  6420. * @param stride the stride (optional)
  6421. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6422. * @param instanced whether the buffer is instanced (optional)
  6423. * @param useBytes set to true if the stride in in bytes (optional)
  6424. * @param divisor sets an optional divisor for instances (1 by default)
  6425. */
  6426. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6427. /**
  6428. * Create a new VertexBuffer based on the current buffer
  6429. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6430. * @param offset defines offset in the buffer (0 by default)
  6431. * @param size defines the size in floats of attributes (position is 3 for instance)
  6432. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6433. * @param instanced defines if the vertex buffer contains indexed data
  6434. * @param useBytes defines if the offset and stride are in bytes *
  6435. * @param divisor sets an optional divisor for instances (1 by default)
  6436. * @returns the new vertex buffer
  6437. */
  6438. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6439. /**
  6440. * Gets a boolean indicating if the Buffer is updatable?
  6441. * @returns true if the buffer is updatable
  6442. */
  6443. isUpdatable(): boolean;
  6444. /**
  6445. * Gets current buffer's data
  6446. * @returns a DataArray or null
  6447. */
  6448. getData(): Nullable<DataArray>;
  6449. /**
  6450. * Gets underlying native buffer
  6451. * @returns underlying native buffer
  6452. */
  6453. getBuffer(): Nullable<DataBuffer>;
  6454. /**
  6455. * Gets the stride in float32 units (i.e. byte stride / 4).
  6456. * May not be an integer if the byte stride is not divisible by 4.
  6457. * @returns the stride in float32 units
  6458. * @deprecated Please use byteStride instead.
  6459. */
  6460. getStrideSize(): number;
  6461. /**
  6462. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6463. * @param data defines the data to store
  6464. */
  6465. create(data?: Nullable<DataArray>): void;
  6466. /** @hidden */
  6467. _rebuild(): void;
  6468. /**
  6469. * Update current buffer data
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates the data directly.
  6475. * @param data the new data
  6476. * @param offset the new offset
  6477. * @param vertexCount the vertex count (optional)
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6481. /**
  6482. * Release all resources
  6483. */
  6484. dispose(): void;
  6485. }
  6486. /**
  6487. * Specialized buffer used to store vertex data
  6488. */
  6489. export class VertexBuffer {
  6490. /** @hidden */
  6491. _buffer: Buffer;
  6492. private _kind;
  6493. private _size;
  6494. private _ownsBuffer;
  6495. private _instanced;
  6496. private _instanceDivisor;
  6497. /**
  6498. * The byte type.
  6499. */
  6500. static readonly BYTE: number;
  6501. /**
  6502. * The unsigned byte type.
  6503. */
  6504. static readonly UNSIGNED_BYTE: number;
  6505. /**
  6506. * The short type.
  6507. */
  6508. static readonly SHORT: number;
  6509. /**
  6510. * The unsigned short type.
  6511. */
  6512. static readonly UNSIGNED_SHORT: number;
  6513. /**
  6514. * The integer type.
  6515. */
  6516. static readonly INT: number;
  6517. /**
  6518. * The unsigned integer type.
  6519. */
  6520. static readonly UNSIGNED_INT: number;
  6521. /**
  6522. * The float type.
  6523. */
  6524. static readonly FLOAT: number;
  6525. /**
  6526. * Gets or sets the instance divisor when in instanced mode
  6527. */
  6528. get instanceDivisor(): number;
  6529. set instanceDivisor(value: number);
  6530. /**
  6531. * Gets the byte stride.
  6532. */
  6533. readonly byteStride: number;
  6534. /**
  6535. * Gets the byte offset.
  6536. */
  6537. readonly byteOffset: number;
  6538. /**
  6539. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6540. */
  6541. readonly normalized: boolean;
  6542. /**
  6543. * Gets the data type of each component in the array.
  6544. */
  6545. readonly type: number;
  6546. /**
  6547. * Constructor
  6548. * @param engine the engine
  6549. * @param data the data to use for this vertex buffer
  6550. * @param kind the vertex buffer kind
  6551. * @param updatable whether the data is updatable
  6552. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6553. * @param stride the stride (optional)
  6554. * @param instanced whether the buffer is instanced (optional)
  6555. * @param offset the offset of the data (optional)
  6556. * @param size the number of components (optional)
  6557. * @param type the type of the component (optional)
  6558. * @param normalized whether the data contains normalized data (optional)
  6559. * @param useBytes set to true if stride and offset are in bytes (optional)
  6560. * @param divisor defines the instance divisor to use (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6563. /** @hidden */
  6564. _rebuild(): void;
  6565. /**
  6566. * Returns the kind of the VertexBuffer (string)
  6567. * @returns a string
  6568. */
  6569. getKind(): string;
  6570. /**
  6571. * Gets a boolean indicating if the VertexBuffer is updatable?
  6572. * @returns true if the buffer is updatable
  6573. */
  6574. isUpdatable(): boolean;
  6575. /**
  6576. * Gets current buffer's data
  6577. * @returns a DataArray or null
  6578. */
  6579. getData(): Nullable<DataArray>;
  6580. /**
  6581. * Gets underlying native buffer
  6582. * @returns underlying native buffer
  6583. */
  6584. getBuffer(): Nullable<DataBuffer>;
  6585. /**
  6586. * Gets the stride in float32 units (i.e. byte stride / 4).
  6587. * May not be an integer if the byte stride is not divisible by 4.
  6588. * @returns the stride in float32 units
  6589. * @deprecated Please use byteStride instead.
  6590. */
  6591. getStrideSize(): number;
  6592. /**
  6593. * Returns the offset as a multiple of the type byte length.
  6594. * @returns the offset in bytes
  6595. * @deprecated Please use byteOffset instead.
  6596. */
  6597. getOffset(): number;
  6598. /**
  6599. * Returns the number of components per vertex attribute (integer)
  6600. * @returns the size in float
  6601. */
  6602. getSize(): number;
  6603. /**
  6604. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6605. * @returns true if this buffer is instanced
  6606. */
  6607. getIsInstanced(): boolean;
  6608. /**
  6609. * Returns the instancing divisor, zero for non-instanced (integer).
  6610. * @returns a number
  6611. */
  6612. getInstanceDivisor(): number;
  6613. /**
  6614. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6615. * @param data defines the data to store
  6616. */
  6617. create(data?: DataArray): void;
  6618. /**
  6619. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6620. * This function will create a new buffer if the current one is not updatable
  6621. * @param data defines the data to store
  6622. */
  6623. update(data: DataArray): void;
  6624. /**
  6625. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6626. * Returns the directly updated WebGLBuffer.
  6627. * @param data the new data
  6628. * @param offset the new offset
  6629. * @param useBytes set to true if the offset is in bytes
  6630. */
  6631. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6632. /**
  6633. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6634. */
  6635. dispose(): void;
  6636. /**
  6637. * Enumerates each value of this vertex buffer as numbers.
  6638. * @param count the number of values to enumerate
  6639. * @param callback the callback function called for each value
  6640. */
  6641. forEach(count: number, callback: (value: number, index: number) => void): void;
  6642. /**
  6643. * Positions
  6644. */
  6645. static readonly PositionKind: string;
  6646. /**
  6647. * Normals
  6648. */
  6649. static readonly NormalKind: string;
  6650. /**
  6651. * Tangents
  6652. */
  6653. static readonly TangentKind: string;
  6654. /**
  6655. * Texture coordinates
  6656. */
  6657. static readonly UVKind: string;
  6658. /**
  6659. * Texture coordinates 2
  6660. */
  6661. static readonly UV2Kind: string;
  6662. /**
  6663. * Texture coordinates 3
  6664. */
  6665. static readonly UV3Kind: string;
  6666. /**
  6667. * Texture coordinates 4
  6668. */
  6669. static readonly UV4Kind: string;
  6670. /**
  6671. * Texture coordinates 5
  6672. */
  6673. static readonly UV5Kind: string;
  6674. /**
  6675. * Texture coordinates 6
  6676. */
  6677. static readonly UV6Kind: string;
  6678. /**
  6679. * Colors
  6680. */
  6681. static readonly ColorKind: string;
  6682. /**
  6683. * Matrix indices (for bones)
  6684. */
  6685. static readonly MatricesIndicesKind: string;
  6686. /**
  6687. * Matrix weights (for bones)
  6688. */
  6689. static readonly MatricesWeightsKind: string;
  6690. /**
  6691. * Additional matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesExtraKind: string;
  6694. /**
  6695. * Additional matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsExtraKind: string;
  6698. /**
  6699. * Deduces the stride given a kind.
  6700. * @param kind The kind string to deduce
  6701. * @returns The deduced stride
  6702. */
  6703. static DeduceStride(kind: string): number;
  6704. /**
  6705. * Gets the byte length of the given type.
  6706. * @param type the type
  6707. * @returns the number of bytes
  6708. */
  6709. static GetTypeByteLength(type: number): number;
  6710. /**
  6711. * Enumerates each value of the given parameters as numbers.
  6712. * @param data the data to enumerate
  6713. * @param byteOffset the byte offset of the data
  6714. * @param byteStride the byte stride of the data
  6715. * @param componentCount the number of components per element
  6716. * @param componentType the type of the component
  6717. * @param count the number of values to enumerate
  6718. * @param normalized whether the data is normalized
  6719. * @param callback the callback function called for each value
  6720. */
  6721. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6722. private static _GetFloatValue;
  6723. }
  6724. }
  6725. declare module BABYLON {
  6726. /**
  6727. * @hidden
  6728. */
  6729. export class IntersectionInfo {
  6730. bu: Nullable<number>;
  6731. bv: Nullable<number>;
  6732. distance: number;
  6733. faceId: number;
  6734. subMeshId: number;
  6735. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6736. }
  6737. }
  6738. declare module BABYLON {
  6739. /**
  6740. * Class used to store bounding sphere information
  6741. */
  6742. export class BoundingSphere {
  6743. /**
  6744. * Gets the center of the bounding sphere in local space
  6745. */
  6746. readonly center: Vector3;
  6747. /**
  6748. * Radius of the bounding sphere in local space
  6749. */
  6750. radius: number;
  6751. /**
  6752. * Gets the center of the bounding sphere in world space
  6753. */
  6754. readonly centerWorld: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in world space
  6757. */
  6758. radiusWorld: number;
  6759. /**
  6760. * Gets the minimum vector in local space
  6761. */
  6762. readonly minimum: Vector3;
  6763. /**
  6764. * Gets the maximum vector in local space
  6765. */
  6766. readonly maximum: Vector3;
  6767. private _worldMatrix;
  6768. private static readonly TmpVector3;
  6769. /**
  6770. * Creates a new bounding sphere
  6771. * @param min defines the minimum vector (in local space)
  6772. * @param max defines the maximum vector (in local space)
  6773. * @param worldMatrix defines the new world matrix
  6774. */
  6775. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6776. /**
  6777. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6778. * @param min defines the new minimum vector (in local space)
  6779. * @param max defines the new maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6783. /**
  6784. * Scale the current bounding sphere by applying a scale factor
  6785. * @param factor defines the scale factor to apply
  6786. * @returns the current bounding box
  6787. */
  6788. scale(factor: number): BoundingSphere;
  6789. /**
  6790. * Gets the world matrix of the bounding box
  6791. * @returns a matrix
  6792. */
  6793. getWorldMatrix(): DeepImmutable<Matrix>;
  6794. /** @hidden */
  6795. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6796. /**
  6797. * Tests if the bounding sphere is intersecting the frustum planes
  6798. * @param frustumPlanes defines the frustum planes to test
  6799. * @returns true if there is an intersection
  6800. */
  6801. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6802. /**
  6803. * Tests if the bounding sphere center is in between the frustum planes.
  6804. * Used for optimistic fast inclusion.
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if the sphere center is in between the frustum planes
  6807. */
  6808. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if a point is inside the bounding sphere
  6811. * @param point defines the point to test
  6812. * @returns true if the point is inside the bounding sphere
  6813. */
  6814. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6815. /**
  6816. * Checks if two sphere intersct
  6817. * @param sphere0 sphere 0
  6818. * @param sphere1 sphere 1
  6819. * @returns true if the speres intersect
  6820. */
  6821. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6822. }
  6823. }
  6824. declare module BABYLON {
  6825. /**
  6826. * Class used to store bounding box information
  6827. */
  6828. export class BoundingBox implements ICullable {
  6829. /**
  6830. * Gets the 8 vectors representing the bounding box in local space
  6831. */
  6832. readonly vectors: Vector3[];
  6833. /**
  6834. * Gets the center of the bounding box in local space
  6835. */
  6836. readonly center: Vector3;
  6837. /**
  6838. * Gets the center of the bounding box in world space
  6839. */
  6840. readonly centerWorld: Vector3;
  6841. /**
  6842. * Gets the extend size in local space
  6843. */
  6844. readonly extendSize: Vector3;
  6845. /**
  6846. * Gets the extend size in world space
  6847. */
  6848. readonly extendSizeWorld: Vector3;
  6849. /**
  6850. * Gets the OBB (object bounding box) directions
  6851. */
  6852. readonly directions: Vector3[];
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in world space
  6855. */
  6856. readonly vectorsWorld: Vector3[];
  6857. /**
  6858. * Gets the minimum vector in world space
  6859. */
  6860. readonly minimumWorld: Vector3;
  6861. /**
  6862. * Gets the maximum vector in world space
  6863. */
  6864. readonly maximumWorld: Vector3;
  6865. /**
  6866. * Gets the minimum vector in local space
  6867. */
  6868. readonly minimum: Vector3;
  6869. /**
  6870. * Gets the maximum vector in local space
  6871. */
  6872. readonly maximum: Vector3;
  6873. private _worldMatrix;
  6874. private static readonly TmpVector3;
  6875. /**
  6876. * @hidden
  6877. */
  6878. _tag: number;
  6879. /**
  6880. * Creates a new bounding box
  6881. * @param min defines the minimum vector (in local space)
  6882. * @param max defines the maximum vector (in local space)
  6883. * @param worldMatrix defines the new world matrix
  6884. */
  6885. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6886. /**
  6887. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6888. * @param min defines the new minimum vector (in local space)
  6889. * @param max defines the new maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6893. /**
  6894. * Scale the current bounding box by applying a scale factor
  6895. * @param factor defines the scale factor to apply
  6896. * @returns the current bounding box
  6897. */
  6898. scale(factor: number): BoundingBox;
  6899. /**
  6900. * Gets the world matrix of the bounding box
  6901. * @returns a matrix
  6902. */
  6903. getWorldMatrix(): DeepImmutable<Matrix>;
  6904. /** @hidden */
  6905. _update(world: DeepImmutable<Matrix>): void;
  6906. /**
  6907. * Tests if the bounding box is intersecting the frustum planes
  6908. * @param frustumPlanes defines the frustum planes to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6912. /**
  6913. * Tests if the bounding box is entirely inside the frustum planes
  6914. * @param frustumPlanes defines the frustum planes to test
  6915. * @returns true if there is an inclusion
  6916. */
  6917. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6918. /**
  6919. * Tests if a point is inside the bounding box
  6920. * @param point defines the point to test
  6921. * @returns true if the point is inside the bounding box
  6922. */
  6923. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6924. /**
  6925. * Tests if the bounding box intersects with a bounding sphere
  6926. * @param sphere defines the sphere to test
  6927. * @returns true if there is an intersection
  6928. */
  6929. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6930. /**
  6931. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6932. * @param min defines the min vector to use
  6933. * @param max defines the max vector to use
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6937. /**
  6938. * Tests if two bounding boxes are intersections
  6939. * @param box0 defines the first box to test
  6940. * @param box1 defines the second box to test
  6941. * @returns true if there is an intersection
  6942. */
  6943. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6944. /**
  6945. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6946. * @param minPoint defines the minimum vector of the bounding box
  6947. * @param maxPoint defines the maximum vector of the bounding box
  6948. * @param sphereCenter defines the sphere center
  6949. * @param sphereRadius defines the sphere radius
  6950. * @returns true if there is an intersection
  6951. */
  6952. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6953. /**
  6954. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6955. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6956. * @param frustumPlanes defines the frustum planes to test
  6957. * @return true if there is an inclusion
  6958. */
  6959. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an intersection
  6965. */
  6966. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. }
  6968. }
  6969. declare module BABYLON {
  6970. /** @hidden */
  6971. export class Collider {
  6972. /** Define if a collision was found */
  6973. collisionFound: boolean;
  6974. /**
  6975. * Define last intersection point in local space
  6976. */
  6977. intersectionPoint: Vector3;
  6978. /**
  6979. * Define last collided mesh
  6980. */
  6981. collidedMesh: Nullable<AbstractMesh>;
  6982. private _collisionPoint;
  6983. private _planeIntersectionPoint;
  6984. private _tempVector;
  6985. private _tempVector2;
  6986. private _tempVector3;
  6987. private _tempVector4;
  6988. private _edge;
  6989. private _baseToVertex;
  6990. private _destinationPoint;
  6991. private _slidePlaneNormal;
  6992. private _displacementVector;
  6993. /** @hidden */
  6994. _radius: Vector3;
  6995. /** @hidden */
  6996. _retry: number;
  6997. private _velocity;
  6998. private _basePoint;
  6999. private _epsilon;
  7000. /** @hidden */
  7001. _velocityWorldLength: number;
  7002. /** @hidden */
  7003. _basePointWorld: Vector3;
  7004. private _velocityWorld;
  7005. private _normalizedVelocity;
  7006. /** @hidden */
  7007. _initialVelocity: Vector3;
  7008. /** @hidden */
  7009. _initialPosition: Vector3;
  7010. private _nearestDistance;
  7011. private _collisionMask;
  7012. get collisionMask(): number;
  7013. set collisionMask(mask: number);
  7014. /**
  7015. * Gets the plane normal used to compute the sliding response (in local space)
  7016. */
  7017. get slidePlaneNormal(): Vector3;
  7018. /** @hidden */
  7019. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7020. /** @hidden */
  7021. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7022. /** @hidden */
  7023. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7024. /** @hidden */
  7025. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7026. /** @hidden */
  7027. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7028. /** @hidden */
  7029. _getResponse(pos: Vector3, vel: Vector3): void;
  7030. }
  7031. }
  7032. declare module BABYLON {
  7033. /**
  7034. * Interface for cullable objects
  7035. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7036. */
  7037. export interface ICullable {
  7038. /**
  7039. * Checks if the object or part of the object is in the frustum
  7040. * @param frustumPlanes Camera near/planes
  7041. * @returns true if the object is in frustum otherwise false
  7042. */
  7043. isInFrustum(frustumPlanes: Plane[]): boolean;
  7044. /**
  7045. * Checks if a cullable object (mesh...) is in the camera frustum
  7046. * Unlike isInFrustum this cheks the full bounding box
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7051. }
  7052. /**
  7053. * Info for a bounding data of a mesh
  7054. */
  7055. export class BoundingInfo implements ICullable {
  7056. /**
  7057. * Bounding box for the mesh
  7058. */
  7059. readonly boundingBox: BoundingBox;
  7060. /**
  7061. * Bounding sphere for the mesh
  7062. */
  7063. readonly boundingSphere: BoundingSphere;
  7064. private _isLocked;
  7065. private static readonly TmpVector3;
  7066. /**
  7067. * Constructs bounding info
  7068. * @param minimum min vector of the bounding box/sphere
  7069. * @param maximum max vector of the bounding box/sphere
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7073. /**
  7074. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7075. * @param min defines the new minimum vector (in local space)
  7076. * @param max defines the new maximum vector (in local space)
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * min vector of the bounding box/sphere
  7082. */
  7083. get minimum(): Vector3;
  7084. /**
  7085. * max vector of the bounding box/sphere
  7086. */
  7087. get maximum(): Vector3;
  7088. /**
  7089. * If the info is locked and won't be updated to avoid perf overhead
  7090. */
  7091. get isLocked(): boolean;
  7092. set isLocked(value: boolean);
  7093. /**
  7094. * Updates the bounding sphere and box
  7095. * @param world world matrix to be used to update
  7096. */
  7097. update(world: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7100. * @param center New center of the bounding info
  7101. * @param extend New extend of the bounding info
  7102. * @returns the current bounding info
  7103. */
  7104. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7105. /**
  7106. * Scale the current bounding info by applying a scale factor
  7107. * @param factor defines the scale factor to apply
  7108. * @returns the current bounding info
  7109. */
  7110. scale(factor: number): BoundingInfo;
  7111. /**
  7112. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7113. * @param frustumPlanes defines the frustum to test
  7114. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7115. * @returns true if the bounding info is in the frustum planes
  7116. */
  7117. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7118. /**
  7119. * Gets the world distance between the min and max points of the bounding box
  7120. */
  7121. get diagonalLength(): number;
  7122. /**
  7123. * Checks if a cullable object (mesh...) is in the camera frustum
  7124. * Unlike isInFrustum this cheks the full bounding box
  7125. * @param frustumPlanes Camera near/planes
  7126. * @returns true if the object is in frustum otherwise false
  7127. */
  7128. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7129. /** @hidden */
  7130. _checkCollision(collider: Collider): boolean;
  7131. /**
  7132. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7133. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7134. * @param point the point to check intersection with
  7135. * @returns if the point intersects
  7136. */
  7137. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7138. /**
  7139. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param boundingInfo the bounding info to check intersection with
  7142. * @param precise if the intersection should be done using OBB
  7143. * @returns if the bounding info intersects
  7144. */
  7145. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7146. }
  7147. }
  7148. declare module BABYLON {
  7149. /**
  7150. * Extracts minimum and maximum values from a list of indexed positions
  7151. * @param positions defines the positions to use
  7152. * @param indices defines the indices to the positions
  7153. * @param indexStart defines the start index
  7154. * @param indexCount defines the end index
  7155. * @param bias defines bias value to add to the result
  7156. * @return minimum and maximum values
  7157. */
  7158. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7159. minimum: Vector3;
  7160. maximum: Vector3;
  7161. };
  7162. /**
  7163. * Extracts minimum and maximum values from a list of positions
  7164. * @param positions defines the positions to use
  7165. * @param start defines the start index in the positions array
  7166. * @param count defines the number of positions to handle
  7167. * @param bias defines bias value to add to the result
  7168. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7169. * @return minimum and maximum values
  7170. */
  7171. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7172. minimum: Vector3;
  7173. maximum: Vector3;
  7174. };
  7175. }
  7176. declare module BABYLON {
  7177. /** @hidden */
  7178. export class WebGLDataBuffer extends DataBuffer {
  7179. private _buffer;
  7180. constructor(resource: WebGLBuffer);
  7181. get underlyingResource(): any;
  7182. }
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLPipelineContext implements IPipelineContext {
  7187. engine: ThinEngine;
  7188. program: Nullable<WebGLProgram>;
  7189. context?: WebGLRenderingContext;
  7190. vertexShader?: WebGLShader;
  7191. fragmentShader?: WebGLShader;
  7192. isParallelCompiled: boolean;
  7193. onCompiled?: () => void;
  7194. transformFeedback?: WebGLTransformFeedback | null;
  7195. vertexCompilationError: Nullable<string>;
  7196. fragmentCompilationError: Nullable<string>;
  7197. programLinkError: Nullable<string>;
  7198. programValidationError: Nullable<string>;
  7199. get isAsync(): boolean;
  7200. get isReady(): boolean;
  7201. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7202. _getVertexShaderCode(): string | null;
  7203. _getFragmentShaderCode(): string | null;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. interface ThinEngine {
  7208. /**
  7209. * Create an uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param elements defines the content of the uniform buffer
  7212. * @returns the webGL uniform buffer
  7213. */
  7214. createUniformBuffer(elements: FloatArray): DataBuffer;
  7215. /**
  7216. * Create a dynamic uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Update an existing uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param uniformBuffer defines the target uniform buffer
  7226. * @param elements defines the content to update
  7227. * @param offset defines the offset in the uniform buffer where update should start
  7228. * @param count defines the size of the data to update
  7229. */
  7230. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7231. /**
  7232. * Bind an uniform buffer to the current webGL context
  7233. * @param buffer defines the buffer to bind
  7234. */
  7235. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7236. /**
  7237. * Bind a buffer to the current webGL context at a given location
  7238. * @param buffer defines the buffer to bind
  7239. * @param location defines the index where to bind the buffer
  7240. */
  7241. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7242. /**
  7243. * Bind a specific block at a given index in a specific shader program
  7244. * @param pipelineContext defines the pipeline context to use
  7245. * @param blockName defines the block name
  7246. * @param index defines the index where to bind the block
  7247. */
  7248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7249. }
  7250. }
  7251. declare module BABYLON {
  7252. /**
  7253. * Uniform buffer objects.
  7254. *
  7255. * Handles blocks of uniform on the GPU.
  7256. *
  7257. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7258. *
  7259. * For more information, please refer to :
  7260. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7261. */
  7262. export class UniformBuffer {
  7263. private _engine;
  7264. private _buffer;
  7265. private _data;
  7266. private _bufferData;
  7267. private _dynamic?;
  7268. private _uniformLocations;
  7269. private _uniformSizes;
  7270. private _uniformLocationPointer;
  7271. private _needSync;
  7272. private _noUBO;
  7273. private _currentEffect;
  7274. /** @hidden */
  7275. _alreadyBound: boolean;
  7276. private static _MAX_UNIFORM_SIZE;
  7277. private static _tempBuffer;
  7278. /**
  7279. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7280. * This is dynamic to allow compat with webgl 1 and 2.
  7281. * You will need to pass the name of the uniform as well as the value.
  7282. */
  7283. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7284. /**
  7285. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7286. * This is dynamic to allow compat with webgl 1 and 2.
  7287. * You will need to pass the name of the uniform as well as the value.
  7288. */
  7289. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7290. /**
  7291. * Lambda to Update a single float in a uniform buffer.
  7292. * This is dynamic to allow compat with webgl 1 and 2.
  7293. * You will need to pass the name of the uniform as well as the value.
  7294. */
  7295. updateFloat: (name: string, x: number) => void;
  7296. /**
  7297. * Lambda to Update a vec2 of float in a uniform buffer.
  7298. * This is dynamic to allow compat with webgl 1 and 2.
  7299. * You will need to pass the name of the uniform as well as the value.
  7300. */
  7301. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7302. /**
  7303. * Lambda to Update a vec3 of float in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7308. /**
  7309. * Lambda to Update a vec4 of float in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7314. /**
  7315. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateMatrix: (name: string, mat: Matrix) => void;
  7320. /**
  7321. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateVector3: (name: string, vector: Vector3) => void;
  7326. /**
  7327. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateVector4: (name: string, vector: Vector4) => void;
  7332. /**
  7333. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7344. /**
  7345. * Instantiates a new Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. * @param engine Define the engine the buffer is associated with
  7354. * @param data Define the data contained in the buffer
  7355. * @param dynamic Define if the buffer is updatable
  7356. */
  7357. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7358. /**
  7359. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7360. * or just falling back on setUniformXXX calls.
  7361. */
  7362. get useUbo(): boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is in sync
  7365. * with the javascript cache data.
  7366. */
  7367. get isSync(): boolean;
  7368. /**
  7369. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7370. * Also, a dynamic UniformBuffer will disable cache verification and always
  7371. * update the underlying WebGL uniform buffer to the GPU.
  7372. * @returns if Dynamic, otherwise false
  7373. */
  7374. isDynamic(): boolean;
  7375. /**
  7376. * The data cache on JS side.
  7377. * @returns the underlying data as a float array
  7378. */
  7379. getData(): Float32Array;
  7380. /**
  7381. * The underlying WebGL Uniform buffer.
  7382. * @returns the webgl buffer
  7383. */
  7384. getBuffer(): Nullable<DataBuffer>;
  7385. /**
  7386. * std140 layout specifies how to align data within an UBO structure.
  7387. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7388. * for specs.
  7389. */
  7390. private _fillAlignment;
  7391. /**
  7392. * Adds an uniform in the buffer.
  7393. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7394. * for the layout to be correct !
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param size Data size, or data directly.
  7397. */
  7398. addUniform(name: string, size: number | number[]): void;
  7399. /**
  7400. * Adds a Matrix 4x4 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param mat A 4x4 matrix.
  7403. */
  7404. addMatrix(name: string, mat: Matrix): void;
  7405. /**
  7406. * Adds a vec2 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param x Define the x component value of the vec2
  7409. * @param y Define the y component value of the vec2
  7410. */
  7411. addFloat2(name: string, x: number, y: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec3
  7416. * @param y Define the y component value of the vec3
  7417. * @param z Define the z component value of the vec3
  7418. */
  7419. addFloat3(name: string, x: number, y: number, z: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param color Define the vec3 from a Color
  7424. */
  7425. addColor3(name: string, color: Color3): void;
  7426. /**
  7427. * Adds a vec4 to the uniform buffer.
  7428. * @param name Name of the uniform, as used in the uniform block in the shader.
  7429. * @param color Define the rgb components from a Color
  7430. * @param alpha Define the a component of the vec4
  7431. */
  7432. addColor4(name: string, color: Color3, alpha: number): void;
  7433. /**
  7434. * Adds a vec3 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param vector Define the vec3 components from a Vector
  7437. */
  7438. addVector3(name: string, vector: Vector3): void;
  7439. /**
  7440. * Adds a Matrix 3x3 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix3x3(name: string): void;
  7444. /**
  7445. * Adds a Matrix 2x2 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. */
  7448. addMatrix2x2(name: string): void;
  7449. /**
  7450. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7451. */
  7452. create(): void;
  7453. /** @hidden */
  7454. _rebuild(): void;
  7455. /**
  7456. * Updates the WebGL Uniform Buffer on the GPU.
  7457. * If the `dynamic` flag is set to true, no cache comparison is done.
  7458. * Otherwise, the buffer will be updated only if the cache differs.
  7459. */
  7460. update(): void;
  7461. /**
  7462. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7463. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7464. * @param data Define the flattened data
  7465. * @param size Define the size of the data.
  7466. */
  7467. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7468. private _valueCache;
  7469. private _cacheMatrix;
  7470. private _updateMatrix3x3ForUniform;
  7471. private _updateMatrix3x3ForEffect;
  7472. private _updateMatrix2x2ForEffect;
  7473. private _updateMatrix2x2ForUniform;
  7474. private _updateFloatForEffect;
  7475. private _updateFloatForUniform;
  7476. private _updateFloat2ForEffect;
  7477. private _updateFloat2ForUniform;
  7478. private _updateFloat3ForEffect;
  7479. private _updateFloat3ForUniform;
  7480. private _updateFloat4ForEffect;
  7481. private _updateFloat4ForUniform;
  7482. private _updateMatrixForEffect;
  7483. private _updateMatrixForUniform;
  7484. private _updateVector3ForEffect;
  7485. private _updateVector3ForUniform;
  7486. private _updateVector4ForEffect;
  7487. private _updateVector4ForUniform;
  7488. private _updateColor3ForEffect;
  7489. private _updateColor3ForUniform;
  7490. private _updateColor4ForEffect;
  7491. private _updateColor4ForUniform;
  7492. /**
  7493. * Sets a sampler uniform on the effect.
  7494. * @param name Define the name of the sampler.
  7495. * @param texture Define the texture to set in the sampler
  7496. */
  7497. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7498. /**
  7499. * Directly updates the value of the uniform in the cache AND on the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. */
  7503. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7504. /**
  7505. * Binds this uniform buffer to an effect.
  7506. * @param effect Define the effect to bind the buffer to
  7507. * @param name Name of the uniform block in the shader.
  7508. */
  7509. bindToEffect(effect: Effect, name: string): void;
  7510. /**
  7511. * Disposes the uniform buffer.
  7512. */
  7513. dispose(): void;
  7514. }
  7515. }
  7516. declare module BABYLON {
  7517. /**
  7518. * Enum that determines the text-wrapping mode to use.
  7519. */
  7520. export enum InspectableType {
  7521. /**
  7522. * Checkbox for booleans
  7523. */
  7524. Checkbox = 0,
  7525. /**
  7526. * Sliders for numbers
  7527. */
  7528. Slider = 1,
  7529. /**
  7530. * Vector3
  7531. */
  7532. Vector3 = 2,
  7533. /**
  7534. * Quaternions
  7535. */
  7536. Quaternion = 3,
  7537. /**
  7538. * Color3
  7539. */
  7540. Color3 = 4,
  7541. /**
  7542. * String
  7543. */
  7544. String = 5
  7545. }
  7546. /**
  7547. * Interface used to define custom inspectable properties.
  7548. * This interface is used by the inspector to display custom property grids
  7549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7550. */
  7551. export interface IInspectable {
  7552. /**
  7553. * Gets the label to display
  7554. */
  7555. label: string;
  7556. /**
  7557. * Gets the name of the property to edit
  7558. */
  7559. propertyName: string;
  7560. /**
  7561. * Gets the type of the editor to use
  7562. */
  7563. type: InspectableType;
  7564. /**
  7565. * Gets the minimum value of the property when using in "slider" mode
  7566. */
  7567. min?: number;
  7568. /**
  7569. * Gets the maximum value of the property when using in "slider" mode
  7570. */
  7571. max?: number;
  7572. /**
  7573. * Gets the setp to use when using in "slider" mode
  7574. */
  7575. step?: number;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. /**
  7580. * Class used to provide helper for timing
  7581. */
  7582. export class TimingTools {
  7583. /**
  7584. * Polyfill for setImmediate
  7585. * @param action defines the action to execute after the current execution block
  7586. */
  7587. static SetImmediate(action: () => void): void;
  7588. }
  7589. }
  7590. declare module BABYLON {
  7591. /**
  7592. * Class used to enable instatition of objects by class name
  7593. */
  7594. export class InstantiationTools {
  7595. /**
  7596. * Use this object to register external classes like custom textures or material
  7597. * to allow the laoders to instantiate them
  7598. */
  7599. static RegisteredExternalClasses: {
  7600. [key: string]: Object;
  7601. };
  7602. /**
  7603. * Tries to instantiate a new object from a given class name
  7604. * @param className defines the class name to instantiate
  7605. * @returns the new object or null if the system was not able to do the instantiation
  7606. */
  7607. static Instantiate(className: string): any;
  7608. }
  7609. }
  7610. declare module BABYLON {
  7611. /**
  7612. * Define options used to create a depth texture
  7613. */
  7614. export class DepthTextureCreationOptions {
  7615. /** Specifies whether or not a stencil should be allocated in the texture */
  7616. generateStencil?: boolean;
  7617. /** Specifies whether or not bilinear filtering is enable on the texture */
  7618. bilinearFiltering?: boolean;
  7619. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7620. comparisonFunction?: number;
  7621. /** Specifies if the created texture is a cube texture */
  7622. isCube?: boolean;
  7623. }
  7624. }
  7625. declare module BABYLON {
  7626. interface ThinEngine {
  7627. /**
  7628. * Creates a depth stencil cube texture.
  7629. * This is only available in WebGL 2.
  7630. * @param size The size of face edge in the cube texture.
  7631. * @param options The options defining the cube texture.
  7632. * @returns The cube texture
  7633. */
  7634. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7635. /**
  7636. * Creates a cube texture
  7637. * @param rootUrl defines the url where the files to load is located
  7638. * @param scene defines the current scene
  7639. * @param files defines the list of files to load (1 per face)
  7640. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7641. * @param onLoad defines an optional callback raised when the texture is loaded
  7642. * @param onError defines an optional callback raised if there is an issue to load the texture
  7643. * @param format defines the format of the data
  7644. * @param forcedExtension defines the extension to use to pick the right loader
  7645. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7646. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7647. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7648. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7649. * @returns the cube texture as an InternalTexture
  7650. */
  7651. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7652. /**
  7653. * Creates a cube texture
  7654. * @param rootUrl defines the url where the files to load is located
  7655. * @param scene defines the current scene
  7656. * @param files defines the list of files to load (1 per face)
  7657. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7658. * @param onLoad defines an optional callback raised when the texture is loaded
  7659. * @param onError defines an optional callback raised if there is an issue to load the texture
  7660. * @param format defines the format of the data
  7661. * @param forcedExtension defines the extension to use to pick the right loader
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7665. /**
  7666. * Creates a cube texture
  7667. * @param rootUrl defines the url where the files to load is located
  7668. * @param scene defines the current scene
  7669. * @param files defines the list of files to load (1 per face)
  7670. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7671. * @param onLoad defines an optional callback raised when the texture is loaded
  7672. * @param onError defines an optional callback raised if there is an issue to load the texture
  7673. * @param format defines the format of the data
  7674. * @param forcedExtension defines the extension to use to pick the right loader
  7675. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7676. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7677. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7678. * @returns the cube texture as an InternalTexture
  7679. */
  7680. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7681. /** @hidden */
  7682. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7683. /** @hidden */
  7684. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7687. /** @hidden */
  7688. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /**
  7690. * @hidden
  7691. */
  7692. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7693. }
  7694. }
  7695. declare module BABYLON {
  7696. /**
  7697. * Class for creating a cube texture
  7698. */
  7699. export class CubeTexture extends BaseTexture {
  7700. private _delayedOnLoad;
  7701. /**
  7702. * Observable triggered once the texture has been loaded.
  7703. */
  7704. onLoadObservable: Observable<CubeTexture>;
  7705. /**
  7706. * The url of the texture
  7707. */
  7708. url: string;
  7709. /**
  7710. * Gets or sets the center of the bounding box associated with the cube texture.
  7711. * It must define where the camera used to render the texture was set
  7712. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7713. */
  7714. boundingBoxPosition: Vector3;
  7715. private _boundingBoxSize;
  7716. /**
  7717. * Gets or sets the size of the bounding box associated with the cube texture
  7718. * When defined, the cubemap will switch to local mode
  7719. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7720. * @example https://www.babylonjs-playground.com/#RNASML
  7721. */
  7722. set boundingBoxSize(value: Vector3);
  7723. /**
  7724. * Returns the bounding box size
  7725. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7726. */
  7727. get boundingBoxSize(): Vector3;
  7728. protected _rotationY: number;
  7729. /**
  7730. * Sets texture matrix rotation angle around Y axis in radians.
  7731. */
  7732. set rotationY(value: number);
  7733. /**
  7734. * Gets texture matrix rotation angle around Y axis radians.
  7735. */
  7736. get rotationY(): number;
  7737. /**
  7738. * Are mip maps generated for this texture or not.
  7739. */
  7740. get noMipmap(): boolean;
  7741. private _noMipmap;
  7742. private _files;
  7743. protected _forcedExtension: Nullable<string>;
  7744. private _extensions;
  7745. private _textureMatrix;
  7746. private _format;
  7747. private _createPolynomials;
  7748. /** @hidden */
  7749. _prefiltered: boolean;
  7750. /**
  7751. * Creates a cube texture from an array of image urls
  7752. * @param files defines an array of image urls
  7753. * @param scene defines the hosting scene
  7754. * @param noMipmap specifies if mip maps are not used
  7755. * @returns a cube texture
  7756. */
  7757. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7758. /**
  7759. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7760. * @param url defines the url of the prefiltered texture
  7761. * @param scene defines the scene the texture is attached to
  7762. * @param forcedExtension defines the extension of the file if different from the url
  7763. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7764. * @return the prefiltered texture
  7765. */
  7766. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7767. /**
  7768. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7769. * as prefiltered data.
  7770. * @param rootUrl defines the url of the texture or the root name of the six images
  7771. * @param scene defines the scene the texture is attached to
  7772. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7773. * @param noMipmap defines if mipmaps should be created or not
  7774. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7775. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7776. * @param onError defines a callback triggered in case of error during load
  7777. * @param format defines the internal format to use for the texture once loaded
  7778. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7779. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7780. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7783. * @return the cube texture
  7784. */
  7785. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7786. /**
  7787. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7788. */
  7789. get isPrefiltered(): boolean;
  7790. /**
  7791. * Get the current class name of the texture useful for serialization or dynamic coding.
  7792. * @returns "CubeTexture"
  7793. */
  7794. getClassName(): string;
  7795. /**
  7796. * Update the url (and optional buffer) of this texture if url was null during construction.
  7797. * @param url the url of the texture
  7798. * @param forcedExtension defines the extension to use
  7799. * @param onLoad callback called when the texture is loaded (defaults to null)
  7800. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7801. */
  7802. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7803. /**
  7804. * Delays loading of the cube texture
  7805. * @param forcedExtension defines the extension to use
  7806. */
  7807. delayLoad(forcedExtension?: string): void;
  7808. /**
  7809. * Returns the reflection texture matrix
  7810. * @returns the reflection texture matrix
  7811. */
  7812. getReflectionTextureMatrix(): Matrix;
  7813. /**
  7814. * Sets the reflection texture matrix
  7815. * @param value Reflection texture matrix
  7816. */
  7817. setReflectionTextureMatrix(value: Matrix): void;
  7818. /**
  7819. * Parses text to create a cube texture
  7820. * @param parsedTexture define the serialized text to read from
  7821. * @param scene defines the hosting scene
  7822. * @param rootUrl defines the root url of the cube texture
  7823. * @returns a cube texture
  7824. */
  7825. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7826. /**
  7827. * Makes a clone, or deep copy, of the cube texture
  7828. * @returns a new cube texture
  7829. */
  7830. clone(): CubeTexture;
  7831. }
  7832. }
  7833. declare module BABYLON {
  7834. /**
  7835. * Manages the defines for the Material
  7836. */
  7837. export class MaterialDefines {
  7838. /** @hidden */
  7839. protected _keys: string[];
  7840. private _isDirty;
  7841. /** @hidden */
  7842. _renderId: number;
  7843. /** @hidden */
  7844. _areLightsDirty: boolean;
  7845. /** @hidden */
  7846. _areLightsDisposed: boolean;
  7847. /** @hidden */
  7848. _areAttributesDirty: boolean;
  7849. /** @hidden */
  7850. _areTexturesDirty: boolean;
  7851. /** @hidden */
  7852. _areFresnelDirty: boolean;
  7853. /** @hidden */
  7854. _areMiscDirty: boolean;
  7855. /** @hidden */
  7856. _areImageProcessingDirty: boolean;
  7857. /** @hidden */
  7858. _normals: boolean;
  7859. /** @hidden */
  7860. _uvs: boolean;
  7861. /** @hidden */
  7862. _needNormals: boolean;
  7863. /** @hidden */
  7864. _needUVs: boolean;
  7865. [id: string]: any;
  7866. /**
  7867. * Specifies if the material needs to be re-calculated
  7868. */
  7869. get isDirty(): boolean;
  7870. /**
  7871. * Marks the material to indicate that it has been re-calculated
  7872. */
  7873. markAsProcessed(): void;
  7874. /**
  7875. * Marks the material to indicate that it needs to be re-calculated
  7876. */
  7877. markAsUnprocessed(): void;
  7878. /**
  7879. * Marks the material to indicate all of its defines need to be re-calculated
  7880. */
  7881. markAllAsDirty(): void;
  7882. /**
  7883. * Marks the material to indicate that image processing needs to be re-calculated
  7884. */
  7885. markAsImageProcessingDirty(): void;
  7886. /**
  7887. * Marks the material to indicate the lights need to be re-calculated
  7888. * @param disposed Defines whether the light is dirty due to dispose or not
  7889. */
  7890. markAsLightDirty(disposed?: boolean): void;
  7891. /**
  7892. * Marks the attribute state as changed
  7893. */
  7894. markAsAttributesDirty(): void;
  7895. /**
  7896. * Marks the texture state as changed
  7897. */
  7898. markAsTexturesDirty(): void;
  7899. /**
  7900. * Marks the fresnel state as changed
  7901. */
  7902. markAsFresnelDirty(): void;
  7903. /**
  7904. * Marks the misc state as changed
  7905. */
  7906. markAsMiscDirty(): void;
  7907. /**
  7908. * Rebuilds the material defines
  7909. */
  7910. rebuild(): void;
  7911. /**
  7912. * Specifies if two material defines are equal
  7913. * @param other - A material define instance to compare to
  7914. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7915. */
  7916. isEqual(other: MaterialDefines): boolean;
  7917. /**
  7918. * Clones this instance's defines to another instance
  7919. * @param other - material defines to clone values to
  7920. */
  7921. cloneTo(other: MaterialDefines): void;
  7922. /**
  7923. * Resets the material define values
  7924. */
  7925. reset(): void;
  7926. /**
  7927. * Converts the material define values to a string
  7928. * @returns - String of material define information
  7929. */
  7930. toString(): string;
  7931. }
  7932. }
  7933. declare module BABYLON {
  7934. /**
  7935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7937. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7939. */
  7940. export class ColorCurves {
  7941. private _dirty;
  7942. private _tempColor;
  7943. private _globalCurve;
  7944. private _highlightsCurve;
  7945. private _midtonesCurve;
  7946. private _shadowsCurve;
  7947. private _positiveCurve;
  7948. private _negativeCurve;
  7949. private _globalHue;
  7950. private _globalDensity;
  7951. private _globalSaturation;
  7952. private _globalExposure;
  7953. /**
  7954. * Gets the global Hue value.
  7955. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7956. */
  7957. get globalHue(): number;
  7958. /**
  7959. * Sets the global Hue value.
  7960. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7961. */
  7962. set globalHue(value: number);
  7963. /**
  7964. * Gets the global Density value.
  7965. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7966. * Values less than zero provide a filter of opposite hue.
  7967. */
  7968. get globalDensity(): number;
  7969. /**
  7970. * Sets the global Density value.
  7971. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. set globalDensity(value: number);
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7978. */
  7979. get globalSaturation(): number;
  7980. /**
  7981. * Sets the global Saturation value.
  7982. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7983. */
  7984. set globalSaturation(value: number);
  7985. /**
  7986. * Gets the global Exposure value.
  7987. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7988. */
  7989. get globalExposure(): number;
  7990. /**
  7991. * Sets the global Exposure value.
  7992. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7993. */
  7994. set globalExposure(value: number);
  7995. private _highlightsHue;
  7996. private _highlightsDensity;
  7997. private _highlightsSaturation;
  7998. private _highlightsExposure;
  7999. /**
  8000. * Gets the highlights Hue value.
  8001. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8002. */
  8003. get highlightsHue(): number;
  8004. /**
  8005. * Sets the highlights Hue value.
  8006. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8007. */
  8008. set highlightsHue(value: number);
  8009. /**
  8010. * Gets the highlights Density value.
  8011. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. get highlightsDensity(): number;
  8015. /**
  8016. * Sets the highlights Density value.
  8017. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. set highlightsDensity(value: number);
  8021. /**
  8022. * Gets the highlights Saturation value.
  8023. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8024. */
  8025. get highlightsSaturation(): number;
  8026. /**
  8027. * Sets the highlights Saturation value.
  8028. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8029. */
  8030. set highlightsSaturation(value: number);
  8031. /**
  8032. * Gets the highlights Exposure value.
  8033. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8034. */
  8035. get highlightsExposure(): number;
  8036. /**
  8037. * Sets the highlights Exposure value.
  8038. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8039. */
  8040. set highlightsExposure(value: number);
  8041. private _midtonesHue;
  8042. private _midtonesDensity;
  8043. private _midtonesSaturation;
  8044. private _midtonesExposure;
  8045. /**
  8046. * Gets the midtones Hue value.
  8047. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8048. */
  8049. get midtonesHue(): number;
  8050. /**
  8051. * Sets the midtones Hue value.
  8052. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8053. */
  8054. set midtonesHue(value: number);
  8055. /**
  8056. * Gets the midtones Density value.
  8057. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. get midtonesDensity(): number;
  8061. /**
  8062. * Sets the midtones Density value.
  8063. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. set midtonesDensity(value: number);
  8067. /**
  8068. * Gets the midtones Saturation value.
  8069. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8070. */
  8071. get midtonesSaturation(): number;
  8072. /**
  8073. * Sets the midtones Saturation value.
  8074. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8075. */
  8076. set midtonesSaturation(value: number);
  8077. /**
  8078. * Gets the midtones Exposure value.
  8079. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8080. */
  8081. get midtonesExposure(): number;
  8082. /**
  8083. * Sets the midtones Exposure value.
  8084. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8085. */
  8086. set midtonesExposure(value: number);
  8087. private _shadowsHue;
  8088. private _shadowsDensity;
  8089. private _shadowsSaturation;
  8090. private _shadowsExposure;
  8091. /**
  8092. * Gets the shadows Hue value.
  8093. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8094. */
  8095. get shadowsHue(): number;
  8096. /**
  8097. * Sets the shadows Hue value.
  8098. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8099. */
  8100. set shadowsHue(value: number);
  8101. /**
  8102. * Gets the shadows Density value.
  8103. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. get shadowsDensity(): number;
  8107. /**
  8108. * Sets the shadows Density value.
  8109. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. set shadowsDensity(value: number);
  8113. /**
  8114. * Gets the shadows Saturation value.
  8115. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8116. */
  8117. get shadowsSaturation(): number;
  8118. /**
  8119. * Sets the shadows Saturation value.
  8120. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8121. */
  8122. set shadowsSaturation(value: number);
  8123. /**
  8124. * Gets the shadows Exposure value.
  8125. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8126. */
  8127. get shadowsExposure(): number;
  8128. /**
  8129. * Sets the shadows Exposure value.
  8130. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8131. */
  8132. set shadowsExposure(value: number);
  8133. /**
  8134. * Returns the class name
  8135. * @returns The class name
  8136. */
  8137. getClassName(): string;
  8138. /**
  8139. * Binds the color curves to the shader.
  8140. * @param colorCurves The color curve to bind
  8141. * @param effect The effect to bind to
  8142. * @param positiveUniform The positive uniform shader parameter
  8143. * @param neutralUniform The neutral uniform shader parameter
  8144. * @param negativeUniform The negative uniform shader parameter
  8145. */
  8146. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8147. /**
  8148. * Prepare the list of uniforms associated with the ColorCurves effects.
  8149. * @param uniformsList The list of uniforms used in the effect
  8150. */
  8151. static PrepareUniforms(uniformsList: string[]): void;
  8152. /**
  8153. * Returns color grading data based on a hue, density, saturation and exposure value.
  8154. * @param filterHue The hue of the color filter.
  8155. * @param filterDensity The density of the color filter.
  8156. * @param saturation The saturation.
  8157. * @param exposure The exposure.
  8158. * @param result The result data container.
  8159. */
  8160. private getColorGradingDataToRef;
  8161. /**
  8162. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8163. * @param value The input slider value in range [-100,100].
  8164. * @returns Adjusted value.
  8165. */
  8166. private static applyColorGradingSliderNonlinear;
  8167. /**
  8168. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8169. * @param hue The hue (H) input.
  8170. * @param saturation The saturation (S) input.
  8171. * @param brightness The brightness (B) input.
  8172. * @result An RGBA color represented as Vector4.
  8173. */
  8174. private static fromHSBToRef;
  8175. /**
  8176. * Returns a value clamped between min and max
  8177. * @param value The value to clamp
  8178. * @param min The minimum of value
  8179. * @param max The maximum of value
  8180. * @returns The clamped value.
  8181. */
  8182. private static clamp;
  8183. /**
  8184. * Clones the current color curve instance.
  8185. * @return The cloned curves
  8186. */
  8187. clone(): ColorCurves;
  8188. /**
  8189. * Serializes the current color curve instance to a json representation.
  8190. * @return a JSON representation
  8191. */
  8192. serialize(): any;
  8193. /**
  8194. * Parses the color curve from a json representation.
  8195. * @param source the JSON source to parse
  8196. * @return The parsed curves
  8197. */
  8198. static Parse(source: any): ColorCurves;
  8199. }
  8200. }
  8201. declare module BABYLON {
  8202. /**
  8203. * Interface to follow in your material defines to integrate easily the
  8204. * Image proccessing functions.
  8205. * @hidden
  8206. */
  8207. export interface IImageProcessingConfigurationDefines {
  8208. IMAGEPROCESSING: boolean;
  8209. VIGNETTE: boolean;
  8210. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8211. VIGNETTEBLENDMODEOPAQUE: boolean;
  8212. TONEMAPPING: boolean;
  8213. TONEMAPPING_ACES: boolean;
  8214. CONTRAST: boolean;
  8215. EXPOSURE: boolean;
  8216. COLORCURVES: boolean;
  8217. COLORGRADING: boolean;
  8218. COLORGRADING3D: boolean;
  8219. SAMPLER3DGREENDEPTH: boolean;
  8220. SAMPLER3DBGRMAP: boolean;
  8221. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8222. }
  8223. /**
  8224. * @hidden
  8225. */
  8226. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8227. IMAGEPROCESSING: boolean;
  8228. VIGNETTE: boolean;
  8229. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8230. VIGNETTEBLENDMODEOPAQUE: boolean;
  8231. TONEMAPPING: boolean;
  8232. TONEMAPPING_ACES: boolean;
  8233. CONTRAST: boolean;
  8234. COLORCURVES: boolean;
  8235. COLORGRADING: boolean;
  8236. COLORGRADING3D: boolean;
  8237. SAMPLER3DGREENDEPTH: boolean;
  8238. SAMPLER3DBGRMAP: boolean;
  8239. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8240. EXPOSURE: boolean;
  8241. constructor();
  8242. }
  8243. /**
  8244. * This groups together the common properties used for image processing either in direct forward pass
  8245. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8246. * or not.
  8247. */
  8248. export class ImageProcessingConfiguration {
  8249. /**
  8250. * Default tone mapping applied in BabylonJS.
  8251. */
  8252. static readonly TONEMAPPING_STANDARD: number;
  8253. /**
  8254. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8255. * to other engines rendering to increase portability.
  8256. */
  8257. static readonly TONEMAPPING_ACES: number;
  8258. /**
  8259. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8260. */
  8261. colorCurves: Nullable<ColorCurves>;
  8262. private _colorCurvesEnabled;
  8263. /**
  8264. * Gets wether the color curves effect is enabled.
  8265. */
  8266. get colorCurvesEnabled(): boolean;
  8267. /**
  8268. * Sets wether the color curves effect is enabled.
  8269. */
  8270. set colorCurvesEnabled(value: boolean);
  8271. private _colorGradingTexture;
  8272. /**
  8273. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8274. */
  8275. get colorGradingTexture(): Nullable<BaseTexture>;
  8276. /**
  8277. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8278. */
  8279. set colorGradingTexture(value: Nullable<BaseTexture>);
  8280. private _colorGradingEnabled;
  8281. /**
  8282. * Gets wether the color grading effect is enabled.
  8283. */
  8284. get colorGradingEnabled(): boolean;
  8285. /**
  8286. * Sets wether the color grading effect is enabled.
  8287. */
  8288. set colorGradingEnabled(value: boolean);
  8289. private _colorGradingWithGreenDepth;
  8290. /**
  8291. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8292. */
  8293. get colorGradingWithGreenDepth(): boolean;
  8294. /**
  8295. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8296. */
  8297. set colorGradingWithGreenDepth(value: boolean);
  8298. private _colorGradingBGR;
  8299. /**
  8300. * Gets wether the color grading texture contains BGR values.
  8301. */
  8302. get colorGradingBGR(): boolean;
  8303. /**
  8304. * Sets wether the color grading texture contains BGR values.
  8305. */
  8306. set colorGradingBGR(value: boolean);
  8307. /** @hidden */
  8308. _exposure: number;
  8309. /**
  8310. * Gets the Exposure used in the effect.
  8311. */
  8312. get exposure(): number;
  8313. /**
  8314. * Sets the Exposure used in the effect.
  8315. */
  8316. set exposure(value: number);
  8317. private _toneMappingEnabled;
  8318. /**
  8319. * Gets wether the tone mapping effect is enabled.
  8320. */
  8321. get toneMappingEnabled(): boolean;
  8322. /**
  8323. * Sets wether the tone mapping effect is enabled.
  8324. */
  8325. set toneMappingEnabled(value: boolean);
  8326. private _toneMappingType;
  8327. /**
  8328. * Gets the type of tone mapping effect.
  8329. */
  8330. get toneMappingType(): number;
  8331. /**
  8332. * Sets the type of tone mapping effect used in BabylonJS.
  8333. */
  8334. set toneMappingType(value: number);
  8335. protected _contrast: number;
  8336. /**
  8337. * Gets the contrast used in the effect.
  8338. */
  8339. get contrast(): number;
  8340. /**
  8341. * Sets the contrast used in the effect.
  8342. */
  8343. set contrast(value: number);
  8344. /**
  8345. * Vignette stretch size.
  8346. */
  8347. vignetteStretch: number;
  8348. /**
  8349. * Vignette centre X Offset.
  8350. */
  8351. vignetteCentreX: number;
  8352. /**
  8353. * Vignette centre Y Offset.
  8354. */
  8355. vignetteCentreY: number;
  8356. /**
  8357. * Vignette weight or intensity of the vignette effect.
  8358. */
  8359. vignetteWeight: number;
  8360. /**
  8361. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8362. * if vignetteEnabled is set to true.
  8363. */
  8364. vignetteColor: Color4;
  8365. /**
  8366. * Camera field of view used by the Vignette effect.
  8367. */
  8368. vignetteCameraFov: number;
  8369. private _vignetteBlendMode;
  8370. /**
  8371. * Gets the vignette blend mode allowing different kind of effect.
  8372. */
  8373. get vignetteBlendMode(): number;
  8374. /**
  8375. * Sets the vignette blend mode allowing different kind of effect.
  8376. */
  8377. set vignetteBlendMode(value: number);
  8378. private _vignetteEnabled;
  8379. /**
  8380. * Gets wether the vignette effect is enabled.
  8381. */
  8382. get vignetteEnabled(): boolean;
  8383. /**
  8384. * Sets wether the vignette effect is enabled.
  8385. */
  8386. set vignetteEnabled(value: boolean);
  8387. private _applyByPostProcess;
  8388. /**
  8389. * Gets wether the image processing is applied through a post process or not.
  8390. */
  8391. get applyByPostProcess(): boolean;
  8392. /**
  8393. * Sets wether the image processing is applied through a post process or not.
  8394. */
  8395. set applyByPostProcess(value: boolean);
  8396. private _isEnabled;
  8397. /**
  8398. * Gets wether the image processing is enabled or not.
  8399. */
  8400. get isEnabled(): boolean;
  8401. /**
  8402. * Sets wether the image processing is enabled or not.
  8403. */
  8404. set isEnabled(value: boolean);
  8405. /**
  8406. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8407. */
  8408. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8409. /**
  8410. * Method called each time the image processing information changes requires to recompile the effect.
  8411. */
  8412. protected _updateParameters(): void;
  8413. /**
  8414. * Gets the current class name.
  8415. * @return "ImageProcessingConfiguration"
  8416. */
  8417. getClassName(): string;
  8418. /**
  8419. * Prepare the list of uniforms associated with the Image Processing effects.
  8420. * @param uniforms The list of uniforms used in the effect
  8421. * @param defines the list of defines currently in use
  8422. */
  8423. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8424. /**
  8425. * Prepare the list of samplers associated with the Image Processing effects.
  8426. * @param samplersList The list of uniforms used in the effect
  8427. * @param defines the list of defines currently in use
  8428. */
  8429. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8430. /**
  8431. * Prepare the list of defines associated to the shader.
  8432. * @param defines the list of defines to complete
  8433. * @param forPostProcess Define if we are currently in post process mode or not
  8434. */
  8435. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8436. /**
  8437. * Returns true if all the image processing information are ready.
  8438. * @returns True if ready, otherwise, false
  8439. */
  8440. isReady(): boolean;
  8441. /**
  8442. * Binds the image processing to the shader.
  8443. * @param effect The effect to bind to
  8444. * @param overrideAspectRatio Override the aspect ratio of the effect
  8445. */
  8446. bind(effect: Effect, overrideAspectRatio?: number): void;
  8447. /**
  8448. * Clones the current image processing instance.
  8449. * @return The cloned image processing
  8450. */
  8451. clone(): ImageProcessingConfiguration;
  8452. /**
  8453. * Serializes the current image processing instance to a json representation.
  8454. * @return a JSON representation
  8455. */
  8456. serialize(): any;
  8457. /**
  8458. * Parses the image processing from a json representation.
  8459. * @param source the JSON source to parse
  8460. * @return The parsed image processing
  8461. */
  8462. static Parse(source: any): ImageProcessingConfiguration;
  8463. private static _VIGNETTEMODE_MULTIPLY;
  8464. private static _VIGNETTEMODE_OPAQUE;
  8465. /**
  8466. * Used to apply the vignette as a mix with the pixel color.
  8467. */
  8468. static get VIGNETTEMODE_MULTIPLY(): number;
  8469. /**
  8470. * Used to apply the vignette as a replacement of the pixel color.
  8471. */
  8472. static get VIGNETTEMODE_OPAQUE(): number;
  8473. }
  8474. }
  8475. declare module BABYLON {
  8476. /** @hidden */
  8477. export var postprocessVertexShader: {
  8478. name: string;
  8479. shader: string;
  8480. };
  8481. }
  8482. declare module BABYLON {
  8483. interface ThinEngine {
  8484. /**
  8485. * Creates a new render target texture
  8486. * @param size defines the size of the texture
  8487. * @param options defines the options used to create the texture
  8488. * @returns a new render target texture stored in an InternalTexture
  8489. */
  8490. createRenderTargetTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. layers?: number;
  8494. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8495. /**
  8496. * Creates a depth stencil texture.
  8497. * This is only available in WebGL 2 or with the depth texture extension available.
  8498. * @param size The size of face edge in the texture.
  8499. * @param options The options defining the texture.
  8500. * @returns The texture
  8501. */
  8502. createDepthStencilTexture(size: number | {
  8503. width: number;
  8504. height: number;
  8505. layers?: number;
  8506. }, options: DepthTextureCreationOptions): InternalTexture;
  8507. /** @hidden */
  8508. _createDepthStencilTexture(size: number | {
  8509. width: number;
  8510. height: number;
  8511. layers?: number;
  8512. }, options: DepthTextureCreationOptions): InternalTexture;
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /** Defines supported spaces */
  8517. export enum Space {
  8518. /** Local (object) space */
  8519. LOCAL = 0,
  8520. /** World space */
  8521. WORLD = 1,
  8522. /** Bone space */
  8523. BONE = 2
  8524. }
  8525. /** Defines the 3 main axes */
  8526. export class Axis {
  8527. /** X axis */
  8528. static X: Vector3;
  8529. /** Y axis */
  8530. static Y: Vector3;
  8531. /** Z axis */
  8532. static Z: Vector3;
  8533. }
  8534. }
  8535. declare module BABYLON {
  8536. /**
  8537. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8538. * This is the base of the follow, arc rotate cameras and Free camera
  8539. * @see http://doc.babylonjs.com/features/cameras
  8540. */
  8541. export class TargetCamera extends Camera {
  8542. private static _RigCamTransformMatrix;
  8543. private static _TargetTransformMatrix;
  8544. private static _TargetFocalPoint;
  8545. /**
  8546. * Define the current direction the camera is moving to
  8547. */
  8548. cameraDirection: Vector3;
  8549. /**
  8550. * Define the current rotation the camera is rotating to
  8551. */
  8552. cameraRotation: Vector2;
  8553. /**
  8554. * When set, the up vector of the camera will be updated by the rotation of the camera
  8555. */
  8556. updateUpVectorFromRotation: boolean;
  8557. private _tmpQuaternion;
  8558. /**
  8559. * Define the current rotation of the camera
  8560. */
  8561. rotation: Vector3;
  8562. /**
  8563. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8564. */
  8565. rotationQuaternion: Quaternion;
  8566. /**
  8567. * Define the current speed of the camera
  8568. */
  8569. speed: number;
  8570. /**
  8571. * Add constraint to the camera to prevent it to move freely in all directions and
  8572. * around all axis.
  8573. */
  8574. noRotationConstraint: boolean;
  8575. /**
  8576. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8577. * panning
  8578. */
  8579. invertRotation: boolean;
  8580. /**
  8581. * Speed multiplier for inverse camera panning
  8582. */
  8583. inverseRotationSpeed: number;
  8584. /**
  8585. * Define the current target of the camera as an object or a position.
  8586. */
  8587. lockedTarget: any;
  8588. /** @hidden */
  8589. _currentTarget: Vector3;
  8590. /** @hidden */
  8591. _initialFocalDistance: number;
  8592. /** @hidden */
  8593. _viewMatrix: Matrix;
  8594. /** @hidden */
  8595. _camMatrix: Matrix;
  8596. /** @hidden */
  8597. _cameraTransformMatrix: Matrix;
  8598. /** @hidden */
  8599. _cameraRotationMatrix: Matrix;
  8600. /** @hidden */
  8601. _referencePoint: Vector3;
  8602. /** @hidden */
  8603. _transformedReferencePoint: Vector3;
  8604. protected _globalCurrentTarget: Vector3;
  8605. protected _globalCurrentUpVector: Vector3;
  8606. /** @hidden */
  8607. _reset: () => void;
  8608. private _defaultUp;
  8609. /**
  8610. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8611. * This is the base of the follow, arc rotate cameras and Free camera
  8612. * @see http://doc.babylonjs.com/features/cameras
  8613. * @param name Defines the name of the camera in the scene
  8614. * @param position Defines the start position of the camera in the scene
  8615. * @param scene Defines the scene the camera belongs to
  8616. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8617. */
  8618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8619. /**
  8620. * Gets the position in front of the camera at a given distance.
  8621. * @param distance The distance from the camera we want the position to be
  8622. * @returns the position
  8623. */
  8624. getFrontPosition(distance: number): Vector3;
  8625. /** @hidden */
  8626. _getLockedTargetPosition(): Nullable<Vector3>;
  8627. private _storedPosition;
  8628. private _storedRotation;
  8629. private _storedRotationQuaternion;
  8630. /**
  8631. * Store current camera state of the camera (fov, position, rotation, etc..)
  8632. * @returns the camera
  8633. */
  8634. storeState(): Camera;
  8635. /**
  8636. * Restored camera state. You must call storeState() first
  8637. * @returns whether it was successful or not
  8638. * @hidden
  8639. */
  8640. _restoreStateValues(): boolean;
  8641. /** @hidden */
  8642. _initCache(): void;
  8643. /** @hidden */
  8644. _updateCache(ignoreParentClass?: boolean): void;
  8645. /** @hidden */
  8646. _isSynchronizedViewMatrix(): boolean;
  8647. /** @hidden */
  8648. _computeLocalCameraSpeed(): number;
  8649. /**
  8650. * Defines the target the camera should look at.
  8651. * @param target Defines the new target as a Vector or a mesh
  8652. */
  8653. setTarget(target: Vector3): void;
  8654. /**
  8655. * Return the current target position of the camera. This value is expressed in local space.
  8656. * @returns the target position
  8657. */
  8658. getTarget(): Vector3;
  8659. /** @hidden */
  8660. _decideIfNeedsToMove(): boolean;
  8661. /** @hidden */
  8662. _updatePosition(): void;
  8663. /** @hidden */
  8664. _checkInputs(): void;
  8665. protected _updateCameraRotationMatrix(): void;
  8666. /**
  8667. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8668. * @returns the current camera
  8669. */
  8670. private _rotateUpVectorWithCameraRotationMatrix;
  8671. private _cachedRotationZ;
  8672. private _cachedQuaternionRotationZ;
  8673. /** @hidden */
  8674. _getViewMatrix(): Matrix;
  8675. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8676. /**
  8677. * @hidden
  8678. */
  8679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8680. /**
  8681. * @hidden
  8682. */
  8683. _updateRigCameras(): void;
  8684. private _getRigCamPositionAndTarget;
  8685. /**
  8686. * Gets the current object class name.
  8687. * @return the class name
  8688. */
  8689. getClassName(): string;
  8690. }
  8691. }
  8692. declare module BABYLON {
  8693. /**
  8694. * Gather the list of keyboard event types as constants.
  8695. */
  8696. export class KeyboardEventTypes {
  8697. /**
  8698. * The keydown event is fired when a key becomes active (pressed).
  8699. */
  8700. static readonly KEYDOWN: number;
  8701. /**
  8702. * The keyup event is fired when a key has been released.
  8703. */
  8704. static readonly KEYUP: number;
  8705. }
  8706. /**
  8707. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8708. */
  8709. export class KeyboardInfo {
  8710. /**
  8711. * Defines the type of event (KeyboardEventTypes)
  8712. */
  8713. type: number;
  8714. /**
  8715. * Defines the related dom event
  8716. */
  8717. event: KeyboardEvent;
  8718. /**
  8719. * Instantiates a new keyboard info.
  8720. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8721. * @param type Defines the type of event (KeyboardEventTypes)
  8722. * @param event Defines the related dom event
  8723. */
  8724. constructor(
  8725. /**
  8726. * Defines the type of event (KeyboardEventTypes)
  8727. */
  8728. type: number,
  8729. /**
  8730. * Defines the related dom event
  8731. */
  8732. event: KeyboardEvent);
  8733. }
  8734. /**
  8735. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8736. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8737. */
  8738. export class KeyboardInfoPre extends KeyboardInfo {
  8739. /**
  8740. * Defines the type of event (KeyboardEventTypes)
  8741. */
  8742. type: number;
  8743. /**
  8744. * Defines the related dom event
  8745. */
  8746. event: KeyboardEvent;
  8747. /**
  8748. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8749. */
  8750. skipOnPointerObservable: boolean;
  8751. /**
  8752. * Instantiates a new keyboard pre info.
  8753. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8754. * @param type Defines the type of event (KeyboardEventTypes)
  8755. * @param event Defines the related dom event
  8756. */
  8757. constructor(
  8758. /**
  8759. * Defines the type of event (KeyboardEventTypes)
  8760. */
  8761. type: number,
  8762. /**
  8763. * Defines the related dom event
  8764. */
  8765. event: KeyboardEvent);
  8766. }
  8767. }
  8768. declare module BABYLON {
  8769. /**
  8770. * Manage the keyboard inputs to control the movement of a free camera.
  8771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8772. */
  8773. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8774. /**
  8775. * Defines the camera the input is attached to.
  8776. */
  8777. camera: FreeCamera;
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8780. */
  8781. keysUp: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8784. */
  8785. keysUpward: number[];
  8786. /**
  8787. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8788. */
  8789. keysDown: number[];
  8790. /**
  8791. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8792. */
  8793. keysDownward: number[];
  8794. /**
  8795. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8796. */
  8797. keysLeft: number[];
  8798. /**
  8799. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8800. */
  8801. keysRight: number[];
  8802. private _keys;
  8803. private _onCanvasBlurObserver;
  8804. private _onKeyboardObserver;
  8805. private _engine;
  8806. private _scene;
  8807. /**
  8808. * Attach the input controls to a specific dom element to get the input from.
  8809. * @param element Defines the element the controls should be listened from
  8810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8811. */
  8812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8813. /**
  8814. * Detach the current controls from the specified dom element.
  8815. * @param element Defines the element to stop listening the inputs from
  8816. */
  8817. detachControl(element: Nullable<HTMLElement>): void;
  8818. /**
  8819. * Update the current camera state depending on the inputs that have been used this frame.
  8820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8821. */
  8822. checkInputs(): void;
  8823. /**
  8824. * Gets the class name of the current intput.
  8825. * @returns the class name
  8826. */
  8827. getClassName(): string;
  8828. /** @hidden */
  8829. _onLostFocus(): void;
  8830. /**
  8831. * Get the friendly name associated with the input class.
  8832. * @returns the input friendly name
  8833. */
  8834. getSimpleName(): string;
  8835. }
  8836. }
  8837. declare module BABYLON {
  8838. /**
  8839. * Interface describing all the common properties and methods a shadow light needs to implement.
  8840. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8841. * as well as binding the different shadow properties to the effects.
  8842. */
  8843. export interface IShadowLight extends Light {
  8844. /**
  8845. * The light id in the scene (used in scene.findLighById for instance)
  8846. */
  8847. id: string;
  8848. /**
  8849. * The position the shdow will be casted from.
  8850. */
  8851. position: Vector3;
  8852. /**
  8853. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8854. */
  8855. direction: Vector3;
  8856. /**
  8857. * The transformed position. Position of the light in world space taking parenting in account.
  8858. */
  8859. transformedPosition: Vector3;
  8860. /**
  8861. * The transformed direction. Direction of the light in world space taking parenting in account.
  8862. */
  8863. transformedDirection: Vector3;
  8864. /**
  8865. * The friendly name of the light in the scene.
  8866. */
  8867. name: string;
  8868. /**
  8869. * Defines the shadow projection clipping minimum z value.
  8870. */
  8871. shadowMinZ: number;
  8872. /**
  8873. * Defines the shadow projection clipping maximum z value.
  8874. */
  8875. shadowMaxZ: number;
  8876. /**
  8877. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8878. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8879. */
  8880. computeTransformedInformation(): boolean;
  8881. /**
  8882. * Gets the scene the light belongs to.
  8883. * @returns The scene
  8884. */
  8885. getScene(): Scene;
  8886. /**
  8887. * Callback defining a custom Projection Matrix Builder.
  8888. * This can be used to override the default projection matrix computation.
  8889. */
  8890. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8891. /**
  8892. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8893. * @param matrix The materix to updated with the projection information
  8894. * @param viewMatrix The transform matrix of the light
  8895. * @param renderList The list of mesh to render in the map
  8896. * @returns The current light
  8897. */
  8898. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8899. /**
  8900. * Gets the current depth scale used in ESM.
  8901. * @returns The scale
  8902. */
  8903. getDepthScale(): number;
  8904. /**
  8905. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8906. * @returns true if a cube texture needs to be use
  8907. */
  8908. needCube(): boolean;
  8909. /**
  8910. * Detects if the projection matrix requires to be recomputed this frame.
  8911. * @returns true if it requires to be recomputed otherwise, false.
  8912. */
  8913. needProjectionMatrixCompute(): boolean;
  8914. /**
  8915. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8916. */
  8917. forceProjectionMatrixCompute(): void;
  8918. /**
  8919. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8922. */
  8923. getShadowDirection(faceIndex?: number): Vector3;
  8924. /**
  8925. * Gets the minZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the min for
  8927. * @returns the depth min z
  8928. */
  8929. getDepthMinZ(activeCamera: Camera): number;
  8930. /**
  8931. * Gets the maxZ used for shadow according to both the scene and the light.
  8932. * @param activeCamera The camera we are returning the max for
  8933. * @returns the depth max z
  8934. */
  8935. getDepthMaxZ(activeCamera: Camera): number;
  8936. }
  8937. /**
  8938. * Base implementation IShadowLight
  8939. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8940. */
  8941. export abstract class ShadowLight extends Light implements IShadowLight {
  8942. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8943. protected _position: Vector3;
  8944. protected _setPosition(value: Vector3): void;
  8945. /**
  8946. * Sets the position the shadow will be casted from. Also use as the light position for both
  8947. * point and spot lights.
  8948. */
  8949. get position(): Vector3;
  8950. /**
  8951. * Sets the position the shadow will be casted from. Also use as the light position for both
  8952. * point and spot lights.
  8953. */
  8954. set position(value: Vector3);
  8955. protected _direction: Vector3;
  8956. protected _setDirection(value: Vector3): void;
  8957. /**
  8958. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8959. * Also use as the light direction on spot and directional lights.
  8960. */
  8961. get direction(): Vector3;
  8962. /**
  8963. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8964. * Also use as the light direction on spot and directional lights.
  8965. */
  8966. set direction(value: Vector3);
  8967. protected _shadowMinZ: number;
  8968. /**
  8969. * Gets the shadow projection clipping minimum z value.
  8970. */
  8971. get shadowMinZ(): number;
  8972. /**
  8973. * Sets the shadow projection clipping minimum z value.
  8974. */
  8975. set shadowMinZ(value: number);
  8976. protected _shadowMaxZ: number;
  8977. /**
  8978. * Sets the shadow projection clipping maximum z value.
  8979. */
  8980. get shadowMaxZ(): number;
  8981. /**
  8982. * Gets the shadow projection clipping maximum z value.
  8983. */
  8984. set shadowMaxZ(value: number);
  8985. /**
  8986. * Callback defining a custom Projection Matrix Builder.
  8987. * This can be used to override the default projection matrix computation.
  8988. */
  8989. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. private _needProjectionMatrixCompute;
  8999. /**
  9000. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9001. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9002. */
  9003. computeTransformedInformation(): boolean;
  9004. /**
  9005. * Return the depth scale used for the shadow map.
  9006. * @returns the depth scale.
  9007. */
  9008. getDepthScale(): number;
  9009. /**
  9010. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9011. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9012. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9013. */
  9014. getShadowDirection(faceIndex?: number): Vector3;
  9015. /**
  9016. * Returns the ShadowLight absolute position in the World.
  9017. * @returns the position vector in world space
  9018. */
  9019. getAbsolutePosition(): Vector3;
  9020. /**
  9021. * Sets the ShadowLight direction toward the passed target.
  9022. * @param target The point to target in local space
  9023. * @returns the updated ShadowLight direction
  9024. */
  9025. setDirectionToTarget(target: Vector3): Vector3;
  9026. /**
  9027. * Returns the light rotation in euler definition.
  9028. * @returns the x y z rotation in local space.
  9029. */
  9030. getRotation(): Vector3;
  9031. /**
  9032. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9033. * @returns true if a cube texture needs to be use
  9034. */
  9035. needCube(): boolean;
  9036. /**
  9037. * Detects if the projection matrix requires to be recomputed this frame.
  9038. * @returns true if it requires to be recomputed otherwise, false.
  9039. */
  9040. needProjectionMatrixCompute(): boolean;
  9041. /**
  9042. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9043. */
  9044. forceProjectionMatrixCompute(): void;
  9045. /** @hidden */
  9046. _initCache(): void;
  9047. /** @hidden */
  9048. _isSynchronized(): boolean;
  9049. /**
  9050. * Computes the world matrix of the node
  9051. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9052. * @returns the world matrix
  9053. */
  9054. computeWorldMatrix(force?: boolean): Matrix;
  9055. /**
  9056. * Gets the minZ used for shadow according to both the scene and the light.
  9057. * @param activeCamera The camera we are returning the min for
  9058. * @returns the depth min z
  9059. */
  9060. getDepthMinZ(activeCamera: Camera): number;
  9061. /**
  9062. * Gets the maxZ used for shadow according to both the scene and the light.
  9063. * @param activeCamera The camera we are returning the max for
  9064. * @returns the depth max z
  9065. */
  9066. getDepthMaxZ(activeCamera: Camera): number;
  9067. /**
  9068. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9069. * @param matrix The materix to updated with the projection information
  9070. * @param viewMatrix The transform matrix of the light
  9071. * @param renderList The list of mesh to render in the map
  9072. * @returns The current light
  9073. */
  9074. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9075. }
  9076. }
  9077. declare module BABYLON {
  9078. /**
  9079. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9080. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9081. */
  9082. export class EffectFallbacks implements IEffectFallbacks {
  9083. private _defines;
  9084. private _currentRank;
  9085. private _maxRank;
  9086. private _mesh;
  9087. /**
  9088. * Removes the fallback from the bound mesh.
  9089. */
  9090. unBindMesh(): void;
  9091. /**
  9092. * Adds a fallback on the specified property.
  9093. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9094. * @param define The name of the define in the shader
  9095. */
  9096. addFallback(rank: number, define: string): void;
  9097. /**
  9098. * Sets the mesh to use CPU skinning when needing to fallback.
  9099. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9100. * @param mesh The mesh to use the fallbacks.
  9101. */
  9102. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9103. /**
  9104. * Checks to see if more fallbacks are still availible.
  9105. */
  9106. get hasMoreFallbacks(): boolean;
  9107. /**
  9108. * Removes the defines that should be removed when falling back.
  9109. * @param currentDefines defines the current define statements for the shader.
  9110. * @param effect defines the current effect we try to compile
  9111. * @returns The resulting defines with defines of the current rank removed.
  9112. */
  9113. reduce(currentDefines: string, effect: Effect): string;
  9114. }
  9115. }
  9116. declare module BABYLON {
  9117. /**
  9118. * "Static Class" containing the most commonly used helper while dealing with material for
  9119. * rendering purpose.
  9120. *
  9121. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9122. *
  9123. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9124. */
  9125. export class MaterialHelper {
  9126. /**
  9127. * Bind the current view position to an effect.
  9128. * @param effect The effect to be bound
  9129. * @param scene The scene the eyes position is used from
  9130. */
  9131. static BindEyePosition(effect: Effect, scene: Scene): void;
  9132. /**
  9133. * Helps preparing the defines values about the UVs in used in the effect.
  9134. * UVs are shared as much as we can accross channels in the shaders.
  9135. * @param texture The texture we are preparing the UVs for
  9136. * @param defines The defines to update
  9137. * @param key The channel key "diffuse", "specular"... used in the shader
  9138. */
  9139. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9140. /**
  9141. * Binds a texture matrix value to its corrsponding uniform
  9142. * @param texture The texture to bind the matrix for
  9143. * @param uniformBuffer The uniform buffer receivin the data
  9144. * @param key The channel key "diffuse", "specular"... used in the shader
  9145. */
  9146. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9147. /**
  9148. * Gets the current status of the fog (should it be enabled?)
  9149. * @param mesh defines the mesh to evaluate for fog support
  9150. * @param scene defines the hosting scene
  9151. * @returns true if fog must be enabled
  9152. */
  9153. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9154. /**
  9155. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9156. * @param mesh defines the current mesh
  9157. * @param scene defines the current scene
  9158. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9159. * @param pointsCloud defines if point cloud rendering has to be turned on
  9160. * @param fogEnabled defines if fog has to be turned on
  9161. * @param alphaTest defines if alpha testing has to be turned on
  9162. * @param defines defines the current list of defines
  9163. */
  9164. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9165. /**
  9166. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9167. * @param scene defines the current scene
  9168. * @param engine defines the current engine
  9169. * @param defines specifies the list of active defines
  9170. * @param useInstances defines if instances have to be turned on
  9171. * @param useClipPlane defines if clip plane have to be turned on
  9172. */
  9173. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9174. /**
  9175. * Prepares the defines for bones
  9176. * @param mesh The mesh containing the geometry data we will draw
  9177. * @param defines The defines to update
  9178. */
  9179. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9180. /**
  9181. * Prepares the defines for morph targets
  9182. * @param mesh The mesh containing the geometry data we will draw
  9183. * @param defines The defines to update
  9184. */
  9185. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9186. /**
  9187. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9188. * @param mesh The mesh containing the geometry data we will draw
  9189. * @param defines The defines to update
  9190. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9191. * @param useBones Precise whether bones should be used or not (override mesh info)
  9192. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9193. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9194. * @returns false if defines are considered not dirty and have not been checked
  9195. */
  9196. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9197. /**
  9198. * Prepares the defines related to multiview
  9199. * @param scene The scene we are intending to draw
  9200. * @param defines The defines to update
  9201. */
  9202. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9203. /**
  9204. * Prepares the defines related to the light information passed in parameter
  9205. * @param scene The scene we are intending to draw
  9206. * @param mesh The mesh the effect is compiling for
  9207. * @param light The light the effect is compiling for
  9208. * @param lightIndex The index of the light
  9209. * @param defines The defines to update
  9210. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9211. * @param state Defines the current state regarding what is needed (normals, etc...)
  9212. */
  9213. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9214. needNormals: boolean;
  9215. needRebuild: boolean;
  9216. shadowEnabled: boolean;
  9217. specularEnabled: boolean;
  9218. lightmapMode: boolean;
  9219. }): void;
  9220. /**
  9221. * Prepares the defines related to the light information passed in parameter
  9222. * @param scene The scene we are intending to draw
  9223. * @param mesh The mesh the effect is compiling for
  9224. * @param defines The defines to update
  9225. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9226. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9227. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9228. * @returns true if normals will be required for the rest of the effect
  9229. */
  9230. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9231. /**
  9232. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9233. * @param lightIndex defines the light index
  9234. * @param uniformsList The uniform list
  9235. * @param samplersList The sampler list
  9236. * @param projectedLightTexture defines if projected texture must be used
  9237. * @param uniformBuffersList defines an optional list of uniform buffers
  9238. */
  9239. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9240. /**
  9241. * Prepares the uniforms and samplers list to be used in the effect
  9242. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9243. * @param samplersList The sampler list
  9244. * @param defines The defines helping in the list generation
  9245. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9246. */
  9247. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9248. /**
  9249. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9250. * @param defines The defines to update while falling back
  9251. * @param fallbacks The authorized effect fallbacks
  9252. * @param maxSimultaneousLights The maximum number of lights allowed
  9253. * @param rank the current rank of the Effect
  9254. * @returns The newly affected rank
  9255. */
  9256. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9257. private static _TmpMorphInfluencers;
  9258. /**
  9259. * Prepares the list of attributes required for morph targets according to the effect defines.
  9260. * @param attribs The current list of supported attribs
  9261. * @param mesh The mesh to prepare the morph targets attributes for
  9262. * @param influencers The number of influencers
  9263. */
  9264. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9265. /**
  9266. * Prepares the list of attributes required for morph targets according to the effect defines.
  9267. * @param attribs The current list of supported attribs
  9268. * @param mesh The mesh to prepare the morph targets attributes for
  9269. * @param defines The current Defines of the effect
  9270. */
  9271. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9272. /**
  9273. * Prepares the list of attributes required for bones according to the effect defines.
  9274. * @param attribs The current list of supported attribs
  9275. * @param mesh The mesh to prepare the bones attributes for
  9276. * @param defines The current Defines of the effect
  9277. * @param fallbacks The current efffect fallback strategy
  9278. */
  9279. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9280. /**
  9281. * Check and prepare the list of attributes required for instances according to the effect defines.
  9282. * @param attribs The current list of supported attribs
  9283. * @param defines The current MaterialDefines of the effect
  9284. */
  9285. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9286. /**
  9287. * Add the list of attributes required for instances to the attribs array.
  9288. * @param attribs The current list of supported attribs
  9289. */
  9290. static PushAttributesForInstances(attribs: string[]): void;
  9291. /**
  9292. * Binds the light information to the effect.
  9293. * @param light The light containing the generator
  9294. * @param effect The effect we are binding the data to
  9295. * @param lightIndex The light index in the effect used to render
  9296. */
  9297. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9298. /**
  9299. * Binds the lights information from the scene to the effect for the given mesh.
  9300. * @param light Light to bind
  9301. * @param lightIndex Light index
  9302. * @param scene The scene where the light belongs to
  9303. * @param effect The effect we are binding the data to
  9304. * @param useSpecular Defines if specular is supported
  9305. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9306. */
  9307. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9308. /**
  9309. * Binds the lights information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param defines The generated defines for the effect
  9314. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9315. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9316. */
  9317. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9318. private static _tempFogColor;
  9319. /**
  9320. * Binds the fog information from the scene to the effect for the given mesh.
  9321. * @param scene The scene the lights belongs to
  9322. * @param mesh The mesh we are binding the information to render
  9323. * @param effect The effect we are binding the data to
  9324. * @param linearSpace Defines if the fog effect is applied in linear space
  9325. */
  9326. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9327. /**
  9328. * Binds the bones information from the mesh to the effect.
  9329. * @param mesh The mesh we are binding the information to render
  9330. * @param effect The effect we are binding the data to
  9331. */
  9332. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9333. /**
  9334. * Binds the morph targets information from the mesh to the effect.
  9335. * @param abstractMesh The mesh we are binding the information to render
  9336. * @param effect The effect we are binding the data to
  9337. */
  9338. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9339. /**
  9340. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9341. * @param defines The generated defines used in the effect
  9342. * @param effect The effect we are binding the data to
  9343. * @param scene The scene we are willing to render with logarithmic scale for
  9344. */
  9345. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9346. /**
  9347. * Binds the clip plane information from the scene to the effect.
  9348. * @param scene The scene the clip plane information are extracted from
  9349. * @param effect The effect we are binding the data to
  9350. */
  9351. static BindClipPlane(effect: Effect, scene: Scene): void;
  9352. }
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var packingFunctions: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var shadowMapFragmentDeclaration: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var clipPlaneFragmentDeclaration: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var clipPlaneFragment: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var shadowMapFragment: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var shadowMapPixelShader: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var bonesDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /** @hidden */
  9405. export var morphTargetsVertexGlobalDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. export var morphTargetsVertexDeclaration: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module BABYLON {
  9418. /** @hidden */
  9419. export var instancesDeclaration: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module BABYLON {
  9425. /** @hidden */
  9426. export var helperFunctions: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module BABYLON {
  9432. /** @hidden */
  9433. export var shadowMapVertexDeclaration: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module BABYLON {
  9439. /** @hidden */
  9440. export var clipPlaneVertexDeclaration: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module BABYLON {
  9446. /** @hidden */
  9447. export var morphTargetsVertex: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module BABYLON {
  9453. /** @hidden */
  9454. export var instancesVertex: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module BABYLON {
  9460. /** @hidden */
  9461. export var bonesVertex: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module BABYLON {
  9467. /** @hidden */
  9468. export var shadowMapVertexNormalBias: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module BABYLON {
  9474. /** @hidden */
  9475. export var shadowMapVertexMetric: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module BABYLON {
  9481. /** @hidden */
  9482. export var clipPlaneVertex: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module BABYLON {
  9488. /** @hidden */
  9489. export var shadowMapVertexShader: {
  9490. name: string;
  9491. shader: string;
  9492. };
  9493. }
  9494. declare module BABYLON {
  9495. /** @hidden */
  9496. export var depthBoxBlurPixelShader: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module BABYLON {
  9502. /**
  9503. * Class representing a ray with position and direction
  9504. */
  9505. export class Ray {
  9506. /** origin point */
  9507. origin: Vector3;
  9508. /** direction */
  9509. direction: Vector3;
  9510. /** length of the ray */
  9511. length: number;
  9512. private static readonly TmpVector3;
  9513. private _tmpRay;
  9514. /**
  9515. * Creates a new ray
  9516. * @param origin origin point
  9517. * @param direction direction
  9518. * @param length length of the ray
  9519. */
  9520. constructor(
  9521. /** origin point */
  9522. origin: Vector3,
  9523. /** direction */
  9524. direction: Vector3,
  9525. /** length of the ray */
  9526. length?: number);
  9527. /**
  9528. * Checks if the ray intersects a box
  9529. * This does not account for the ray lenght by design to improve perfs.
  9530. * @param minimum bound of the box
  9531. * @param maximum bound of the box
  9532. * @param intersectionTreshold extra extend to be added to the box in all direction
  9533. * @returns if the box was hit
  9534. */
  9535. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9536. /**
  9537. * Checks if the ray intersects a box
  9538. * This does not account for the ray lenght by design to improve perfs.
  9539. * @param box the bounding box to check
  9540. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9541. * @returns if the box was hit
  9542. */
  9543. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9544. /**
  9545. * If the ray hits a sphere
  9546. * @param sphere the bounding sphere to check
  9547. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9548. * @returns true if it hits the sphere
  9549. */
  9550. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9551. /**
  9552. * If the ray hits a triange
  9553. * @param vertex0 triangle vertex
  9554. * @param vertex1 triangle vertex
  9555. * @param vertex2 triangle vertex
  9556. * @returns intersection information if hit
  9557. */
  9558. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9559. /**
  9560. * Checks if ray intersects a plane
  9561. * @param plane the plane to check
  9562. * @returns the distance away it was hit
  9563. */
  9564. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9565. /**
  9566. * Calculate the intercept of a ray on a given axis
  9567. * @param axis to check 'x' | 'y' | 'z'
  9568. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9569. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9570. */
  9571. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9572. /**
  9573. * Checks if ray intersects a mesh
  9574. * @param mesh the mesh to check
  9575. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9576. * @returns picking info of the intersecton
  9577. */
  9578. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9579. /**
  9580. * Checks if ray intersects a mesh
  9581. * @param meshes the meshes to check
  9582. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9583. * @param results array to store result in
  9584. * @returns Array of picking infos
  9585. */
  9586. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9587. private _comparePickingInfo;
  9588. private static smallnum;
  9589. private static rayl;
  9590. /**
  9591. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9592. * @param sega the first point of the segment to test the intersection against
  9593. * @param segb the second point of the segment to test the intersection against
  9594. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9595. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9596. */
  9597. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9598. /**
  9599. * Update the ray from viewport position
  9600. * @param x position
  9601. * @param y y position
  9602. * @param viewportWidth viewport width
  9603. * @param viewportHeight viewport height
  9604. * @param world world matrix
  9605. * @param view view matrix
  9606. * @param projection projection matrix
  9607. * @returns this ray updated
  9608. */
  9609. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9610. /**
  9611. * Creates a ray with origin and direction of 0,0,0
  9612. * @returns the new ray
  9613. */
  9614. static Zero(): Ray;
  9615. /**
  9616. * Creates a new ray from screen space and viewport
  9617. * @param x position
  9618. * @param y y position
  9619. * @param viewportWidth viewport width
  9620. * @param viewportHeight viewport height
  9621. * @param world world matrix
  9622. * @param view view matrix
  9623. * @param projection projection matrix
  9624. * @returns new ray
  9625. */
  9626. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9627. /**
  9628. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9629. * transformed to the given world matrix.
  9630. * @param origin The origin point
  9631. * @param end The end point
  9632. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9633. * @returns the new ray
  9634. */
  9635. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9636. /**
  9637. * Transforms a ray by a matrix
  9638. * @param ray ray to transform
  9639. * @param matrix matrix to apply
  9640. * @returns the resulting new ray
  9641. */
  9642. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9643. /**
  9644. * Transforms a ray by a matrix
  9645. * @param ray ray to transform
  9646. * @param matrix matrix to apply
  9647. * @param result ray to store result in
  9648. */
  9649. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9650. /**
  9651. * Unproject a ray from screen space to object space
  9652. * @param sourceX defines the screen space x coordinate to use
  9653. * @param sourceY defines the screen space y coordinate to use
  9654. * @param viewportWidth defines the current width of the viewport
  9655. * @param viewportHeight defines the current height of the viewport
  9656. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9657. * @param view defines the view matrix to use
  9658. * @param projection defines the projection matrix to use
  9659. */
  9660. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9661. }
  9662. /**
  9663. * Type used to define predicate used to select faces when a mesh intersection is detected
  9664. */
  9665. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9666. interface Scene {
  9667. /** @hidden */
  9668. _tempPickingRay: Nullable<Ray>;
  9669. /** @hidden */
  9670. _cachedRayForTransform: Ray;
  9671. /** @hidden */
  9672. _pickWithRayInverseMatrix: Matrix;
  9673. /** @hidden */
  9674. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9675. /** @hidden */
  9676. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9677. }
  9678. }
  9679. declare module BABYLON {
  9680. /**
  9681. * Groups all the scene component constants in one place to ease maintenance.
  9682. * @hidden
  9683. */
  9684. export class SceneComponentConstants {
  9685. static readonly NAME_EFFECTLAYER: string;
  9686. static readonly NAME_LAYER: string;
  9687. static readonly NAME_LENSFLARESYSTEM: string;
  9688. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9689. static readonly NAME_PARTICLESYSTEM: string;
  9690. static readonly NAME_GAMEPAD: string;
  9691. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9692. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9693. static readonly NAME_DEPTHRENDERER: string;
  9694. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9695. static readonly NAME_SPRITE: string;
  9696. static readonly NAME_OUTLINERENDERER: string;
  9697. static readonly NAME_PROCEDURALTEXTURE: string;
  9698. static readonly NAME_SHADOWGENERATOR: string;
  9699. static readonly NAME_OCTREE: string;
  9700. static readonly NAME_PHYSICSENGINE: string;
  9701. static readonly NAME_AUDIO: string;
  9702. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9703. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9704. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9705. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9706. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9707. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9708. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9709. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9710. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9711. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9712. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9713. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9714. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9715. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9716. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9717. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9718. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9719. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9720. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9721. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9722. static readonly STEP_AFTERRENDER_AUDIO: number;
  9723. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9724. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9725. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9726. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9727. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9728. static readonly STEP_POINTERMOVE_SPRITE: number;
  9729. static readonly STEP_POINTERDOWN_SPRITE: number;
  9730. static readonly STEP_POINTERUP_SPRITE: number;
  9731. }
  9732. /**
  9733. * This represents a scene component.
  9734. *
  9735. * This is used to decouple the dependency the scene is having on the different workloads like
  9736. * layers, post processes...
  9737. */
  9738. export interface ISceneComponent {
  9739. /**
  9740. * The name of the component. Each component must have a unique name.
  9741. */
  9742. name: string;
  9743. /**
  9744. * The scene the component belongs to.
  9745. */
  9746. scene: Scene;
  9747. /**
  9748. * Register the component to one instance of a scene.
  9749. */
  9750. register(): void;
  9751. /**
  9752. * Rebuilds the elements related to this component in case of
  9753. * context lost for instance.
  9754. */
  9755. rebuild(): void;
  9756. /**
  9757. * Disposes the component and the associated ressources.
  9758. */
  9759. dispose(): void;
  9760. }
  9761. /**
  9762. * This represents a SERIALIZABLE scene component.
  9763. *
  9764. * This extends Scene Component to add Serialization methods on top.
  9765. */
  9766. export interface ISceneSerializableComponent extends ISceneComponent {
  9767. /**
  9768. * Adds all the elements from the container to the scene
  9769. * @param container the container holding the elements
  9770. */
  9771. addFromContainer(container: AbstractScene): void;
  9772. /**
  9773. * Removes all the elements in the container from the scene
  9774. * @param container contains the elements to remove
  9775. * @param dispose if the removed element should be disposed (default: false)
  9776. */
  9777. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9778. /**
  9779. * Serializes the component data to the specified json object
  9780. * @param serializationObject The object to serialize to
  9781. */
  9782. serialize(serializationObject: any): void;
  9783. }
  9784. /**
  9785. * Strong typing of a Mesh related stage step action
  9786. */
  9787. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9788. /**
  9789. * Strong typing of a Evaluate Sub Mesh related stage step action
  9790. */
  9791. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9792. /**
  9793. * Strong typing of a Active Mesh related stage step action
  9794. */
  9795. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9796. /**
  9797. * Strong typing of a Camera related stage step action
  9798. */
  9799. export type CameraStageAction = (camera: Camera) => void;
  9800. /**
  9801. * Strong typing of a Camera Frame buffer related stage step action
  9802. */
  9803. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9804. /**
  9805. * Strong typing of a Render Target related stage step action
  9806. */
  9807. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9808. /**
  9809. * Strong typing of a RenderingGroup related stage step action
  9810. */
  9811. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9812. /**
  9813. * Strong typing of a Mesh Render related stage step action
  9814. */
  9815. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9816. /**
  9817. * Strong typing of a simple stage step action
  9818. */
  9819. export type SimpleStageAction = () => void;
  9820. /**
  9821. * Strong typing of a render target action.
  9822. */
  9823. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9824. /**
  9825. * Strong typing of a pointer move action.
  9826. */
  9827. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9828. /**
  9829. * Strong typing of a pointer up/down action.
  9830. */
  9831. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9832. /**
  9833. * Representation of a stage in the scene (Basically a list of ordered steps)
  9834. * @hidden
  9835. */
  9836. export class Stage<T extends Function> extends Array<{
  9837. index: number;
  9838. component: ISceneComponent;
  9839. action: T;
  9840. }> {
  9841. /**
  9842. * Hide ctor from the rest of the world.
  9843. * @param items The items to add.
  9844. */
  9845. private constructor();
  9846. /**
  9847. * Creates a new Stage.
  9848. * @returns A new instance of a Stage
  9849. */
  9850. static Create<T extends Function>(): Stage<T>;
  9851. /**
  9852. * Registers a step in an ordered way in the targeted stage.
  9853. * @param index Defines the position to register the step in
  9854. * @param component Defines the component attached to the step
  9855. * @param action Defines the action to launch during the step
  9856. */
  9857. registerStep(index: number, component: ISceneComponent, action: T): void;
  9858. /**
  9859. * Clears all the steps from the stage.
  9860. */
  9861. clear(): void;
  9862. }
  9863. }
  9864. declare module BABYLON {
  9865. interface Scene {
  9866. /** @hidden */
  9867. _pointerOverSprite: Nullable<Sprite>;
  9868. /** @hidden */
  9869. _pickedDownSprite: Nullable<Sprite>;
  9870. /** @hidden */
  9871. _tempSpritePickingRay: Nullable<Ray>;
  9872. /**
  9873. * All of the sprite managers added to this scene
  9874. * @see http://doc.babylonjs.com/babylon101/sprites
  9875. */
  9876. spriteManagers: Array<ISpriteManager>;
  9877. /**
  9878. * An event triggered when sprites rendering is about to start
  9879. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9880. */
  9881. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9882. /**
  9883. * An event triggered when sprites rendering is done
  9884. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9885. */
  9886. onAfterSpritesRenderingObservable: Observable<Scene>;
  9887. /** @hidden */
  9888. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9889. /** Launch a ray to try to pick a sprite in the scene
  9890. * @param x position on screen
  9891. * @param y position on screen
  9892. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9893. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9894. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9895. * @returns a PickingInfo
  9896. */
  9897. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9898. /** Use the given ray to pick a sprite in the scene
  9899. * @param ray The ray (in world space) to use to pick meshes
  9900. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9901. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9902. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9903. * @returns a PickingInfo
  9904. */
  9905. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9906. /** @hidden */
  9907. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9908. /** Launch a ray to try to pick sprites in the scene
  9909. * @param x position on screen
  9910. * @param y position on screen
  9911. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9912. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9913. * @returns a PickingInfo array
  9914. */
  9915. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9916. /** Use the given ray to pick sprites in the scene
  9917. * @param ray The ray (in world space) to use to pick meshes
  9918. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9919. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9920. * @returns a PickingInfo array
  9921. */
  9922. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9923. /**
  9924. * Force the sprite under the pointer
  9925. * @param sprite defines the sprite to use
  9926. */
  9927. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9928. /**
  9929. * Gets the sprite under the pointer
  9930. * @returns a Sprite or null if no sprite is under the pointer
  9931. */
  9932. getPointerOverSprite(): Nullable<Sprite>;
  9933. }
  9934. /**
  9935. * Defines the sprite scene component responsible to manage sprites
  9936. * in a given scene.
  9937. */
  9938. export class SpriteSceneComponent implements ISceneComponent {
  9939. /**
  9940. * The component name helpfull to identify the component in the list of scene components.
  9941. */
  9942. readonly name: string;
  9943. /**
  9944. * The scene the component belongs to.
  9945. */
  9946. scene: Scene;
  9947. /** @hidden */
  9948. private _spritePredicate;
  9949. /**
  9950. * Creates a new instance of the component for the given scene
  9951. * @param scene Defines the scene to register the component in
  9952. */
  9953. constructor(scene: Scene);
  9954. /**
  9955. * Registers the component in a given scene
  9956. */
  9957. register(): void;
  9958. /**
  9959. * Rebuilds the elements related to this component in case of
  9960. * context lost for instance.
  9961. */
  9962. rebuild(): void;
  9963. /**
  9964. * Disposes the component and the associated ressources.
  9965. */
  9966. dispose(): void;
  9967. private _pickSpriteButKeepRay;
  9968. private _pointerMove;
  9969. private _pointerDown;
  9970. private _pointerUp;
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /** @hidden */
  9975. export var fogFragmentDeclaration: {
  9976. name: string;
  9977. shader: string;
  9978. };
  9979. }
  9980. declare module BABYLON {
  9981. /** @hidden */
  9982. export var fogFragment: {
  9983. name: string;
  9984. shader: string;
  9985. };
  9986. }
  9987. declare module BABYLON {
  9988. /** @hidden */
  9989. export var spritesPixelShader: {
  9990. name: string;
  9991. shader: string;
  9992. };
  9993. }
  9994. declare module BABYLON {
  9995. /** @hidden */
  9996. export var fogVertexDeclaration: {
  9997. name: string;
  9998. shader: string;
  9999. };
  10000. }
  10001. declare module BABYLON {
  10002. /** @hidden */
  10003. export var spritesVertexShader: {
  10004. name: string;
  10005. shader: string;
  10006. };
  10007. }
  10008. declare module BABYLON {
  10009. /**
  10010. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10011. */
  10012. export interface ISpriteManager extends IDisposable {
  10013. /**
  10014. * Restricts the camera to viewing objects with the same layerMask.
  10015. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10016. */
  10017. layerMask: number;
  10018. /**
  10019. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10020. */
  10021. isPickable: boolean;
  10022. /**
  10023. * Specifies the rendering group id for this mesh (0 by default)
  10024. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10025. */
  10026. renderingGroupId: number;
  10027. /**
  10028. * Defines the list of sprites managed by the manager.
  10029. */
  10030. sprites: Array<Sprite>;
  10031. /**
  10032. * Tests the intersection of a sprite with a specific ray.
  10033. * @param ray The ray we are sending to test the collision
  10034. * @param camera The camera space we are sending rays in
  10035. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10036. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10037. * @returns picking info or null.
  10038. */
  10039. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10040. /**
  10041. * Intersects the sprites with a ray
  10042. * @param ray defines the ray to intersect with
  10043. * @param camera defines the current active camera
  10044. * @param predicate defines a predicate used to select candidate sprites
  10045. * @returns null if no hit or a PickingInfo array
  10046. */
  10047. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10048. /**
  10049. * Renders the list of sprites on screen.
  10050. */
  10051. render(): void;
  10052. }
  10053. /**
  10054. * Class used to manage multiple sprites on the same spritesheet
  10055. * @see http://doc.babylonjs.com/babylon101/sprites
  10056. */
  10057. export class SpriteManager implements ISpriteManager {
  10058. /** defines the manager's name */
  10059. name: string;
  10060. /** Gets the list of sprites */
  10061. sprites: Sprite[];
  10062. /** Gets or sets the rendering group id (0 by default) */
  10063. renderingGroupId: number;
  10064. /** Gets or sets camera layer mask */
  10065. layerMask: number;
  10066. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10067. fogEnabled: boolean;
  10068. /** Gets or sets a boolean indicating if the sprites are pickable */
  10069. isPickable: boolean;
  10070. /** Defines the default width of a cell in the spritesheet */
  10071. cellWidth: number;
  10072. /** Defines the default height of a cell in the spritesheet */
  10073. cellHeight: number;
  10074. /** Associative array from JSON sprite data file */
  10075. private _cellData;
  10076. /** Array of sprite names from JSON sprite data file */
  10077. private _spriteMap;
  10078. /** True when packed cell data from JSON file is ready*/
  10079. private _packedAndReady;
  10080. private _textureContent;
  10081. /**
  10082. * An event triggered when the manager is disposed.
  10083. */
  10084. onDisposeObservable: Observable<SpriteManager>;
  10085. private _onDisposeObserver;
  10086. /**
  10087. * Callback called when the manager is disposed
  10088. */
  10089. set onDispose(callback: () => void);
  10090. private _capacity;
  10091. private _fromPacked;
  10092. private _spriteTexture;
  10093. private _epsilon;
  10094. private _scene;
  10095. private _vertexData;
  10096. private _buffer;
  10097. private _vertexBuffers;
  10098. private _indexBuffer;
  10099. private _effectBase;
  10100. private _effectFog;
  10101. /**
  10102. * Gets or sets the spritesheet texture
  10103. */
  10104. get texture(): Texture;
  10105. set texture(value: Texture);
  10106. private _blendMode;
  10107. /**
  10108. * Blend mode use to render the particle, it can be any of
  10109. * the static Constants.ALPHA_x properties provided in this class.
  10110. * Default value is Constants.ALPHA_COMBINE
  10111. */
  10112. get blendMode(): number;
  10113. set blendMode(blendMode: number);
  10114. /** Disables writing to the depth buffer when rendering the sprites.
  10115. * It can be handy to disable depth writing when using textures without alpha channel
  10116. * and setting some specific blend modes.
  10117. */
  10118. disableDepthWrite: boolean;
  10119. /**
  10120. * Creates a new sprite manager
  10121. * @param name defines the manager's name
  10122. * @param imgUrl defines the sprite sheet url
  10123. * @param capacity defines the maximum allowed number of sprites
  10124. * @param cellSize defines the size of a sprite cell
  10125. * @param scene defines the hosting scene
  10126. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10127. * @param samplingMode defines the smapling mode to use with spritesheet
  10128. * @param fromPacked set to false; do not alter
  10129. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10130. */
  10131. constructor(
  10132. /** defines the manager's name */
  10133. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10134. private _makePacked;
  10135. private _appendSpriteVertex;
  10136. private _checkTextureAlpha;
  10137. /**
  10138. * Intersects the sprites with a ray
  10139. * @param ray defines the ray to intersect with
  10140. * @param camera defines the current active camera
  10141. * @param predicate defines a predicate used to select candidate sprites
  10142. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10143. * @returns null if no hit or a PickingInfo
  10144. */
  10145. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10146. /**
  10147. * Intersects the sprites with a ray
  10148. * @param ray defines the ray to intersect with
  10149. * @param camera defines the current active camera
  10150. * @param predicate defines a predicate used to select candidate sprites
  10151. * @returns null if no hit or a PickingInfo array
  10152. */
  10153. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10154. /**
  10155. * Render all child sprites
  10156. */
  10157. render(): void;
  10158. /**
  10159. * Release associated resources
  10160. */
  10161. dispose(): void;
  10162. }
  10163. }
  10164. declare module BABYLON {
  10165. /** Interface used by value gradients (color, factor, ...) */
  10166. export interface IValueGradient {
  10167. /**
  10168. * Gets or sets the gradient value (between 0 and 1)
  10169. */
  10170. gradient: number;
  10171. }
  10172. /** Class used to store color4 gradient */
  10173. export class ColorGradient implements IValueGradient {
  10174. /**
  10175. * Gets or sets the gradient value (between 0 and 1)
  10176. */
  10177. gradient: number;
  10178. /**
  10179. * Gets or sets first associated color
  10180. */
  10181. color1: Color4;
  10182. /**
  10183. * Gets or sets second associated color
  10184. */
  10185. color2?: Color4 | undefined;
  10186. /**
  10187. * Creates a new color4 gradient
  10188. * @param gradient gets or sets the gradient value (between 0 and 1)
  10189. * @param color1 gets or sets first associated color
  10190. * @param color2 gets or sets first second color
  10191. */
  10192. constructor(
  10193. /**
  10194. * Gets or sets the gradient value (between 0 and 1)
  10195. */
  10196. gradient: number,
  10197. /**
  10198. * Gets or sets first associated color
  10199. */
  10200. color1: Color4,
  10201. /**
  10202. * Gets or sets second associated color
  10203. */
  10204. color2?: Color4 | undefined);
  10205. /**
  10206. * Will get a color picked randomly between color1 and color2.
  10207. * If color2 is undefined then color1 will be used
  10208. * @param result defines the target Color4 to store the result in
  10209. */
  10210. getColorToRef(result: Color4): void;
  10211. }
  10212. /** Class used to store color 3 gradient */
  10213. export class Color3Gradient implements IValueGradient {
  10214. /**
  10215. * Gets or sets the gradient value (between 0 and 1)
  10216. */
  10217. gradient: number;
  10218. /**
  10219. * Gets or sets the associated color
  10220. */
  10221. color: Color3;
  10222. /**
  10223. * Creates a new color3 gradient
  10224. * @param gradient gets or sets the gradient value (between 0 and 1)
  10225. * @param color gets or sets associated color
  10226. */
  10227. constructor(
  10228. /**
  10229. * Gets or sets the gradient value (between 0 and 1)
  10230. */
  10231. gradient: number,
  10232. /**
  10233. * Gets or sets the associated color
  10234. */
  10235. color: Color3);
  10236. }
  10237. /** Class used to store factor gradient */
  10238. export class FactorGradient implements IValueGradient {
  10239. /**
  10240. * Gets or sets the gradient value (between 0 and 1)
  10241. */
  10242. gradient: number;
  10243. /**
  10244. * Gets or sets first associated factor
  10245. */
  10246. factor1: number;
  10247. /**
  10248. * Gets or sets second associated factor
  10249. */
  10250. factor2?: number | undefined;
  10251. /**
  10252. * Creates a new factor gradient
  10253. * @param gradient gets or sets the gradient value (between 0 and 1)
  10254. * @param factor1 gets or sets first associated factor
  10255. * @param factor2 gets or sets second associated factor
  10256. */
  10257. constructor(
  10258. /**
  10259. * Gets or sets the gradient value (between 0 and 1)
  10260. */
  10261. gradient: number,
  10262. /**
  10263. * Gets or sets first associated factor
  10264. */
  10265. factor1: number,
  10266. /**
  10267. * Gets or sets second associated factor
  10268. */
  10269. factor2?: number | undefined);
  10270. /**
  10271. * Will get a number picked randomly between factor1 and factor2.
  10272. * If factor2 is undefined then factor1 will be used
  10273. * @returns the picked number
  10274. */
  10275. getFactor(): number;
  10276. }
  10277. /**
  10278. * Helper used to simplify some generic gradient tasks
  10279. */
  10280. export class GradientHelper {
  10281. /**
  10282. * Gets the current gradient from an array of IValueGradient
  10283. * @param ratio defines the current ratio to get
  10284. * @param gradients defines the array of IValueGradient
  10285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10286. */
  10287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10288. }
  10289. }
  10290. declare module BABYLON {
  10291. /**
  10292. * Interface for the size containing width and height
  10293. */
  10294. export interface ISize {
  10295. /**
  10296. * Width
  10297. */
  10298. width: number;
  10299. /**
  10300. * Heighht
  10301. */
  10302. height: number;
  10303. }
  10304. /**
  10305. * Size containing widht and height
  10306. */
  10307. export class Size implements ISize {
  10308. /**
  10309. * Width
  10310. */
  10311. width: number;
  10312. /**
  10313. * Height
  10314. */
  10315. height: number;
  10316. /**
  10317. * Creates a Size object from the given width and height (floats).
  10318. * @param width width of the new size
  10319. * @param height height of the new size
  10320. */
  10321. constructor(width: number, height: number);
  10322. /**
  10323. * Returns a string with the Size width and height
  10324. * @returns a string with the Size width and height
  10325. */
  10326. toString(): string;
  10327. /**
  10328. * "Size"
  10329. * @returns the string "Size"
  10330. */
  10331. getClassName(): string;
  10332. /**
  10333. * Returns the Size hash code.
  10334. * @returns a hash code for a unique width and height
  10335. */
  10336. getHashCode(): number;
  10337. /**
  10338. * Updates the current size from the given one.
  10339. * @param src the given size
  10340. */
  10341. copyFrom(src: Size): void;
  10342. /**
  10343. * Updates in place the current Size from the given floats.
  10344. * @param width width of the new size
  10345. * @param height height of the new size
  10346. * @returns the updated Size.
  10347. */
  10348. copyFromFloats(width: number, height: number): Size;
  10349. /**
  10350. * Updates in place the current Size from the given floats.
  10351. * @param width width to set
  10352. * @param height height to set
  10353. * @returns the updated Size.
  10354. */
  10355. set(width: number, height: number): Size;
  10356. /**
  10357. * Multiplies the width and height by numbers
  10358. * @param w factor to multiple the width by
  10359. * @param h factor to multiple the height by
  10360. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10361. */
  10362. multiplyByFloats(w: number, h: number): Size;
  10363. /**
  10364. * Clones the size
  10365. * @returns a new Size copied from the given one.
  10366. */
  10367. clone(): Size;
  10368. /**
  10369. * True if the current Size and the given one width and height are strictly equal.
  10370. * @param other the other size to compare against
  10371. * @returns True if the current Size and the given one width and height are strictly equal.
  10372. */
  10373. equals(other: Size): boolean;
  10374. /**
  10375. * The surface of the Size : width * height (float).
  10376. */
  10377. get surface(): number;
  10378. /**
  10379. * Create a new size of zero
  10380. * @returns a new Size set to (0.0, 0.0)
  10381. */
  10382. static Zero(): Size;
  10383. /**
  10384. * Sums the width and height of two sizes
  10385. * @param otherSize size to add to this size
  10386. * @returns a new Size set as the addition result of the current Size and the given one.
  10387. */
  10388. add(otherSize: Size): Size;
  10389. /**
  10390. * Subtracts the width and height of two
  10391. * @param otherSize size to subtract to this size
  10392. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10393. */
  10394. subtract(otherSize: Size): Size;
  10395. /**
  10396. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10397. * @param start starting size to lerp between
  10398. * @param end end size to lerp between
  10399. * @param amount amount to lerp between the start and end values
  10400. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10401. */
  10402. static Lerp(start: Size, end: Size, amount: number): Size;
  10403. }
  10404. }
  10405. declare module BABYLON {
  10406. interface ThinEngine {
  10407. /**
  10408. * Creates a dynamic texture
  10409. * @param width defines the width of the texture
  10410. * @param height defines the height of the texture
  10411. * @param generateMipMaps defines if the engine should generate the mip levels
  10412. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10413. * @returns the dynamic texture inside an InternalTexture
  10414. */
  10415. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10416. /**
  10417. * Update the content of a dynamic texture
  10418. * @param texture defines the texture to update
  10419. * @param canvas defines the canvas containing the source
  10420. * @param invertY defines if data must be stored with Y axis inverted
  10421. * @param premulAlpha defines if alpha is stored as premultiplied
  10422. * @param format defines the format of the data
  10423. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10424. */
  10425. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10426. }
  10427. }
  10428. declare module BABYLON {
  10429. /**
  10430. * Helper class used to generate a canvas to manipulate images
  10431. */
  10432. export class CanvasGenerator {
  10433. /**
  10434. * Create a new canvas (or offscreen canvas depending on the context)
  10435. * @param width defines the expected width
  10436. * @param height defines the expected height
  10437. * @return a new canvas or offscreen canvas
  10438. */
  10439. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10440. }
  10441. }
  10442. declare module BABYLON {
  10443. /**
  10444. * A class extending Texture allowing drawing on a texture
  10445. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10446. */
  10447. export class DynamicTexture extends Texture {
  10448. private _generateMipMaps;
  10449. private _canvas;
  10450. private _context;
  10451. private _engine;
  10452. /**
  10453. * Creates a DynamicTexture
  10454. * @param name defines the name of the texture
  10455. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10456. * @param scene defines the scene where you want the texture
  10457. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10458. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10459. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10460. */
  10461. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10462. /**
  10463. * Get the current class name of the texture useful for serialization or dynamic coding.
  10464. * @returns "DynamicTexture"
  10465. */
  10466. getClassName(): string;
  10467. /**
  10468. * Gets the current state of canRescale
  10469. */
  10470. get canRescale(): boolean;
  10471. private _recreate;
  10472. /**
  10473. * Scales the texture
  10474. * @param ratio the scale factor to apply to both width and height
  10475. */
  10476. scale(ratio: number): void;
  10477. /**
  10478. * Resizes the texture
  10479. * @param width the new width
  10480. * @param height the new height
  10481. */
  10482. scaleTo(width: number, height: number): void;
  10483. /**
  10484. * Gets the context of the canvas used by the texture
  10485. * @returns the canvas context of the dynamic texture
  10486. */
  10487. getContext(): CanvasRenderingContext2D;
  10488. /**
  10489. * Clears the texture
  10490. */
  10491. clear(): void;
  10492. /**
  10493. * Updates the texture
  10494. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10495. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10496. */
  10497. update(invertY?: boolean, premulAlpha?: boolean): void;
  10498. /**
  10499. * Draws text onto the texture
  10500. * @param text defines the text to be drawn
  10501. * @param x defines the placement of the text from the left
  10502. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10503. * @param font defines the font to be used with font-style, font-size, font-name
  10504. * @param color defines the color used for the text
  10505. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10506. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10507. * @param update defines whether texture is immediately update (default is true)
  10508. */
  10509. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10510. /**
  10511. * Clones the texture
  10512. * @returns the clone of the texture.
  10513. */
  10514. clone(): DynamicTexture;
  10515. /**
  10516. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10517. * @returns a serialized dynamic texture object
  10518. */
  10519. serialize(): any;
  10520. /** @hidden */
  10521. _rebuild(): void;
  10522. }
  10523. }
  10524. declare module BABYLON {
  10525. interface ThinEngine {
  10526. /**
  10527. * Creates a raw texture
  10528. * @param data defines the data to store in the texture
  10529. * @param width defines the width of the texture
  10530. * @param height defines the height of the texture
  10531. * @param format defines the format of the data
  10532. * @param generateMipMaps defines if the engine should generate the mip levels
  10533. * @param invertY defines if data must be stored with Y axis inverted
  10534. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10535. * @param compression defines the compression used (null by default)
  10536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10537. * @returns the raw texture inside an InternalTexture
  10538. */
  10539. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10540. /**
  10541. * Update a raw texture
  10542. * @param texture defines the texture to update
  10543. * @param data defines the data to store in the texture
  10544. * @param format defines the format of the data
  10545. * @param invertY defines if data must be stored with Y axis inverted
  10546. */
  10547. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10548. /**
  10549. * Update a raw texture
  10550. * @param texture defines the texture to update
  10551. * @param data defines the data to store in the texture
  10552. * @param format defines the format of the data
  10553. * @param invertY defines if data must be stored with Y axis inverted
  10554. * @param compression defines the compression used (null by default)
  10555. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10556. */
  10557. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10558. /**
  10559. * Creates a new raw cube texture
  10560. * @param data defines the array of data to use to create each face
  10561. * @param size defines the size of the textures
  10562. * @param format defines the format of the data
  10563. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10564. * @param generateMipMaps defines if the engine should generate the mip levels
  10565. * @param invertY defines if data must be stored with Y axis inverted
  10566. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10567. * @param compression defines the compression used (null by default)
  10568. * @returns the cube texture as an InternalTexture
  10569. */
  10570. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10571. /**
  10572. * Update a raw cube texture
  10573. * @param texture defines the texture to udpdate
  10574. * @param data defines the data to store
  10575. * @param format defines the data format
  10576. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. */
  10579. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10580. /**
  10581. * Update a raw cube texture
  10582. * @param texture defines the texture to udpdate
  10583. * @param data defines the data to store
  10584. * @param format defines the data format
  10585. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10586. * @param invertY defines if data must be stored with Y axis inverted
  10587. * @param compression defines the compression used (null by default)
  10588. */
  10589. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10590. /**
  10591. * Update a raw cube texture
  10592. * @param texture defines the texture to udpdate
  10593. * @param data defines the data to store
  10594. * @param format defines the data format
  10595. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10596. * @param invertY defines if data must be stored with Y axis inverted
  10597. * @param compression defines the compression used (null by default)
  10598. * @param level defines which level of the texture to update
  10599. */
  10600. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10601. /**
  10602. * Creates a new raw cube texture from a specified url
  10603. * @param url defines the url where the data is located
  10604. * @param scene defines the current scene
  10605. * @param size defines the size of the textures
  10606. * @param format defines the format of the data
  10607. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10608. * @param noMipmap defines if the engine should avoid generating the mip levels
  10609. * @param callback defines a callback used to extract texture data from loaded data
  10610. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10611. * @param onLoad defines a callback called when texture is loaded
  10612. * @param onError defines a callback called if there is an error
  10613. * @returns the cube texture as an InternalTexture
  10614. */
  10615. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10616. /**
  10617. * Creates a new raw cube texture from a specified url
  10618. * @param url defines the url where the data is located
  10619. * @param scene defines the current scene
  10620. * @param size defines the size of the textures
  10621. * @param format defines the format of the data
  10622. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10623. * @param noMipmap defines if the engine should avoid generating the mip levels
  10624. * @param callback defines a callback used to extract texture data from loaded data
  10625. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10626. * @param onLoad defines a callback called when texture is loaded
  10627. * @param onError defines a callback called if there is an error
  10628. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10629. * @param invertY defines if data must be stored with Y axis inverted
  10630. * @returns the cube texture as an InternalTexture
  10631. */
  10632. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10633. /**
  10634. * Creates a new raw 3D texture
  10635. * @param data defines the data used to create the texture
  10636. * @param width defines the width of the texture
  10637. * @param height defines the height of the texture
  10638. * @param depth defines the depth of the texture
  10639. * @param format defines the format of the texture
  10640. * @param generateMipMaps defines if the engine must generate mip levels
  10641. * @param invertY defines if data must be stored with Y axis inverted
  10642. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10643. * @param compression defines the compressed used (can be null)
  10644. * @param textureType defines the compressed used (can be null)
  10645. * @returns a new raw 3D texture (stored in an InternalTexture)
  10646. */
  10647. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10648. /**
  10649. * Update a raw 3D texture
  10650. * @param texture defines the texture to update
  10651. * @param data defines the data to store
  10652. * @param format defines the data format
  10653. * @param invertY defines if data must be stored with Y axis inverted
  10654. */
  10655. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10656. /**
  10657. * Update a raw 3D texture
  10658. * @param texture defines the texture to update
  10659. * @param data defines the data to store
  10660. * @param format defines the data format
  10661. * @param invertY defines if data must be stored with Y axis inverted
  10662. * @param compression defines the used compression (can be null)
  10663. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10664. */
  10665. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10666. /**
  10667. * Creates a new raw 2D array texture
  10668. * @param data defines the data used to create the texture
  10669. * @param width defines the width of the texture
  10670. * @param height defines the height of the texture
  10671. * @param depth defines the number of layers of the texture
  10672. * @param format defines the format of the texture
  10673. * @param generateMipMaps defines if the engine must generate mip levels
  10674. * @param invertY defines if data must be stored with Y axis inverted
  10675. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10676. * @param compression defines the compressed used (can be null)
  10677. * @param textureType defines the compressed used (can be null)
  10678. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10679. */
  10680. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10681. /**
  10682. * Update a raw 2D array texture
  10683. * @param texture defines the texture to update
  10684. * @param data defines the data to store
  10685. * @param format defines the data format
  10686. * @param invertY defines if data must be stored with Y axis inverted
  10687. */
  10688. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10689. /**
  10690. * Update a raw 2D array texture
  10691. * @param texture defines the texture to update
  10692. * @param data defines the data to store
  10693. * @param format defines the data format
  10694. * @param invertY defines if data must be stored with Y axis inverted
  10695. * @param compression defines the used compression (can be null)
  10696. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10697. */
  10698. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10699. }
  10700. }
  10701. declare module BABYLON {
  10702. /**
  10703. * Raw texture can help creating a texture directly from an array of data.
  10704. * This can be super useful if you either get the data from an uncompressed source or
  10705. * if you wish to create your texture pixel by pixel.
  10706. */
  10707. export class RawTexture extends Texture {
  10708. /**
  10709. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10710. */
  10711. format: number;
  10712. private _engine;
  10713. /**
  10714. * Instantiates a new RawTexture.
  10715. * Raw texture can help creating a texture directly from an array of data.
  10716. * This can be super useful if you either get the data from an uncompressed source or
  10717. * if you wish to create your texture pixel by pixel.
  10718. * @param data define the array of data to use to create the texture
  10719. * @param width define the width of the texture
  10720. * @param height define the height of the texture
  10721. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10722. * @param scene define the scene the texture belongs to
  10723. * @param generateMipMaps define whether mip maps should be generated or not
  10724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10726. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10727. */
  10728. constructor(data: ArrayBufferView, width: number, height: number,
  10729. /**
  10730. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10731. */
  10732. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10733. /**
  10734. * Updates the texture underlying data.
  10735. * @param data Define the new data of the texture
  10736. */
  10737. update(data: ArrayBufferView): void;
  10738. /**
  10739. * Creates a luminance texture from some data.
  10740. * @param data Define the texture data
  10741. * @param width Define the width of the texture
  10742. * @param height Define the height of the texture
  10743. * @param scene Define the scene the texture belongs to
  10744. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10745. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10746. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10747. * @returns the luminance texture
  10748. */
  10749. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10750. /**
  10751. * Creates a luminance alpha texture from some data.
  10752. * @param data Define the texture data
  10753. * @param width Define the width of the texture
  10754. * @param height Define the height of the texture
  10755. * @param scene Define the scene the texture belongs to
  10756. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10757. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10758. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10759. * @returns the luminance alpha texture
  10760. */
  10761. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10762. /**
  10763. * Creates an alpha texture from some data.
  10764. * @param data Define the texture data
  10765. * @param width Define the width of the texture
  10766. * @param height Define the height of the texture
  10767. * @param scene Define the scene the texture belongs to
  10768. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10769. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10770. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10771. * @returns the alpha texture
  10772. */
  10773. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10774. /**
  10775. * Creates a RGB texture from some data.
  10776. * @param data Define the texture data
  10777. * @param width Define the width of the texture
  10778. * @param height Define the height of the texture
  10779. * @param scene Define the scene the texture belongs to
  10780. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10781. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10782. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10783. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10784. * @returns the RGB alpha texture
  10785. */
  10786. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10787. /**
  10788. * Creates a RGBA texture from some data.
  10789. * @param data Define the texture data
  10790. * @param width Define the width of the texture
  10791. * @param height Define the height of the texture
  10792. * @param scene Define the scene the texture belongs to
  10793. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10794. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10795. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10796. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10797. * @returns the RGBA texture
  10798. */
  10799. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10800. /**
  10801. * Creates a R texture from some data.
  10802. * @param data Define the texture data
  10803. * @param width Define the width of the texture
  10804. * @param height Define the height of the texture
  10805. * @param scene Define the scene the texture belongs to
  10806. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10807. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10808. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10809. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10810. * @returns the R texture
  10811. */
  10812. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10813. }
  10814. }
  10815. declare module BABYLON {
  10816. interface AbstractScene {
  10817. /**
  10818. * The list of procedural textures added to the scene
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10820. */
  10821. proceduralTextures: Array<ProceduralTexture>;
  10822. }
  10823. /**
  10824. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10825. * in a given scene.
  10826. */
  10827. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10828. /**
  10829. * The component name helpfull to identify the component in the list of scene components.
  10830. */
  10831. readonly name: string;
  10832. /**
  10833. * The scene the component belongs to.
  10834. */
  10835. scene: Scene;
  10836. /**
  10837. * Creates a new instance of the component for the given scene
  10838. * @param scene Defines the scene to register the component in
  10839. */
  10840. constructor(scene: Scene);
  10841. /**
  10842. * Registers the component in a given scene
  10843. */
  10844. register(): void;
  10845. /**
  10846. * Rebuilds the elements related to this component in case of
  10847. * context lost for instance.
  10848. */
  10849. rebuild(): void;
  10850. /**
  10851. * Disposes the component and the associated ressources.
  10852. */
  10853. dispose(): void;
  10854. private _beforeClear;
  10855. }
  10856. }
  10857. declare module BABYLON {
  10858. interface ThinEngine {
  10859. /**
  10860. * Creates a new render target cube texture
  10861. * @param size defines the size of the texture
  10862. * @param options defines the options used to create the texture
  10863. * @returns a new render target cube texture stored in an InternalTexture
  10864. */
  10865. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10866. }
  10867. }
  10868. declare module BABYLON {
  10869. /** @hidden */
  10870. export var proceduralVertexShader: {
  10871. name: string;
  10872. shader: string;
  10873. };
  10874. }
  10875. declare module BABYLON {
  10876. /**
  10877. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10878. * This is the base class of any Procedural texture and contains most of the shareable code.
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10880. */
  10881. export class ProceduralTexture extends Texture {
  10882. isCube: boolean;
  10883. /**
  10884. * Define if the texture is enabled or not (disabled texture will not render)
  10885. */
  10886. isEnabled: boolean;
  10887. /**
  10888. * Define if the texture must be cleared before rendering (default is true)
  10889. */
  10890. autoClear: boolean;
  10891. /**
  10892. * Callback called when the texture is generated
  10893. */
  10894. onGenerated: () => void;
  10895. /**
  10896. * Event raised when the texture is generated
  10897. */
  10898. onGeneratedObservable: Observable<ProceduralTexture>;
  10899. /** @hidden */
  10900. _generateMipMaps: boolean;
  10901. /** @hidden **/
  10902. _effect: Effect;
  10903. /** @hidden */
  10904. _textures: {
  10905. [key: string]: Texture;
  10906. };
  10907. /** @hidden */
  10908. protected _fallbackTexture: Nullable<Texture>;
  10909. private _size;
  10910. private _currentRefreshId;
  10911. private _frameId;
  10912. private _refreshRate;
  10913. private _vertexBuffers;
  10914. private _indexBuffer;
  10915. private _uniforms;
  10916. private _samplers;
  10917. private _fragment;
  10918. private _floats;
  10919. private _ints;
  10920. private _floatsArrays;
  10921. private _colors3;
  10922. private _colors4;
  10923. private _vectors2;
  10924. private _vectors3;
  10925. private _matrices;
  10926. private _fallbackTextureUsed;
  10927. private _engine;
  10928. private _cachedDefines;
  10929. private _contentUpdateId;
  10930. private _contentData;
  10931. /**
  10932. * Instantiates a new procedural texture.
  10933. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  10934. * This is the base class of any Procedural texture and contains most of the shareable code.
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10936. * @param name Define the name of the texture
  10937. * @param size Define the size of the texture to create
  10938. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10939. * @param scene Define the scene the texture belongs to
  10940. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10941. * @param generateMipMaps Define if the texture should creates mip maps or not
  10942. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10943. */
  10944. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10945. /**
  10946. * The effect that is created when initializing the post process.
  10947. * @returns The created effect corresponding the the postprocess.
  10948. */
  10949. getEffect(): Effect;
  10950. /**
  10951. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10952. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10953. */
  10954. getContent(): Nullable<ArrayBufferView>;
  10955. private _createIndexBuffer;
  10956. /** @hidden */
  10957. _rebuild(): void;
  10958. /**
  10959. * Resets the texture in order to recreate its associated resources.
  10960. * This can be called in case of context loss
  10961. */
  10962. reset(): void;
  10963. protected _getDefines(): string;
  10964. /**
  10965. * Is the texture ready to be used ? (rendered at least once)
  10966. * @returns true if ready, otherwise, false.
  10967. */
  10968. isReady(): boolean;
  10969. /**
  10970. * Resets the refresh counter of the texture and start bak from scratch.
  10971. * Could be useful to regenerate the texture if it is setup to render only once.
  10972. */
  10973. resetRefreshCounter(): void;
  10974. /**
  10975. * Set the fragment shader to use in order to render the texture.
  10976. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10977. */
  10978. setFragment(fragment: any): void;
  10979. /**
  10980. * Define the refresh rate of the texture or the rendering frequency.
  10981. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10982. */
  10983. get refreshRate(): number;
  10984. set refreshRate(value: number);
  10985. /** @hidden */
  10986. _shouldRender(): boolean;
  10987. /**
  10988. * Get the size the texture is rendering at.
  10989. * @returns the size (texture is always squared)
  10990. */
  10991. getRenderSize(): number;
  10992. /**
  10993. * Resize the texture to new value.
  10994. * @param size Define the new size the texture should have
  10995. * @param generateMipMaps Define whether the new texture should create mip maps
  10996. */
  10997. resize(size: number, generateMipMaps: boolean): void;
  10998. private _checkUniform;
  10999. /**
  11000. * Set a texture in the shader program used to render.
  11001. * @param name Define the name of the uniform samplers as defined in the shader
  11002. * @param texture Define the texture to bind to this sampler
  11003. * @return the texture itself allowing "fluent" like uniform updates
  11004. */
  11005. setTexture(name: string, texture: Texture): ProceduralTexture;
  11006. /**
  11007. * Set a float in the shader.
  11008. * @param name Define the name of the uniform as defined in the shader
  11009. * @param value Define the value to give to the uniform
  11010. * @return the texture itself allowing "fluent" like uniform updates
  11011. */
  11012. setFloat(name: string, value: number): ProceduralTexture;
  11013. /**
  11014. * Set a int in the shader.
  11015. * @param name Define the name of the uniform as defined in the shader
  11016. * @param value Define the value to give to the uniform
  11017. * @return the texture itself allowing "fluent" like uniform updates
  11018. */
  11019. setInt(name: string, value: number): ProceduralTexture;
  11020. /**
  11021. * Set an array of floats in the shader.
  11022. * @param name Define the name of the uniform as defined in the shader
  11023. * @param value Define the value to give to the uniform
  11024. * @return the texture itself allowing "fluent" like uniform updates
  11025. */
  11026. setFloats(name: string, value: number[]): ProceduralTexture;
  11027. /**
  11028. * Set a vec3 in the shader from a Color3.
  11029. * @param name Define the name of the uniform as defined in the shader
  11030. * @param value Define the value to give to the uniform
  11031. * @return the texture itself allowing "fluent" like uniform updates
  11032. */
  11033. setColor3(name: string, value: Color3): ProceduralTexture;
  11034. /**
  11035. * Set a vec4 in the shader from a Color4.
  11036. * @param name Define the name of the uniform as defined in the shader
  11037. * @param value Define the value to give to the uniform
  11038. * @return the texture itself allowing "fluent" like uniform updates
  11039. */
  11040. setColor4(name: string, value: Color4): ProceduralTexture;
  11041. /**
  11042. * Set a vec2 in the shader from a Vector2.
  11043. * @param name Define the name of the uniform as defined in the shader
  11044. * @param value Define the value to give to the uniform
  11045. * @return the texture itself allowing "fluent" like uniform updates
  11046. */
  11047. setVector2(name: string, value: Vector2): ProceduralTexture;
  11048. /**
  11049. * Set a vec3 in the shader from a Vector3.
  11050. * @param name Define the name of the uniform as defined in the shader
  11051. * @param value Define the value to give to the uniform
  11052. * @return the texture itself allowing "fluent" like uniform updates
  11053. */
  11054. setVector3(name: string, value: Vector3): ProceduralTexture;
  11055. /**
  11056. * Set a mat4 in the shader from a MAtrix.
  11057. * @param name Define the name of the uniform as defined in the shader
  11058. * @param value Define the value to give to the uniform
  11059. * @return the texture itself allowing "fluent" like uniform updates
  11060. */
  11061. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11062. /**
  11063. * Render the texture to its associated render target.
  11064. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11065. */
  11066. render(useCameraPostProcess?: boolean): void;
  11067. /**
  11068. * Clone the texture.
  11069. * @returns the cloned texture
  11070. */
  11071. clone(): ProceduralTexture;
  11072. /**
  11073. * Dispose the texture and release its asoociated resources.
  11074. */
  11075. dispose(): void;
  11076. }
  11077. }
  11078. declare module BABYLON {
  11079. /**
  11080. * This represents the base class for particle system in Babylon.
  11081. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11082. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11083. * @example https://doc.babylonjs.com/babylon101/particles
  11084. */
  11085. export class BaseParticleSystem {
  11086. /**
  11087. * Source color is added to the destination color without alpha affecting the result
  11088. */
  11089. static BLENDMODE_ONEONE: number;
  11090. /**
  11091. * Blend current color and particle color using particle’s alpha
  11092. */
  11093. static BLENDMODE_STANDARD: number;
  11094. /**
  11095. * Add current color and particle color multiplied by particle’s alpha
  11096. */
  11097. static BLENDMODE_ADD: number;
  11098. /**
  11099. * Multiply current color with particle color
  11100. */
  11101. static BLENDMODE_MULTIPLY: number;
  11102. /**
  11103. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11104. */
  11105. static BLENDMODE_MULTIPLYADD: number;
  11106. /**
  11107. * List of animations used by the particle system.
  11108. */
  11109. animations: Animation[];
  11110. /**
  11111. * Gets or sets the unique id of the particle system
  11112. */
  11113. uniqueId: number;
  11114. /**
  11115. * The id of the Particle system.
  11116. */
  11117. id: string;
  11118. /**
  11119. * The friendly name of the Particle system.
  11120. */
  11121. name: string;
  11122. /**
  11123. * Snippet ID if the particle system was created from the snippet server
  11124. */
  11125. snippetId: string;
  11126. /**
  11127. * The rendering group used by the Particle system to chose when to render.
  11128. */
  11129. renderingGroupId: number;
  11130. /**
  11131. * The emitter represents the Mesh or position we are attaching the particle system to.
  11132. */
  11133. emitter: Nullable<AbstractMesh | Vector3>;
  11134. /**
  11135. * The maximum number of particles to emit per frame
  11136. */
  11137. emitRate: number;
  11138. /**
  11139. * If you want to launch only a few particles at once, that can be done, as well.
  11140. */
  11141. manualEmitCount: number;
  11142. /**
  11143. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11144. */
  11145. updateSpeed: number;
  11146. /**
  11147. * The amount of time the particle system is running (depends of the overall update speed).
  11148. */
  11149. targetStopDuration: number;
  11150. /**
  11151. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11152. */
  11153. disposeOnStop: boolean;
  11154. /**
  11155. * Minimum power of emitting particles.
  11156. */
  11157. minEmitPower: number;
  11158. /**
  11159. * Maximum power of emitting particles.
  11160. */
  11161. maxEmitPower: number;
  11162. /**
  11163. * Minimum life time of emitting particles.
  11164. */
  11165. minLifeTime: number;
  11166. /**
  11167. * Maximum life time of emitting particles.
  11168. */
  11169. maxLifeTime: number;
  11170. /**
  11171. * Minimum Size of emitting particles.
  11172. */
  11173. minSize: number;
  11174. /**
  11175. * Maximum Size of emitting particles.
  11176. */
  11177. maxSize: number;
  11178. /**
  11179. * Minimum scale of emitting particles on X axis.
  11180. */
  11181. minScaleX: number;
  11182. /**
  11183. * Maximum scale of emitting particles on X axis.
  11184. */
  11185. maxScaleX: number;
  11186. /**
  11187. * Minimum scale of emitting particles on Y axis.
  11188. */
  11189. minScaleY: number;
  11190. /**
  11191. * Maximum scale of emitting particles on Y axis.
  11192. */
  11193. maxScaleY: number;
  11194. /**
  11195. * Gets or sets the minimal initial rotation in radians.
  11196. */
  11197. minInitialRotation: number;
  11198. /**
  11199. * Gets or sets the maximal initial rotation in radians.
  11200. */
  11201. maxInitialRotation: number;
  11202. /**
  11203. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11204. */
  11205. minAngularSpeed: number;
  11206. /**
  11207. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11208. */
  11209. maxAngularSpeed: number;
  11210. /**
  11211. * The texture used to render each particle. (this can be a spritesheet)
  11212. */
  11213. particleTexture: Nullable<Texture>;
  11214. /**
  11215. * The layer mask we are rendering the particles through.
  11216. */
  11217. layerMask: number;
  11218. /**
  11219. * This can help using your own shader to render the particle system.
  11220. * The according effect will be created
  11221. */
  11222. customShader: any;
  11223. /**
  11224. * By default particle system starts as soon as they are created. This prevents the
  11225. * automatic start to happen and let you decide when to start emitting particles.
  11226. */
  11227. preventAutoStart: boolean;
  11228. private _noiseTexture;
  11229. /**
  11230. * Gets or sets a texture used to add random noise to particle positions
  11231. */
  11232. get noiseTexture(): Nullable<ProceduralTexture>;
  11233. set noiseTexture(value: Nullable<ProceduralTexture>);
  11234. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11235. noiseStrength: Vector3;
  11236. /**
  11237. * Callback triggered when the particle animation is ending.
  11238. */
  11239. onAnimationEnd: Nullable<() => void>;
  11240. /**
  11241. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11242. */
  11243. blendMode: number;
  11244. /**
  11245. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11246. * to override the particles.
  11247. */
  11248. forceDepthWrite: boolean;
  11249. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11250. preWarmCycles: number;
  11251. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11252. preWarmStepOffset: number;
  11253. /**
  11254. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11255. */
  11256. spriteCellChangeSpeed: number;
  11257. /**
  11258. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11259. */
  11260. startSpriteCellID: number;
  11261. /**
  11262. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11263. */
  11264. endSpriteCellID: number;
  11265. /**
  11266. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11267. */
  11268. spriteCellWidth: number;
  11269. /**
  11270. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11271. */
  11272. spriteCellHeight: number;
  11273. /**
  11274. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11275. */
  11276. spriteRandomStartCell: boolean;
  11277. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11278. translationPivot: Vector2;
  11279. /** @hidden */
  11280. protected _isAnimationSheetEnabled: boolean;
  11281. /**
  11282. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11283. */
  11284. beginAnimationOnStart: boolean;
  11285. /**
  11286. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11287. */
  11288. beginAnimationFrom: number;
  11289. /**
  11290. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11291. */
  11292. beginAnimationTo: number;
  11293. /**
  11294. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11295. */
  11296. beginAnimationLoop: boolean;
  11297. /**
  11298. * Gets or sets a world offset applied to all particles
  11299. */
  11300. worldOffset: Vector3;
  11301. /**
  11302. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11303. */
  11304. get isAnimationSheetEnabled(): boolean;
  11305. set isAnimationSheetEnabled(value: boolean);
  11306. /**
  11307. * Get hosting scene
  11308. * @returns the scene
  11309. */
  11310. getScene(): Scene;
  11311. /**
  11312. * You can use gravity if you want to give an orientation to your particles.
  11313. */
  11314. gravity: Vector3;
  11315. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11316. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11317. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11318. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11319. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11320. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11321. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11322. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11323. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11324. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11325. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11326. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11327. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11328. /**
  11329. * Defines the delay in milliseconds before starting the system (0 by default)
  11330. */
  11331. startDelay: number;
  11332. /**
  11333. * Gets the current list of drag gradients.
  11334. * You must use addDragGradient and removeDragGradient to udpate this list
  11335. * @returns the list of drag gradients
  11336. */
  11337. getDragGradients(): Nullable<Array<FactorGradient>>;
  11338. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11339. limitVelocityDamping: number;
  11340. /**
  11341. * Gets the current list of limit velocity gradients.
  11342. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11343. * @returns the list of limit velocity gradients
  11344. */
  11345. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11346. /**
  11347. * Gets the current list of color gradients.
  11348. * You must use addColorGradient and removeColorGradient to udpate this list
  11349. * @returns the list of color gradients
  11350. */
  11351. getColorGradients(): Nullable<Array<ColorGradient>>;
  11352. /**
  11353. * Gets the current list of size gradients.
  11354. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11355. * @returns the list of size gradients
  11356. */
  11357. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11358. /**
  11359. * Gets the current list of color remap gradients.
  11360. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11361. * @returns the list of color remap gradients
  11362. */
  11363. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11364. /**
  11365. * Gets the current list of alpha remap gradients.
  11366. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11367. * @returns the list of alpha remap gradients
  11368. */
  11369. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11370. /**
  11371. * Gets the current list of life time gradients.
  11372. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11373. * @returns the list of life time gradients
  11374. */
  11375. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11376. /**
  11377. * Gets the current list of angular speed gradients.
  11378. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11379. * @returns the list of angular speed gradients
  11380. */
  11381. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11382. /**
  11383. * Gets the current list of velocity gradients.
  11384. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11385. * @returns the list of velocity gradients
  11386. */
  11387. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11388. /**
  11389. * Gets the current list of start size gradients.
  11390. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11391. * @returns the list of start size gradients
  11392. */
  11393. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11394. /**
  11395. * Gets the current list of emit rate gradients.
  11396. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11397. * @returns the list of emit rate gradients
  11398. */
  11399. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11400. /**
  11401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11402. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11403. */
  11404. get direction1(): Vector3;
  11405. set direction1(value: Vector3);
  11406. /**
  11407. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11408. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11409. */
  11410. get direction2(): Vector3;
  11411. set direction2(value: Vector3);
  11412. /**
  11413. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11414. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11415. */
  11416. get minEmitBox(): Vector3;
  11417. set minEmitBox(value: Vector3);
  11418. /**
  11419. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11420. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11421. */
  11422. get maxEmitBox(): Vector3;
  11423. set maxEmitBox(value: Vector3);
  11424. /**
  11425. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11426. */
  11427. color1: Color4;
  11428. /**
  11429. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11430. */
  11431. color2: Color4;
  11432. /**
  11433. * Color the particle will have at the end of its lifetime
  11434. */
  11435. colorDead: Color4;
  11436. /**
  11437. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11438. */
  11439. textureMask: Color4;
  11440. /**
  11441. * The particle emitter type defines the emitter used by the particle system.
  11442. * It can be for example box, sphere, or cone...
  11443. */
  11444. particleEmitterType: IParticleEmitterType;
  11445. /** @hidden */
  11446. _isSubEmitter: boolean;
  11447. /**
  11448. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11449. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11450. */
  11451. billboardMode: number;
  11452. protected _isBillboardBased: boolean;
  11453. /**
  11454. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11455. */
  11456. get isBillboardBased(): boolean;
  11457. set isBillboardBased(value: boolean);
  11458. /**
  11459. * The scene the particle system belongs to.
  11460. */
  11461. protected _scene: Scene;
  11462. /**
  11463. * Local cache of defines for image processing.
  11464. */
  11465. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11466. /**
  11467. * Default configuration related to image processing available in the standard Material.
  11468. */
  11469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11470. /**
  11471. * Gets the image processing configuration used either in this material.
  11472. */
  11473. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11474. /**
  11475. * Sets the Default image processing configuration used either in the this material.
  11476. *
  11477. * If sets to null, the scene one is in use.
  11478. */
  11479. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11480. /**
  11481. * Attaches a new image processing configuration to the Standard Material.
  11482. * @param configuration
  11483. */
  11484. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11485. /** @hidden */
  11486. protected _reset(): void;
  11487. /** @hidden */
  11488. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11489. /**
  11490. * Instantiates a particle system.
  11491. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11492. * @param name The name of the particle system
  11493. */
  11494. constructor(name: string);
  11495. /**
  11496. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11497. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11498. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11499. * @returns the emitter
  11500. */
  11501. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11502. /**
  11503. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11504. * @param radius The radius of the hemisphere to emit from
  11505. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11506. * @returns the emitter
  11507. */
  11508. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11509. /**
  11510. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11511. * @param radius The radius of the sphere to emit from
  11512. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11513. * @returns the emitter
  11514. */
  11515. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11516. /**
  11517. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11518. * @param radius The radius of the sphere to emit from
  11519. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11520. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11521. * @returns the emitter
  11522. */
  11523. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11524. /**
  11525. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11526. * @param radius The radius of the emission cylinder
  11527. * @param height The height of the emission cylinder
  11528. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11529. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11530. * @returns the emitter
  11531. */
  11532. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11533. /**
  11534. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11535. * @param radius The radius of the cylinder to emit from
  11536. * @param height The height of the emission cylinder
  11537. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11540. * @returns the emitter
  11541. */
  11542. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11543. /**
  11544. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11545. * @param radius The radius of the cone to emit from
  11546. * @param angle The base angle of the cone
  11547. * @returns the emitter
  11548. */
  11549. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11550. /**
  11551. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11552. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11553. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11554. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11555. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11556. * @returns the emitter
  11557. */
  11558. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11559. }
  11560. }
  11561. declare module BABYLON {
  11562. /**
  11563. * Type of sub emitter
  11564. */
  11565. export enum SubEmitterType {
  11566. /**
  11567. * Attached to the particle over it's lifetime
  11568. */
  11569. ATTACHED = 0,
  11570. /**
  11571. * Created when the particle dies
  11572. */
  11573. END = 1
  11574. }
  11575. /**
  11576. * Sub emitter class used to emit particles from an existing particle
  11577. */
  11578. export class SubEmitter {
  11579. /**
  11580. * the particle system to be used by the sub emitter
  11581. */
  11582. particleSystem: ParticleSystem;
  11583. /**
  11584. * Type of the submitter (Default: END)
  11585. */
  11586. type: SubEmitterType;
  11587. /**
  11588. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11589. * Note: This only is supported when using an emitter of type Mesh
  11590. */
  11591. inheritDirection: boolean;
  11592. /**
  11593. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11594. */
  11595. inheritedVelocityAmount: number;
  11596. /**
  11597. * Creates a sub emitter
  11598. * @param particleSystem the particle system to be used by the sub emitter
  11599. */
  11600. constructor(
  11601. /**
  11602. * the particle system to be used by the sub emitter
  11603. */
  11604. particleSystem: ParticleSystem);
  11605. /**
  11606. * Clones the sub emitter
  11607. * @returns the cloned sub emitter
  11608. */
  11609. clone(): SubEmitter;
  11610. /**
  11611. * Serialize current object to a JSON object
  11612. * @returns the serialized object
  11613. */
  11614. serialize(): any;
  11615. /** @hidden */
  11616. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11617. /**
  11618. * Creates a new SubEmitter from a serialized JSON version
  11619. * @param serializationObject defines the JSON object to read from
  11620. * @param scene defines the hosting scene
  11621. * @param rootUrl defines the rootUrl for data loading
  11622. * @returns a new SubEmitter
  11623. */
  11624. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11625. /** Release associated resources */
  11626. dispose(): void;
  11627. }
  11628. }
  11629. declare module BABYLON {
  11630. /** @hidden */
  11631. export var imageProcessingDeclaration: {
  11632. name: string;
  11633. shader: string;
  11634. };
  11635. }
  11636. declare module BABYLON {
  11637. /** @hidden */
  11638. export var imageProcessingFunctions: {
  11639. name: string;
  11640. shader: string;
  11641. };
  11642. }
  11643. declare module BABYLON {
  11644. /** @hidden */
  11645. export var particlesPixelShader: {
  11646. name: string;
  11647. shader: string;
  11648. };
  11649. }
  11650. declare module BABYLON {
  11651. /** @hidden */
  11652. export var particlesVertexShader: {
  11653. name: string;
  11654. shader: string;
  11655. };
  11656. }
  11657. declare module BABYLON {
  11658. /**
  11659. * This represents a particle system in Babylon.
  11660. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11661. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11662. * @example https://doc.babylonjs.com/babylon101/particles
  11663. */
  11664. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11665. /**
  11666. * Billboard mode will only apply to Y axis
  11667. */
  11668. static readonly BILLBOARDMODE_Y: number;
  11669. /**
  11670. * Billboard mode will apply to all axes
  11671. */
  11672. static readonly BILLBOARDMODE_ALL: number;
  11673. /**
  11674. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11675. */
  11676. static readonly BILLBOARDMODE_STRETCHED: number;
  11677. /**
  11678. * This function can be defined to provide custom update for active particles.
  11679. * This function will be called instead of regular update (age, position, color, etc.).
  11680. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11681. */
  11682. updateFunction: (particles: Particle[]) => void;
  11683. private _emitterWorldMatrix;
  11684. /**
  11685. * This function can be defined to specify initial direction for every new particle.
  11686. * It by default use the emitterType defined function
  11687. */
  11688. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11689. /**
  11690. * This function can be defined to specify initial position for every new particle.
  11691. * It by default use the emitterType defined function
  11692. */
  11693. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11694. /**
  11695. * @hidden
  11696. */
  11697. _inheritedVelocityOffset: Vector3;
  11698. /**
  11699. * An event triggered when the system is disposed
  11700. */
  11701. onDisposeObservable: Observable<ParticleSystem>;
  11702. private _onDisposeObserver;
  11703. /**
  11704. * Sets a callback that will be triggered when the system is disposed
  11705. */
  11706. set onDispose(callback: () => void);
  11707. private _particles;
  11708. private _epsilon;
  11709. private _capacity;
  11710. private _stockParticles;
  11711. private _newPartsExcess;
  11712. private _vertexData;
  11713. private _vertexBuffer;
  11714. private _vertexBuffers;
  11715. private _spriteBuffer;
  11716. private _indexBuffer;
  11717. private _effect;
  11718. private _customEffect;
  11719. private _cachedDefines;
  11720. private _scaledColorStep;
  11721. private _colorDiff;
  11722. private _scaledDirection;
  11723. private _scaledGravity;
  11724. private _currentRenderId;
  11725. private _alive;
  11726. private _useInstancing;
  11727. private _started;
  11728. private _stopped;
  11729. private _actualFrame;
  11730. private _scaledUpdateSpeed;
  11731. private _vertexBufferSize;
  11732. /** @hidden */
  11733. _currentEmitRateGradient: Nullable<FactorGradient>;
  11734. /** @hidden */
  11735. _currentEmitRate1: number;
  11736. /** @hidden */
  11737. _currentEmitRate2: number;
  11738. /** @hidden */
  11739. _currentStartSizeGradient: Nullable<FactorGradient>;
  11740. /** @hidden */
  11741. _currentStartSize1: number;
  11742. /** @hidden */
  11743. _currentStartSize2: number;
  11744. private readonly _rawTextureWidth;
  11745. private _rampGradientsTexture;
  11746. private _useRampGradients;
  11747. /** Gets or sets a boolean indicating that ramp gradients must be used
  11748. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11749. */
  11750. get useRampGradients(): boolean;
  11751. set useRampGradients(value: boolean);
  11752. /**
  11753. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11754. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11755. */
  11756. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11757. private _subEmitters;
  11758. /**
  11759. * @hidden
  11760. * If the particle systems emitter should be disposed when the particle system is disposed
  11761. */
  11762. _disposeEmitterOnDispose: boolean;
  11763. /**
  11764. * The current active Sub-systems, this property is used by the root particle system only.
  11765. */
  11766. activeSubSystems: Array<ParticleSystem>;
  11767. /**
  11768. * Specifies if the particles are updated in emitter local space or world space
  11769. */
  11770. isLocal: boolean;
  11771. private _rootParticleSystem;
  11772. /**
  11773. * Gets the current list of active particles
  11774. */
  11775. get particles(): Particle[];
  11776. /**
  11777. * Gets the number of particles active at the same time.
  11778. * @returns The number of active particles.
  11779. */
  11780. getActiveCount(): number;
  11781. /**
  11782. * Returns the string "ParticleSystem"
  11783. * @returns a string containing the class name
  11784. */
  11785. getClassName(): string;
  11786. /**
  11787. * Gets a boolean indicating that the system is stopping
  11788. * @returns true if the system is currently stopping
  11789. */
  11790. isStopping(): boolean;
  11791. /**
  11792. * Instantiates a particle system.
  11793. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11794. * @param name The name of the particle system
  11795. * @param capacity The max number of particles alive at the same time
  11796. * @param scene The scene the particle system belongs to
  11797. * @param customEffect a custom effect used to change the way particles are rendered by default
  11798. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11799. * @param epsilon Offset used to render the particles
  11800. */
  11801. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11802. private _addFactorGradient;
  11803. private _removeFactorGradient;
  11804. /**
  11805. * Adds a new life time gradient
  11806. * @param gradient defines the gradient to use (between 0 and 1)
  11807. * @param factor defines the life time factor to affect to the specified gradient
  11808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11809. * @returns the current particle system
  11810. */
  11811. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11812. /**
  11813. * Remove a specific life time gradient
  11814. * @param gradient defines the gradient to remove
  11815. * @returns the current particle system
  11816. */
  11817. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11818. /**
  11819. * Adds a new size gradient
  11820. * @param gradient defines the gradient to use (between 0 and 1)
  11821. * @param factor defines the size factor to affect to the specified gradient
  11822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11823. * @returns the current particle system
  11824. */
  11825. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11826. /**
  11827. * Remove a specific size gradient
  11828. * @param gradient defines the gradient to remove
  11829. * @returns the current particle system
  11830. */
  11831. removeSizeGradient(gradient: number): IParticleSystem;
  11832. /**
  11833. * Adds a new color remap gradient
  11834. * @param gradient defines the gradient to use (between 0 and 1)
  11835. * @param min defines the color remap minimal range
  11836. * @param max defines the color remap maximal range
  11837. * @returns the current particle system
  11838. */
  11839. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11840. /**
  11841. * Remove a specific color remap gradient
  11842. * @param gradient defines the gradient to remove
  11843. * @returns the current particle system
  11844. */
  11845. removeColorRemapGradient(gradient: number): IParticleSystem;
  11846. /**
  11847. * Adds a new alpha remap gradient
  11848. * @param gradient defines the gradient to use (between 0 and 1)
  11849. * @param min defines the alpha remap minimal range
  11850. * @param max defines the alpha remap maximal range
  11851. * @returns the current particle system
  11852. */
  11853. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11854. /**
  11855. * Remove a specific alpha remap gradient
  11856. * @param gradient defines the gradient to remove
  11857. * @returns the current particle system
  11858. */
  11859. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11860. /**
  11861. * Adds a new angular speed gradient
  11862. * @param gradient defines the gradient to use (between 0 and 1)
  11863. * @param factor defines the angular speed to affect to the specified gradient
  11864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11865. * @returns the current particle system
  11866. */
  11867. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11868. /**
  11869. * Remove a specific angular speed gradient
  11870. * @param gradient defines the gradient to remove
  11871. * @returns the current particle system
  11872. */
  11873. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11874. /**
  11875. * Adds a new velocity gradient
  11876. * @param gradient defines the gradient to use (between 0 and 1)
  11877. * @param factor defines the velocity to affect to the specified gradient
  11878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11879. * @returns the current particle system
  11880. */
  11881. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11882. /**
  11883. * Remove a specific velocity gradient
  11884. * @param gradient defines the gradient to remove
  11885. * @returns the current particle system
  11886. */
  11887. removeVelocityGradient(gradient: number): IParticleSystem;
  11888. /**
  11889. * Adds a new limit velocity gradient
  11890. * @param gradient defines the gradient to use (between 0 and 1)
  11891. * @param factor defines the limit velocity value to affect to the specified gradient
  11892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11893. * @returns the current particle system
  11894. */
  11895. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11896. /**
  11897. * Remove a specific limit velocity gradient
  11898. * @param gradient defines the gradient to remove
  11899. * @returns the current particle system
  11900. */
  11901. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11902. /**
  11903. * Adds a new drag gradient
  11904. * @param gradient defines the gradient to use (between 0 and 1)
  11905. * @param factor defines the drag value to affect to the specified gradient
  11906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11907. * @returns the current particle system
  11908. */
  11909. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11910. /**
  11911. * Remove a specific drag gradient
  11912. * @param gradient defines the gradient to remove
  11913. * @returns the current particle system
  11914. */
  11915. removeDragGradient(gradient: number): IParticleSystem;
  11916. /**
  11917. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11918. * @param gradient defines the gradient to use (between 0 and 1)
  11919. * @param factor defines the emit rate value to affect to the specified gradient
  11920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11921. * @returns the current particle system
  11922. */
  11923. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11924. /**
  11925. * Remove a specific emit rate gradient
  11926. * @param gradient defines the gradient to remove
  11927. * @returns the current particle system
  11928. */
  11929. removeEmitRateGradient(gradient: number): IParticleSystem;
  11930. /**
  11931. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11932. * @param gradient defines the gradient to use (between 0 and 1)
  11933. * @param factor defines the start size value to affect to the specified gradient
  11934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11935. * @returns the current particle system
  11936. */
  11937. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11938. /**
  11939. * Remove a specific start size gradient
  11940. * @param gradient defines the gradient to remove
  11941. * @returns the current particle system
  11942. */
  11943. removeStartSizeGradient(gradient: number): IParticleSystem;
  11944. private _createRampGradientTexture;
  11945. /**
  11946. * Gets the current list of ramp gradients.
  11947. * You must use addRampGradient and removeRampGradient to udpate this list
  11948. * @returns the list of ramp gradients
  11949. */
  11950. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11951. /** Force the system to rebuild all gradients that need to be resync */
  11952. forceRefreshGradients(): void;
  11953. private _syncRampGradientTexture;
  11954. /**
  11955. * Adds a new ramp gradient used to remap particle colors
  11956. * @param gradient defines the gradient to use (between 0 and 1)
  11957. * @param color defines the color to affect to the specified gradient
  11958. * @returns the current particle system
  11959. */
  11960. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11961. /**
  11962. * Remove a specific ramp gradient
  11963. * @param gradient defines the gradient to remove
  11964. * @returns the current particle system
  11965. */
  11966. removeRampGradient(gradient: number): ParticleSystem;
  11967. /**
  11968. * Adds a new color gradient
  11969. * @param gradient defines the gradient to use (between 0 and 1)
  11970. * @param color1 defines the color to affect to the specified gradient
  11971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11972. * @returns this particle system
  11973. */
  11974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11975. /**
  11976. * Remove a specific color gradient
  11977. * @param gradient defines the gradient to remove
  11978. * @returns this particle system
  11979. */
  11980. removeColorGradient(gradient: number): IParticleSystem;
  11981. private _fetchR;
  11982. protected _reset(): void;
  11983. private _resetEffect;
  11984. private _createVertexBuffers;
  11985. private _createIndexBuffer;
  11986. /**
  11987. * Gets the maximum number of particles active at the same time.
  11988. * @returns The max number of active particles.
  11989. */
  11990. getCapacity(): number;
  11991. /**
  11992. * Gets whether there are still active particles in the system.
  11993. * @returns True if it is alive, otherwise false.
  11994. */
  11995. isAlive(): boolean;
  11996. /**
  11997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11998. * @returns True if it has been started, otherwise false.
  11999. */
  12000. isStarted(): boolean;
  12001. private _prepareSubEmitterInternalArray;
  12002. /**
  12003. * Starts the particle system and begins to emit
  12004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12005. */
  12006. start(delay?: number): void;
  12007. /**
  12008. * Stops the particle system.
  12009. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12010. */
  12011. stop(stopSubEmitters?: boolean): void;
  12012. /**
  12013. * Remove all active particles
  12014. */
  12015. reset(): void;
  12016. /**
  12017. * @hidden (for internal use only)
  12018. */
  12019. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12020. /**
  12021. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12022. * Its lifetime will start back at 0.
  12023. */
  12024. recycleParticle: (particle: Particle) => void;
  12025. private _stopSubEmitters;
  12026. private _createParticle;
  12027. private _removeFromRoot;
  12028. private _emitFromParticle;
  12029. private _update;
  12030. /** @hidden */
  12031. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12032. /** @hidden */
  12033. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12034. /** @hidden */
  12035. private _getEffect;
  12036. /**
  12037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12039. */
  12040. animate(preWarmOnly?: boolean): void;
  12041. private _appendParticleVertices;
  12042. /**
  12043. * Rebuilds the particle system.
  12044. */
  12045. rebuild(): void;
  12046. /**
  12047. * Is this system ready to be used/rendered
  12048. * @return true if the system is ready
  12049. */
  12050. isReady(): boolean;
  12051. private _render;
  12052. /**
  12053. * Renders the particle system in its current state.
  12054. * @returns the current number of particles
  12055. */
  12056. render(): number;
  12057. /**
  12058. * Disposes the particle system and free the associated resources
  12059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12060. */
  12061. dispose(disposeTexture?: boolean): void;
  12062. /**
  12063. * Clones the particle system.
  12064. * @param name The name of the cloned object
  12065. * @param newEmitter The new emitter to use
  12066. * @returns the cloned particle system
  12067. */
  12068. clone(name: string, newEmitter: any): ParticleSystem;
  12069. /**
  12070. * Serializes the particle system to a JSON object
  12071. * @param serializeTexture defines if the texture must be serialized as well
  12072. * @returns the JSON object
  12073. */
  12074. serialize(serializeTexture?: boolean): any;
  12075. /** @hidden */
  12076. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12077. /** @hidden */
  12078. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12079. /**
  12080. * Parses a JSON object to create a particle system.
  12081. * @param parsedParticleSystem The JSON object to parse
  12082. * @param scene The scene to create the particle system in
  12083. * @param rootUrl The root url to use to load external dependencies like texture
  12084. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12085. * @returns the Parsed particle system
  12086. */
  12087. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12088. }
  12089. }
  12090. declare module BABYLON {
  12091. /**
  12092. * A particle represents one of the element emitted by a particle system.
  12093. * This is mainly define by its coordinates, direction, velocity and age.
  12094. */
  12095. export class Particle {
  12096. /**
  12097. * The particle system the particle belongs to.
  12098. */
  12099. particleSystem: ParticleSystem;
  12100. private static _Count;
  12101. /**
  12102. * Unique ID of the particle
  12103. */
  12104. id: number;
  12105. /**
  12106. * The world position of the particle in the scene.
  12107. */
  12108. position: Vector3;
  12109. /**
  12110. * The world direction of the particle in the scene.
  12111. */
  12112. direction: Vector3;
  12113. /**
  12114. * The color of the particle.
  12115. */
  12116. color: Color4;
  12117. /**
  12118. * The color change of the particle per step.
  12119. */
  12120. colorStep: Color4;
  12121. /**
  12122. * Defines how long will the life of the particle be.
  12123. */
  12124. lifeTime: number;
  12125. /**
  12126. * The current age of the particle.
  12127. */
  12128. age: number;
  12129. /**
  12130. * The current size of the particle.
  12131. */
  12132. size: number;
  12133. /**
  12134. * The current scale of the particle.
  12135. */
  12136. scale: Vector2;
  12137. /**
  12138. * The current angle of the particle.
  12139. */
  12140. angle: number;
  12141. /**
  12142. * Defines how fast is the angle changing.
  12143. */
  12144. angularSpeed: number;
  12145. /**
  12146. * Defines the cell index used by the particle to be rendered from a sprite.
  12147. */
  12148. cellIndex: number;
  12149. /**
  12150. * The information required to support color remapping
  12151. */
  12152. remapData: Vector4;
  12153. /** @hidden */
  12154. _randomCellOffset?: number;
  12155. /** @hidden */
  12156. _initialDirection: Nullable<Vector3>;
  12157. /** @hidden */
  12158. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12159. /** @hidden */
  12160. _initialStartSpriteCellID: number;
  12161. /** @hidden */
  12162. _initialEndSpriteCellID: number;
  12163. /** @hidden */
  12164. _currentColorGradient: Nullable<ColorGradient>;
  12165. /** @hidden */
  12166. _currentColor1: Color4;
  12167. /** @hidden */
  12168. _currentColor2: Color4;
  12169. /** @hidden */
  12170. _currentSizeGradient: Nullable<FactorGradient>;
  12171. /** @hidden */
  12172. _currentSize1: number;
  12173. /** @hidden */
  12174. _currentSize2: number;
  12175. /** @hidden */
  12176. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12177. /** @hidden */
  12178. _currentAngularSpeed1: number;
  12179. /** @hidden */
  12180. _currentAngularSpeed2: number;
  12181. /** @hidden */
  12182. _currentVelocityGradient: Nullable<FactorGradient>;
  12183. /** @hidden */
  12184. _currentVelocity1: number;
  12185. /** @hidden */
  12186. _currentVelocity2: number;
  12187. /** @hidden */
  12188. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12189. /** @hidden */
  12190. _currentLimitVelocity1: number;
  12191. /** @hidden */
  12192. _currentLimitVelocity2: number;
  12193. /** @hidden */
  12194. _currentDragGradient: Nullable<FactorGradient>;
  12195. /** @hidden */
  12196. _currentDrag1: number;
  12197. /** @hidden */
  12198. _currentDrag2: number;
  12199. /** @hidden */
  12200. _randomNoiseCoordinates1: Vector3;
  12201. /** @hidden */
  12202. _randomNoiseCoordinates2: Vector3;
  12203. /** @hidden */
  12204. _localPosition?: Vector3;
  12205. /**
  12206. * Creates a new instance Particle
  12207. * @param particleSystem the particle system the particle belongs to
  12208. */
  12209. constructor(
  12210. /**
  12211. * The particle system the particle belongs to.
  12212. */
  12213. particleSystem: ParticleSystem);
  12214. private updateCellInfoFromSystem;
  12215. /**
  12216. * Defines how the sprite cell index is updated for the particle
  12217. */
  12218. updateCellIndex(): void;
  12219. /** @hidden */
  12220. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12221. /** @hidden */
  12222. _inheritParticleInfoToSubEmitters(): void;
  12223. /** @hidden */
  12224. _reset(): void;
  12225. /**
  12226. * Copy the properties of particle to another one.
  12227. * @param other the particle to copy the information to.
  12228. */
  12229. copyTo(other: Particle): void;
  12230. }
  12231. }
  12232. declare module BABYLON {
  12233. /**
  12234. * Particle emitter represents a volume emitting particles.
  12235. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12236. */
  12237. export interface IParticleEmitterType {
  12238. /**
  12239. * Called by the particle System when the direction is computed for the created particle.
  12240. * @param worldMatrix is the world matrix of the particle system
  12241. * @param directionToUpdate is the direction vector to update with the result
  12242. * @param particle is the particle we are computed the direction for
  12243. * @param isLocal defines if the direction should be set in local space
  12244. */
  12245. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12246. /**
  12247. * Called by the particle System when the position is computed for the created particle.
  12248. * @param worldMatrix is the world matrix of the particle system
  12249. * @param positionToUpdate is the position vector to update with the result
  12250. * @param particle is the particle we are computed the position for
  12251. * @param isLocal defines if the position should be set in local space
  12252. */
  12253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12254. /**
  12255. * Clones the current emitter and returns a copy of it
  12256. * @returns the new emitter
  12257. */
  12258. clone(): IParticleEmitterType;
  12259. /**
  12260. * Called by the GPUParticleSystem to setup the update shader
  12261. * @param effect defines the update shader
  12262. */
  12263. applyToShader(effect: Effect): void;
  12264. /**
  12265. * Returns a string to use to update the GPU particles update shader
  12266. * @returns the effect defines string
  12267. */
  12268. getEffectDefines(): string;
  12269. /**
  12270. * Returns a string representing the class name
  12271. * @returns a string containing the class name
  12272. */
  12273. getClassName(): string;
  12274. /**
  12275. * Serializes the particle system to a JSON object.
  12276. * @returns the JSON object
  12277. */
  12278. serialize(): any;
  12279. /**
  12280. * Parse properties from a JSON object
  12281. * @param serializationObject defines the JSON object
  12282. * @param scene defines the hosting scene
  12283. */
  12284. parse(serializationObject: any, scene: Scene): void;
  12285. }
  12286. }
  12287. declare module BABYLON {
  12288. /**
  12289. * Particle emitter emitting particles from the inside of a box.
  12290. * It emits the particles randomly between 2 given directions.
  12291. */
  12292. export class BoxParticleEmitter implements IParticleEmitterType {
  12293. /**
  12294. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12295. */
  12296. direction1: Vector3;
  12297. /**
  12298. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12299. */
  12300. direction2: Vector3;
  12301. /**
  12302. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12303. */
  12304. minEmitBox: Vector3;
  12305. /**
  12306. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12307. */
  12308. maxEmitBox: Vector3;
  12309. /**
  12310. * Creates a new instance BoxParticleEmitter
  12311. */
  12312. constructor();
  12313. /**
  12314. * Called by the particle System when the direction is computed for the created particle.
  12315. * @param worldMatrix is the world matrix of the particle system
  12316. * @param directionToUpdate is the direction vector to update with the result
  12317. * @param particle is the particle we are computed the direction for
  12318. * @param isLocal defines if the direction should be set in local space
  12319. */
  12320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12321. /**
  12322. * Called by the particle System when the position is computed for the created particle.
  12323. * @param worldMatrix is the world matrix of the particle system
  12324. * @param positionToUpdate is the position vector to update with the result
  12325. * @param particle is the particle we are computed the position for
  12326. * @param isLocal defines if the position should be set in local space
  12327. */
  12328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12329. /**
  12330. * Clones the current emitter and returns a copy of it
  12331. * @returns the new emitter
  12332. */
  12333. clone(): BoxParticleEmitter;
  12334. /**
  12335. * Called by the GPUParticleSystem to setup the update shader
  12336. * @param effect defines the update shader
  12337. */
  12338. applyToShader(effect: Effect): void;
  12339. /**
  12340. * Returns a string to use to update the GPU particles update shader
  12341. * @returns a string containng the defines string
  12342. */
  12343. getEffectDefines(): string;
  12344. /**
  12345. * Returns the string "BoxParticleEmitter"
  12346. * @returns a string containing the class name
  12347. */
  12348. getClassName(): string;
  12349. /**
  12350. * Serializes the particle system to a JSON object.
  12351. * @returns the JSON object
  12352. */
  12353. serialize(): any;
  12354. /**
  12355. * Parse properties from a JSON object
  12356. * @param serializationObject defines the JSON object
  12357. */
  12358. parse(serializationObject: any): void;
  12359. }
  12360. }
  12361. declare module BABYLON {
  12362. /**
  12363. * Particle emitter emitting particles from the inside of a cone.
  12364. * It emits the particles alongside the cone volume from the base to the particle.
  12365. * The emission direction might be randomized.
  12366. */
  12367. export class ConeParticleEmitter implements IParticleEmitterType {
  12368. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12369. directionRandomizer: number;
  12370. private _radius;
  12371. private _angle;
  12372. private _height;
  12373. /**
  12374. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12375. */
  12376. radiusRange: number;
  12377. /**
  12378. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12379. */
  12380. heightRange: number;
  12381. /**
  12382. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12383. */
  12384. emitFromSpawnPointOnly: boolean;
  12385. /**
  12386. * Gets or sets the radius of the emission cone
  12387. */
  12388. get radius(): number;
  12389. set radius(value: number);
  12390. /**
  12391. * Gets or sets the angle of the emission cone
  12392. */
  12393. get angle(): number;
  12394. set angle(value: number);
  12395. private _buildHeight;
  12396. /**
  12397. * Creates a new instance ConeParticleEmitter
  12398. * @param radius the radius of the emission cone (1 by default)
  12399. * @param angle the cone base angle (PI by default)
  12400. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12401. */
  12402. constructor(radius?: number, angle?: number,
  12403. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12404. directionRandomizer?: number);
  12405. /**
  12406. * Called by the particle System when the direction is computed for the created particle.
  12407. * @param worldMatrix is the world matrix of the particle system
  12408. * @param directionToUpdate is the direction vector to update with the result
  12409. * @param particle is the particle we are computed the direction for
  12410. * @param isLocal defines if the direction should be set in local space
  12411. */
  12412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12413. /**
  12414. * Called by the particle System when the position is computed for the created particle.
  12415. * @param worldMatrix is the world matrix of the particle system
  12416. * @param positionToUpdate is the position vector to update with the result
  12417. * @param particle is the particle we are computed the position for
  12418. * @param isLocal defines if the position should be set in local space
  12419. */
  12420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12421. /**
  12422. * Clones the current emitter and returns a copy of it
  12423. * @returns the new emitter
  12424. */
  12425. clone(): ConeParticleEmitter;
  12426. /**
  12427. * Called by the GPUParticleSystem to setup the update shader
  12428. * @param effect defines the update shader
  12429. */
  12430. applyToShader(effect: Effect): void;
  12431. /**
  12432. * Returns a string to use to update the GPU particles update shader
  12433. * @returns a string containng the defines string
  12434. */
  12435. getEffectDefines(): string;
  12436. /**
  12437. * Returns the string "ConeParticleEmitter"
  12438. * @returns a string containing the class name
  12439. */
  12440. getClassName(): string;
  12441. /**
  12442. * Serializes the particle system to a JSON object.
  12443. * @returns the JSON object
  12444. */
  12445. serialize(): any;
  12446. /**
  12447. * Parse properties from a JSON object
  12448. * @param serializationObject defines the JSON object
  12449. */
  12450. parse(serializationObject: any): void;
  12451. }
  12452. }
  12453. declare module BABYLON {
  12454. /**
  12455. * Particle emitter emitting particles from the inside of a cylinder.
  12456. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12457. */
  12458. export class CylinderParticleEmitter implements IParticleEmitterType {
  12459. /**
  12460. * The radius of the emission cylinder.
  12461. */
  12462. radius: number;
  12463. /**
  12464. * The height of the emission cylinder.
  12465. */
  12466. height: number;
  12467. /**
  12468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12469. */
  12470. radiusRange: number;
  12471. /**
  12472. * How much to randomize the particle direction [0-1].
  12473. */
  12474. directionRandomizer: number;
  12475. /**
  12476. * Creates a new instance CylinderParticleEmitter
  12477. * @param radius the radius of the emission cylinder (1 by default)
  12478. * @param height the height of the emission cylinder (1 by default)
  12479. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12480. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12481. */
  12482. constructor(
  12483. /**
  12484. * The radius of the emission cylinder.
  12485. */
  12486. radius?: number,
  12487. /**
  12488. * The height of the emission cylinder.
  12489. */
  12490. height?: number,
  12491. /**
  12492. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12493. */
  12494. radiusRange?: number,
  12495. /**
  12496. * How much to randomize the particle direction [0-1].
  12497. */
  12498. directionRandomizer?: number);
  12499. /**
  12500. * Called by the particle System when the direction is computed for the created particle.
  12501. * @param worldMatrix is the world matrix of the particle system
  12502. * @param directionToUpdate is the direction vector to update with the result
  12503. * @param particle is the particle we are computed the direction for
  12504. * @param isLocal defines if the direction should be set in local space
  12505. */
  12506. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12507. /**
  12508. * Called by the particle System when the position is computed for the created particle.
  12509. * @param worldMatrix is the world matrix of the particle system
  12510. * @param positionToUpdate is the position vector to update with the result
  12511. * @param particle is the particle we are computed the position for
  12512. * @param isLocal defines if the position should be set in local space
  12513. */
  12514. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12515. /**
  12516. * Clones the current emitter and returns a copy of it
  12517. * @returns the new emitter
  12518. */
  12519. clone(): CylinderParticleEmitter;
  12520. /**
  12521. * Called by the GPUParticleSystem to setup the update shader
  12522. * @param effect defines the update shader
  12523. */
  12524. applyToShader(effect: Effect): void;
  12525. /**
  12526. * Returns a string to use to update the GPU particles update shader
  12527. * @returns a string containng the defines string
  12528. */
  12529. getEffectDefines(): string;
  12530. /**
  12531. * Returns the string "CylinderParticleEmitter"
  12532. * @returns a string containing the class name
  12533. */
  12534. getClassName(): string;
  12535. /**
  12536. * Serializes the particle system to a JSON object.
  12537. * @returns the JSON object
  12538. */
  12539. serialize(): any;
  12540. /**
  12541. * Parse properties from a JSON object
  12542. * @param serializationObject defines the JSON object
  12543. */
  12544. parse(serializationObject: any): void;
  12545. }
  12546. /**
  12547. * Particle emitter emitting particles from the inside of a cylinder.
  12548. * It emits the particles randomly between two vectors.
  12549. */
  12550. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12551. /**
  12552. * The min limit of the emission direction.
  12553. */
  12554. direction1: Vector3;
  12555. /**
  12556. * The max limit of the emission direction.
  12557. */
  12558. direction2: Vector3;
  12559. /**
  12560. * Creates a new instance CylinderDirectedParticleEmitter
  12561. * @param radius the radius of the emission cylinder (1 by default)
  12562. * @param height the height of the emission cylinder (1 by default)
  12563. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12564. * @param direction1 the min limit of the emission direction (up vector by default)
  12565. * @param direction2 the max limit of the emission direction (up vector by default)
  12566. */
  12567. constructor(radius?: number, height?: number, radiusRange?: number,
  12568. /**
  12569. * The min limit of the emission direction.
  12570. */
  12571. direction1?: Vector3,
  12572. /**
  12573. * The max limit of the emission direction.
  12574. */
  12575. direction2?: Vector3);
  12576. /**
  12577. * Called by the particle System when the direction is computed for the created particle.
  12578. * @param worldMatrix is the world matrix of the particle system
  12579. * @param directionToUpdate is the direction vector to update with the result
  12580. * @param particle is the particle we are computed the direction for
  12581. */
  12582. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12583. /**
  12584. * Clones the current emitter and returns a copy of it
  12585. * @returns the new emitter
  12586. */
  12587. clone(): CylinderDirectedParticleEmitter;
  12588. /**
  12589. * Called by the GPUParticleSystem to setup the update shader
  12590. * @param effect defines the update shader
  12591. */
  12592. applyToShader(effect: Effect): void;
  12593. /**
  12594. * Returns a string to use to update the GPU particles update shader
  12595. * @returns a string containng the defines string
  12596. */
  12597. getEffectDefines(): string;
  12598. /**
  12599. * Returns the string "CylinderDirectedParticleEmitter"
  12600. * @returns a string containing the class name
  12601. */
  12602. getClassName(): string;
  12603. /**
  12604. * Serializes the particle system to a JSON object.
  12605. * @returns the JSON object
  12606. */
  12607. serialize(): any;
  12608. /**
  12609. * Parse properties from a JSON object
  12610. * @param serializationObject defines the JSON object
  12611. */
  12612. parse(serializationObject: any): void;
  12613. }
  12614. }
  12615. declare module BABYLON {
  12616. /**
  12617. * Particle emitter emitting particles from the inside of a hemisphere.
  12618. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12619. */
  12620. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12621. /**
  12622. * The radius of the emission hemisphere.
  12623. */
  12624. radius: number;
  12625. /**
  12626. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12627. */
  12628. radiusRange: number;
  12629. /**
  12630. * How much to randomize the particle direction [0-1].
  12631. */
  12632. directionRandomizer: number;
  12633. /**
  12634. * Creates a new instance HemisphericParticleEmitter
  12635. * @param radius the radius of the emission hemisphere (1 by default)
  12636. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12637. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12638. */
  12639. constructor(
  12640. /**
  12641. * The radius of the emission hemisphere.
  12642. */
  12643. radius?: number,
  12644. /**
  12645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12646. */
  12647. radiusRange?: number,
  12648. /**
  12649. * How much to randomize the particle direction [0-1].
  12650. */
  12651. directionRandomizer?: number);
  12652. /**
  12653. * Called by the particle System when the direction is computed for the created particle.
  12654. * @param worldMatrix is the world matrix of the particle system
  12655. * @param directionToUpdate is the direction vector to update with the result
  12656. * @param particle is the particle we are computed the direction for
  12657. * @param isLocal defines if the direction should be set in local space
  12658. */
  12659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12660. /**
  12661. * Called by the particle System when the position is computed for the created particle.
  12662. * @param worldMatrix is the world matrix of the particle system
  12663. * @param positionToUpdate is the position vector to update with the result
  12664. * @param particle is the particle we are computed the position for
  12665. * @param isLocal defines if the position should be set in local space
  12666. */
  12667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12668. /**
  12669. * Clones the current emitter and returns a copy of it
  12670. * @returns the new emitter
  12671. */
  12672. clone(): HemisphericParticleEmitter;
  12673. /**
  12674. * Called by the GPUParticleSystem to setup the update shader
  12675. * @param effect defines the update shader
  12676. */
  12677. applyToShader(effect: Effect): void;
  12678. /**
  12679. * Returns a string to use to update the GPU particles update shader
  12680. * @returns a string containng the defines string
  12681. */
  12682. getEffectDefines(): string;
  12683. /**
  12684. * Returns the string "HemisphericParticleEmitter"
  12685. * @returns a string containing the class name
  12686. */
  12687. getClassName(): string;
  12688. /**
  12689. * Serializes the particle system to a JSON object.
  12690. * @returns the JSON object
  12691. */
  12692. serialize(): any;
  12693. /**
  12694. * Parse properties from a JSON object
  12695. * @param serializationObject defines the JSON object
  12696. */
  12697. parse(serializationObject: any): void;
  12698. }
  12699. }
  12700. declare module BABYLON {
  12701. /**
  12702. * Particle emitter emitting particles from a point.
  12703. * It emits the particles randomly between 2 given directions.
  12704. */
  12705. export class PointParticleEmitter implements IParticleEmitterType {
  12706. /**
  12707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12708. */
  12709. direction1: Vector3;
  12710. /**
  12711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12712. */
  12713. direction2: Vector3;
  12714. /**
  12715. * Creates a new instance PointParticleEmitter
  12716. */
  12717. constructor();
  12718. /**
  12719. * Called by the particle System when the direction is computed for the created particle.
  12720. * @param worldMatrix is the world matrix of the particle system
  12721. * @param directionToUpdate is the direction vector to update with the result
  12722. * @param particle is the particle we are computed the direction for
  12723. * @param isLocal defines if the direction should be set in local space
  12724. */
  12725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12726. /**
  12727. * Called by the particle System when the position is computed for the created particle.
  12728. * @param worldMatrix is the world matrix of the particle system
  12729. * @param positionToUpdate is the position vector to update with the result
  12730. * @param particle is the particle we are computed the position for
  12731. * @param isLocal defines if the position should be set in local space
  12732. */
  12733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12734. /**
  12735. * Clones the current emitter and returns a copy of it
  12736. * @returns the new emitter
  12737. */
  12738. clone(): PointParticleEmitter;
  12739. /**
  12740. * Called by the GPUParticleSystem to setup the update shader
  12741. * @param effect defines the update shader
  12742. */
  12743. applyToShader(effect: Effect): void;
  12744. /**
  12745. * Returns a string to use to update the GPU particles update shader
  12746. * @returns a string containng the defines string
  12747. */
  12748. getEffectDefines(): string;
  12749. /**
  12750. * Returns the string "PointParticleEmitter"
  12751. * @returns a string containing the class name
  12752. */
  12753. getClassName(): string;
  12754. /**
  12755. * Serializes the particle system to a JSON object.
  12756. * @returns the JSON object
  12757. */
  12758. serialize(): any;
  12759. /**
  12760. * Parse properties from a JSON object
  12761. * @param serializationObject defines the JSON object
  12762. */
  12763. parse(serializationObject: any): void;
  12764. }
  12765. }
  12766. declare module BABYLON {
  12767. /**
  12768. * Particle emitter emitting particles from the inside of a sphere.
  12769. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12770. */
  12771. export class SphereParticleEmitter implements IParticleEmitterType {
  12772. /**
  12773. * The radius of the emission sphere.
  12774. */
  12775. radius: number;
  12776. /**
  12777. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12778. */
  12779. radiusRange: number;
  12780. /**
  12781. * How much to randomize the particle direction [0-1].
  12782. */
  12783. directionRandomizer: number;
  12784. /**
  12785. * Creates a new instance SphereParticleEmitter
  12786. * @param radius the radius of the emission sphere (1 by default)
  12787. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12789. */
  12790. constructor(
  12791. /**
  12792. * The radius of the emission sphere.
  12793. */
  12794. radius?: number,
  12795. /**
  12796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12797. */
  12798. radiusRange?: number,
  12799. /**
  12800. * How much to randomize the particle direction [0-1].
  12801. */
  12802. directionRandomizer?: number);
  12803. /**
  12804. * Called by the particle System when the direction is computed for the created particle.
  12805. * @param worldMatrix is the world matrix of the particle system
  12806. * @param directionToUpdate is the direction vector to update with the result
  12807. * @param particle is the particle we are computed the direction for
  12808. * @param isLocal defines if the direction should be set in local space
  12809. */
  12810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12811. /**
  12812. * Called by the particle System when the position is computed for the created particle.
  12813. * @param worldMatrix is the world matrix of the particle system
  12814. * @param positionToUpdate is the position vector to update with the result
  12815. * @param particle is the particle we are computed the position for
  12816. * @param isLocal defines if the position should be set in local space
  12817. */
  12818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12819. /**
  12820. * Clones the current emitter and returns a copy of it
  12821. * @returns the new emitter
  12822. */
  12823. clone(): SphereParticleEmitter;
  12824. /**
  12825. * Called by the GPUParticleSystem to setup the update shader
  12826. * @param effect defines the update shader
  12827. */
  12828. applyToShader(effect: Effect): void;
  12829. /**
  12830. * Returns a string to use to update the GPU particles update shader
  12831. * @returns a string containng the defines string
  12832. */
  12833. getEffectDefines(): string;
  12834. /**
  12835. * Returns the string "SphereParticleEmitter"
  12836. * @returns a string containing the class name
  12837. */
  12838. getClassName(): string;
  12839. /**
  12840. * Serializes the particle system to a JSON object.
  12841. * @returns the JSON object
  12842. */
  12843. serialize(): any;
  12844. /**
  12845. * Parse properties from a JSON object
  12846. * @param serializationObject defines the JSON object
  12847. */
  12848. parse(serializationObject: any): void;
  12849. }
  12850. /**
  12851. * Particle emitter emitting particles from the inside of a sphere.
  12852. * It emits the particles randomly between two vectors.
  12853. */
  12854. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12855. /**
  12856. * The min limit of the emission direction.
  12857. */
  12858. direction1: Vector3;
  12859. /**
  12860. * The max limit of the emission direction.
  12861. */
  12862. direction2: Vector3;
  12863. /**
  12864. * Creates a new instance SphereDirectedParticleEmitter
  12865. * @param radius the radius of the emission sphere (1 by default)
  12866. * @param direction1 the min limit of the emission direction (up vector by default)
  12867. * @param direction2 the max limit of the emission direction (up vector by default)
  12868. */
  12869. constructor(radius?: number,
  12870. /**
  12871. * The min limit of the emission direction.
  12872. */
  12873. direction1?: Vector3,
  12874. /**
  12875. * The max limit of the emission direction.
  12876. */
  12877. direction2?: Vector3);
  12878. /**
  12879. * Called by the particle System when the direction is computed for the created particle.
  12880. * @param worldMatrix is the world matrix of the particle system
  12881. * @param directionToUpdate is the direction vector to update with the result
  12882. * @param particle is the particle we are computed the direction for
  12883. */
  12884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12885. /**
  12886. * Clones the current emitter and returns a copy of it
  12887. * @returns the new emitter
  12888. */
  12889. clone(): SphereDirectedParticleEmitter;
  12890. /**
  12891. * Called by the GPUParticleSystem to setup the update shader
  12892. * @param effect defines the update shader
  12893. */
  12894. applyToShader(effect: Effect): void;
  12895. /**
  12896. * Returns a string to use to update the GPU particles update shader
  12897. * @returns a string containng the defines string
  12898. */
  12899. getEffectDefines(): string;
  12900. /**
  12901. * Returns the string "SphereDirectedParticleEmitter"
  12902. * @returns a string containing the class name
  12903. */
  12904. getClassName(): string;
  12905. /**
  12906. * Serializes the particle system to a JSON object.
  12907. * @returns the JSON object
  12908. */
  12909. serialize(): any;
  12910. /**
  12911. * Parse properties from a JSON object
  12912. * @param serializationObject defines the JSON object
  12913. */
  12914. parse(serializationObject: any): void;
  12915. }
  12916. }
  12917. declare module BABYLON {
  12918. /**
  12919. * Particle emitter emitting particles from a custom list of positions.
  12920. */
  12921. export class CustomParticleEmitter implements IParticleEmitterType {
  12922. /**
  12923. * Gets or sets the position generator that will create the inital position of each particle.
  12924. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12925. */
  12926. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12927. /**
  12928. * Gets or sets the destination generator that will create the final destination of each particle.
  12929. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12930. */
  12931. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12932. /**
  12933. * Creates a new instance CustomParticleEmitter
  12934. */
  12935. constructor();
  12936. /**
  12937. * Called by the particle System when the direction is computed for the created particle.
  12938. * @param worldMatrix is the world matrix of the particle system
  12939. * @param directionToUpdate is the direction vector to update with the result
  12940. * @param particle is the particle we are computed the direction for
  12941. * @param isLocal defines if the direction should be set in local space
  12942. */
  12943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12944. /**
  12945. * Called by the particle System when the position is computed for the created particle.
  12946. * @param worldMatrix is the world matrix of the particle system
  12947. * @param positionToUpdate is the position vector to update with the result
  12948. * @param particle is the particle we are computed the position for
  12949. * @param isLocal defines if the position should be set in local space
  12950. */
  12951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12952. /**
  12953. * Clones the current emitter and returns a copy of it
  12954. * @returns the new emitter
  12955. */
  12956. clone(): CustomParticleEmitter;
  12957. /**
  12958. * Called by the GPUParticleSystem to setup the update shader
  12959. * @param effect defines the update shader
  12960. */
  12961. applyToShader(effect: Effect): void;
  12962. /**
  12963. * Returns a string to use to update the GPU particles update shader
  12964. * @returns a string containng the defines string
  12965. */
  12966. getEffectDefines(): string;
  12967. /**
  12968. * Returns the string "PointParticleEmitter"
  12969. * @returns a string containing the class name
  12970. */
  12971. getClassName(): string;
  12972. /**
  12973. * Serializes the particle system to a JSON object.
  12974. * @returns the JSON object
  12975. */
  12976. serialize(): any;
  12977. /**
  12978. * Parse properties from a JSON object
  12979. * @param serializationObject defines the JSON object
  12980. */
  12981. parse(serializationObject: any): void;
  12982. }
  12983. }
  12984. declare module BABYLON {
  12985. /**
  12986. * Particle emitter emitting particles from the inside of a box.
  12987. * It emits the particles randomly between 2 given directions.
  12988. */
  12989. export class MeshParticleEmitter implements IParticleEmitterType {
  12990. private _indices;
  12991. private _positions;
  12992. private _normals;
  12993. private _storedNormal;
  12994. private _mesh;
  12995. /**
  12996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12997. */
  12998. direction1: Vector3;
  12999. /**
  13000. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13001. */
  13002. direction2: Vector3;
  13003. /**
  13004. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13005. */
  13006. useMeshNormalsForDirection: boolean;
  13007. /** Defines the mesh to use as source */
  13008. get mesh(): Nullable<AbstractMesh>;
  13009. set mesh(value: Nullable<AbstractMesh>);
  13010. /**
  13011. * Creates a new instance MeshParticleEmitter
  13012. * @param mesh defines the mesh to use as source
  13013. */
  13014. constructor(mesh?: Nullable<AbstractMesh>);
  13015. /**
  13016. * Called by the particle System when the direction is computed for the created particle.
  13017. * @param worldMatrix is the world matrix of the particle system
  13018. * @param directionToUpdate is the direction vector to update with the result
  13019. * @param particle is the particle we are computed the direction for
  13020. * @param isLocal defines if the direction should be set in local space
  13021. */
  13022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13023. /**
  13024. * Called by the particle System when the position is computed for the created particle.
  13025. * @param worldMatrix is the world matrix of the particle system
  13026. * @param positionToUpdate is the position vector to update with the result
  13027. * @param particle is the particle we are computed the position for
  13028. * @param isLocal defines if the position should be set in local space
  13029. */
  13030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13031. /**
  13032. * Clones the current emitter and returns a copy of it
  13033. * @returns the new emitter
  13034. */
  13035. clone(): MeshParticleEmitter;
  13036. /**
  13037. * Called by the GPUParticleSystem to setup the update shader
  13038. * @param effect defines the update shader
  13039. */
  13040. applyToShader(effect: Effect): void;
  13041. /**
  13042. * Returns a string to use to update the GPU particles update shader
  13043. * @returns a string containng the defines string
  13044. */
  13045. getEffectDefines(): string;
  13046. /**
  13047. * Returns the string "BoxParticleEmitter"
  13048. * @returns a string containing the class name
  13049. */
  13050. getClassName(): string;
  13051. /**
  13052. * Serializes the particle system to a JSON object.
  13053. * @returns the JSON object
  13054. */
  13055. serialize(): any;
  13056. /**
  13057. * Parse properties from a JSON object
  13058. * @param serializationObject defines the JSON object
  13059. * @param scene defines the hosting scene
  13060. */
  13061. parse(serializationObject: any, scene: Scene): void;
  13062. }
  13063. }
  13064. declare module BABYLON {
  13065. /**
  13066. * Interface representing a particle system in Babylon.js.
  13067. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13068. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13069. */
  13070. export interface IParticleSystem {
  13071. /**
  13072. * List of animations used by the particle system.
  13073. */
  13074. animations: Animation[];
  13075. /**
  13076. * The id of the Particle system.
  13077. */
  13078. id: string;
  13079. /**
  13080. * The name of the Particle system.
  13081. */
  13082. name: string;
  13083. /**
  13084. * The emitter represents the Mesh or position we are attaching the particle system to.
  13085. */
  13086. emitter: Nullable<AbstractMesh | Vector3>;
  13087. /**
  13088. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13089. */
  13090. isBillboardBased: boolean;
  13091. /**
  13092. * The rendering group used by the Particle system to chose when to render.
  13093. */
  13094. renderingGroupId: number;
  13095. /**
  13096. * The layer mask we are rendering the particles through.
  13097. */
  13098. layerMask: number;
  13099. /**
  13100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13101. */
  13102. updateSpeed: number;
  13103. /**
  13104. * The amount of time the particle system is running (depends of the overall update speed).
  13105. */
  13106. targetStopDuration: number;
  13107. /**
  13108. * The texture used to render each particle. (this can be a spritesheet)
  13109. */
  13110. particleTexture: Nullable<Texture>;
  13111. /**
  13112. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13113. */
  13114. blendMode: number;
  13115. /**
  13116. * Minimum life time of emitting particles.
  13117. */
  13118. minLifeTime: number;
  13119. /**
  13120. * Maximum life time of emitting particles.
  13121. */
  13122. maxLifeTime: number;
  13123. /**
  13124. * Minimum Size of emitting particles.
  13125. */
  13126. minSize: number;
  13127. /**
  13128. * Maximum Size of emitting particles.
  13129. */
  13130. maxSize: number;
  13131. /**
  13132. * Minimum scale of emitting particles on X axis.
  13133. */
  13134. minScaleX: number;
  13135. /**
  13136. * Maximum scale of emitting particles on X axis.
  13137. */
  13138. maxScaleX: number;
  13139. /**
  13140. * Minimum scale of emitting particles on Y axis.
  13141. */
  13142. minScaleY: number;
  13143. /**
  13144. * Maximum scale of emitting particles on Y axis.
  13145. */
  13146. maxScaleY: number;
  13147. /**
  13148. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13149. */
  13150. color1: Color4;
  13151. /**
  13152. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13153. */
  13154. color2: Color4;
  13155. /**
  13156. * Color the particle will have at the end of its lifetime.
  13157. */
  13158. colorDead: Color4;
  13159. /**
  13160. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13161. */
  13162. emitRate: number;
  13163. /**
  13164. * You can use gravity if you want to give an orientation to your particles.
  13165. */
  13166. gravity: Vector3;
  13167. /**
  13168. * Minimum power of emitting particles.
  13169. */
  13170. minEmitPower: number;
  13171. /**
  13172. * Maximum power of emitting particles.
  13173. */
  13174. maxEmitPower: number;
  13175. /**
  13176. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13177. */
  13178. minAngularSpeed: number;
  13179. /**
  13180. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13181. */
  13182. maxAngularSpeed: number;
  13183. /**
  13184. * Gets or sets the minimal initial rotation in radians.
  13185. */
  13186. minInitialRotation: number;
  13187. /**
  13188. * Gets or sets the maximal initial rotation in radians.
  13189. */
  13190. maxInitialRotation: number;
  13191. /**
  13192. * The particle emitter type defines the emitter used by the particle system.
  13193. * It can be for example box, sphere, or cone...
  13194. */
  13195. particleEmitterType: Nullable<IParticleEmitterType>;
  13196. /**
  13197. * Defines the delay in milliseconds before starting the system (0 by default)
  13198. */
  13199. startDelay: number;
  13200. /**
  13201. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13202. */
  13203. preWarmCycles: number;
  13204. /**
  13205. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13206. */
  13207. preWarmStepOffset: number;
  13208. /**
  13209. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13210. */
  13211. spriteCellChangeSpeed: number;
  13212. /**
  13213. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13214. */
  13215. startSpriteCellID: number;
  13216. /**
  13217. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13218. */
  13219. endSpriteCellID: number;
  13220. /**
  13221. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13222. */
  13223. spriteCellWidth: number;
  13224. /**
  13225. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13226. */
  13227. spriteCellHeight: number;
  13228. /**
  13229. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13230. */
  13231. spriteRandomStartCell: boolean;
  13232. /**
  13233. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13234. */
  13235. isAnimationSheetEnabled: boolean;
  13236. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13237. translationPivot: Vector2;
  13238. /**
  13239. * Gets or sets a texture used to add random noise to particle positions
  13240. */
  13241. noiseTexture: Nullable<BaseTexture>;
  13242. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13243. noiseStrength: Vector3;
  13244. /**
  13245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13246. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13247. */
  13248. billboardMode: number;
  13249. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13250. limitVelocityDamping: number;
  13251. /**
  13252. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13253. */
  13254. beginAnimationOnStart: boolean;
  13255. /**
  13256. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13257. */
  13258. beginAnimationFrom: number;
  13259. /**
  13260. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13261. */
  13262. beginAnimationTo: number;
  13263. /**
  13264. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13265. */
  13266. beginAnimationLoop: boolean;
  13267. /**
  13268. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13269. */
  13270. disposeOnStop: boolean;
  13271. /**
  13272. * Specifies if the particles are updated in emitter local space or world space
  13273. */
  13274. isLocal: boolean;
  13275. /** Snippet ID if the particle system was created from the snippet server */
  13276. snippetId: string;
  13277. /**
  13278. * Gets the maximum number of particles active at the same time.
  13279. * @returns The max number of active particles.
  13280. */
  13281. getCapacity(): number;
  13282. /**
  13283. * Gets the number of particles active at the same time.
  13284. * @returns The number of active particles.
  13285. */
  13286. getActiveCount(): number;
  13287. /**
  13288. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13289. * @returns True if it has been started, otherwise false.
  13290. */
  13291. isStarted(): boolean;
  13292. /**
  13293. * Animates the particle system for this frame.
  13294. */
  13295. animate(): void;
  13296. /**
  13297. * Renders the particle system in its current state.
  13298. * @returns the current number of particles
  13299. */
  13300. render(): number;
  13301. /**
  13302. * Dispose the particle system and frees its associated resources.
  13303. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13304. */
  13305. dispose(disposeTexture?: boolean): void;
  13306. /**
  13307. * Clones the particle system.
  13308. * @param name The name of the cloned object
  13309. * @param newEmitter The new emitter to use
  13310. * @returns the cloned particle system
  13311. */
  13312. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13313. /**
  13314. * Serializes the particle system to a JSON object
  13315. * @param serializeTexture defines if the texture must be serialized as well
  13316. * @returns the JSON object
  13317. */
  13318. serialize(serializeTexture: boolean): any;
  13319. /**
  13320. * Rebuild the particle system
  13321. */
  13322. rebuild(): void;
  13323. /** Force the system to rebuild all gradients that need to be resync */
  13324. forceRefreshGradients(): void;
  13325. /**
  13326. * Starts the particle system and begins to emit
  13327. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13328. */
  13329. start(delay?: number): void;
  13330. /**
  13331. * Stops the particle system.
  13332. */
  13333. stop(): void;
  13334. /**
  13335. * Remove all active particles
  13336. */
  13337. reset(): void;
  13338. /**
  13339. * Gets a boolean indicating that the system is stopping
  13340. * @returns true if the system is currently stopping
  13341. */
  13342. isStopping(): boolean;
  13343. /**
  13344. * Is this system ready to be used/rendered
  13345. * @return true if the system is ready
  13346. */
  13347. isReady(): boolean;
  13348. /**
  13349. * Returns the string "ParticleSystem"
  13350. * @returns a string containing the class name
  13351. */
  13352. getClassName(): string;
  13353. /**
  13354. * Adds a new color gradient
  13355. * @param gradient defines the gradient to use (between 0 and 1)
  13356. * @param color1 defines the color to affect to the specified gradient
  13357. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13358. * @returns the current particle system
  13359. */
  13360. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13361. /**
  13362. * Remove a specific color gradient
  13363. * @param gradient defines the gradient to remove
  13364. * @returns the current particle system
  13365. */
  13366. removeColorGradient(gradient: number): IParticleSystem;
  13367. /**
  13368. * Adds a new size gradient
  13369. * @param gradient defines the gradient to use (between 0 and 1)
  13370. * @param factor defines the size factor to affect to the specified gradient
  13371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13372. * @returns the current particle system
  13373. */
  13374. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13375. /**
  13376. * Remove a specific size gradient
  13377. * @param gradient defines the gradient to remove
  13378. * @returns the current particle system
  13379. */
  13380. removeSizeGradient(gradient: number): IParticleSystem;
  13381. /**
  13382. * Gets the current list of color gradients.
  13383. * You must use addColorGradient and removeColorGradient to udpate this list
  13384. * @returns the list of color gradients
  13385. */
  13386. getColorGradients(): Nullable<Array<ColorGradient>>;
  13387. /**
  13388. * Gets the current list of size gradients.
  13389. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13390. * @returns the list of size gradients
  13391. */
  13392. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13393. /**
  13394. * Gets the current list of angular speed gradients.
  13395. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13396. * @returns the list of angular speed gradients
  13397. */
  13398. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13399. /**
  13400. * Adds a new angular speed gradient
  13401. * @param gradient defines the gradient to use (between 0 and 1)
  13402. * @param factor defines the angular speed to affect to the specified gradient
  13403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13404. * @returns the current particle system
  13405. */
  13406. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13407. /**
  13408. * Remove a specific angular speed gradient
  13409. * @param gradient defines the gradient to remove
  13410. * @returns the current particle system
  13411. */
  13412. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13413. /**
  13414. * Gets the current list of velocity gradients.
  13415. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13416. * @returns the list of velocity gradients
  13417. */
  13418. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13419. /**
  13420. * Adds a new velocity gradient
  13421. * @param gradient defines the gradient to use (between 0 and 1)
  13422. * @param factor defines the velocity to affect to the specified gradient
  13423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13424. * @returns the current particle system
  13425. */
  13426. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13427. /**
  13428. * Remove a specific velocity gradient
  13429. * @param gradient defines the gradient to remove
  13430. * @returns the current particle system
  13431. */
  13432. removeVelocityGradient(gradient: number): IParticleSystem;
  13433. /**
  13434. * Gets the current list of limit velocity gradients.
  13435. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13436. * @returns the list of limit velocity gradients
  13437. */
  13438. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13439. /**
  13440. * Adds a new limit velocity gradient
  13441. * @param gradient defines the gradient to use (between 0 and 1)
  13442. * @param factor defines the limit velocity to affect to the specified gradient
  13443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13444. * @returns the current particle system
  13445. */
  13446. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13447. /**
  13448. * Remove a specific limit velocity gradient
  13449. * @param gradient defines the gradient to remove
  13450. * @returns the current particle system
  13451. */
  13452. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13453. /**
  13454. * Adds a new drag gradient
  13455. * @param gradient defines the gradient to use (between 0 and 1)
  13456. * @param factor defines the drag to affect to the specified gradient
  13457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13458. * @returns the current particle system
  13459. */
  13460. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13461. /**
  13462. * Remove a specific drag gradient
  13463. * @param gradient defines the gradient to remove
  13464. * @returns the current particle system
  13465. */
  13466. removeDragGradient(gradient: number): IParticleSystem;
  13467. /**
  13468. * Gets the current list of drag gradients.
  13469. * You must use addDragGradient and removeDragGradient to udpate this list
  13470. * @returns the list of drag gradients
  13471. */
  13472. getDragGradients(): Nullable<Array<FactorGradient>>;
  13473. /**
  13474. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13475. * @param gradient defines the gradient to use (between 0 and 1)
  13476. * @param factor defines the emit rate to affect to the specified gradient
  13477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13478. * @returns the current particle system
  13479. */
  13480. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13481. /**
  13482. * Remove a specific emit rate gradient
  13483. * @param gradient defines the gradient to remove
  13484. * @returns the current particle system
  13485. */
  13486. removeEmitRateGradient(gradient: number): IParticleSystem;
  13487. /**
  13488. * Gets the current list of emit rate gradients.
  13489. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13490. * @returns the list of emit rate gradients
  13491. */
  13492. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13493. /**
  13494. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13495. * @param gradient defines the gradient to use (between 0 and 1)
  13496. * @param factor defines the start size to affect to the specified gradient
  13497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13498. * @returns the current particle system
  13499. */
  13500. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13501. /**
  13502. * Remove a specific start size gradient
  13503. * @param gradient defines the gradient to remove
  13504. * @returns the current particle system
  13505. */
  13506. removeStartSizeGradient(gradient: number): IParticleSystem;
  13507. /**
  13508. * Gets the current list of start size gradients.
  13509. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13510. * @returns the list of start size gradients
  13511. */
  13512. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13513. /**
  13514. * Adds a new life time gradient
  13515. * @param gradient defines the gradient to use (between 0 and 1)
  13516. * @param factor defines the life time factor to affect to the specified gradient
  13517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13518. * @returns the current particle system
  13519. */
  13520. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13521. /**
  13522. * Remove a specific life time gradient
  13523. * @param gradient defines the gradient to remove
  13524. * @returns the current particle system
  13525. */
  13526. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13527. /**
  13528. * Gets the current list of life time gradients.
  13529. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13530. * @returns the list of life time gradients
  13531. */
  13532. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13533. /**
  13534. * Gets the current list of color gradients.
  13535. * You must use addColorGradient and removeColorGradient to udpate this list
  13536. * @returns the list of color gradients
  13537. */
  13538. getColorGradients(): Nullable<Array<ColorGradient>>;
  13539. /**
  13540. * Adds a new ramp gradient used to remap particle colors
  13541. * @param gradient defines the gradient to use (between 0 and 1)
  13542. * @param color defines the color to affect to the specified gradient
  13543. * @returns the current particle system
  13544. */
  13545. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13546. /**
  13547. * Gets the current list of ramp gradients.
  13548. * You must use addRampGradient and removeRampGradient to udpate this list
  13549. * @returns the list of ramp gradients
  13550. */
  13551. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13552. /** Gets or sets a boolean indicating that ramp gradients must be used
  13553. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13554. */
  13555. useRampGradients: boolean;
  13556. /**
  13557. * Adds a new color remap gradient
  13558. * @param gradient defines the gradient to use (between 0 and 1)
  13559. * @param min defines the color remap minimal range
  13560. * @param max defines the color remap maximal range
  13561. * @returns the current particle system
  13562. */
  13563. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13564. /**
  13565. * Gets the current list of color remap gradients.
  13566. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13567. * @returns the list of color remap gradients
  13568. */
  13569. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13570. /**
  13571. * Adds a new alpha remap gradient
  13572. * @param gradient defines the gradient to use (between 0 and 1)
  13573. * @param min defines the alpha remap minimal range
  13574. * @param max defines the alpha remap maximal range
  13575. * @returns the current particle system
  13576. */
  13577. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13578. /**
  13579. * Gets the current list of alpha remap gradients.
  13580. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13581. * @returns the list of alpha remap gradients
  13582. */
  13583. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13584. /**
  13585. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13588. * @returns the emitter
  13589. */
  13590. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13591. /**
  13592. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13593. * @param radius The radius of the hemisphere to emit from
  13594. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13595. * @returns the emitter
  13596. */
  13597. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13598. /**
  13599. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13600. * @param radius The radius of the sphere to emit from
  13601. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13602. * @returns the emitter
  13603. */
  13604. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13605. /**
  13606. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13607. * @param radius The radius of the sphere to emit from
  13608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13610. * @returns the emitter
  13611. */
  13612. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13613. /**
  13614. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13615. * @param radius The radius of the emission cylinder
  13616. * @param height The height of the emission cylinder
  13617. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13618. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13619. * @returns the emitter
  13620. */
  13621. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13622. /**
  13623. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13624. * @param radius The radius of the cylinder to emit from
  13625. * @param height The height of the emission cylinder
  13626. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13629. * @returns the emitter
  13630. */
  13631. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13632. /**
  13633. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13634. * @param radius The radius of the cone to emit from
  13635. * @param angle The base angle of the cone
  13636. * @returns the emitter
  13637. */
  13638. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13639. /**
  13640. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13643. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13644. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13645. * @returns the emitter
  13646. */
  13647. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13648. /**
  13649. * Get hosting scene
  13650. * @returns the scene
  13651. */
  13652. getScene(): Scene;
  13653. }
  13654. }
  13655. declare module BABYLON {
  13656. /**
  13657. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13658. * @see https://doc.babylonjs.com/how_to/transformnode
  13659. */
  13660. export class TransformNode extends Node {
  13661. /**
  13662. * Object will not rotate to face the camera
  13663. */
  13664. static BILLBOARDMODE_NONE: number;
  13665. /**
  13666. * Object will rotate to face the camera but only on the x axis
  13667. */
  13668. static BILLBOARDMODE_X: number;
  13669. /**
  13670. * Object will rotate to face the camera but only on the y axis
  13671. */
  13672. static BILLBOARDMODE_Y: number;
  13673. /**
  13674. * Object will rotate to face the camera but only on the z axis
  13675. */
  13676. static BILLBOARDMODE_Z: number;
  13677. /**
  13678. * Object will rotate to face the camera
  13679. */
  13680. static BILLBOARDMODE_ALL: number;
  13681. /**
  13682. * Object will rotate to face the camera's position instead of orientation
  13683. */
  13684. static BILLBOARDMODE_USE_POSITION: number;
  13685. private _forward;
  13686. private _forwardInverted;
  13687. private _up;
  13688. private _right;
  13689. private _rightInverted;
  13690. private _position;
  13691. private _rotation;
  13692. private _rotationQuaternion;
  13693. protected _scaling: Vector3;
  13694. protected _isDirty: boolean;
  13695. private _transformToBoneReferal;
  13696. private _isAbsoluteSynced;
  13697. private _billboardMode;
  13698. /**
  13699. * Gets or sets the billboard mode. Default is 0.
  13700. *
  13701. * | Value | Type | Description |
  13702. * | --- | --- | --- |
  13703. * | 0 | BILLBOARDMODE_NONE | |
  13704. * | 1 | BILLBOARDMODE_X | |
  13705. * | 2 | BILLBOARDMODE_Y | |
  13706. * | 4 | BILLBOARDMODE_Z | |
  13707. * | 7 | BILLBOARDMODE_ALL | |
  13708. *
  13709. */
  13710. get billboardMode(): number;
  13711. set billboardMode(value: number);
  13712. private _preserveParentRotationForBillboard;
  13713. /**
  13714. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13715. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13716. */
  13717. get preserveParentRotationForBillboard(): boolean;
  13718. set preserveParentRotationForBillboard(value: boolean);
  13719. /**
  13720. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13721. */
  13722. scalingDeterminant: number;
  13723. private _infiniteDistance;
  13724. /**
  13725. * Gets or sets the distance of the object to max, often used by skybox
  13726. */
  13727. get infiniteDistance(): boolean;
  13728. set infiniteDistance(value: boolean);
  13729. /**
  13730. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13731. * By default the system will update normals to compensate
  13732. */
  13733. ignoreNonUniformScaling: boolean;
  13734. /**
  13735. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13736. */
  13737. reIntegrateRotationIntoRotationQuaternion: boolean;
  13738. /** @hidden */
  13739. _poseMatrix: Nullable<Matrix>;
  13740. /** @hidden */
  13741. _localMatrix: Matrix;
  13742. private _usePivotMatrix;
  13743. private _absolutePosition;
  13744. private _absoluteScaling;
  13745. private _absoluteRotationQuaternion;
  13746. private _pivotMatrix;
  13747. private _pivotMatrixInverse;
  13748. protected _postMultiplyPivotMatrix: boolean;
  13749. protected _isWorldMatrixFrozen: boolean;
  13750. /** @hidden */
  13751. _indexInSceneTransformNodesArray: number;
  13752. /**
  13753. * An event triggered after the world matrix is updated
  13754. */
  13755. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13756. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13757. /**
  13758. * Gets a string identifying the name of the class
  13759. * @returns "TransformNode" string
  13760. */
  13761. getClassName(): string;
  13762. /**
  13763. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13764. */
  13765. get position(): Vector3;
  13766. set position(newPosition: Vector3);
  13767. /**
  13768. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13769. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13770. */
  13771. get rotation(): Vector3;
  13772. set rotation(newRotation: Vector3);
  13773. /**
  13774. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13775. */
  13776. get scaling(): Vector3;
  13777. set scaling(newScaling: Vector3);
  13778. /**
  13779. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13780. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13781. */
  13782. get rotationQuaternion(): Nullable<Quaternion>;
  13783. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13784. /**
  13785. * The forward direction of that transform in world space.
  13786. */
  13787. get forward(): Vector3;
  13788. /**
  13789. * The up direction of that transform in world space.
  13790. */
  13791. get up(): Vector3;
  13792. /**
  13793. * The right direction of that transform in world space.
  13794. */
  13795. get right(): Vector3;
  13796. /**
  13797. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13798. * @param matrix the matrix to copy the pose from
  13799. * @returns this TransformNode.
  13800. */
  13801. updatePoseMatrix(matrix: Matrix): TransformNode;
  13802. /**
  13803. * Returns the mesh Pose matrix.
  13804. * @returns the pose matrix
  13805. */
  13806. getPoseMatrix(): Matrix;
  13807. /** @hidden */
  13808. _isSynchronized(): boolean;
  13809. /** @hidden */
  13810. _initCache(): void;
  13811. /**
  13812. * Flag the transform node as dirty (Forcing it to update everything)
  13813. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13814. * @returns this transform node
  13815. */
  13816. markAsDirty(property: string): TransformNode;
  13817. /**
  13818. * Returns the current mesh absolute position.
  13819. * Returns a Vector3.
  13820. */
  13821. get absolutePosition(): Vector3;
  13822. /**
  13823. * Returns the current mesh absolute scaling.
  13824. * Returns a Vector3.
  13825. */
  13826. get absoluteScaling(): Vector3;
  13827. /**
  13828. * Returns the current mesh absolute rotation.
  13829. * Returns a Quaternion.
  13830. */
  13831. get absoluteRotationQuaternion(): Quaternion;
  13832. /**
  13833. * Sets a new matrix to apply before all other transformation
  13834. * @param matrix defines the transform matrix
  13835. * @returns the current TransformNode
  13836. */
  13837. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13838. /**
  13839. * Sets a new pivot matrix to the current node
  13840. * @param matrix defines the new pivot matrix to use
  13841. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  13842. * @returns the current TransformNode
  13843. */
  13844. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13845. /**
  13846. * Returns the mesh pivot matrix.
  13847. * Default : Identity.
  13848. * @returns the matrix
  13849. */
  13850. getPivotMatrix(): Matrix;
  13851. /**
  13852. * Instantiate (when possible) or clone that node with its hierarchy
  13853. * @param newParent defines the new parent to use for the instance (or clone)
  13854. * @param options defines options to configure how copy is done
  13855. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13856. * @returns an instance (or a clone) of the current node with its hiearchy
  13857. */
  13858. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13859. doNotInstantiate: boolean;
  13860. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13861. /**
  13862. * Prevents the World matrix to be computed any longer
  13863. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13864. * @returns the TransformNode.
  13865. */
  13866. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13867. /**
  13868. * Allows back the World matrix computation.
  13869. * @returns the TransformNode.
  13870. */
  13871. unfreezeWorldMatrix(): this;
  13872. /**
  13873. * True if the World matrix has been frozen.
  13874. */
  13875. get isWorldMatrixFrozen(): boolean;
  13876. /**
  13877. * Retuns the mesh absolute position in the World.
  13878. * @returns a Vector3.
  13879. */
  13880. getAbsolutePosition(): Vector3;
  13881. /**
  13882. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13883. * @param absolutePosition the absolute position to set
  13884. * @returns the TransformNode.
  13885. */
  13886. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13887. /**
  13888. * Sets the mesh position in its local space.
  13889. * @param vector3 the position to set in localspace
  13890. * @returns the TransformNode.
  13891. */
  13892. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13893. /**
  13894. * Returns the mesh position in the local space from the current World matrix values.
  13895. * @returns a new Vector3.
  13896. */
  13897. getPositionExpressedInLocalSpace(): Vector3;
  13898. /**
  13899. * Translates the mesh along the passed Vector3 in its local space.
  13900. * @param vector3 the distance to translate in localspace
  13901. * @returns the TransformNode.
  13902. */
  13903. locallyTranslate(vector3: Vector3): TransformNode;
  13904. private static _lookAtVectorCache;
  13905. /**
  13906. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13907. * @param targetPoint the position (must be in same space as current mesh) to look at
  13908. * @param yawCor optional yaw (y-axis) correction in radians
  13909. * @param pitchCor optional pitch (x-axis) correction in radians
  13910. * @param rollCor optional roll (z-axis) correction in radians
  13911. * @param space the choosen space of the target
  13912. * @returns the TransformNode.
  13913. */
  13914. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13915. /**
  13916. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13917. * This Vector3 is expressed in the World space.
  13918. * @param localAxis axis to rotate
  13919. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13920. */
  13921. getDirection(localAxis: Vector3): Vector3;
  13922. /**
  13923. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13924. * localAxis is expressed in the mesh local space.
  13925. * result is computed in the Wordl space from the mesh World matrix.
  13926. * @param localAxis axis to rotate
  13927. * @param result the resulting transformnode
  13928. * @returns this TransformNode.
  13929. */
  13930. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13931. /**
  13932. * Sets this transform node rotation to the given local axis.
  13933. * @param localAxis the axis in local space
  13934. * @param yawCor optional yaw (y-axis) correction in radians
  13935. * @param pitchCor optional pitch (x-axis) correction in radians
  13936. * @param rollCor optional roll (z-axis) correction in radians
  13937. * @returns this TransformNode
  13938. */
  13939. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13940. /**
  13941. * Sets a new pivot point to the current node
  13942. * @param point defines the new pivot point to use
  13943. * @param space defines if the point is in world or local space (local by default)
  13944. * @returns the current TransformNode
  13945. */
  13946. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13947. /**
  13948. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13949. * @returns the pivot point
  13950. */
  13951. getPivotPoint(): Vector3;
  13952. /**
  13953. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13954. * @param result the vector3 to store the result
  13955. * @returns this TransformNode.
  13956. */
  13957. getPivotPointToRef(result: Vector3): TransformNode;
  13958. /**
  13959. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13960. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13961. */
  13962. getAbsolutePivotPoint(): Vector3;
  13963. /**
  13964. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13965. * @param result vector3 to store the result
  13966. * @returns this TransformNode.
  13967. */
  13968. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13969. /**
  13970. * Defines the passed node as the parent of the current node.
  13971. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13972. * @see https://doc.babylonjs.com/how_to/parenting
  13973. * @param node the node ot set as the parent
  13974. * @returns this TransformNode.
  13975. */
  13976. setParent(node: Nullable<Node>): TransformNode;
  13977. private _nonUniformScaling;
  13978. /**
  13979. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13980. */
  13981. get nonUniformScaling(): boolean;
  13982. /** @hidden */
  13983. _updateNonUniformScalingState(value: boolean): boolean;
  13984. /**
  13985. * Attach the current TransformNode to another TransformNode associated with a bone
  13986. * @param bone Bone affecting the TransformNode
  13987. * @param affectedTransformNode TransformNode associated with the bone
  13988. * @returns this object
  13989. */
  13990. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13991. /**
  13992. * Detach the transform node if its associated with a bone
  13993. * @returns this object
  13994. */
  13995. detachFromBone(): TransformNode;
  13996. private static _rotationAxisCache;
  13997. /**
  13998. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13999. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14000. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14001. * The passed axis is also normalized.
  14002. * @param axis the axis to rotate around
  14003. * @param amount the amount to rotate in radians
  14004. * @param space Space to rotate in (Default: local)
  14005. * @returns the TransformNode.
  14006. */
  14007. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14008. /**
  14009. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14010. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14011. * The passed axis is also normalized. .
  14012. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14013. * @param point the point to rotate around
  14014. * @param axis the axis to rotate around
  14015. * @param amount the amount to rotate in radians
  14016. * @returns the TransformNode
  14017. */
  14018. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14019. /**
  14020. * Translates the mesh along the axis vector for the passed distance in the given space.
  14021. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14022. * @param axis the axis to translate in
  14023. * @param distance the distance to translate
  14024. * @param space Space to rotate in (Default: local)
  14025. * @returns the TransformNode.
  14026. */
  14027. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14028. /**
  14029. * Adds a rotation step to the mesh current rotation.
  14030. * x, y, z are Euler angles expressed in radians.
  14031. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14032. * This means this rotation is made in the mesh local space only.
  14033. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14034. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14035. * ```javascript
  14036. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14037. * ```
  14038. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14039. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14040. * @param x Rotation to add
  14041. * @param y Rotation to add
  14042. * @param z Rotation to add
  14043. * @returns the TransformNode.
  14044. */
  14045. addRotation(x: number, y: number, z: number): TransformNode;
  14046. /**
  14047. * @hidden
  14048. */
  14049. protected _getEffectiveParent(): Nullable<Node>;
  14050. /**
  14051. * Computes the world matrix of the node
  14052. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14053. * @returns the world matrix
  14054. */
  14055. computeWorldMatrix(force?: boolean): Matrix;
  14056. /**
  14057. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14058. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14059. */
  14060. resetLocalMatrix(independentOfChildren?: boolean): void;
  14061. protected _afterComputeWorldMatrix(): void;
  14062. /**
  14063. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14064. * @param func callback function to add
  14065. *
  14066. * @returns the TransformNode.
  14067. */
  14068. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14069. /**
  14070. * Removes a registered callback function.
  14071. * @param func callback function to remove
  14072. * @returns the TransformNode.
  14073. */
  14074. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14075. /**
  14076. * Gets the position of the current mesh in camera space
  14077. * @param camera defines the camera to use
  14078. * @returns a position
  14079. */
  14080. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14081. /**
  14082. * Returns the distance from the mesh to the active camera
  14083. * @param camera defines the camera to use
  14084. * @returns the distance
  14085. */
  14086. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14087. /**
  14088. * Clone the current transform node
  14089. * @param name Name of the new clone
  14090. * @param newParent New parent for the clone
  14091. * @param doNotCloneChildren Do not clone children hierarchy
  14092. * @returns the new transform node
  14093. */
  14094. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14095. /**
  14096. * Serializes the objects information.
  14097. * @param currentSerializationObject defines the object to serialize in
  14098. * @returns the serialized object
  14099. */
  14100. serialize(currentSerializationObject?: any): any;
  14101. /**
  14102. * Returns a new TransformNode object parsed from the source provided.
  14103. * @param parsedTransformNode is the source.
  14104. * @param scene the scne the object belongs to
  14105. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14106. * @returns a new TransformNode object parsed from the source provided.
  14107. */
  14108. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14109. /**
  14110. * Get all child-transformNodes of this node
  14111. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14112. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14113. * @returns an array of TransformNode
  14114. */
  14115. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14116. /**
  14117. * Releases resources associated with this transform node.
  14118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14120. */
  14121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14122. /**
  14123. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14124. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14125. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14126. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14127. * @returns the current mesh
  14128. */
  14129. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14130. private _syncAbsoluteScalingAndRotation;
  14131. }
  14132. }
  14133. declare module BABYLON {
  14134. /**
  14135. * Class used to override all child animations of a given target
  14136. */
  14137. export class AnimationPropertiesOverride {
  14138. /**
  14139. * Gets or sets a value indicating if animation blending must be used
  14140. */
  14141. enableBlending: boolean;
  14142. /**
  14143. * Gets or sets the blending speed to use when enableBlending is true
  14144. */
  14145. blendingSpeed: number;
  14146. /**
  14147. * Gets or sets the default loop mode to use
  14148. */
  14149. loopMode: number;
  14150. }
  14151. }
  14152. declare module BABYLON {
  14153. /**
  14154. * Class used to store bone information
  14155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14156. */
  14157. export class Bone extends Node {
  14158. /**
  14159. * defines the bone name
  14160. */
  14161. name: string;
  14162. private static _tmpVecs;
  14163. private static _tmpQuat;
  14164. private static _tmpMats;
  14165. /**
  14166. * Gets the list of child bones
  14167. */
  14168. children: Bone[];
  14169. /** Gets the animations associated with this bone */
  14170. animations: Animation[];
  14171. /**
  14172. * Gets or sets bone length
  14173. */
  14174. length: number;
  14175. /**
  14176. * @hidden Internal only
  14177. * Set this value to map this bone to a different index in the transform matrices
  14178. * Set this value to -1 to exclude the bone from the transform matrices
  14179. */
  14180. _index: Nullable<number>;
  14181. private _skeleton;
  14182. private _localMatrix;
  14183. private _restPose;
  14184. private _baseMatrix;
  14185. private _absoluteTransform;
  14186. private _invertedAbsoluteTransform;
  14187. private _parent;
  14188. private _scalingDeterminant;
  14189. private _worldTransform;
  14190. private _localScaling;
  14191. private _localRotation;
  14192. private _localPosition;
  14193. private _needToDecompose;
  14194. private _needToCompose;
  14195. /** @hidden */
  14196. _linkedTransformNode: Nullable<TransformNode>;
  14197. /** @hidden */
  14198. _waitingTransformNodeId: Nullable<string>;
  14199. /** @hidden */
  14200. get _matrix(): Matrix;
  14201. /** @hidden */
  14202. set _matrix(value: Matrix);
  14203. /**
  14204. * Create a new bone
  14205. * @param name defines the bone name
  14206. * @param skeleton defines the parent skeleton
  14207. * @param parentBone defines the parent (can be null if the bone is the root)
  14208. * @param localMatrix defines the local matrix
  14209. * @param restPose defines the rest pose matrix
  14210. * @param baseMatrix defines the base matrix
  14211. * @param index defines index of the bone in the hiearchy
  14212. */
  14213. constructor(
  14214. /**
  14215. * defines the bone name
  14216. */
  14217. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14218. /**
  14219. * Gets the current object class name.
  14220. * @return the class name
  14221. */
  14222. getClassName(): string;
  14223. /**
  14224. * Gets the parent skeleton
  14225. * @returns a skeleton
  14226. */
  14227. getSkeleton(): Skeleton;
  14228. /**
  14229. * Gets parent bone
  14230. * @returns a bone or null if the bone is the root of the bone hierarchy
  14231. */
  14232. getParent(): Nullable<Bone>;
  14233. /**
  14234. * Returns an array containing the root bones
  14235. * @returns an array containing the root bones
  14236. */
  14237. getChildren(): Array<Bone>;
  14238. /**
  14239. * Gets the node index in matrix array generated for rendering
  14240. * @returns the node index
  14241. */
  14242. getIndex(): number;
  14243. /**
  14244. * Sets the parent bone
  14245. * @param parent defines the parent (can be null if the bone is the root)
  14246. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14247. */
  14248. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14249. /**
  14250. * Gets the local matrix
  14251. * @returns a matrix
  14252. */
  14253. getLocalMatrix(): Matrix;
  14254. /**
  14255. * Gets the base matrix (initial matrix which remains unchanged)
  14256. * @returns a matrix
  14257. */
  14258. getBaseMatrix(): Matrix;
  14259. /**
  14260. * Gets the rest pose matrix
  14261. * @returns a matrix
  14262. */
  14263. getRestPose(): Matrix;
  14264. /**
  14265. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14266. */
  14267. getWorldMatrix(): Matrix;
  14268. /**
  14269. * Sets the local matrix to rest pose matrix
  14270. */
  14271. returnToRest(): void;
  14272. /**
  14273. * Gets the inverse of the absolute transform matrix.
  14274. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14275. * @returns a matrix
  14276. */
  14277. getInvertedAbsoluteTransform(): Matrix;
  14278. /**
  14279. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14280. * @returns a matrix
  14281. */
  14282. getAbsoluteTransform(): Matrix;
  14283. /**
  14284. * Links with the given transform node.
  14285. * The local matrix of this bone is copied from the transform node every frame.
  14286. * @param transformNode defines the transform node to link to
  14287. */
  14288. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14289. /**
  14290. * Gets the node used to drive the bone's transformation
  14291. * @returns a transform node or null
  14292. */
  14293. getTransformNode(): Nullable<TransformNode>;
  14294. /** Gets or sets current position (in local space) */
  14295. get position(): Vector3;
  14296. set position(newPosition: Vector3);
  14297. /** Gets or sets current rotation (in local space) */
  14298. get rotation(): Vector3;
  14299. set rotation(newRotation: Vector3);
  14300. /** Gets or sets current rotation quaternion (in local space) */
  14301. get rotationQuaternion(): Quaternion;
  14302. set rotationQuaternion(newRotation: Quaternion);
  14303. /** Gets or sets current scaling (in local space) */
  14304. get scaling(): Vector3;
  14305. set scaling(newScaling: Vector3);
  14306. /**
  14307. * Gets the animation properties override
  14308. */
  14309. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14310. private _decompose;
  14311. private _compose;
  14312. /**
  14313. * Update the base and local matrices
  14314. * @param matrix defines the new base or local matrix
  14315. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14316. * @param updateLocalMatrix defines if the local matrix should be updated
  14317. */
  14318. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14319. /** @hidden */
  14320. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14321. /**
  14322. * Flag the bone as dirty (Forcing it to update everything)
  14323. */
  14324. markAsDirty(): void;
  14325. /** @hidden */
  14326. _markAsDirtyAndCompose(): void;
  14327. private _markAsDirtyAndDecompose;
  14328. /**
  14329. * Translate the bone in local or world space
  14330. * @param vec The amount to translate the bone
  14331. * @param space The space that the translation is in
  14332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14333. */
  14334. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14335. /**
  14336. * Set the postion of the bone in local or world space
  14337. * @param position The position to set the bone
  14338. * @param space The space that the position is in
  14339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14340. */
  14341. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14342. /**
  14343. * Set the absolute position of the bone (world space)
  14344. * @param position The position to set the bone
  14345. * @param mesh The mesh that this bone is attached to
  14346. */
  14347. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14348. /**
  14349. * Scale the bone on the x, y and z axes (in local space)
  14350. * @param x The amount to scale the bone on the x axis
  14351. * @param y The amount to scale the bone on the y axis
  14352. * @param z The amount to scale the bone on the z axis
  14353. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14354. */
  14355. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14356. /**
  14357. * Set the bone scaling in local space
  14358. * @param scale defines the scaling vector
  14359. */
  14360. setScale(scale: Vector3): void;
  14361. /**
  14362. * Gets the current scaling in local space
  14363. * @returns the current scaling vector
  14364. */
  14365. getScale(): Vector3;
  14366. /**
  14367. * Gets the current scaling in local space and stores it in a target vector
  14368. * @param result defines the target vector
  14369. */
  14370. getScaleToRef(result: Vector3): void;
  14371. /**
  14372. * Set the yaw, pitch, and roll of the bone in local or world space
  14373. * @param yaw The rotation of the bone on the y axis
  14374. * @param pitch The rotation of the bone on the x axis
  14375. * @param roll The rotation of the bone on the z axis
  14376. * @param space The space that the axes of rotation are in
  14377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14378. */
  14379. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14380. /**
  14381. * Add a rotation to the bone on an axis in local or world space
  14382. * @param axis The axis to rotate the bone on
  14383. * @param amount The amount to rotate the bone
  14384. * @param space The space that the axis is in
  14385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14386. */
  14387. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14388. /**
  14389. * Set the rotation of the bone to a particular axis angle in local or world space
  14390. * @param axis The axis to rotate the bone on
  14391. * @param angle The angle that the bone should be rotated to
  14392. * @param space The space that the axis is in
  14393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14394. */
  14395. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14396. /**
  14397. * Set the euler rotation of the bone in local of world space
  14398. * @param rotation The euler rotation that the bone should be set to
  14399. * @param space The space that the rotation is in
  14400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14401. */
  14402. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14403. /**
  14404. * Set the quaternion rotation of the bone in local of world space
  14405. * @param quat The quaternion rotation that the bone should be set to
  14406. * @param space The space that the rotation is in
  14407. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14408. */
  14409. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14410. /**
  14411. * Set the rotation matrix of the bone in local of world space
  14412. * @param rotMat The rotation matrix that the bone should be set to
  14413. * @param space The space that the rotation is in
  14414. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14415. */
  14416. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14417. private _rotateWithMatrix;
  14418. private _getNegativeRotationToRef;
  14419. /**
  14420. * Get the position of the bone in local or world space
  14421. * @param space The space that the returned position is in
  14422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14423. * @returns The position of the bone
  14424. */
  14425. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14426. /**
  14427. * Copy the position of the bone to a vector3 in local or world space
  14428. * @param space The space that the returned position is in
  14429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14430. * @param result The vector3 to copy the position to
  14431. */
  14432. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14433. /**
  14434. * Get the absolute position of the bone (world space)
  14435. * @param mesh The mesh that this bone is attached to
  14436. * @returns The absolute position of the bone
  14437. */
  14438. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14439. /**
  14440. * Copy the absolute position of the bone (world space) to the result param
  14441. * @param mesh The mesh that this bone is attached to
  14442. * @param result The vector3 to copy the absolute position to
  14443. */
  14444. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14445. /**
  14446. * Compute the absolute transforms of this bone and its children
  14447. */
  14448. computeAbsoluteTransforms(): void;
  14449. /**
  14450. * Get the world direction from an axis that is in the local space of the bone
  14451. * @param localAxis The local direction that is used to compute the world direction
  14452. * @param mesh The mesh that this bone is attached to
  14453. * @returns The world direction
  14454. */
  14455. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14456. /**
  14457. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14458. * @param localAxis The local direction that is used to compute the world direction
  14459. * @param mesh The mesh that this bone is attached to
  14460. * @param result The vector3 that the world direction will be copied to
  14461. */
  14462. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14463. /**
  14464. * Get the euler rotation of the bone in local or world space
  14465. * @param space The space that the rotation should be in
  14466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14467. * @returns The euler rotation
  14468. */
  14469. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14470. /**
  14471. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14472. * @param space The space that the rotation should be in
  14473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14474. * @param result The vector3 that the rotation should be copied to
  14475. */
  14476. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14477. /**
  14478. * Get the quaternion rotation of the bone in either local or world space
  14479. * @param space The space that the rotation should be in
  14480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14481. * @returns The quaternion rotation
  14482. */
  14483. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14484. /**
  14485. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14486. * @param space The space that the rotation should be in
  14487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14488. * @param result The quaternion that the rotation should be copied to
  14489. */
  14490. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14491. /**
  14492. * Get the rotation matrix of the bone in local or world space
  14493. * @param space The space that the rotation should be in
  14494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14495. * @returns The rotation matrix
  14496. */
  14497. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14498. /**
  14499. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14500. * @param space The space that the rotation should be in
  14501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14502. * @param result The quaternion that the rotation should be copied to
  14503. */
  14504. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14505. /**
  14506. * Get the world position of a point that is in the local space of the bone
  14507. * @param position The local position
  14508. * @param mesh The mesh that this bone is attached to
  14509. * @returns The world position
  14510. */
  14511. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14512. /**
  14513. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14514. * @param position The local position
  14515. * @param mesh The mesh that this bone is attached to
  14516. * @param result The vector3 that the world position should be copied to
  14517. */
  14518. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14519. /**
  14520. * Get the local position of a point that is in world space
  14521. * @param position The world position
  14522. * @param mesh The mesh that this bone is attached to
  14523. * @returns The local position
  14524. */
  14525. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14526. /**
  14527. * Get the local position of a point that is in world space and copy it to the result param
  14528. * @param position The world position
  14529. * @param mesh The mesh that this bone is attached to
  14530. * @param result The vector3 that the local position should be copied to
  14531. */
  14532. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14533. }
  14534. }
  14535. declare module BABYLON {
  14536. /**
  14537. * Defines a runtime animation
  14538. */
  14539. export class RuntimeAnimation {
  14540. private _events;
  14541. /**
  14542. * The current frame of the runtime animation
  14543. */
  14544. private _currentFrame;
  14545. /**
  14546. * The animation used by the runtime animation
  14547. */
  14548. private _animation;
  14549. /**
  14550. * The target of the runtime animation
  14551. */
  14552. private _target;
  14553. /**
  14554. * The initiating animatable
  14555. */
  14556. private _host;
  14557. /**
  14558. * The original value of the runtime animation
  14559. */
  14560. private _originalValue;
  14561. /**
  14562. * The original blend value of the runtime animation
  14563. */
  14564. private _originalBlendValue;
  14565. /**
  14566. * The offsets cache of the runtime animation
  14567. */
  14568. private _offsetsCache;
  14569. /**
  14570. * The high limits cache of the runtime animation
  14571. */
  14572. private _highLimitsCache;
  14573. /**
  14574. * Specifies if the runtime animation has been stopped
  14575. */
  14576. private _stopped;
  14577. /**
  14578. * The blending factor of the runtime animation
  14579. */
  14580. private _blendingFactor;
  14581. /**
  14582. * The BabylonJS scene
  14583. */
  14584. private _scene;
  14585. /**
  14586. * The current value of the runtime animation
  14587. */
  14588. private _currentValue;
  14589. /** @hidden */
  14590. _animationState: _IAnimationState;
  14591. /**
  14592. * The active target of the runtime animation
  14593. */
  14594. private _activeTargets;
  14595. private _currentActiveTarget;
  14596. private _directTarget;
  14597. /**
  14598. * The target path of the runtime animation
  14599. */
  14600. private _targetPath;
  14601. /**
  14602. * The weight of the runtime animation
  14603. */
  14604. private _weight;
  14605. /**
  14606. * The ratio offset of the runtime animation
  14607. */
  14608. private _ratioOffset;
  14609. /**
  14610. * The previous delay of the runtime animation
  14611. */
  14612. private _previousDelay;
  14613. /**
  14614. * The previous ratio of the runtime animation
  14615. */
  14616. private _previousRatio;
  14617. private _enableBlending;
  14618. private _keys;
  14619. private _minFrame;
  14620. private _maxFrame;
  14621. private _minValue;
  14622. private _maxValue;
  14623. private _targetIsArray;
  14624. /**
  14625. * Gets the current frame of the runtime animation
  14626. */
  14627. get currentFrame(): number;
  14628. /**
  14629. * Gets the weight of the runtime animation
  14630. */
  14631. get weight(): number;
  14632. /**
  14633. * Gets the current value of the runtime animation
  14634. */
  14635. get currentValue(): any;
  14636. /**
  14637. * Gets the target path of the runtime animation
  14638. */
  14639. get targetPath(): string;
  14640. /**
  14641. * Gets the actual target of the runtime animation
  14642. */
  14643. get target(): any;
  14644. /**
  14645. * Gets the additive state of the runtime animation
  14646. */
  14647. get isAdditive(): boolean;
  14648. /** @hidden */
  14649. _onLoop: () => void;
  14650. /**
  14651. * Create a new RuntimeAnimation object
  14652. * @param target defines the target of the animation
  14653. * @param animation defines the source animation object
  14654. * @param scene defines the hosting scene
  14655. * @param host defines the initiating Animatable
  14656. */
  14657. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14658. private _preparePath;
  14659. /**
  14660. * Gets the animation from the runtime animation
  14661. */
  14662. get animation(): Animation;
  14663. /**
  14664. * Resets the runtime animation to the beginning
  14665. * @param restoreOriginal defines whether to restore the target property to the original value
  14666. */
  14667. reset(restoreOriginal?: boolean): void;
  14668. /**
  14669. * Specifies if the runtime animation is stopped
  14670. * @returns Boolean specifying if the runtime animation is stopped
  14671. */
  14672. isStopped(): boolean;
  14673. /**
  14674. * Disposes of the runtime animation
  14675. */
  14676. dispose(): void;
  14677. /**
  14678. * Apply the interpolated value to the target
  14679. * @param currentValue defines the value computed by the animation
  14680. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14681. */
  14682. setValue(currentValue: any, weight: number): void;
  14683. private _getOriginalValues;
  14684. private _setValue;
  14685. /**
  14686. * Gets the loop pmode of the runtime animation
  14687. * @returns Loop Mode
  14688. */
  14689. private _getCorrectLoopMode;
  14690. /**
  14691. * Move the current animation to a given frame
  14692. * @param frame defines the frame to move to
  14693. */
  14694. goToFrame(frame: number): void;
  14695. /**
  14696. * @hidden Internal use only
  14697. */
  14698. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14699. /**
  14700. * Execute the current animation
  14701. * @param delay defines the delay to add to the current frame
  14702. * @param from defines the lower bound of the animation range
  14703. * @param to defines the upper bound of the animation range
  14704. * @param loop defines if the current animation must loop
  14705. * @param speedRatio defines the current speed ratio
  14706. * @param weight defines the weight of the animation (default is -1 so no weight)
  14707. * @param onLoop optional callback called when animation loops
  14708. * @returns a boolean indicating if the animation is running
  14709. */
  14710. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14711. }
  14712. }
  14713. declare module BABYLON {
  14714. /**
  14715. * Class used to store an actual running animation
  14716. */
  14717. export class Animatable {
  14718. /** defines the target object */
  14719. target: any;
  14720. /** defines the starting frame number (default is 0) */
  14721. fromFrame: number;
  14722. /** defines the ending frame number (default is 100) */
  14723. toFrame: number;
  14724. /** defines if the animation must loop (default is false) */
  14725. loopAnimation: boolean;
  14726. /** defines a callback to call when animation ends if it is not looping */
  14727. onAnimationEnd?: (() => void) | null | undefined;
  14728. /** defines a callback to call when animation loops */
  14729. onAnimationLoop?: (() => void) | null | undefined;
  14730. /** defines whether the animation should be evaluated additively */
  14731. isAdditive: boolean;
  14732. private _localDelayOffset;
  14733. private _pausedDelay;
  14734. private _runtimeAnimations;
  14735. private _paused;
  14736. private _scene;
  14737. private _speedRatio;
  14738. private _weight;
  14739. private _syncRoot;
  14740. /**
  14741. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14742. * This will only apply for non looping animation (default is true)
  14743. */
  14744. disposeOnEnd: boolean;
  14745. /**
  14746. * Gets a boolean indicating if the animation has started
  14747. */
  14748. animationStarted: boolean;
  14749. /**
  14750. * Observer raised when the animation ends
  14751. */
  14752. onAnimationEndObservable: Observable<Animatable>;
  14753. /**
  14754. * Observer raised when the animation loops
  14755. */
  14756. onAnimationLoopObservable: Observable<Animatable>;
  14757. /**
  14758. * Gets the root Animatable used to synchronize and normalize animations
  14759. */
  14760. get syncRoot(): Nullable<Animatable>;
  14761. /**
  14762. * Gets the current frame of the first RuntimeAnimation
  14763. * Used to synchronize Animatables
  14764. */
  14765. get masterFrame(): number;
  14766. /**
  14767. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14768. */
  14769. get weight(): number;
  14770. set weight(value: number);
  14771. /**
  14772. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14773. */
  14774. get speedRatio(): number;
  14775. set speedRatio(value: number);
  14776. /**
  14777. * Creates a new Animatable
  14778. * @param scene defines the hosting scene
  14779. * @param target defines the target object
  14780. * @param fromFrame defines the starting frame number (default is 0)
  14781. * @param toFrame defines the ending frame number (default is 100)
  14782. * @param loopAnimation defines if the animation must loop (default is false)
  14783. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14784. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14785. * @param animations defines a group of animation to add to the new Animatable
  14786. * @param onAnimationLoop defines a callback to call when animation loops
  14787. * @param isAdditive defines whether the animation should be evaluated additively
  14788. */
  14789. constructor(scene: Scene,
  14790. /** defines the target object */
  14791. target: any,
  14792. /** defines the starting frame number (default is 0) */
  14793. fromFrame?: number,
  14794. /** defines the ending frame number (default is 100) */
  14795. toFrame?: number,
  14796. /** defines if the animation must loop (default is false) */
  14797. loopAnimation?: boolean, speedRatio?: number,
  14798. /** defines a callback to call when animation ends if it is not looping */
  14799. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14800. /** defines a callback to call when animation loops */
  14801. onAnimationLoop?: (() => void) | null | undefined,
  14802. /** defines whether the animation should be evaluated additively */
  14803. isAdditive?: boolean);
  14804. /**
  14805. * Synchronize and normalize current Animatable with a source Animatable
  14806. * This is useful when using animation weights and when animations are not of the same length
  14807. * @param root defines the root Animatable to synchronize with
  14808. * @returns the current Animatable
  14809. */
  14810. syncWith(root: Animatable): Animatable;
  14811. /**
  14812. * Gets the list of runtime animations
  14813. * @returns an array of RuntimeAnimation
  14814. */
  14815. getAnimations(): RuntimeAnimation[];
  14816. /**
  14817. * Adds more animations to the current animatable
  14818. * @param target defines the target of the animations
  14819. * @param animations defines the new animations to add
  14820. */
  14821. appendAnimations(target: any, animations: Animation[]): void;
  14822. /**
  14823. * Gets the source animation for a specific property
  14824. * @param property defines the propertyu to look for
  14825. * @returns null or the source animation for the given property
  14826. */
  14827. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14828. /**
  14829. * Gets the runtime animation for a specific property
  14830. * @param property defines the propertyu to look for
  14831. * @returns null or the runtime animation for the given property
  14832. */
  14833. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14834. /**
  14835. * Resets the animatable to its original state
  14836. */
  14837. reset(): void;
  14838. /**
  14839. * Allows the animatable to blend with current running animations
  14840. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14841. * @param blendingSpeed defines the blending speed to use
  14842. */
  14843. enableBlending(blendingSpeed: number): void;
  14844. /**
  14845. * Disable animation blending
  14846. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14847. */
  14848. disableBlending(): void;
  14849. /**
  14850. * Jump directly to a given frame
  14851. * @param frame defines the frame to jump to
  14852. */
  14853. goToFrame(frame: number): void;
  14854. /**
  14855. * Pause the animation
  14856. */
  14857. pause(): void;
  14858. /**
  14859. * Restart the animation
  14860. */
  14861. restart(): void;
  14862. private _raiseOnAnimationEnd;
  14863. /**
  14864. * Stop and delete the current animation
  14865. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14866. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  14867. */
  14868. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14869. /**
  14870. * Wait asynchronously for the animation to end
  14871. * @returns a promise which will be fullfilled when the animation ends
  14872. */
  14873. waitAsync(): Promise<Animatable>;
  14874. /** @hidden */
  14875. _animate(delay: number): boolean;
  14876. }
  14877. interface Scene {
  14878. /** @hidden */
  14879. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14880. /** @hidden */
  14881. _processLateAnimationBindingsForMatrices(holder: {
  14882. totalWeight: number;
  14883. totalAdditiveWeight: number;
  14884. animations: RuntimeAnimation[];
  14885. additiveAnimations: RuntimeAnimation[];
  14886. originalValue: Matrix;
  14887. }): any;
  14888. /** @hidden */
  14889. _processLateAnimationBindingsForQuaternions(holder: {
  14890. totalWeight: number;
  14891. totalAdditiveWeight: number;
  14892. animations: RuntimeAnimation[];
  14893. additiveAnimations: RuntimeAnimation[];
  14894. originalValue: Quaternion;
  14895. }, refQuaternion: Quaternion): Quaternion;
  14896. /** @hidden */
  14897. _processLateAnimationBindings(): void;
  14898. /**
  14899. * Will start the animation sequence of a given target
  14900. * @param target defines the target
  14901. * @param from defines from which frame should animation start
  14902. * @param to defines until which frame should animation run.
  14903. * @param weight defines the weight to apply to the animation (1.0 by default)
  14904. * @param loop defines if the animation loops
  14905. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14906. * @param onAnimationEnd defines the function to be executed when the animation ends
  14907. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14908. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14909. * @param onAnimationLoop defines the callback to call when an animation loops
  14910. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14911. * @returns the animatable object created for this animation
  14912. */
  14913. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14914. /**
  14915. * Will start the animation sequence of a given target
  14916. * @param target defines the target
  14917. * @param from defines from which frame should animation start
  14918. * @param to defines until which frame should animation run.
  14919. * @param loop defines if the animation loops
  14920. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14921. * @param onAnimationEnd defines the function to be executed when the animation ends
  14922. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14923. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14924. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14925. * @param onAnimationLoop defines the callback to call when an animation loops
  14926. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14927. * @returns the animatable object created for this animation
  14928. */
  14929. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14930. /**
  14931. * Will start the animation sequence of a given target and its hierarchy
  14932. * @param target defines the target
  14933. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  14934. * @param from defines from which frame should animation start
  14935. * @param to defines until which frame should animation run.
  14936. * @param loop defines if the animation loops
  14937. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14938. * @param onAnimationEnd defines the function to be executed when the animation ends
  14939. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14940. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14941. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14942. * @param onAnimationLoop defines the callback to call when an animation loops
  14943. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14944. * @returns the list of created animatables
  14945. */
  14946. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14947. /**
  14948. * Begin a new animation on a given node
  14949. * @param target defines the target where the animation will take place
  14950. * @param animations defines the list of animations to start
  14951. * @param from defines the initial value
  14952. * @param to defines the final value
  14953. * @param loop defines if you want animation to loop (off by default)
  14954. * @param speedRatio defines the speed ratio to apply to all animations
  14955. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14956. * @param onAnimationLoop defines the callback to call when an animation loops
  14957. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14958. * @returns the list of created animatables
  14959. */
  14960. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14961. /**
  14962. * Begin a new animation on a given node and its hierarchy
  14963. * @param target defines the root node where the animation will take place
  14964. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  14965. * @param animations defines the list of animations to start
  14966. * @param from defines the initial value
  14967. * @param to defines the final value
  14968. * @param loop defines if you want animation to loop (off by default)
  14969. * @param speedRatio defines the speed ratio to apply to all animations
  14970. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14971. * @param onAnimationLoop defines the callback to call when an animation loops
  14972. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14973. * @returns the list of animatables created for all nodes
  14974. */
  14975. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14976. /**
  14977. * Gets the animatable associated with a specific target
  14978. * @param target defines the target of the animatable
  14979. * @returns the required animatable if found
  14980. */
  14981. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14982. /**
  14983. * Gets all animatables associated with a given target
  14984. * @param target defines the target to look animatables for
  14985. * @returns an array of Animatables
  14986. */
  14987. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14988. /**
  14989. * Stops and removes all animations that have been applied to the scene
  14990. */
  14991. stopAllAnimations(): void;
  14992. /**
  14993. * Gets the current delta time used by animation engine
  14994. */
  14995. deltaTime: number;
  14996. }
  14997. interface Bone {
  14998. /**
  14999. * Copy an animation range from another bone
  15000. * @param source defines the source bone
  15001. * @param rangeName defines the range name to copy
  15002. * @param frameOffset defines the frame offset
  15003. * @param rescaleAsRequired defines if rescaling must be applied if required
  15004. * @param skelDimensionsRatio defines the scaling ratio
  15005. * @returns true if operation was successful
  15006. */
  15007. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Class used to handle skinning animations
  15013. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15014. */
  15015. export class Skeleton implements IAnimatable {
  15016. /** defines the skeleton name */
  15017. name: string;
  15018. /** defines the skeleton Id */
  15019. id: string;
  15020. /**
  15021. * Defines the list of child bones
  15022. */
  15023. bones: Bone[];
  15024. /**
  15025. * Defines an estimate of the dimension of the skeleton at rest
  15026. */
  15027. dimensionsAtRest: Vector3;
  15028. /**
  15029. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15030. */
  15031. needInitialSkinMatrix: boolean;
  15032. /**
  15033. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15034. */
  15035. overrideMesh: Nullable<AbstractMesh>;
  15036. /**
  15037. * Gets the list of animations attached to this skeleton
  15038. */
  15039. animations: Array<Animation>;
  15040. private _scene;
  15041. private _isDirty;
  15042. private _transformMatrices;
  15043. private _transformMatrixTexture;
  15044. private _meshesWithPoseMatrix;
  15045. private _animatables;
  15046. private _identity;
  15047. private _synchronizedWithMesh;
  15048. private _ranges;
  15049. private _lastAbsoluteTransformsUpdateId;
  15050. private _canUseTextureForBones;
  15051. private _uniqueId;
  15052. /** @hidden */
  15053. _numBonesWithLinkedTransformNode: number;
  15054. /** @hidden */
  15055. _hasWaitingData: Nullable<boolean>;
  15056. /**
  15057. * Specifies if the skeleton should be serialized
  15058. */
  15059. doNotSerialize: boolean;
  15060. private _useTextureToStoreBoneMatrices;
  15061. /**
  15062. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15063. * Please note that this option is not available if the hardware does not support it
  15064. */
  15065. get useTextureToStoreBoneMatrices(): boolean;
  15066. set useTextureToStoreBoneMatrices(value: boolean);
  15067. private _animationPropertiesOverride;
  15068. /**
  15069. * Gets or sets the animation properties override
  15070. */
  15071. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15072. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15073. /**
  15074. * List of inspectable custom properties (used by the Inspector)
  15075. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15076. */
  15077. inspectableCustomProperties: IInspectable[];
  15078. /**
  15079. * An observable triggered before computing the skeleton's matrices
  15080. */
  15081. onBeforeComputeObservable: Observable<Skeleton>;
  15082. /**
  15083. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15084. */
  15085. get isUsingTextureForMatrices(): boolean;
  15086. /**
  15087. * Gets the unique ID of this skeleton
  15088. */
  15089. get uniqueId(): number;
  15090. /**
  15091. * Creates a new skeleton
  15092. * @param name defines the skeleton name
  15093. * @param id defines the skeleton Id
  15094. * @param scene defines the hosting scene
  15095. */
  15096. constructor(
  15097. /** defines the skeleton name */
  15098. name: string,
  15099. /** defines the skeleton Id */
  15100. id: string, scene: Scene);
  15101. /**
  15102. * Gets the current object class name.
  15103. * @return the class name
  15104. */
  15105. getClassName(): string;
  15106. /**
  15107. * Returns an array containing the root bones
  15108. * @returns an array containing the root bones
  15109. */
  15110. getChildren(): Array<Bone>;
  15111. /**
  15112. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15113. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15114. * @returns a Float32Array containing matrices data
  15115. */
  15116. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15117. /**
  15118. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15119. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15120. * @returns a raw texture containing the data
  15121. */
  15122. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15123. /**
  15124. * Gets the current hosting scene
  15125. * @returns a scene object
  15126. */
  15127. getScene(): Scene;
  15128. /**
  15129. * Gets a string representing the current skeleton data
  15130. * @param fullDetails defines a boolean indicating if we want a verbose version
  15131. * @returns a string representing the current skeleton data
  15132. */
  15133. toString(fullDetails?: boolean): string;
  15134. /**
  15135. * Get bone's index searching by name
  15136. * @param name defines bone's name to search for
  15137. * @return the indice of the bone. Returns -1 if not found
  15138. */
  15139. getBoneIndexByName(name: string): number;
  15140. /**
  15141. * Creater a new animation range
  15142. * @param name defines the name of the range
  15143. * @param from defines the start key
  15144. * @param to defines the end key
  15145. */
  15146. createAnimationRange(name: string, from: number, to: number): void;
  15147. /**
  15148. * Delete a specific animation range
  15149. * @param name defines the name of the range
  15150. * @param deleteFrames defines if frames must be removed as well
  15151. */
  15152. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15153. /**
  15154. * Gets a specific animation range
  15155. * @param name defines the name of the range to look for
  15156. * @returns the requested animation range or null if not found
  15157. */
  15158. getAnimationRange(name: string): Nullable<AnimationRange>;
  15159. /**
  15160. * Gets the list of all animation ranges defined on this skeleton
  15161. * @returns an array
  15162. */
  15163. getAnimationRanges(): Nullable<AnimationRange>[];
  15164. /**
  15165. * Copy animation range from a source skeleton.
  15166. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15167. * @param source defines the source skeleton
  15168. * @param name defines the name of the range to copy
  15169. * @param rescaleAsRequired defines if rescaling must be applied if required
  15170. * @returns true if operation was successful
  15171. */
  15172. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15173. /**
  15174. * Forces the skeleton to go to rest pose
  15175. */
  15176. returnToRest(): void;
  15177. private _getHighestAnimationFrame;
  15178. /**
  15179. * Begin a specific animation range
  15180. * @param name defines the name of the range to start
  15181. * @param loop defines if looping must be turned on (false by default)
  15182. * @param speedRatio defines the speed ratio to apply (1 by default)
  15183. * @param onAnimationEnd defines a callback which will be called when animation will end
  15184. * @returns a new animatable
  15185. */
  15186. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15187. /**
  15188. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15189. * @param skeleton defines the Skeleton containing the animation range to convert
  15190. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15191. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15192. * @returns the original skeleton
  15193. */
  15194. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15195. /** @hidden */
  15196. _markAsDirty(): void;
  15197. /** @hidden */
  15198. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15199. /** @hidden */
  15200. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15201. private _computeTransformMatrices;
  15202. /**
  15203. * Build all resources required to render a skeleton
  15204. */
  15205. prepare(): void;
  15206. /**
  15207. * Gets the list of animatables currently running for this skeleton
  15208. * @returns an array of animatables
  15209. */
  15210. getAnimatables(): IAnimatable[];
  15211. /**
  15212. * Clone the current skeleton
  15213. * @param name defines the name of the new skeleton
  15214. * @param id defines the id of the new skeleton
  15215. * @returns the new skeleton
  15216. */
  15217. clone(name: string, id?: string): Skeleton;
  15218. /**
  15219. * Enable animation blending for this skeleton
  15220. * @param blendingSpeed defines the blending speed to apply
  15221. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15222. */
  15223. enableBlending(blendingSpeed?: number): void;
  15224. /**
  15225. * Releases all resources associated with the current skeleton
  15226. */
  15227. dispose(): void;
  15228. /**
  15229. * Serialize the skeleton in a JSON object
  15230. * @returns a JSON object
  15231. */
  15232. serialize(): any;
  15233. /**
  15234. * Creates a new skeleton from serialized data
  15235. * @param parsedSkeleton defines the serialized data
  15236. * @param scene defines the hosting scene
  15237. * @returns a new skeleton
  15238. */
  15239. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15240. /**
  15241. * Compute all node absolute transforms
  15242. * @param forceUpdate defines if computation must be done even if cache is up to date
  15243. */
  15244. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15245. /**
  15246. * Gets the root pose matrix
  15247. * @returns a matrix
  15248. */
  15249. getPoseMatrix(): Nullable<Matrix>;
  15250. /**
  15251. * Sorts bones per internal index
  15252. */
  15253. sortBones(): void;
  15254. private _sortBones;
  15255. }
  15256. }
  15257. declare module BABYLON {
  15258. /**
  15259. * Creates an instance based on a source mesh.
  15260. */
  15261. export class InstancedMesh extends AbstractMesh {
  15262. private _sourceMesh;
  15263. private _currentLOD;
  15264. /** @hidden */
  15265. _indexInSourceMeshInstanceArray: number;
  15266. constructor(name: string, source: Mesh);
  15267. /**
  15268. * Returns the string "InstancedMesh".
  15269. */
  15270. getClassName(): string;
  15271. /** Gets the list of lights affecting that mesh */
  15272. get lightSources(): Light[];
  15273. _resyncLightSources(): void;
  15274. _resyncLightSource(light: Light): void;
  15275. _removeLightSource(light: Light, dispose: boolean): void;
  15276. /**
  15277. * If the source mesh receives shadows
  15278. */
  15279. get receiveShadows(): boolean;
  15280. /**
  15281. * The material of the source mesh
  15282. */
  15283. get material(): Nullable<Material>;
  15284. /**
  15285. * Visibility of the source mesh
  15286. */
  15287. get visibility(): number;
  15288. /**
  15289. * Skeleton of the source mesh
  15290. */
  15291. get skeleton(): Nullable<Skeleton>;
  15292. /**
  15293. * Rendering ground id of the source mesh
  15294. */
  15295. get renderingGroupId(): number;
  15296. set renderingGroupId(value: number);
  15297. /**
  15298. * Returns the total number of vertices (integer).
  15299. */
  15300. getTotalVertices(): number;
  15301. /**
  15302. * Returns a positive integer : the total number of indices in this mesh geometry.
  15303. * @returns the numner of indices or zero if the mesh has no geometry.
  15304. */
  15305. getTotalIndices(): number;
  15306. /**
  15307. * The source mesh of the instance
  15308. */
  15309. get sourceMesh(): Mesh;
  15310. /**
  15311. * Is this node ready to be used/rendered
  15312. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15313. * @return {boolean} is it ready
  15314. */
  15315. isReady(completeCheck?: boolean): boolean;
  15316. /**
  15317. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15318. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15319. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15320. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15321. */
  15322. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15323. /**
  15324. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15325. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15326. * The `data` are either a numeric array either a Float32Array.
  15327. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15328. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15329. * Note that a new underlying VertexBuffer object is created each call.
  15330. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15331. *
  15332. * Possible `kind` values :
  15333. * - VertexBuffer.PositionKind
  15334. * - VertexBuffer.UVKind
  15335. * - VertexBuffer.UV2Kind
  15336. * - VertexBuffer.UV3Kind
  15337. * - VertexBuffer.UV4Kind
  15338. * - VertexBuffer.UV5Kind
  15339. * - VertexBuffer.UV6Kind
  15340. * - VertexBuffer.ColorKind
  15341. * - VertexBuffer.MatricesIndicesKind
  15342. * - VertexBuffer.MatricesIndicesExtraKind
  15343. * - VertexBuffer.MatricesWeightsKind
  15344. * - VertexBuffer.MatricesWeightsExtraKind
  15345. *
  15346. * Returns the Mesh.
  15347. */
  15348. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15349. /**
  15350. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15351. * If the mesh has no geometry, it is simply returned as it is.
  15352. * The `data` are either a numeric array either a Float32Array.
  15353. * No new underlying VertexBuffer object is created.
  15354. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15355. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15356. *
  15357. * Possible `kind` values :
  15358. * - VertexBuffer.PositionKind
  15359. * - VertexBuffer.UVKind
  15360. * - VertexBuffer.UV2Kind
  15361. * - VertexBuffer.UV3Kind
  15362. * - VertexBuffer.UV4Kind
  15363. * - VertexBuffer.UV5Kind
  15364. * - VertexBuffer.UV6Kind
  15365. * - VertexBuffer.ColorKind
  15366. * - VertexBuffer.MatricesIndicesKind
  15367. * - VertexBuffer.MatricesIndicesExtraKind
  15368. * - VertexBuffer.MatricesWeightsKind
  15369. * - VertexBuffer.MatricesWeightsExtraKind
  15370. *
  15371. * Returns the Mesh.
  15372. */
  15373. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15374. /**
  15375. * Sets the mesh indices.
  15376. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15377. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15378. * This method creates a new index buffer each call.
  15379. * Returns the Mesh.
  15380. */
  15381. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15382. /**
  15383. * Boolean : True if the mesh owns the requested kind of data.
  15384. */
  15385. isVerticesDataPresent(kind: string): boolean;
  15386. /**
  15387. * Returns an array of indices (IndicesArray).
  15388. */
  15389. getIndices(): Nullable<IndicesArray>;
  15390. get _positions(): Nullable<Vector3[]>;
  15391. /**
  15392. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15393. * This means the mesh underlying bounding box and sphere are recomputed.
  15394. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15395. * @returns the current mesh
  15396. */
  15397. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15398. /** @hidden */
  15399. _preActivate(): InstancedMesh;
  15400. /** @hidden */
  15401. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15402. /** @hidden */
  15403. _postActivate(): void;
  15404. getWorldMatrix(): Matrix;
  15405. get isAnInstance(): boolean;
  15406. /**
  15407. * Returns the current associated LOD AbstractMesh.
  15408. */
  15409. getLOD(camera: Camera): AbstractMesh;
  15410. /** @hidden */
  15411. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15412. /** @hidden */
  15413. _syncSubMeshes(): InstancedMesh;
  15414. /** @hidden */
  15415. _generatePointsArray(): boolean;
  15416. /**
  15417. * Creates a new InstancedMesh from the current mesh.
  15418. * - name (string) : the cloned mesh name
  15419. * - newParent (optional Node) : the optional Node to parent the clone to.
  15420. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15421. *
  15422. * Returns the clone.
  15423. */
  15424. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15425. /**
  15426. * Disposes the InstancedMesh.
  15427. * Returns nothing.
  15428. */
  15429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15430. }
  15431. interface Mesh {
  15432. /**
  15433. * Register a custom buffer that will be instanced
  15434. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15435. * @param kind defines the buffer kind
  15436. * @param stride defines the stride in floats
  15437. */
  15438. registerInstancedBuffer(kind: string, stride: number): void;
  15439. /** @hidden */
  15440. _userInstancedBuffersStorage: {
  15441. data: {
  15442. [key: string]: Float32Array;
  15443. };
  15444. sizes: {
  15445. [key: string]: number;
  15446. };
  15447. vertexBuffers: {
  15448. [key: string]: Nullable<VertexBuffer>;
  15449. };
  15450. strides: {
  15451. [key: string]: number;
  15452. };
  15453. };
  15454. }
  15455. interface AbstractMesh {
  15456. /**
  15457. * Object used to store instanced buffers defined by user
  15458. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15459. */
  15460. instancedBuffers: {
  15461. [key: string]: any;
  15462. };
  15463. }
  15464. }
  15465. declare module BABYLON {
  15466. /**
  15467. * Defines the options associated with the creation of a shader material.
  15468. */
  15469. export interface IShaderMaterialOptions {
  15470. /**
  15471. * Does the material work in alpha blend mode
  15472. */
  15473. needAlphaBlending: boolean;
  15474. /**
  15475. * Does the material work in alpha test mode
  15476. */
  15477. needAlphaTesting: boolean;
  15478. /**
  15479. * The list of attribute names used in the shader
  15480. */
  15481. attributes: string[];
  15482. /**
  15483. * The list of unifrom names used in the shader
  15484. */
  15485. uniforms: string[];
  15486. /**
  15487. * The list of UBO names used in the shader
  15488. */
  15489. uniformBuffers: string[];
  15490. /**
  15491. * The list of sampler names used in the shader
  15492. */
  15493. samplers: string[];
  15494. /**
  15495. * The list of defines used in the shader
  15496. */
  15497. defines: string[];
  15498. }
  15499. /**
  15500. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15501. *
  15502. * This returned material effects how the mesh will look based on the code in the shaders.
  15503. *
  15504. * @see http://doc.babylonjs.com/how_to/shader_material
  15505. */
  15506. export class ShaderMaterial extends Material {
  15507. private _shaderPath;
  15508. private _options;
  15509. private _textures;
  15510. private _textureArrays;
  15511. private _floats;
  15512. private _ints;
  15513. private _floatsArrays;
  15514. private _colors3;
  15515. private _colors3Arrays;
  15516. private _colors4;
  15517. private _colors4Arrays;
  15518. private _vectors2;
  15519. private _vectors3;
  15520. private _vectors4;
  15521. private _matrices;
  15522. private _matrixArrays;
  15523. private _matrices3x3;
  15524. private _matrices2x2;
  15525. private _vectors2Arrays;
  15526. private _vectors3Arrays;
  15527. private _vectors4Arrays;
  15528. private _cachedWorldViewMatrix;
  15529. private _cachedWorldViewProjectionMatrix;
  15530. private _renderId;
  15531. private _multiview;
  15532. private _cachedDefines;
  15533. /**
  15534. * Instantiate a new shader material.
  15535. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15536. * This returned material effects how the mesh will look based on the code in the shaders.
  15537. * @see http://doc.babylonjs.com/how_to/shader_material
  15538. * @param name Define the name of the material in the scene
  15539. * @param scene Define the scene the material belongs to
  15540. * @param shaderPath Defines the route to the shader code in one of three ways:
  15541. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15542. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15543. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15544. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15545. * @param options Define the options used to create the shader
  15546. */
  15547. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15548. /**
  15549. * Gets the shader path used to define the shader code
  15550. * It can be modified to trigger a new compilation
  15551. */
  15552. get shaderPath(): any;
  15553. /**
  15554. * Sets the shader path used to define the shader code
  15555. * It can be modified to trigger a new compilation
  15556. */
  15557. set shaderPath(shaderPath: any);
  15558. /**
  15559. * Gets the options used to compile the shader.
  15560. * They can be modified to trigger a new compilation
  15561. */
  15562. get options(): IShaderMaterialOptions;
  15563. /**
  15564. * Gets the current class name of the material e.g. "ShaderMaterial"
  15565. * Mainly use in serialization.
  15566. * @returns the class name
  15567. */
  15568. getClassName(): string;
  15569. /**
  15570. * Specifies if the material will require alpha blending
  15571. * @returns a boolean specifying if alpha blending is needed
  15572. */
  15573. needAlphaBlending(): boolean;
  15574. /**
  15575. * Specifies if this material should be rendered in alpha test mode
  15576. * @returns a boolean specifying if an alpha test is needed.
  15577. */
  15578. needAlphaTesting(): boolean;
  15579. private _checkUniform;
  15580. /**
  15581. * Set a texture in the shader.
  15582. * @param name Define the name of the uniform samplers as defined in the shader
  15583. * @param texture Define the texture to bind to this sampler
  15584. * @return the material itself allowing "fluent" like uniform updates
  15585. */
  15586. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15587. /**
  15588. * Set a texture array in the shader.
  15589. * @param name Define the name of the uniform sampler array as defined in the shader
  15590. * @param textures Define the list of textures to bind to this sampler
  15591. * @return the material itself allowing "fluent" like uniform updates
  15592. */
  15593. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15594. /**
  15595. * Set a float in the shader.
  15596. * @param name Define the name of the uniform as defined in the shader
  15597. * @param value Define the value to give to the uniform
  15598. * @return the material itself allowing "fluent" like uniform updates
  15599. */
  15600. setFloat(name: string, value: number): ShaderMaterial;
  15601. /**
  15602. * Set a int in the shader.
  15603. * @param name Define the name of the uniform as defined in the shader
  15604. * @param value Define the value to give to the uniform
  15605. * @return the material itself allowing "fluent" like uniform updates
  15606. */
  15607. setInt(name: string, value: number): ShaderMaterial;
  15608. /**
  15609. * Set an array of floats in the shader.
  15610. * @param name Define the name of the uniform as defined in the shader
  15611. * @param value Define the value to give to the uniform
  15612. * @return the material itself allowing "fluent" like uniform updates
  15613. */
  15614. setFloats(name: string, value: number[]): ShaderMaterial;
  15615. /**
  15616. * Set a vec3 in the shader from a Color3.
  15617. * @param name Define the name of the uniform as defined in the shader
  15618. * @param value Define the value to give to the uniform
  15619. * @return the material itself allowing "fluent" like uniform updates
  15620. */
  15621. setColor3(name: string, value: Color3): ShaderMaterial;
  15622. /**
  15623. * Set a vec3 array in the shader from a Color3 array.
  15624. * @param name Define the name of the uniform as defined in the shader
  15625. * @param value Define the value to give to the uniform
  15626. * @return the material itself allowing "fluent" like uniform updates
  15627. */
  15628. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15629. /**
  15630. * Set a vec4 in the shader from a Color4.
  15631. * @param name Define the name of the uniform as defined in the shader
  15632. * @param value Define the value to give to the uniform
  15633. * @return the material itself allowing "fluent" like uniform updates
  15634. */
  15635. setColor4(name: string, value: Color4): ShaderMaterial;
  15636. /**
  15637. * Set a vec4 array in the shader from a Color4 array.
  15638. * @param name Define the name of the uniform as defined in the shader
  15639. * @param value Define the value to give to the uniform
  15640. * @return the material itself allowing "fluent" like uniform updates
  15641. */
  15642. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15643. /**
  15644. * Set a vec2 in the shader from a Vector2.
  15645. * @param name Define the name of the uniform as defined in the shader
  15646. * @param value Define the value to give to the uniform
  15647. * @return the material itself allowing "fluent" like uniform updates
  15648. */
  15649. setVector2(name: string, value: Vector2): ShaderMaterial;
  15650. /**
  15651. * Set a vec3 in the shader from a Vector3.
  15652. * @param name Define the name of the uniform as defined in the shader
  15653. * @param value Define the value to give to the uniform
  15654. * @return the material itself allowing "fluent" like uniform updates
  15655. */
  15656. setVector3(name: string, value: Vector3): ShaderMaterial;
  15657. /**
  15658. * Set a vec4 in the shader from a Vector4.
  15659. * @param name Define the name of the uniform as defined in the shader
  15660. * @param value Define the value to give to the uniform
  15661. * @return the material itself allowing "fluent" like uniform updates
  15662. */
  15663. setVector4(name: string, value: Vector4): ShaderMaterial;
  15664. /**
  15665. * Set a mat4 in the shader from a Matrix.
  15666. * @param name Define the name of the uniform as defined in the shader
  15667. * @param value Define the value to give to the uniform
  15668. * @return the material itself allowing "fluent" like uniform updates
  15669. */
  15670. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15671. /**
  15672. * Set a float32Array in the shader from a matrix array.
  15673. * @param name Define the name of the uniform as defined in the shader
  15674. * @param value Define the value to give to the uniform
  15675. * @return the material itself allowing "fluent" like uniform updates
  15676. */
  15677. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15678. /**
  15679. * Set a mat3 in the shader from a Float32Array.
  15680. * @param name Define the name of the uniform as defined in the shader
  15681. * @param value Define the value to give to the uniform
  15682. * @return the material itself allowing "fluent" like uniform updates
  15683. */
  15684. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15685. /**
  15686. * Set a mat2 in the shader from a Float32Array.
  15687. * @param name Define the name of the uniform as defined in the shader
  15688. * @param value Define the value to give to the uniform
  15689. * @return the material itself allowing "fluent" like uniform updates
  15690. */
  15691. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15692. /**
  15693. * Set a vec2 array in the shader from a number array.
  15694. * @param name Define the name of the uniform as defined in the shader
  15695. * @param value Define the value to give to the uniform
  15696. * @return the material itself allowing "fluent" like uniform updates
  15697. */
  15698. setArray2(name: string, value: number[]): ShaderMaterial;
  15699. /**
  15700. * Set a vec3 array in the shader from a number array.
  15701. * @param name Define the name of the uniform as defined in the shader
  15702. * @param value Define the value to give to the uniform
  15703. * @return the material itself allowing "fluent" like uniform updates
  15704. */
  15705. setArray3(name: string, value: number[]): ShaderMaterial;
  15706. /**
  15707. * Set a vec4 array in the shader from a number array.
  15708. * @param name Define the name of the uniform as defined in the shader
  15709. * @param value Define the value to give to the uniform
  15710. * @return the material itself allowing "fluent" like uniform updates
  15711. */
  15712. setArray4(name: string, value: number[]): ShaderMaterial;
  15713. private _checkCache;
  15714. /**
  15715. * Specifies that the submesh is ready to be used
  15716. * @param mesh defines the mesh to check
  15717. * @param subMesh defines which submesh to check
  15718. * @param useInstances specifies that instances should be used
  15719. * @returns a boolean indicating that the submesh is ready or not
  15720. */
  15721. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15722. /**
  15723. * Checks if the material is ready to render the requested mesh
  15724. * @param mesh Define the mesh to render
  15725. * @param useInstances Define whether or not the material is used with instances
  15726. * @returns true if ready, otherwise false
  15727. */
  15728. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15729. /**
  15730. * Binds the world matrix to the material
  15731. * @param world defines the world transformation matrix
  15732. * @param effectOverride - If provided, use this effect instead of internal effect
  15733. */
  15734. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15735. /**
  15736. * Binds the submesh to this material by preparing the effect and shader to draw
  15737. * @param world defines the world transformation matrix
  15738. * @param mesh defines the mesh containing the submesh
  15739. * @param subMesh defines the submesh to bind the material to
  15740. */
  15741. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15742. /**
  15743. * Binds the material to the mesh
  15744. * @param world defines the world transformation matrix
  15745. * @param mesh defines the mesh to bind the material to
  15746. * @param effectOverride - If provided, use this effect instead of internal effect
  15747. */
  15748. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15749. protected _afterBind(mesh?: Mesh): void;
  15750. /**
  15751. * Gets the active textures from the material
  15752. * @returns an array of textures
  15753. */
  15754. getActiveTextures(): BaseTexture[];
  15755. /**
  15756. * Specifies if the material uses a texture
  15757. * @param texture defines the texture to check against the material
  15758. * @returns a boolean specifying if the material uses the texture
  15759. */
  15760. hasTexture(texture: BaseTexture): boolean;
  15761. /**
  15762. * Makes a duplicate of the material, and gives it a new name
  15763. * @param name defines the new name for the duplicated material
  15764. * @returns the cloned material
  15765. */
  15766. clone(name: string): ShaderMaterial;
  15767. /**
  15768. * Disposes the material
  15769. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15770. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15771. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15772. */
  15773. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15774. /**
  15775. * Serializes this material in a JSON representation
  15776. * @returns the serialized material object
  15777. */
  15778. serialize(): any;
  15779. /**
  15780. * Creates a shader material from parsed shader material data
  15781. * @param source defines the JSON represnetation of the material
  15782. * @param scene defines the hosting scene
  15783. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15784. * @returns a new material
  15785. */
  15786. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15787. }
  15788. }
  15789. declare module BABYLON {
  15790. /** @hidden */
  15791. export var colorPixelShader: {
  15792. name: string;
  15793. shader: string;
  15794. };
  15795. }
  15796. declare module BABYLON {
  15797. /** @hidden */
  15798. export var colorVertexShader: {
  15799. name: string;
  15800. shader: string;
  15801. };
  15802. }
  15803. declare module BABYLON {
  15804. /**
  15805. * Line mesh
  15806. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15807. */
  15808. export class LinesMesh extends Mesh {
  15809. /**
  15810. * If vertex color should be applied to the mesh
  15811. */
  15812. readonly useVertexColor?: boolean | undefined;
  15813. /**
  15814. * If vertex alpha should be applied to the mesh
  15815. */
  15816. readonly useVertexAlpha?: boolean | undefined;
  15817. /**
  15818. * Color of the line (Default: White)
  15819. */
  15820. color: Color3;
  15821. /**
  15822. * Alpha of the line (Default: 1)
  15823. */
  15824. alpha: number;
  15825. /**
  15826. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15827. * This margin is expressed in world space coordinates, so its value may vary.
  15828. * Default value is 0.1
  15829. */
  15830. intersectionThreshold: number;
  15831. private _colorShader;
  15832. private color4;
  15833. /**
  15834. * Creates a new LinesMesh
  15835. * @param name defines the name
  15836. * @param scene defines the hosting scene
  15837. * @param parent defines the parent mesh if any
  15838. * @param source defines the optional source LinesMesh used to clone data from
  15839. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15840. * When false, achieved by calling a clone(), also passing False.
  15841. * This will make creation of children, recursive.
  15842. * @param useVertexColor defines if this LinesMesh supports vertex color
  15843. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15844. */
  15845. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15846. /**
  15847. * If vertex color should be applied to the mesh
  15848. */
  15849. useVertexColor?: boolean | undefined,
  15850. /**
  15851. * If vertex alpha should be applied to the mesh
  15852. */
  15853. useVertexAlpha?: boolean | undefined);
  15854. private _addClipPlaneDefine;
  15855. private _removeClipPlaneDefine;
  15856. isReady(): boolean;
  15857. /**
  15858. * Returns the string "LineMesh"
  15859. */
  15860. getClassName(): string;
  15861. /**
  15862. * @hidden
  15863. */
  15864. get material(): Material;
  15865. /**
  15866. * @hidden
  15867. */
  15868. set material(value: Material);
  15869. /**
  15870. * @hidden
  15871. */
  15872. get checkCollisions(): boolean;
  15873. /** @hidden */
  15874. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15875. /** @hidden */
  15876. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15877. /**
  15878. * Disposes of the line mesh
  15879. * @param doNotRecurse If children should be disposed
  15880. */
  15881. dispose(doNotRecurse?: boolean): void;
  15882. /**
  15883. * Returns a new LineMesh object cloned from the current one.
  15884. */
  15885. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15886. /**
  15887. * Creates a new InstancedLinesMesh object from the mesh model.
  15888. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15889. * @param name defines the name of the new instance
  15890. * @returns a new InstancedLinesMesh
  15891. */
  15892. createInstance(name: string): InstancedLinesMesh;
  15893. }
  15894. /**
  15895. * Creates an instance based on a source LinesMesh
  15896. */
  15897. export class InstancedLinesMesh extends InstancedMesh {
  15898. /**
  15899. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15900. * This margin is expressed in world space coordinates, so its value may vary.
  15901. * Initilized with the intersectionThreshold value of the source LinesMesh
  15902. */
  15903. intersectionThreshold: number;
  15904. constructor(name: string, source: LinesMesh);
  15905. /**
  15906. * Returns the string "InstancedLinesMesh".
  15907. */
  15908. getClassName(): string;
  15909. }
  15910. }
  15911. declare module BABYLON {
  15912. /** @hidden */
  15913. export var linePixelShader: {
  15914. name: string;
  15915. shader: string;
  15916. };
  15917. }
  15918. declare module BABYLON {
  15919. /** @hidden */
  15920. export var lineVertexShader: {
  15921. name: string;
  15922. shader: string;
  15923. };
  15924. }
  15925. declare module BABYLON {
  15926. interface AbstractMesh {
  15927. /**
  15928. * Gets the edgesRenderer associated with the mesh
  15929. */
  15930. edgesRenderer: Nullable<EdgesRenderer>;
  15931. }
  15932. interface LinesMesh {
  15933. /**
  15934. * Enables the edge rendering mode on the mesh.
  15935. * This mode makes the mesh edges visible
  15936. * @param epsilon defines the maximal distance between two angles to detect a face
  15937. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15938. * @returns the currentAbstractMesh
  15939. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15940. */
  15941. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15942. }
  15943. interface InstancedLinesMesh {
  15944. /**
  15945. * Enables the edge rendering mode on the mesh.
  15946. * This mode makes the mesh edges visible
  15947. * @param epsilon defines the maximal distance between two angles to detect a face
  15948. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15949. * @returns the current InstancedLinesMesh
  15950. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15951. */
  15952. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15953. }
  15954. /**
  15955. * Defines the minimum contract an Edges renderer should follow.
  15956. */
  15957. export interface IEdgesRenderer extends IDisposable {
  15958. /**
  15959. * Gets or sets a boolean indicating if the edgesRenderer is active
  15960. */
  15961. isEnabled: boolean;
  15962. /**
  15963. * Renders the edges of the attached mesh,
  15964. */
  15965. render(): void;
  15966. /**
  15967. * Checks wether or not the edges renderer is ready to render.
  15968. * @return true if ready, otherwise false.
  15969. */
  15970. isReady(): boolean;
  15971. }
  15972. /**
  15973. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15974. */
  15975. export class EdgesRenderer implements IEdgesRenderer {
  15976. /**
  15977. * Define the size of the edges with an orthographic camera
  15978. */
  15979. edgesWidthScalerForOrthographic: number;
  15980. /**
  15981. * Define the size of the edges with a perspective camera
  15982. */
  15983. edgesWidthScalerForPerspective: number;
  15984. protected _source: AbstractMesh;
  15985. protected _linesPositions: number[];
  15986. protected _linesNormals: number[];
  15987. protected _linesIndices: number[];
  15988. protected _epsilon: number;
  15989. protected _indicesCount: number;
  15990. protected _lineShader: ShaderMaterial;
  15991. protected _ib: DataBuffer;
  15992. protected _buffers: {
  15993. [key: string]: Nullable<VertexBuffer>;
  15994. };
  15995. protected _checkVerticesInsteadOfIndices: boolean;
  15996. private _meshRebuildObserver;
  15997. private _meshDisposeObserver;
  15998. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15999. isEnabled: boolean;
  16000. /**
  16001. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16002. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16003. * @param source Mesh used to create edges
  16004. * @param epsilon sum of angles in adjacency to check for edge
  16005. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16006. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16007. */
  16008. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16009. protected _prepareRessources(): void;
  16010. /** @hidden */
  16011. _rebuild(): void;
  16012. /**
  16013. * Releases the required resources for the edges renderer
  16014. */
  16015. dispose(): void;
  16016. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16017. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16018. /**
  16019. * Checks if the pair of p0 and p1 is en edge
  16020. * @param faceIndex
  16021. * @param edge
  16022. * @param faceNormals
  16023. * @param p0
  16024. * @param p1
  16025. * @private
  16026. */
  16027. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16028. /**
  16029. * push line into the position, normal and index buffer
  16030. * @protected
  16031. */
  16032. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16033. /**
  16034. * Generates lines edges from adjacencjes
  16035. * @private
  16036. */
  16037. _generateEdgesLines(): void;
  16038. /**
  16039. * Checks wether or not the edges renderer is ready to render.
  16040. * @return true if ready, otherwise false.
  16041. */
  16042. isReady(): boolean;
  16043. /**
  16044. * Renders the edges of the attached mesh,
  16045. */
  16046. render(): void;
  16047. }
  16048. /**
  16049. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16050. */
  16051. export class LineEdgesRenderer extends EdgesRenderer {
  16052. /**
  16053. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16054. * @param source LineMesh used to generate edges
  16055. * @param epsilon not important (specified angle for edge detection)
  16056. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16057. */
  16058. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16059. /**
  16060. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16061. */
  16062. _generateEdgesLines(): void;
  16063. }
  16064. }
  16065. declare module BABYLON {
  16066. /**
  16067. * This represents the object necessary to create a rendering group.
  16068. * This is exclusively used and created by the rendering manager.
  16069. * To modify the behavior, you use the available helpers in your scene or meshes.
  16070. * @hidden
  16071. */
  16072. export class RenderingGroup {
  16073. index: number;
  16074. private static _zeroVector;
  16075. private _scene;
  16076. private _opaqueSubMeshes;
  16077. private _transparentSubMeshes;
  16078. private _alphaTestSubMeshes;
  16079. private _depthOnlySubMeshes;
  16080. private _particleSystems;
  16081. private _spriteManagers;
  16082. private _opaqueSortCompareFn;
  16083. private _alphaTestSortCompareFn;
  16084. private _transparentSortCompareFn;
  16085. private _renderOpaque;
  16086. private _renderAlphaTest;
  16087. private _renderTransparent;
  16088. /** @hidden */
  16089. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16090. onBeforeTransparentRendering: () => void;
  16091. /**
  16092. * Set the opaque sort comparison function.
  16093. * If null the sub meshes will be render in the order they were created
  16094. */
  16095. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16096. /**
  16097. * Set the alpha test sort comparison function.
  16098. * If null the sub meshes will be render in the order they were created
  16099. */
  16100. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16101. /**
  16102. * Set the transparent sort comparison function.
  16103. * If null the sub meshes will be render in the order they were created
  16104. */
  16105. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16106. /**
  16107. * Creates a new rendering group.
  16108. * @param index The rendering group index
  16109. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16110. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16111. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16112. */
  16113. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16114. /**
  16115. * Render all the sub meshes contained in the group.
  16116. * @param customRenderFunction Used to override the default render behaviour of the group.
  16117. * @returns true if rendered some submeshes.
  16118. */
  16119. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16120. /**
  16121. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16122. * @param subMeshes The submeshes to render
  16123. */
  16124. private renderOpaqueSorted;
  16125. /**
  16126. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16127. * @param subMeshes The submeshes to render
  16128. */
  16129. private renderAlphaTestSorted;
  16130. /**
  16131. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16132. * @param subMeshes The submeshes to render
  16133. */
  16134. private renderTransparentSorted;
  16135. /**
  16136. * Renders the submeshes in a specified order.
  16137. * @param subMeshes The submeshes to sort before render
  16138. * @param sortCompareFn The comparison function use to sort
  16139. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16140. * @param transparent Specifies to activate blending if true
  16141. */
  16142. private static renderSorted;
  16143. /**
  16144. * Renders the submeshes in the order they were dispatched (no sort applied).
  16145. * @param subMeshes The submeshes to render
  16146. */
  16147. private static renderUnsorted;
  16148. /**
  16149. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16150. * are rendered back to front if in the same alpha index.
  16151. *
  16152. * @param a The first submesh
  16153. * @param b The second submesh
  16154. * @returns The result of the comparison
  16155. */
  16156. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16157. /**
  16158. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16159. * are rendered back to front.
  16160. *
  16161. * @param a The first submesh
  16162. * @param b The second submesh
  16163. * @returns The result of the comparison
  16164. */
  16165. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16166. /**
  16167. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16168. * are rendered front to back (prevent overdraw).
  16169. *
  16170. * @param a The first submesh
  16171. * @param b The second submesh
  16172. * @returns The result of the comparison
  16173. */
  16174. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16175. /**
  16176. * Resets the different lists of submeshes to prepare a new frame.
  16177. */
  16178. prepare(): void;
  16179. dispose(): void;
  16180. /**
  16181. * Inserts the submesh in its correct queue depending on its material.
  16182. * @param subMesh The submesh to dispatch
  16183. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16184. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16185. */
  16186. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16187. dispatchSprites(spriteManager: ISpriteManager): void;
  16188. dispatchParticles(particleSystem: IParticleSystem): void;
  16189. private _renderParticles;
  16190. private _renderSprites;
  16191. }
  16192. }
  16193. declare module BABYLON {
  16194. /**
  16195. * Interface describing the different options available in the rendering manager
  16196. * regarding Auto Clear between groups.
  16197. */
  16198. export interface IRenderingManagerAutoClearSetup {
  16199. /**
  16200. * Defines whether or not autoclear is enable.
  16201. */
  16202. autoClear: boolean;
  16203. /**
  16204. * Defines whether or not to autoclear the depth buffer.
  16205. */
  16206. depth: boolean;
  16207. /**
  16208. * Defines whether or not to autoclear the stencil buffer.
  16209. */
  16210. stencil: boolean;
  16211. }
  16212. /**
  16213. * This class is used by the onRenderingGroupObservable
  16214. */
  16215. export class RenderingGroupInfo {
  16216. /**
  16217. * The Scene that being rendered
  16218. */
  16219. scene: Scene;
  16220. /**
  16221. * The camera currently used for the rendering pass
  16222. */
  16223. camera: Nullable<Camera>;
  16224. /**
  16225. * The ID of the renderingGroup being processed
  16226. */
  16227. renderingGroupId: number;
  16228. }
  16229. /**
  16230. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16231. * It is enable to manage the different groups as well as the different necessary sort functions.
  16232. * This should not be used directly aside of the few static configurations
  16233. */
  16234. export class RenderingManager {
  16235. /**
  16236. * The max id used for rendering groups (not included)
  16237. */
  16238. static MAX_RENDERINGGROUPS: number;
  16239. /**
  16240. * The min id used for rendering groups (included)
  16241. */
  16242. static MIN_RENDERINGGROUPS: number;
  16243. /**
  16244. * Used to globally prevent autoclearing scenes.
  16245. */
  16246. static AUTOCLEAR: boolean;
  16247. /**
  16248. * @hidden
  16249. */
  16250. _useSceneAutoClearSetup: boolean;
  16251. private _scene;
  16252. private _renderingGroups;
  16253. private _depthStencilBufferAlreadyCleaned;
  16254. private _autoClearDepthStencil;
  16255. private _customOpaqueSortCompareFn;
  16256. private _customAlphaTestSortCompareFn;
  16257. private _customTransparentSortCompareFn;
  16258. private _renderingGroupInfo;
  16259. /**
  16260. * Instantiates a new rendering group for a particular scene
  16261. * @param scene Defines the scene the groups belongs to
  16262. */
  16263. constructor(scene: Scene);
  16264. private _clearDepthStencilBuffer;
  16265. /**
  16266. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16267. * @hidden
  16268. */
  16269. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16270. /**
  16271. * Resets the different information of the group to prepare a new frame
  16272. * @hidden
  16273. */
  16274. reset(): void;
  16275. /**
  16276. * Dispose and release the group and its associated resources.
  16277. * @hidden
  16278. */
  16279. dispose(): void;
  16280. /**
  16281. * Clear the info related to rendering groups preventing retention points during dispose.
  16282. */
  16283. freeRenderingGroups(): void;
  16284. private _prepareRenderingGroup;
  16285. /**
  16286. * Add a sprite manager to the rendering manager in order to render it this frame.
  16287. * @param spriteManager Define the sprite manager to render
  16288. */
  16289. dispatchSprites(spriteManager: ISpriteManager): void;
  16290. /**
  16291. * Add a particle system to the rendering manager in order to render it this frame.
  16292. * @param particleSystem Define the particle system to render
  16293. */
  16294. dispatchParticles(particleSystem: IParticleSystem): void;
  16295. /**
  16296. * Add a submesh to the manager in order to render it this frame
  16297. * @param subMesh The submesh to dispatch
  16298. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16299. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16300. */
  16301. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16302. /**
  16303. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16304. * This allowed control for front to back rendering or reversly depending of the special needs.
  16305. *
  16306. * @param renderingGroupId The rendering group id corresponding to its index
  16307. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16308. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16309. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16310. */
  16311. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  16312. /**
  16313. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16314. *
  16315. * @param renderingGroupId The rendering group id corresponding to its index
  16316. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16317. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16318. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16319. */
  16320. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16321. /**
  16322. * Gets the current auto clear configuration for one rendering group of the rendering
  16323. * manager.
  16324. * @param index the rendering group index to get the information for
  16325. * @returns The auto clear setup for the requested rendering group
  16326. */
  16327. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16333. */
  16334. export interface ICustomShaderOptions {
  16335. /**
  16336. * Gets or sets the custom shader name to use
  16337. */
  16338. shaderName: string;
  16339. /**
  16340. * The list of attribute names used in the shader
  16341. */
  16342. attributes?: string[];
  16343. /**
  16344. * The list of unifrom names used in the shader
  16345. */
  16346. uniforms?: string[];
  16347. /**
  16348. * The list of sampler names used in the shader
  16349. */
  16350. samplers?: string[];
  16351. /**
  16352. * The list of defines used in the shader
  16353. */
  16354. defines?: string[];
  16355. }
  16356. /**
  16357. * Interface to implement to create a shadow generator compatible with BJS.
  16358. */
  16359. export interface IShadowGenerator {
  16360. /**
  16361. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16362. * @returns The render target texture if present otherwise, null
  16363. */
  16364. getShadowMap(): Nullable<RenderTargetTexture>;
  16365. /**
  16366. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16367. * @param subMesh The submesh we want to render in the shadow map
  16368. * @param useInstances Defines wether will draw in the map using instances
  16369. * @returns true if ready otherwise, false
  16370. */
  16371. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16372. /**
  16373. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16374. * @param defines Defines of the material we want to update
  16375. * @param lightIndex Index of the light in the enabled light list of the material
  16376. */
  16377. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16378. /**
  16379. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16380. * defined in the generator but impacting the effect).
  16381. * It implies the unifroms available on the materials are the standard BJS ones.
  16382. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16383. * @param effect The effect we are binfing the information for
  16384. */
  16385. bindShadowLight(lightIndex: string, effect: Effect): void;
  16386. /**
  16387. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16388. * (eq to shadow prjection matrix * light transform matrix)
  16389. * @returns The transform matrix used to create the shadow map
  16390. */
  16391. getTransformMatrix(): Matrix;
  16392. /**
  16393. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16394. * Cube and 2D textures for instance.
  16395. */
  16396. recreateShadowMap(): void;
  16397. /**
  16398. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16399. * @param onCompiled Callback triggered at the and of the effects compilation
  16400. * @param options Sets of optional options forcing the compilation with different modes
  16401. */
  16402. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16403. useInstances: boolean;
  16404. }>): void;
  16405. /**
  16406. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16407. * @param options Sets of optional options forcing the compilation with different modes
  16408. * @returns A promise that resolves when the compilation completes
  16409. */
  16410. forceCompilationAsync(options?: Partial<{
  16411. useInstances: boolean;
  16412. }>): Promise<void>;
  16413. /**
  16414. * Serializes the shadow generator setup to a json object.
  16415. * @returns The serialized JSON object
  16416. */
  16417. serialize(): any;
  16418. /**
  16419. * Disposes the Shadow map and related Textures and effects.
  16420. */
  16421. dispose(): void;
  16422. }
  16423. /**
  16424. * Default implementation IShadowGenerator.
  16425. * This is the main object responsible of generating shadows in the framework.
  16426. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16427. */
  16428. export class ShadowGenerator implements IShadowGenerator {
  16429. /**
  16430. * Name of the shadow generator class
  16431. */
  16432. static CLASSNAME: string;
  16433. /**
  16434. * Shadow generator mode None: no filtering applied.
  16435. */
  16436. static readonly FILTER_NONE: number;
  16437. /**
  16438. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16439. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16440. */
  16441. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16442. /**
  16443. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16444. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16445. */
  16446. static readonly FILTER_POISSONSAMPLING: number;
  16447. /**
  16448. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16449. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16450. */
  16451. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16452. /**
  16453. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16454. * edge artifacts on steep falloff.
  16455. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16456. */
  16457. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16458. /**
  16459. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16460. * edge artifacts on steep falloff.
  16461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16462. */
  16463. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16464. /**
  16465. * Shadow generator mode PCF: Percentage Closer Filtering
  16466. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16467. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16468. */
  16469. static readonly FILTER_PCF: number;
  16470. /**
  16471. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16472. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16473. * Contact Hardening
  16474. */
  16475. static readonly FILTER_PCSS: number;
  16476. /**
  16477. * Reserved for PCF and PCSS
  16478. * Highest Quality.
  16479. *
  16480. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16481. *
  16482. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16483. */
  16484. static readonly QUALITY_HIGH: number;
  16485. /**
  16486. * Reserved for PCF and PCSS
  16487. * Good tradeoff for quality/perf cross devices
  16488. *
  16489. * Execute PCF on a 3*3 kernel.
  16490. *
  16491. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16492. */
  16493. static readonly QUALITY_MEDIUM: number;
  16494. /**
  16495. * Reserved for PCF and PCSS
  16496. * The lowest quality but the fastest.
  16497. *
  16498. * Execute PCF on a 1*1 kernel.
  16499. *
  16500. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16501. */
  16502. static readonly QUALITY_LOW: number;
  16503. /** Gets or sets the custom shader name to use */
  16504. customShaderOptions: ICustomShaderOptions;
  16505. /**
  16506. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16507. */
  16508. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16509. /**
  16510. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16511. */
  16512. onAfterShadowMapRenderObservable: Observable<Effect>;
  16513. /**
  16514. * Observable triggered before a mesh is rendered in the shadow map.
  16515. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16516. */
  16517. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16518. /**
  16519. * Observable triggered after a mesh is rendered in the shadow map.
  16520. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16521. */
  16522. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16523. protected _bias: number;
  16524. /**
  16525. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16526. */
  16527. get bias(): number;
  16528. /**
  16529. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16530. */
  16531. set bias(bias: number);
  16532. protected _normalBias: number;
  16533. /**
  16534. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16535. */
  16536. get normalBias(): number;
  16537. /**
  16538. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16539. */
  16540. set normalBias(normalBias: number);
  16541. protected _blurBoxOffset: number;
  16542. /**
  16543. * Gets the blur box offset: offset applied during the blur pass.
  16544. * Only useful if useKernelBlur = false
  16545. */
  16546. get blurBoxOffset(): number;
  16547. /**
  16548. * Sets the blur box offset: offset applied during the blur pass.
  16549. * Only useful if useKernelBlur = false
  16550. */
  16551. set blurBoxOffset(value: number);
  16552. protected _blurScale: number;
  16553. /**
  16554. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16555. * 2 means half of the size.
  16556. */
  16557. get blurScale(): number;
  16558. /**
  16559. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16560. * 2 means half of the size.
  16561. */
  16562. set blurScale(value: number);
  16563. protected _blurKernel: number;
  16564. /**
  16565. * Gets the blur kernel: kernel size of the blur pass.
  16566. * Only useful if useKernelBlur = true
  16567. */
  16568. get blurKernel(): number;
  16569. /**
  16570. * Sets the blur kernel: kernel size of the blur pass.
  16571. * Only useful if useKernelBlur = true
  16572. */
  16573. set blurKernel(value: number);
  16574. protected _useKernelBlur: boolean;
  16575. /**
  16576. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16577. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16578. */
  16579. get useKernelBlur(): boolean;
  16580. /**
  16581. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16582. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16583. */
  16584. set useKernelBlur(value: boolean);
  16585. protected _depthScale: number;
  16586. /**
  16587. * Gets the depth scale used in ESM mode.
  16588. */
  16589. get depthScale(): number;
  16590. /**
  16591. * Sets the depth scale used in ESM mode.
  16592. * This can override the scale stored on the light.
  16593. */
  16594. set depthScale(value: number);
  16595. protected _validateFilter(filter: number): number;
  16596. protected _filter: number;
  16597. /**
  16598. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16599. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16600. */
  16601. get filter(): number;
  16602. /**
  16603. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16604. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16605. */
  16606. set filter(value: number);
  16607. /**
  16608. * Gets if the current filter is set to Poisson Sampling.
  16609. */
  16610. get usePoissonSampling(): boolean;
  16611. /**
  16612. * Sets the current filter to Poisson Sampling.
  16613. */
  16614. set usePoissonSampling(value: boolean);
  16615. /**
  16616. * Gets if the current filter is set to ESM.
  16617. */
  16618. get useExponentialShadowMap(): boolean;
  16619. /**
  16620. * Sets the current filter is to ESM.
  16621. */
  16622. set useExponentialShadowMap(value: boolean);
  16623. /**
  16624. * Gets if the current filter is set to filtered ESM.
  16625. */
  16626. get useBlurExponentialShadowMap(): boolean;
  16627. /**
  16628. * Gets if the current filter is set to filtered ESM.
  16629. */
  16630. set useBlurExponentialShadowMap(value: boolean);
  16631. /**
  16632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16633. * exponential to prevent steep falloff artifacts).
  16634. */
  16635. get useCloseExponentialShadowMap(): boolean;
  16636. /**
  16637. * Sets the current filter to "close ESM" (using the inverse of the
  16638. * exponential to prevent steep falloff artifacts).
  16639. */
  16640. set useCloseExponentialShadowMap(value: boolean);
  16641. /**
  16642. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16643. * exponential to prevent steep falloff artifacts).
  16644. */
  16645. get useBlurCloseExponentialShadowMap(): boolean;
  16646. /**
  16647. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16648. * exponential to prevent steep falloff artifacts).
  16649. */
  16650. set useBlurCloseExponentialShadowMap(value: boolean);
  16651. /**
  16652. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16653. */
  16654. get usePercentageCloserFiltering(): boolean;
  16655. /**
  16656. * Sets the current filter to "PCF" (percentage closer filtering).
  16657. */
  16658. set usePercentageCloserFiltering(value: boolean);
  16659. protected _filteringQuality: number;
  16660. /**
  16661. * Gets the PCF or PCSS Quality.
  16662. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16663. */
  16664. get filteringQuality(): number;
  16665. /**
  16666. * Sets the PCF or PCSS Quality.
  16667. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16668. */
  16669. set filteringQuality(filteringQuality: number);
  16670. /**
  16671. * Gets if the current filter is set to "PCSS" (contact hardening).
  16672. */
  16673. get useContactHardeningShadow(): boolean;
  16674. /**
  16675. * Sets the current filter to "PCSS" (contact hardening).
  16676. */
  16677. set useContactHardeningShadow(value: boolean);
  16678. protected _contactHardeningLightSizeUVRatio: number;
  16679. /**
  16680. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16681. * Using a ratio helps keeping shape stability independently of the map size.
  16682. *
  16683. * It does not account for the light projection as it was having too much
  16684. * instability during the light setup or during light position changes.
  16685. *
  16686. * Only valid if useContactHardeningShadow is true.
  16687. */
  16688. get contactHardeningLightSizeUVRatio(): number;
  16689. /**
  16690. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16691. * Using a ratio helps keeping shape stability independently of the map size.
  16692. *
  16693. * It does not account for the light projection as it was having too much
  16694. * instability during the light setup or during light position changes.
  16695. *
  16696. * Only valid if useContactHardeningShadow is true.
  16697. */
  16698. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16699. protected _darkness: number;
  16700. /** Gets or sets the actual darkness of a shadow */
  16701. get darkness(): number;
  16702. set darkness(value: number);
  16703. /**
  16704. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16705. * 0 means strongest and 1 would means no shadow.
  16706. * @returns the darkness.
  16707. */
  16708. getDarkness(): number;
  16709. /**
  16710. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16711. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16712. * @returns the shadow generator allowing fluent coding.
  16713. */
  16714. setDarkness(darkness: number): ShadowGenerator;
  16715. protected _transparencyShadow: boolean;
  16716. /** Gets or sets the ability to have transparent shadow */
  16717. get transparencyShadow(): boolean;
  16718. set transparencyShadow(value: boolean);
  16719. /**
  16720. * Sets the ability to have transparent shadow (boolean).
  16721. * @param transparent True if transparent else False
  16722. * @returns the shadow generator allowing fluent coding
  16723. */
  16724. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16725. protected _shadowMap: Nullable<RenderTargetTexture>;
  16726. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16727. /**
  16728. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16729. * @returns The render target texture if present otherwise, null
  16730. */
  16731. getShadowMap(): Nullable<RenderTargetTexture>;
  16732. /**
  16733. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16734. * @returns The render target texture if the shadow map is present otherwise, null
  16735. */
  16736. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16737. /**
  16738. * Gets the class name of that object
  16739. * @returns "ShadowGenerator"
  16740. */
  16741. getClassName(): string;
  16742. /**
  16743. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16744. * @param mesh Mesh to add
  16745. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16746. * @returns the Shadow Generator itself
  16747. */
  16748. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16749. /**
  16750. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16751. * @param mesh Mesh to remove
  16752. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16753. * @returns the Shadow Generator itself
  16754. */
  16755. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16756. /**
  16757. * Controls the extent to which the shadows fade out at the edge of the frustum
  16758. */
  16759. frustumEdgeFalloff: number;
  16760. protected _light: IShadowLight;
  16761. /**
  16762. * Returns the associated light object.
  16763. * @returns the light generating the shadow
  16764. */
  16765. getLight(): IShadowLight;
  16766. /**
  16767. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16768. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16769. * It might on the other hand introduce peter panning.
  16770. */
  16771. forceBackFacesOnly: boolean;
  16772. protected _scene: Scene;
  16773. protected _lightDirection: Vector3;
  16774. protected _effect: Effect;
  16775. protected _viewMatrix: Matrix;
  16776. protected _projectionMatrix: Matrix;
  16777. protected _transformMatrix: Matrix;
  16778. protected _cachedPosition: Vector3;
  16779. protected _cachedDirection: Vector3;
  16780. protected _cachedDefines: string;
  16781. protected _currentRenderID: number;
  16782. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16783. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16784. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16785. protected _blurPostProcesses: PostProcess[];
  16786. protected _mapSize: number;
  16787. protected _currentFaceIndex: number;
  16788. protected _currentFaceIndexCache: number;
  16789. protected _textureType: number;
  16790. protected _defaultTextureMatrix: Matrix;
  16791. protected _storedUniqueId: Nullable<number>;
  16792. /** @hidden */
  16793. static _SceneComponentInitialization: (scene: Scene) => void;
  16794. /**
  16795. * Creates a ShadowGenerator object.
  16796. * A ShadowGenerator is the required tool to use the shadows.
  16797. * Each light casting shadows needs to use its own ShadowGenerator.
  16798. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16799. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16800. * @param light The light object generating the shadows.
  16801. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  16802. */
  16803. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16804. protected _initializeGenerator(): void;
  16805. protected _createTargetRenderTexture(): void;
  16806. protected _initializeShadowMap(): void;
  16807. protected _initializeBlurRTTAndPostProcesses(): void;
  16808. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16809. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16810. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16811. protected _applyFilterValues(): void;
  16812. /**
  16813. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16814. * @param onCompiled Callback triggered at the and of the effects compilation
  16815. * @param options Sets of optional options forcing the compilation with different modes
  16816. */
  16817. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16818. useInstances: boolean;
  16819. }>): void;
  16820. /**
  16821. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16822. * @param options Sets of optional options forcing the compilation with different modes
  16823. * @returns A promise that resolves when the compilation completes
  16824. */
  16825. forceCompilationAsync(options?: Partial<{
  16826. useInstances: boolean;
  16827. }>): Promise<void>;
  16828. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16829. private _prepareShadowDefines;
  16830. /**
  16831. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16832. * @param subMesh The submesh we want to render in the shadow map
  16833. * @param useInstances Defines wether will draw in the map using instances
  16834. * @returns true if ready otherwise, false
  16835. */
  16836. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16837. /**
  16838. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16839. * @param defines Defines of the material we want to update
  16840. * @param lightIndex Index of the light in the enabled light list of the material
  16841. */
  16842. prepareDefines(defines: any, lightIndex: number): void;
  16843. /**
  16844. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16845. * defined in the generator but impacting the effect).
  16846. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16847. * @param effect The effect we are binfing the information for
  16848. */
  16849. bindShadowLight(lightIndex: string, effect: Effect): void;
  16850. /**
  16851. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16852. * (eq to shadow prjection matrix * light transform matrix)
  16853. * @returns The transform matrix used to create the shadow map
  16854. */
  16855. getTransformMatrix(): Matrix;
  16856. /**
  16857. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16858. * Cube and 2D textures for instance.
  16859. */
  16860. recreateShadowMap(): void;
  16861. protected _disposeBlurPostProcesses(): void;
  16862. protected _disposeRTTandPostProcesses(): void;
  16863. /**
  16864. * Disposes the ShadowGenerator.
  16865. * Returns nothing.
  16866. */
  16867. dispose(): void;
  16868. /**
  16869. * Serializes the shadow generator setup to a json object.
  16870. * @returns The serialized JSON object
  16871. */
  16872. serialize(): any;
  16873. /**
  16874. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16875. * @param parsedShadowGenerator The JSON object to parse
  16876. * @param scene The scene to create the shadow map for
  16877. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16878. * @returns The parsed shadow generator
  16879. */
  16880. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16881. }
  16882. }
  16883. declare module BABYLON {
  16884. /**
  16885. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16886. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16887. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  16888. */
  16889. export abstract class Light extends Node {
  16890. /**
  16891. * Falloff Default: light is falling off following the material specification:
  16892. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16893. */
  16894. static readonly FALLOFF_DEFAULT: number;
  16895. /**
  16896. * Falloff Physical: light is falling off following the inverse squared distance law.
  16897. */
  16898. static readonly FALLOFF_PHYSICAL: number;
  16899. /**
  16900. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16901. * to enhance interoperability with other engines.
  16902. */
  16903. static readonly FALLOFF_GLTF: number;
  16904. /**
  16905. * Falloff Standard: light is falling off like in the standard material
  16906. * to enhance interoperability with other materials.
  16907. */
  16908. static readonly FALLOFF_STANDARD: number;
  16909. /**
  16910. * If every light affecting the material is in this lightmapMode,
  16911. * material.lightmapTexture adds or multiplies
  16912. * (depends on material.useLightmapAsShadowmap)
  16913. * after every other light calculations.
  16914. */
  16915. static readonly LIGHTMAP_DEFAULT: number;
  16916. /**
  16917. * material.lightmapTexture as only diffuse lighting from this light
  16918. * adds only specular lighting from this light
  16919. * adds dynamic shadows
  16920. */
  16921. static readonly LIGHTMAP_SPECULAR: number;
  16922. /**
  16923. * material.lightmapTexture as only lighting
  16924. * no light calculation from this light
  16925. * only adds dynamic shadows from this light
  16926. */
  16927. static readonly LIGHTMAP_SHADOWSONLY: number;
  16928. /**
  16929. * Each light type uses the default quantity according to its type:
  16930. * point/spot lights use luminous intensity
  16931. * directional lights use illuminance
  16932. */
  16933. static readonly INTENSITYMODE_AUTOMATIC: number;
  16934. /**
  16935. * lumen (lm)
  16936. */
  16937. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16938. /**
  16939. * candela (lm/sr)
  16940. */
  16941. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16942. /**
  16943. * lux (lm/m^2)
  16944. */
  16945. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16946. /**
  16947. * nit (cd/m^2)
  16948. */
  16949. static readonly INTENSITYMODE_LUMINANCE: number;
  16950. /**
  16951. * Light type const id of the point light.
  16952. */
  16953. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16954. /**
  16955. * Light type const id of the directional light.
  16956. */
  16957. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16958. /**
  16959. * Light type const id of the spot light.
  16960. */
  16961. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16962. /**
  16963. * Light type const id of the hemispheric light.
  16964. */
  16965. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16966. /**
  16967. * Diffuse gives the basic color to an object.
  16968. */
  16969. diffuse: Color3;
  16970. /**
  16971. * Specular produces a highlight color on an object.
  16972. * Note: This is note affecting PBR materials.
  16973. */
  16974. specular: Color3;
  16975. /**
  16976. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16977. * falling off base on range or angle.
  16978. * This can be set to any values in Light.FALLOFF_x.
  16979. *
  16980. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16981. * other types of materials.
  16982. */
  16983. falloffType: number;
  16984. /**
  16985. * Strength of the light.
  16986. * Note: By default it is define in the framework own unit.
  16987. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16988. */
  16989. intensity: number;
  16990. private _range;
  16991. protected _inverseSquaredRange: number;
  16992. /**
  16993. * Defines how far from the source the light is impacting in scene units.
  16994. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16995. */
  16996. get range(): number;
  16997. /**
  16998. * Defines how far from the source the light is impacting in scene units.
  16999. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17000. */
  17001. set range(value: number);
  17002. /**
  17003. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17004. * of light.
  17005. */
  17006. private _photometricScale;
  17007. private _intensityMode;
  17008. /**
  17009. * Gets the photometric scale used to interpret the intensity.
  17010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17011. */
  17012. get intensityMode(): number;
  17013. /**
  17014. * Sets the photometric scale used to interpret the intensity.
  17015. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17016. */
  17017. set intensityMode(value: number);
  17018. private _radius;
  17019. /**
  17020. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17021. */
  17022. get radius(): number;
  17023. /**
  17024. * sets the light radius used by PBR Materials to simulate soft area lights.
  17025. */
  17026. set radius(value: number);
  17027. private _renderPriority;
  17028. /**
  17029. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17030. * exceeding the number allowed of the materials.
  17031. */
  17032. renderPriority: number;
  17033. private _shadowEnabled;
  17034. /**
  17035. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17036. * the current shadow generator.
  17037. */
  17038. get shadowEnabled(): boolean;
  17039. /**
  17040. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17041. * the current shadow generator.
  17042. */
  17043. set shadowEnabled(value: boolean);
  17044. private _includedOnlyMeshes;
  17045. /**
  17046. * Gets the only meshes impacted by this light.
  17047. */
  17048. get includedOnlyMeshes(): AbstractMesh[];
  17049. /**
  17050. * Sets the only meshes impacted by this light.
  17051. */
  17052. set includedOnlyMeshes(value: AbstractMesh[]);
  17053. private _excludedMeshes;
  17054. /**
  17055. * Gets the meshes not impacted by this light.
  17056. */
  17057. get excludedMeshes(): AbstractMesh[];
  17058. /**
  17059. * Sets the meshes not impacted by this light.
  17060. */
  17061. set excludedMeshes(value: AbstractMesh[]);
  17062. private _excludeWithLayerMask;
  17063. /**
  17064. * Gets the layer id use to find what meshes are not impacted by the light.
  17065. * Inactive if 0
  17066. */
  17067. get excludeWithLayerMask(): number;
  17068. /**
  17069. * Sets the layer id use to find what meshes are not impacted by the light.
  17070. * Inactive if 0
  17071. */
  17072. set excludeWithLayerMask(value: number);
  17073. private _includeOnlyWithLayerMask;
  17074. /**
  17075. * Gets the layer id use to find what meshes are impacted by the light.
  17076. * Inactive if 0
  17077. */
  17078. get includeOnlyWithLayerMask(): number;
  17079. /**
  17080. * Sets the layer id use to find what meshes are impacted by the light.
  17081. * Inactive if 0
  17082. */
  17083. set includeOnlyWithLayerMask(value: number);
  17084. private _lightmapMode;
  17085. /**
  17086. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17087. */
  17088. get lightmapMode(): number;
  17089. /**
  17090. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17091. */
  17092. set lightmapMode(value: number);
  17093. /**
  17094. * Shadow generator associted to the light.
  17095. * @hidden Internal use only.
  17096. */
  17097. _shadowGenerator: Nullable<IShadowGenerator>;
  17098. /**
  17099. * @hidden Internal use only.
  17100. */
  17101. _excludedMeshesIds: string[];
  17102. /**
  17103. * @hidden Internal use only.
  17104. */
  17105. _includedOnlyMeshesIds: string[];
  17106. /**
  17107. * The current light unifom buffer.
  17108. * @hidden Internal use only.
  17109. */
  17110. _uniformBuffer: UniformBuffer;
  17111. /** @hidden */
  17112. _renderId: number;
  17113. /**
  17114. * Creates a Light object in the scene.
  17115. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17116. * @param name The firendly name of the light
  17117. * @param scene The scene the light belongs too
  17118. */
  17119. constructor(name: string, scene: Scene);
  17120. protected abstract _buildUniformLayout(): void;
  17121. /**
  17122. * Sets the passed Effect "effect" with the Light information.
  17123. * @param effect The effect to update
  17124. * @param lightIndex The index of the light in the effect to update
  17125. * @returns The light
  17126. */
  17127. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17128. /**
  17129. * Sets the passed Effect "effect" with the Light textures.
  17130. * @param effect The effect to update
  17131. * @param lightIndex The index of the light in the effect to update
  17132. * @returns The light
  17133. */
  17134. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17135. /**
  17136. * Binds the lights information from the scene to the effect for the given mesh.
  17137. * @param lightIndex Light index
  17138. * @param scene The scene where the light belongs to
  17139. * @param effect The effect we are binding the data to
  17140. * @param useSpecular Defines if specular is supported
  17141. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17142. */
  17143. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17144. /**
  17145. * Sets the passed Effect "effect" with the Light information.
  17146. * @param effect The effect to update
  17147. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17148. * @returns The light
  17149. */
  17150. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17151. /**
  17152. * Returns the string "Light".
  17153. * @returns the class name
  17154. */
  17155. getClassName(): string;
  17156. /** @hidden */
  17157. readonly _isLight: boolean;
  17158. /**
  17159. * Converts the light information to a readable string for debug purpose.
  17160. * @param fullDetails Supports for multiple levels of logging within scene loading
  17161. * @returns the human readable light info
  17162. */
  17163. toString(fullDetails?: boolean): string;
  17164. /** @hidden */
  17165. protected _syncParentEnabledState(): void;
  17166. /**
  17167. * Set the enabled state of this node.
  17168. * @param value - the new enabled state
  17169. */
  17170. setEnabled(value: boolean): void;
  17171. /**
  17172. * Returns the Light associated shadow generator if any.
  17173. * @return the associated shadow generator.
  17174. */
  17175. getShadowGenerator(): Nullable<IShadowGenerator>;
  17176. /**
  17177. * Returns a Vector3, the absolute light position in the World.
  17178. * @returns the world space position of the light
  17179. */
  17180. getAbsolutePosition(): Vector3;
  17181. /**
  17182. * Specifies if the light will affect the passed mesh.
  17183. * @param mesh The mesh to test against the light
  17184. * @return true the mesh is affected otherwise, false.
  17185. */
  17186. canAffectMesh(mesh: AbstractMesh): boolean;
  17187. /**
  17188. * Sort function to order lights for rendering.
  17189. * @param a First Light object to compare to second.
  17190. * @param b Second Light object to compare first.
  17191. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17192. */
  17193. static CompareLightsPriority(a: Light, b: Light): number;
  17194. /**
  17195. * Releases resources associated with this node.
  17196. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17197. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17198. */
  17199. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17200. /**
  17201. * Returns the light type ID (integer).
  17202. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17203. */
  17204. getTypeID(): number;
  17205. /**
  17206. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17207. * @returns the scaled intensity in intensity mode unit
  17208. */
  17209. getScaledIntensity(): number;
  17210. /**
  17211. * Returns a new Light object, named "name", from the current one.
  17212. * @param name The name of the cloned light
  17213. * @returns the new created light
  17214. */
  17215. clone(name: string): Nullable<Light>;
  17216. /**
  17217. * Serializes the current light into a Serialization object.
  17218. * @returns the serialized object.
  17219. */
  17220. serialize(): any;
  17221. /**
  17222. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17223. * This new light is named "name" and added to the passed scene.
  17224. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17225. * @param name The friendly name of the light
  17226. * @param scene The scene the new light will belong to
  17227. * @returns the constructor function
  17228. */
  17229. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17230. /**
  17231. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17232. * @param parsedLight The JSON representation of the light
  17233. * @param scene The scene to create the parsed light in
  17234. * @returns the created light after parsing
  17235. */
  17236. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17237. private _hookArrayForExcluded;
  17238. private _hookArrayForIncludedOnly;
  17239. private _resyncMeshes;
  17240. /**
  17241. * Forces the meshes to update their light related information in their rendering used effects
  17242. * @hidden Internal Use Only
  17243. */
  17244. _markMeshesAsLightDirty(): void;
  17245. /**
  17246. * Recomputes the cached photometric scale if needed.
  17247. */
  17248. private _computePhotometricScale;
  17249. /**
  17250. * Returns the Photometric Scale according to the light type and intensity mode.
  17251. */
  17252. private _getPhotometricScale;
  17253. /**
  17254. * Reorder the light in the scene according to their defined priority.
  17255. * @hidden Internal Use Only
  17256. */
  17257. _reorderLightsInScene(): void;
  17258. /**
  17259. * Prepares the list of defines specific to the light type.
  17260. * @param defines the list of defines
  17261. * @param lightIndex defines the index of the light for the effect
  17262. */
  17263. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17264. }
  17265. }
  17266. declare module BABYLON {
  17267. /**
  17268. * Interface used to define Action
  17269. */
  17270. export interface IAction {
  17271. /**
  17272. * Trigger for the action
  17273. */
  17274. trigger: number;
  17275. /** Options of the trigger */
  17276. triggerOptions: any;
  17277. /**
  17278. * Gets the trigger parameters
  17279. * @returns the trigger parameters
  17280. */
  17281. getTriggerParameter(): any;
  17282. /**
  17283. * Internal only - executes current action event
  17284. * @hidden
  17285. */
  17286. _executeCurrent(evt?: ActionEvent): void;
  17287. /**
  17288. * Serialize placeholder for child classes
  17289. * @param parent of child
  17290. * @returns the serialized object
  17291. */
  17292. serialize(parent: any): any;
  17293. /**
  17294. * Internal only
  17295. * @hidden
  17296. */
  17297. _prepare(): void;
  17298. /**
  17299. * Internal only - manager for action
  17300. * @hidden
  17301. */
  17302. _actionManager: AbstractActionManager;
  17303. /**
  17304. * Adds action to chain of actions, may be a DoNothingAction
  17305. * @param action defines the next action to execute
  17306. * @returns The action passed in
  17307. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17308. */
  17309. then(action: IAction): IAction;
  17310. }
  17311. /**
  17312. * The action to be carried out following a trigger
  17313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17314. */
  17315. export class Action implements IAction {
  17316. /** the trigger, with or without parameters, for the action */
  17317. triggerOptions: any;
  17318. /**
  17319. * Trigger for the action
  17320. */
  17321. trigger: number;
  17322. /**
  17323. * Internal only - manager for action
  17324. * @hidden
  17325. */
  17326. _actionManager: ActionManager;
  17327. private _nextActiveAction;
  17328. private _child;
  17329. private _condition?;
  17330. private _triggerParameter;
  17331. /**
  17332. * An event triggered prior to action being executed.
  17333. */
  17334. onBeforeExecuteObservable: Observable<Action>;
  17335. /**
  17336. * Creates a new Action
  17337. * @param triggerOptions the trigger, with or without parameters, for the action
  17338. * @param condition an optional determinant of action
  17339. */
  17340. constructor(
  17341. /** the trigger, with or without parameters, for the action */
  17342. triggerOptions: any, condition?: Condition);
  17343. /**
  17344. * Internal only
  17345. * @hidden
  17346. */
  17347. _prepare(): void;
  17348. /**
  17349. * Gets the trigger parameters
  17350. * @returns the trigger parameters
  17351. */
  17352. getTriggerParameter(): any;
  17353. /**
  17354. * Internal only - executes current action event
  17355. * @hidden
  17356. */
  17357. _executeCurrent(evt?: ActionEvent): void;
  17358. /**
  17359. * Execute placeholder for child classes
  17360. * @param evt optional action event
  17361. */
  17362. execute(evt?: ActionEvent): void;
  17363. /**
  17364. * Skips to next active action
  17365. */
  17366. skipToNextActiveAction(): void;
  17367. /**
  17368. * Adds action to chain of actions, may be a DoNothingAction
  17369. * @param action defines the next action to execute
  17370. * @returns The action passed in
  17371. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17372. */
  17373. then(action: Action): Action;
  17374. /**
  17375. * Internal only
  17376. * @hidden
  17377. */
  17378. _getProperty(propertyPath: string): string;
  17379. /**
  17380. * Internal only
  17381. * @hidden
  17382. */
  17383. _getEffectiveTarget(target: any, propertyPath: string): any;
  17384. /**
  17385. * Serialize placeholder for child classes
  17386. * @param parent of child
  17387. * @returns the serialized object
  17388. */
  17389. serialize(parent: any): any;
  17390. /**
  17391. * Internal only called by serialize
  17392. * @hidden
  17393. */
  17394. protected _serialize(serializedAction: any, parent?: any): any;
  17395. /**
  17396. * Internal only
  17397. * @hidden
  17398. */
  17399. static _SerializeValueAsString: (value: any) => string;
  17400. /**
  17401. * Internal only
  17402. * @hidden
  17403. */
  17404. static _GetTargetProperty: (target: Node | Scene) => {
  17405. name: string;
  17406. targetType: string;
  17407. value: string;
  17408. };
  17409. }
  17410. }
  17411. declare module BABYLON {
  17412. /**
  17413. * A Condition applied to an Action
  17414. */
  17415. export class Condition {
  17416. /**
  17417. * Internal only - manager for action
  17418. * @hidden
  17419. */
  17420. _actionManager: ActionManager;
  17421. /**
  17422. * Internal only
  17423. * @hidden
  17424. */
  17425. _evaluationId: number;
  17426. /**
  17427. * Internal only
  17428. * @hidden
  17429. */
  17430. _currentResult: boolean;
  17431. /**
  17432. * Creates a new Condition
  17433. * @param actionManager the manager of the action the condition is applied to
  17434. */
  17435. constructor(actionManager: ActionManager);
  17436. /**
  17437. * Check if the current condition is valid
  17438. * @returns a boolean
  17439. */
  17440. isValid(): boolean;
  17441. /**
  17442. * Internal only
  17443. * @hidden
  17444. */
  17445. _getProperty(propertyPath: string): string;
  17446. /**
  17447. * Internal only
  17448. * @hidden
  17449. */
  17450. _getEffectiveTarget(target: any, propertyPath: string): any;
  17451. /**
  17452. * Serialize placeholder for child classes
  17453. * @returns the serialized object
  17454. */
  17455. serialize(): any;
  17456. /**
  17457. * Internal only
  17458. * @hidden
  17459. */
  17460. protected _serialize(serializedCondition: any): any;
  17461. }
  17462. /**
  17463. * Defines specific conditional operators as extensions of Condition
  17464. */
  17465. export class ValueCondition extends Condition {
  17466. /** path to specify the property of the target the conditional operator uses */
  17467. propertyPath: string;
  17468. /** the value compared by the conditional operator against the current value of the property */
  17469. value: any;
  17470. /** the conditional operator, default ValueCondition.IsEqual */
  17471. operator: number;
  17472. /**
  17473. * Internal only
  17474. * @hidden
  17475. */
  17476. private static _IsEqual;
  17477. /**
  17478. * Internal only
  17479. * @hidden
  17480. */
  17481. private static _IsDifferent;
  17482. /**
  17483. * Internal only
  17484. * @hidden
  17485. */
  17486. private static _IsGreater;
  17487. /**
  17488. * Internal only
  17489. * @hidden
  17490. */
  17491. private static _IsLesser;
  17492. /**
  17493. * returns the number for IsEqual
  17494. */
  17495. static get IsEqual(): number;
  17496. /**
  17497. * Returns the number for IsDifferent
  17498. */
  17499. static get IsDifferent(): number;
  17500. /**
  17501. * Returns the number for IsGreater
  17502. */
  17503. static get IsGreater(): number;
  17504. /**
  17505. * Returns the number for IsLesser
  17506. */
  17507. static get IsLesser(): number;
  17508. /**
  17509. * Internal only The action manager for the condition
  17510. * @hidden
  17511. */
  17512. _actionManager: ActionManager;
  17513. /**
  17514. * Internal only
  17515. * @hidden
  17516. */
  17517. private _target;
  17518. /**
  17519. * Internal only
  17520. * @hidden
  17521. */
  17522. private _effectiveTarget;
  17523. /**
  17524. * Internal only
  17525. * @hidden
  17526. */
  17527. private _property;
  17528. /**
  17529. * Creates a new ValueCondition
  17530. * @param actionManager manager for the action the condition applies to
  17531. * @param target for the action
  17532. * @param propertyPath path to specify the property of the target the conditional operator uses
  17533. * @param value the value compared by the conditional operator against the current value of the property
  17534. * @param operator the conditional operator, default ValueCondition.IsEqual
  17535. */
  17536. constructor(actionManager: ActionManager, target: any,
  17537. /** path to specify the property of the target the conditional operator uses */
  17538. propertyPath: string,
  17539. /** the value compared by the conditional operator against the current value of the property */
  17540. value: any,
  17541. /** the conditional operator, default ValueCondition.IsEqual */
  17542. operator?: number);
  17543. /**
  17544. * Compares the given value with the property value for the specified conditional operator
  17545. * @returns the result of the comparison
  17546. */
  17547. isValid(): boolean;
  17548. /**
  17549. * Serialize the ValueCondition into a JSON compatible object
  17550. * @returns serialization object
  17551. */
  17552. serialize(): any;
  17553. /**
  17554. * Gets the name of the conditional operator for the ValueCondition
  17555. * @param operator the conditional operator
  17556. * @returns the name
  17557. */
  17558. static GetOperatorName(operator: number): string;
  17559. }
  17560. /**
  17561. * Defines a predicate condition as an extension of Condition
  17562. */
  17563. export class PredicateCondition extends Condition {
  17564. /** defines the predicate function used to validate the condition */
  17565. predicate: () => boolean;
  17566. /**
  17567. * Internal only - manager for action
  17568. * @hidden
  17569. */
  17570. _actionManager: ActionManager;
  17571. /**
  17572. * Creates a new PredicateCondition
  17573. * @param actionManager manager for the action the condition applies to
  17574. * @param predicate defines the predicate function used to validate the condition
  17575. */
  17576. constructor(actionManager: ActionManager,
  17577. /** defines the predicate function used to validate the condition */
  17578. predicate: () => boolean);
  17579. /**
  17580. * @returns the validity of the predicate condition
  17581. */
  17582. isValid(): boolean;
  17583. }
  17584. /**
  17585. * Defines a state condition as an extension of Condition
  17586. */
  17587. export class StateCondition extends Condition {
  17588. /** Value to compare with target state */
  17589. value: string;
  17590. /**
  17591. * Internal only - manager for action
  17592. * @hidden
  17593. */
  17594. _actionManager: ActionManager;
  17595. /**
  17596. * Internal only
  17597. * @hidden
  17598. */
  17599. private _target;
  17600. /**
  17601. * Creates a new StateCondition
  17602. * @param actionManager manager for the action the condition applies to
  17603. * @param target of the condition
  17604. * @param value to compare with target state
  17605. */
  17606. constructor(actionManager: ActionManager, target: any,
  17607. /** Value to compare with target state */
  17608. value: string);
  17609. /**
  17610. * Gets a boolean indicating if the current condition is met
  17611. * @returns the validity of the state
  17612. */
  17613. isValid(): boolean;
  17614. /**
  17615. * Serialize the StateCondition into a JSON compatible object
  17616. * @returns serialization object
  17617. */
  17618. serialize(): any;
  17619. }
  17620. }
  17621. declare module BABYLON {
  17622. /**
  17623. * This defines an action responsible to toggle a boolean once triggered.
  17624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17625. */
  17626. export class SwitchBooleanAction extends Action {
  17627. /**
  17628. * The path to the boolean property in the target object
  17629. */
  17630. propertyPath: string;
  17631. private _target;
  17632. private _effectiveTarget;
  17633. private _property;
  17634. /**
  17635. * Instantiate the action
  17636. * @param triggerOptions defines the trigger options
  17637. * @param target defines the object containing the boolean
  17638. * @param propertyPath defines the path to the boolean property in the target object
  17639. * @param condition defines the trigger related conditions
  17640. */
  17641. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17642. /** @hidden */
  17643. _prepare(): void;
  17644. /**
  17645. * Execute the action toggle the boolean value.
  17646. */
  17647. execute(): void;
  17648. /**
  17649. * Serializes the actions and its related information.
  17650. * @param parent defines the object to serialize in
  17651. * @returns the serialized object
  17652. */
  17653. serialize(parent: any): any;
  17654. }
  17655. /**
  17656. * This defines an action responsible to set a the state field of the target
  17657. * to a desired value once triggered.
  17658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17659. */
  17660. export class SetStateAction extends Action {
  17661. /**
  17662. * The value to store in the state field.
  17663. */
  17664. value: string;
  17665. private _target;
  17666. /**
  17667. * Instantiate the action
  17668. * @param triggerOptions defines the trigger options
  17669. * @param target defines the object containing the state property
  17670. * @param value defines the value to store in the state field
  17671. * @param condition defines the trigger related conditions
  17672. */
  17673. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17674. /**
  17675. * Execute the action and store the value on the target state property.
  17676. */
  17677. execute(): void;
  17678. /**
  17679. * Serializes the actions and its related information.
  17680. * @param parent defines the object to serialize in
  17681. * @returns the serialized object
  17682. */
  17683. serialize(parent: any): any;
  17684. }
  17685. /**
  17686. * This defines an action responsible to set a property of the target
  17687. * to a desired value once triggered.
  17688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17689. */
  17690. export class SetValueAction extends Action {
  17691. /**
  17692. * The path of the property to set in the target.
  17693. */
  17694. propertyPath: string;
  17695. /**
  17696. * The value to set in the property
  17697. */
  17698. value: any;
  17699. private _target;
  17700. private _effectiveTarget;
  17701. private _property;
  17702. /**
  17703. * Instantiate the action
  17704. * @param triggerOptions defines the trigger options
  17705. * @param target defines the object containing the property
  17706. * @param propertyPath defines the path of the property to set in the target
  17707. * @param value defines the value to set in the property
  17708. * @param condition defines the trigger related conditions
  17709. */
  17710. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17711. /** @hidden */
  17712. _prepare(): void;
  17713. /**
  17714. * Execute the action and set the targetted property to the desired value.
  17715. */
  17716. execute(): void;
  17717. /**
  17718. * Serializes the actions and its related information.
  17719. * @param parent defines the object to serialize in
  17720. * @returns the serialized object
  17721. */
  17722. serialize(parent: any): any;
  17723. }
  17724. /**
  17725. * This defines an action responsible to increment the target value
  17726. * to a desired value once triggered.
  17727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17728. */
  17729. export class IncrementValueAction extends Action {
  17730. /**
  17731. * The path of the property to increment in the target.
  17732. */
  17733. propertyPath: string;
  17734. /**
  17735. * The value we should increment the property by.
  17736. */
  17737. value: any;
  17738. private _target;
  17739. private _effectiveTarget;
  17740. private _property;
  17741. /**
  17742. * Instantiate the action
  17743. * @param triggerOptions defines the trigger options
  17744. * @param target defines the object containing the property
  17745. * @param propertyPath defines the path of the property to increment in the target
  17746. * @param value defines the value value we should increment the property by
  17747. * @param condition defines the trigger related conditions
  17748. */
  17749. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17750. /** @hidden */
  17751. _prepare(): void;
  17752. /**
  17753. * Execute the action and increment the target of the value amount.
  17754. */
  17755. execute(): void;
  17756. /**
  17757. * Serializes the actions and its related information.
  17758. * @param parent defines the object to serialize in
  17759. * @returns the serialized object
  17760. */
  17761. serialize(parent: any): any;
  17762. }
  17763. /**
  17764. * This defines an action responsible to start an animation once triggered.
  17765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17766. */
  17767. export class PlayAnimationAction extends Action {
  17768. /**
  17769. * Where the animation should start (animation frame)
  17770. */
  17771. from: number;
  17772. /**
  17773. * Where the animation should stop (animation frame)
  17774. */
  17775. to: number;
  17776. /**
  17777. * Define if the animation should loop or stop after the first play.
  17778. */
  17779. loop?: boolean;
  17780. private _target;
  17781. /**
  17782. * Instantiate the action
  17783. * @param triggerOptions defines the trigger options
  17784. * @param target defines the target animation or animation name
  17785. * @param from defines from where the animation should start (animation frame)
  17786. * @param end defines where the animation should stop (animation frame)
  17787. * @param loop defines if the animation should loop or stop after the first play
  17788. * @param condition defines the trigger related conditions
  17789. */
  17790. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17791. /** @hidden */
  17792. _prepare(): void;
  17793. /**
  17794. * Execute the action and play the animation.
  17795. */
  17796. execute(): void;
  17797. /**
  17798. * Serializes the actions and its related information.
  17799. * @param parent defines the object to serialize in
  17800. * @returns the serialized object
  17801. */
  17802. serialize(parent: any): any;
  17803. }
  17804. /**
  17805. * This defines an action responsible to stop an animation once triggered.
  17806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17807. */
  17808. export class StopAnimationAction extends Action {
  17809. private _target;
  17810. /**
  17811. * Instantiate the action
  17812. * @param triggerOptions defines the trigger options
  17813. * @param target defines the target animation or animation name
  17814. * @param condition defines the trigger related conditions
  17815. */
  17816. constructor(triggerOptions: any, target: any, condition?: Condition);
  17817. /** @hidden */
  17818. _prepare(): void;
  17819. /**
  17820. * Execute the action and stop the animation.
  17821. */
  17822. execute(): void;
  17823. /**
  17824. * Serializes the actions and its related information.
  17825. * @param parent defines the object to serialize in
  17826. * @returns the serialized object
  17827. */
  17828. serialize(parent: any): any;
  17829. }
  17830. /**
  17831. * This defines an action responsible that does nothing once triggered.
  17832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17833. */
  17834. export class DoNothingAction extends Action {
  17835. /**
  17836. * Instantiate the action
  17837. * @param triggerOptions defines the trigger options
  17838. * @param condition defines the trigger related conditions
  17839. */
  17840. constructor(triggerOptions?: any, condition?: Condition);
  17841. /**
  17842. * Execute the action and do nothing.
  17843. */
  17844. execute(): void;
  17845. /**
  17846. * Serializes the actions and its related information.
  17847. * @param parent defines the object to serialize in
  17848. * @returns the serialized object
  17849. */
  17850. serialize(parent: any): any;
  17851. }
  17852. /**
  17853. * This defines an action responsible to trigger several actions once triggered.
  17854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17855. */
  17856. export class CombineAction extends Action {
  17857. /**
  17858. * The list of aggregated animations to run.
  17859. */
  17860. children: Action[];
  17861. /**
  17862. * Instantiate the action
  17863. * @param triggerOptions defines the trigger options
  17864. * @param children defines the list of aggregated animations to run
  17865. * @param condition defines the trigger related conditions
  17866. */
  17867. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17868. /** @hidden */
  17869. _prepare(): void;
  17870. /**
  17871. * Execute the action and executes all the aggregated actions.
  17872. */
  17873. execute(evt: ActionEvent): void;
  17874. /**
  17875. * Serializes the actions and its related information.
  17876. * @param parent defines the object to serialize in
  17877. * @returns the serialized object
  17878. */
  17879. serialize(parent: any): any;
  17880. }
  17881. /**
  17882. * This defines an action responsible to run code (external event) once triggered.
  17883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17884. */
  17885. export class ExecuteCodeAction extends Action {
  17886. /**
  17887. * The callback function to run.
  17888. */
  17889. func: (evt: ActionEvent) => void;
  17890. /**
  17891. * Instantiate the action
  17892. * @param triggerOptions defines the trigger options
  17893. * @param func defines the callback function to run
  17894. * @param condition defines the trigger related conditions
  17895. */
  17896. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17897. /**
  17898. * Execute the action and run the attached code.
  17899. */
  17900. execute(evt: ActionEvent): void;
  17901. }
  17902. /**
  17903. * This defines an action responsible to set the parent property of the target once triggered.
  17904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17905. */
  17906. export class SetParentAction extends Action {
  17907. private _parent;
  17908. private _target;
  17909. /**
  17910. * Instantiate the action
  17911. * @param triggerOptions defines the trigger options
  17912. * @param target defines the target containing the parent property
  17913. * @param parent defines from where the animation should start (animation frame)
  17914. * @param condition defines the trigger related conditions
  17915. */
  17916. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17917. /** @hidden */
  17918. _prepare(): void;
  17919. /**
  17920. * Execute the action and set the parent property.
  17921. */
  17922. execute(): void;
  17923. /**
  17924. * Serializes the actions and its related information.
  17925. * @param parent defines the object to serialize in
  17926. * @returns the serialized object
  17927. */
  17928. serialize(parent: any): any;
  17929. }
  17930. }
  17931. declare module BABYLON {
  17932. /**
  17933. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17934. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17936. */
  17937. export class ActionManager extends AbstractActionManager {
  17938. /**
  17939. * Nothing
  17940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17941. */
  17942. static readonly NothingTrigger: number;
  17943. /**
  17944. * On pick
  17945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17946. */
  17947. static readonly OnPickTrigger: number;
  17948. /**
  17949. * On left pick
  17950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17951. */
  17952. static readonly OnLeftPickTrigger: number;
  17953. /**
  17954. * On right pick
  17955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17956. */
  17957. static readonly OnRightPickTrigger: number;
  17958. /**
  17959. * On center pick
  17960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17961. */
  17962. static readonly OnCenterPickTrigger: number;
  17963. /**
  17964. * On pick down
  17965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17966. */
  17967. static readonly OnPickDownTrigger: number;
  17968. /**
  17969. * On double pick
  17970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17971. */
  17972. static readonly OnDoublePickTrigger: number;
  17973. /**
  17974. * On pick up
  17975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17976. */
  17977. static readonly OnPickUpTrigger: number;
  17978. /**
  17979. * On pick out.
  17980. * This trigger will only be raised if you also declared a OnPickDown
  17981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17982. */
  17983. static readonly OnPickOutTrigger: number;
  17984. /**
  17985. * On long press
  17986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17987. */
  17988. static readonly OnLongPressTrigger: number;
  17989. /**
  17990. * On pointer over
  17991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17992. */
  17993. static readonly OnPointerOverTrigger: number;
  17994. /**
  17995. * On pointer out
  17996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17997. */
  17998. static readonly OnPointerOutTrigger: number;
  17999. /**
  18000. * On every frame
  18001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18002. */
  18003. static readonly OnEveryFrameTrigger: number;
  18004. /**
  18005. * On intersection enter
  18006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18007. */
  18008. static readonly OnIntersectionEnterTrigger: number;
  18009. /**
  18010. * On intersection exit
  18011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18012. */
  18013. static readonly OnIntersectionExitTrigger: number;
  18014. /**
  18015. * On key down
  18016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18017. */
  18018. static readonly OnKeyDownTrigger: number;
  18019. /**
  18020. * On key up
  18021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18022. */
  18023. static readonly OnKeyUpTrigger: number;
  18024. private _scene;
  18025. /**
  18026. * Creates a new action manager
  18027. * @param scene defines the hosting scene
  18028. */
  18029. constructor(scene: Scene);
  18030. /**
  18031. * Releases all associated resources
  18032. */
  18033. dispose(): void;
  18034. /**
  18035. * Gets hosting scene
  18036. * @returns the hosting scene
  18037. */
  18038. getScene(): Scene;
  18039. /**
  18040. * Does this action manager handles actions of any of the given triggers
  18041. * @param triggers defines the triggers to be tested
  18042. * @return a boolean indicating whether one (or more) of the triggers is handled
  18043. */
  18044. hasSpecificTriggers(triggers: number[]): boolean;
  18045. /**
  18046. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18047. * speed.
  18048. * @param triggerA defines the trigger to be tested
  18049. * @param triggerB defines the trigger to be tested
  18050. * @return a boolean indicating whether one (or more) of the triggers is handled
  18051. */
  18052. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18053. /**
  18054. * Does this action manager handles actions of a given trigger
  18055. * @param trigger defines the trigger to be tested
  18056. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18057. * @return whether the trigger is handled
  18058. */
  18059. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18060. /**
  18061. * Does this action manager has pointer triggers
  18062. */
  18063. get hasPointerTriggers(): boolean;
  18064. /**
  18065. * Does this action manager has pick triggers
  18066. */
  18067. get hasPickTriggers(): boolean;
  18068. /**
  18069. * Registers an action to this action manager
  18070. * @param action defines the action to be registered
  18071. * @return the action amended (prepared) after registration
  18072. */
  18073. registerAction(action: IAction): Nullable<IAction>;
  18074. /**
  18075. * Unregisters an action to this action manager
  18076. * @param action defines the action to be unregistered
  18077. * @return a boolean indicating whether the action has been unregistered
  18078. */
  18079. unregisterAction(action: IAction): Boolean;
  18080. /**
  18081. * Process a specific trigger
  18082. * @param trigger defines the trigger to process
  18083. * @param evt defines the event details to be processed
  18084. */
  18085. processTrigger(trigger: number, evt?: IActionEvent): void;
  18086. /** @hidden */
  18087. _getEffectiveTarget(target: any, propertyPath: string): any;
  18088. /** @hidden */
  18089. _getProperty(propertyPath: string): string;
  18090. /**
  18091. * Serialize this manager to a JSON object
  18092. * @param name defines the property name to store this manager
  18093. * @returns a JSON representation of this manager
  18094. */
  18095. serialize(name: string): any;
  18096. /**
  18097. * Creates a new ActionManager from a JSON data
  18098. * @param parsedActions defines the JSON data to read from
  18099. * @param object defines the hosting mesh
  18100. * @param scene defines the hosting scene
  18101. */
  18102. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18103. /**
  18104. * Get a trigger name by index
  18105. * @param trigger defines the trigger index
  18106. * @returns a trigger name
  18107. */
  18108. static GetTriggerName(trigger: number): string;
  18109. }
  18110. }
  18111. declare module BABYLON {
  18112. /**
  18113. * Class used to represent a sprite
  18114. * @see http://doc.babylonjs.com/babylon101/sprites
  18115. */
  18116. export class Sprite {
  18117. /** defines the name */
  18118. name: string;
  18119. /** Gets or sets the current world position */
  18120. position: Vector3;
  18121. /** Gets or sets the main color */
  18122. color: Color4;
  18123. /** Gets or sets the width */
  18124. width: number;
  18125. /** Gets or sets the height */
  18126. height: number;
  18127. /** Gets or sets rotation angle */
  18128. angle: number;
  18129. /** Gets or sets the cell index in the sprite sheet */
  18130. cellIndex: number;
  18131. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18132. cellRef: string;
  18133. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18134. invertU: number;
  18135. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18136. invertV: number;
  18137. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18138. disposeWhenFinishedAnimating: boolean;
  18139. /** Gets the list of attached animations */
  18140. animations: Animation[];
  18141. /** Gets or sets a boolean indicating if the sprite can be picked */
  18142. isPickable: boolean;
  18143. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18144. useAlphaForPicking: boolean;
  18145. /** @hidden */
  18146. _xOffset: number;
  18147. /** @hidden */
  18148. _yOffset: number;
  18149. /** @hidden */
  18150. _xSize: number;
  18151. /** @hidden */
  18152. _ySize: number;
  18153. /**
  18154. * Gets or sets the associated action manager
  18155. */
  18156. actionManager: Nullable<ActionManager>;
  18157. private _animationStarted;
  18158. private _loopAnimation;
  18159. private _fromIndex;
  18160. private _toIndex;
  18161. private _delay;
  18162. private _direction;
  18163. private _manager;
  18164. private _time;
  18165. private _onAnimationEnd;
  18166. /**
  18167. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18168. */
  18169. isVisible: boolean;
  18170. /**
  18171. * Gets or sets the sprite size
  18172. */
  18173. get size(): number;
  18174. set size(value: number);
  18175. /**
  18176. * Creates a new Sprite
  18177. * @param name defines the name
  18178. * @param manager defines the manager
  18179. */
  18180. constructor(
  18181. /** defines the name */
  18182. name: string, manager: ISpriteManager);
  18183. /**
  18184. * Starts an animation
  18185. * @param from defines the initial key
  18186. * @param to defines the end key
  18187. * @param loop defines if the animation must loop
  18188. * @param delay defines the start delay (in ms)
  18189. * @param onAnimationEnd defines a callback to call when animation ends
  18190. */
  18191. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18192. /** Stops current animation (if any) */
  18193. stopAnimation(): void;
  18194. /** @hidden */
  18195. _animate(deltaTime: number): void;
  18196. /** Release associated resources */
  18197. dispose(): void;
  18198. }
  18199. }
  18200. declare module BABYLON {
  18201. /**
  18202. * Information about the result of picking within a scene
  18203. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18204. */
  18205. export class PickingInfo {
  18206. /** @hidden */
  18207. _pickingUnavailable: boolean;
  18208. /**
  18209. * If the pick collided with an object
  18210. */
  18211. hit: boolean;
  18212. /**
  18213. * Distance away where the pick collided
  18214. */
  18215. distance: number;
  18216. /**
  18217. * The location of pick collision
  18218. */
  18219. pickedPoint: Nullable<Vector3>;
  18220. /**
  18221. * The mesh corresponding the the pick collision
  18222. */
  18223. pickedMesh: Nullable<AbstractMesh>;
  18224. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18225. bu: number;
  18226. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18227. bv: number;
  18228. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18229. faceId: number;
  18230. /** Id of the the submesh that was picked */
  18231. subMeshId: number;
  18232. /** If a sprite was picked, this will be the sprite the pick collided with */
  18233. pickedSprite: Nullable<Sprite>;
  18234. /**
  18235. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18236. */
  18237. originMesh: Nullable<AbstractMesh>;
  18238. /**
  18239. * The ray that was used to perform the picking.
  18240. */
  18241. ray: Nullable<Ray>;
  18242. /**
  18243. * Gets the normal correspodning to the face the pick collided with
  18244. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18245. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18246. * @returns The normal correspodning to the face the pick collided with
  18247. */
  18248. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18249. /**
  18250. * Gets the texture coordinates of where the pick occured
  18251. * @returns the vector containing the coordnates of the texture
  18252. */
  18253. getTextureCoordinates(): Nullable<Vector2>;
  18254. }
  18255. }
  18256. declare module BABYLON {
  18257. /**
  18258. * Gather the list of pointer event types as constants.
  18259. */
  18260. export class PointerEventTypes {
  18261. /**
  18262. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18263. */
  18264. static readonly POINTERDOWN: number;
  18265. /**
  18266. * The pointerup event is fired when a pointer is no longer active.
  18267. */
  18268. static readonly POINTERUP: number;
  18269. /**
  18270. * The pointermove event is fired when a pointer changes coordinates.
  18271. */
  18272. static readonly POINTERMOVE: number;
  18273. /**
  18274. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18275. */
  18276. static readonly POINTERWHEEL: number;
  18277. /**
  18278. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18279. */
  18280. static readonly POINTERPICK: number;
  18281. /**
  18282. * The pointertap event is fired when a the object has been touched and released without drag.
  18283. */
  18284. static readonly POINTERTAP: number;
  18285. /**
  18286. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18287. */
  18288. static readonly POINTERDOUBLETAP: number;
  18289. }
  18290. /**
  18291. * Base class of pointer info types.
  18292. */
  18293. export class PointerInfoBase {
  18294. /**
  18295. * Defines the type of event (PointerEventTypes)
  18296. */
  18297. type: number;
  18298. /**
  18299. * Defines the related dom event
  18300. */
  18301. event: PointerEvent | MouseWheelEvent;
  18302. /**
  18303. * Instantiates the base class of pointers info.
  18304. * @param type Defines the type of event (PointerEventTypes)
  18305. * @param event Defines the related dom event
  18306. */
  18307. constructor(
  18308. /**
  18309. * Defines the type of event (PointerEventTypes)
  18310. */
  18311. type: number,
  18312. /**
  18313. * Defines the related dom event
  18314. */
  18315. event: PointerEvent | MouseWheelEvent);
  18316. }
  18317. /**
  18318. * This class is used to store pointer related info for the onPrePointerObservable event.
  18319. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18320. */
  18321. export class PointerInfoPre extends PointerInfoBase {
  18322. /**
  18323. * Ray from a pointer if availible (eg. 6dof controller)
  18324. */
  18325. ray: Nullable<Ray>;
  18326. /**
  18327. * Defines the local position of the pointer on the canvas.
  18328. */
  18329. localPosition: Vector2;
  18330. /**
  18331. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18332. */
  18333. skipOnPointerObservable: boolean;
  18334. /**
  18335. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18336. * @param type Defines the type of event (PointerEventTypes)
  18337. * @param event Defines the related dom event
  18338. * @param localX Defines the local x coordinates of the pointer when the event occured
  18339. * @param localY Defines the local y coordinates of the pointer when the event occured
  18340. */
  18341. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18342. }
  18343. /**
  18344. * This type contains all the data related to a pointer event in Babylon.js.
  18345. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18346. */
  18347. export class PointerInfo extends PointerInfoBase {
  18348. /**
  18349. * Defines the picking info associated to the info (if any)\
  18350. */
  18351. pickInfo: Nullable<PickingInfo>;
  18352. /**
  18353. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18354. * @param type Defines the type of event (PointerEventTypes)
  18355. * @param event Defines the related dom event
  18356. * @param pickInfo Defines the picking info associated to the info (if any)\
  18357. */
  18358. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18359. /**
  18360. * Defines the picking info associated to the info (if any)\
  18361. */
  18362. pickInfo: Nullable<PickingInfo>);
  18363. }
  18364. /**
  18365. * Data relating to a touch event on the screen.
  18366. */
  18367. export interface PointerTouch {
  18368. /**
  18369. * X coordinate of touch.
  18370. */
  18371. x: number;
  18372. /**
  18373. * Y coordinate of touch.
  18374. */
  18375. y: number;
  18376. /**
  18377. * Id of touch. Unique for each finger.
  18378. */
  18379. pointerId: number;
  18380. /**
  18381. * Event type passed from DOM.
  18382. */
  18383. type: any;
  18384. }
  18385. }
  18386. declare module BABYLON {
  18387. /**
  18388. * Manage the mouse inputs to control the movement of a free camera.
  18389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18390. */
  18391. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18392. /**
  18393. * Define if touch is enabled in the mouse input
  18394. */
  18395. touchEnabled: boolean;
  18396. /**
  18397. * Defines the camera the input is attached to.
  18398. */
  18399. camera: FreeCamera;
  18400. /**
  18401. * Defines the buttons associated with the input to handle camera move.
  18402. */
  18403. buttons: number[];
  18404. /**
  18405. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18406. */
  18407. angularSensibility: number;
  18408. private _pointerInput;
  18409. private _onMouseMove;
  18410. private _observer;
  18411. private previousPosition;
  18412. /**
  18413. * Observable for when a pointer move event occurs containing the move offset
  18414. */
  18415. onPointerMovedObservable: Observable<{
  18416. offsetX: number;
  18417. offsetY: number;
  18418. }>;
  18419. /**
  18420. * @hidden
  18421. * If the camera should be rotated automatically based on pointer movement
  18422. */
  18423. _allowCameraRotation: boolean;
  18424. /**
  18425. * Manage the mouse inputs to control the movement of a free camera.
  18426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18427. * @param touchEnabled Defines if touch is enabled or not
  18428. */
  18429. constructor(
  18430. /**
  18431. * Define if touch is enabled in the mouse input
  18432. */
  18433. touchEnabled?: boolean);
  18434. /**
  18435. * Attach the input controls to a specific dom element to get the input from.
  18436. * @param element Defines the element the controls should be listened from
  18437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18438. */
  18439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18440. /**
  18441. * Called on JS contextmenu event.
  18442. * Override this method to provide functionality.
  18443. */
  18444. protected onContextMenu(evt: PointerEvent): void;
  18445. /**
  18446. * Detach the current controls from the specified dom element.
  18447. * @param element Defines the element to stop listening the inputs from
  18448. */
  18449. detachControl(element: Nullable<HTMLElement>): void;
  18450. /**
  18451. * Gets the class name of the current intput.
  18452. * @returns the class name
  18453. */
  18454. getClassName(): string;
  18455. /**
  18456. * Get the friendly name associated with the input class.
  18457. * @returns the input friendly name
  18458. */
  18459. getSimpleName(): string;
  18460. }
  18461. }
  18462. declare module BABYLON {
  18463. /**
  18464. * Manage the touch inputs to control the movement of a free camera.
  18465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18466. */
  18467. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18468. /**
  18469. * Defines the camera the input is attached to.
  18470. */
  18471. camera: FreeCamera;
  18472. /**
  18473. * Defines the touch sensibility for rotation.
  18474. * The higher the faster.
  18475. */
  18476. touchAngularSensibility: number;
  18477. /**
  18478. * Defines the touch sensibility for move.
  18479. * The higher the faster.
  18480. */
  18481. touchMoveSensibility: number;
  18482. private _offsetX;
  18483. private _offsetY;
  18484. private _pointerPressed;
  18485. private _pointerInput;
  18486. private _observer;
  18487. private _onLostFocus;
  18488. /**
  18489. * Attach the input controls to a specific dom element to get the input from.
  18490. * @param element Defines the element the controls should be listened from
  18491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18492. */
  18493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18494. /**
  18495. * Detach the current controls from the specified dom element.
  18496. * @param element Defines the element to stop listening the inputs from
  18497. */
  18498. detachControl(element: Nullable<HTMLElement>): void;
  18499. /**
  18500. * Update the current camera state depending on the inputs that have been used this frame.
  18501. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18502. */
  18503. checkInputs(): void;
  18504. /**
  18505. * Gets the class name of the current intput.
  18506. * @returns the class name
  18507. */
  18508. getClassName(): string;
  18509. /**
  18510. * Get the friendly name associated with the input class.
  18511. * @returns the input friendly name
  18512. */
  18513. getSimpleName(): string;
  18514. }
  18515. }
  18516. declare module BABYLON {
  18517. /**
  18518. * Default Inputs manager for the FreeCamera.
  18519. * It groups all the default supported inputs for ease of use.
  18520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18521. */
  18522. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18523. /**
  18524. * @hidden
  18525. */
  18526. _mouseInput: Nullable<FreeCameraMouseInput>;
  18527. /**
  18528. * Instantiates a new FreeCameraInputsManager.
  18529. * @param camera Defines the camera the inputs belong to
  18530. */
  18531. constructor(camera: FreeCamera);
  18532. /**
  18533. * Add keyboard input support to the input manager.
  18534. * @returns the current input manager
  18535. */
  18536. addKeyboard(): FreeCameraInputsManager;
  18537. /**
  18538. * Add mouse input support to the input manager.
  18539. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18540. * @returns the current input manager
  18541. */
  18542. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18543. /**
  18544. * Removes the mouse input support from the manager
  18545. * @returns the current input manager
  18546. */
  18547. removeMouse(): FreeCameraInputsManager;
  18548. /**
  18549. * Add touch input support to the input manager.
  18550. * @returns the current input manager
  18551. */
  18552. addTouch(): FreeCameraInputsManager;
  18553. /**
  18554. * Remove all attached input methods from a camera
  18555. */
  18556. clear(): void;
  18557. }
  18558. }
  18559. declare module BABYLON {
  18560. /**
  18561. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18562. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18563. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18564. */
  18565. export class FreeCamera extends TargetCamera {
  18566. /**
  18567. * Define the collision ellipsoid of the camera.
  18568. * This is helpful to simulate a camera body like the player body around the camera
  18569. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18570. */
  18571. ellipsoid: Vector3;
  18572. /**
  18573. * Define an offset for the position of the ellipsoid around the camera.
  18574. * This can be helpful to determine the center of the body near the gravity center of the body
  18575. * instead of its head.
  18576. */
  18577. ellipsoidOffset: Vector3;
  18578. /**
  18579. * Enable or disable collisions of the camera with the rest of the scene objects.
  18580. */
  18581. checkCollisions: boolean;
  18582. /**
  18583. * Enable or disable gravity on the camera.
  18584. */
  18585. applyGravity: boolean;
  18586. /**
  18587. * Define the input manager associated to the camera.
  18588. */
  18589. inputs: FreeCameraInputsManager;
  18590. /**
  18591. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18592. * Higher values reduce sensitivity.
  18593. */
  18594. get angularSensibility(): number;
  18595. /**
  18596. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18597. * Higher values reduce sensitivity.
  18598. */
  18599. set angularSensibility(value: number);
  18600. /**
  18601. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18602. */
  18603. get keysUp(): number[];
  18604. set keysUp(value: number[]);
  18605. /**
  18606. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18607. */
  18608. get keysUpward(): number[];
  18609. set keysUpward(value: number[]);
  18610. /**
  18611. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18612. */
  18613. get keysDown(): number[];
  18614. set keysDown(value: number[]);
  18615. /**
  18616. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18617. */
  18618. get keysDownward(): number[];
  18619. set keysDownward(value: number[]);
  18620. /**
  18621. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18622. */
  18623. get keysLeft(): number[];
  18624. set keysLeft(value: number[]);
  18625. /**
  18626. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18627. */
  18628. get keysRight(): number[];
  18629. set keysRight(value: number[]);
  18630. /**
  18631. * Event raised when the camera collide with a mesh in the scene.
  18632. */
  18633. onCollide: (collidedMesh: AbstractMesh) => void;
  18634. private _collider;
  18635. private _needMoveForGravity;
  18636. private _oldPosition;
  18637. private _diffPosition;
  18638. private _newPosition;
  18639. /** @hidden */
  18640. _localDirection: Vector3;
  18641. /** @hidden */
  18642. _transformedDirection: Vector3;
  18643. /**
  18644. * Instantiates a Free Camera.
  18645. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18646. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18647. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18648. * @param name Define the name of the camera in the scene
  18649. * @param position Define the start position of the camera in the scene
  18650. * @param scene Define the scene the camera belongs to
  18651. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18652. */
  18653. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18654. /**
  18655. * Attached controls to the current camera.
  18656. * @param element Defines the element the controls should be listened from
  18657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18658. */
  18659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18660. /**
  18661. * Detach the current controls from the camera.
  18662. * The camera will stop reacting to inputs.
  18663. * @param element Defines the element to stop listening the inputs from
  18664. */
  18665. detachControl(element: HTMLElement): void;
  18666. private _collisionMask;
  18667. /**
  18668. * Define a collision mask to limit the list of object the camera can collide with
  18669. */
  18670. get collisionMask(): number;
  18671. set collisionMask(mask: number);
  18672. /** @hidden */
  18673. _collideWithWorld(displacement: Vector3): void;
  18674. private _onCollisionPositionChange;
  18675. /** @hidden */
  18676. _checkInputs(): void;
  18677. /** @hidden */
  18678. _decideIfNeedsToMove(): boolean;
  18679. /** @hidden */
  18680. _updatePosition(): void;
  18681. /**
  18682. * Destroy the camera and release the current resources hold by it.
  18683. */
  18684. dispose(): void;
  18685. /**
  18686. * Gets the current object class name.
  18687. * @return the class name
  18688. */
  18689. getClassName(): string;
  18690. }
  18691. }
  18692. declare module BABYLON {
  18693. /**
  18694. * Represents a gamepad control stick position
  18695. */
  18696. export class StickValues {
  18697. /**
  18698. * The x component of the control stick
  18699. */
  18700. x: number;
  18701. /**
  18702. * The y component of the control stick
  18703. */
  18704. y: number;
  18705. /**
  18706. * Initializes the gamepad x and y control stick values
  18707. * @param x The x component of the gamepad control stick value
  18708. * @param y The y component of the gamepad control stick value
  18709. */
  18710. constructor(
  18711. /**
  18712. * The x component of the control stick
  18713. */
  18714. x: number,
  18715. /**
  18716. * The y component of the control stick
  18717. */
  18718. y: number);
  18719. }
  18720. /**
  18721. * An interface which manages callbacks for gamepad button changes
  18722. */
  18723. export interface GamepadButtonChanges {
  18724. /**
  18725. * Called when a gamepad has been changed
  18726. */
  18727. changed: boolean;
  18728. /**
  18729. * Called when a gamepad press event has been triggered
  18730. */
  18731. pressChanged: boolean;
  18732. /**
  18733. * Called when a touch event has been triggered
  18734. */
  18735. touchChanged: boolean;
  18736. /**
  18737. * Called when a value has changed
  18738. */
  18739. valueChanged: boolean;
  18740. }
  18741. /**
  18742. * Represents a gamepad
  18743. */
  18744. export class Gamepad {
  18745. /**
  18746. * The id of the gamepad
  18747. */
  18748. id: string;
  18749. /**
  18750. * The index of the gamepad
  18751. */
  18752. index: number;
  18753. /**
  18754. * The browser gamepad
  18755. */
  18756. browserGamepad: any;
  18757. /**
  18758. * Specifies what type of gamepad this represents
  18759. */
  18760. type: number;
  18761. private _leftStick;
  18762. private _rightStick;
  18763. /** @hidden */
  18764. _isConnected: boolean;
  18765. private _leftStickAxisX;
  18766. private _leftStickAxisY;
  18767. private _rightStickAxisX;
  18768. private _rightStickAxisY;
  18769. /**
  18770. * Triggered when the left control stick has been changed
  18771. */
  18772. private _onleftstickchanged;
  18773. /**
  18774. * Triggered when the right control stick has been changed
  18775. */
  18776. private _onrightstickchanged;
  18777. /**
  18778. * Represents a gamepad controller
  18779. */
  18780. static GAMEPAD: number;
  18781. /**
  18782. * Represents a generic controller
  18783. */
  18784. static GENERIC: number;
  18785. /**
  18786. * Represents an XBox controller
  18787. */
  18788. static XBOX: number;
  18789. /**
  18790. * Represents a pose-enabled controller
  18791. */
  18792. static POSE_ENABLED: number;
  18793. /**
  18794. * Represents an Dual Shock controller
  18795. */
  18796. static DUALSHOCK: number;
  18797. /**
  18798. * Specifies whether the left control stick should be Y-inverted
  18799. */
  18800. protected _invertLeftStickY: boolean;
  18801. /**
  18802. * Specifies if the gamepad has been connected
  18803. */
  18804. get isConnected(): boolean;
  18805. /**
  18806. * Initializes the gamepad
  18807. * @param id The id of the gamepad
  18808. * @param index The index of the gamepad
  18809. * @param browserGamepad The browser gamepad
  18810. * @param leftStickX The x component of the left joystick
  18811. * @param leftStickY The y component of the left joystick
  18812. * @param rightStickX The x component of the right joystick
  18813. * @param rightStickY The y component of the right joystick
  18814. */
  18815. constructor(
  18816. /**
  18817. * The id of the gamepad
  18818. */
  18819. id: string,
  18820. /**
  18821. * The index of the gamepad
  18822. */
  18823. index: number,
  18824. /**
  18825. * The browser gamepad
  18826. */
  18827. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18828. /**
  18829. * Callback triggered when the left joystick has changed
  18830. * @param callback
  18831. */
  18832. onleftstickchanged(callback: (values: StickValues) => void): void;
  18833. /**
  18834. * Callback triggered when the right joystick has changed
  18835. * @param callback
  18836. */
  18837. onrightstickchanged(callback: (values: StickValues) => void): void;
  18838. /**
  18839. * Gets the left joystick
  18840. */
  18841. get leftStick(): StickValues;
  18842. /**
  18843. * Sets the left joystick values
  18844. */
  18845. set leftStick(newValues: StickValues);
  18846. /**
  18847. * Gets the right joystick
  18848. */
  18849. get rightStick(): StickValues;
  18850. /**
  18851. * Sets the right joystick value
  18852. */
  18853. set rightStick(newValues: StickValues);
  18854. /**
  18855. * Updates the gamepad joystick positions
  18856. */
  18857. update(): void;
  18858. /**
  18859. * Disposes the gamepad
  18860. */
  18861. dispose(): void;
  18862. }
  18863. /**
  18864. * Represents a generic gamepad
  18865. */
  18866. export class GenericPad extends Gamepad {
  18867. private _buttons;
  18868. private _onbuttondown;
  18869. private _onbuttonup;
  18870. /**
  18871. * Observable triggered when a button has been pressed
  18872. */
  18873. onButtonDownObservable: Observable<number>;
  18874. /**
  18875. * Observable triggered when a button has been released
  18876. */
  18877. onButtonUpObservable: Observable<number>;
  18878. /**
  18879. * Callback triggered when a button has been pressed
  18880. * @param callback Called when a button has been pressed
  18881. */
  18882. onbuttondown(callback: (buttonPressed: number) => void): void;
  18883. /**
  18884. * Callback triggered when a button has been released
  18885. * @param callback Called when a button has been released
  18886. */
  18887. onbuttonup(callback: (buttonReleased: number) => void): void;
  18888. /**
  18889. * Initializes the generic gamepad
  18890. * @param id The id of the generic gamepad
  18891. * @param index The index of the generic gamepad
  18892. * @param browserGamepad The browser gamepad
  18893. */
  18894. constructor(id: string, index: number, browserGamepad: any);
  18895. private _setButtonValue;
  18896. /**
  18897. * Updates the generic gamepad
  18898. */
  18899. update(): void;
  18900. /**
  18901. * Disposes the generic gamepad
  18902. */
  18903. dispose(): void;
  18904. }
  18905. }
  18906. declare module BABYLON {
  18907. /**
  18908. * Defines the types of pose enabled controllers that are supported
  18909. */
  18910. export enum PoseEnabledControllerType {
  18911. /**
  18912. * HTC Vive
  18913. */
  18914. VIVE = 0,
  18915. /**
  18916. * Oculus Rift
  18917. */
  18918. OCULUS = 1,
  18919. /**
  18920. * Windows mixed reality
  18921. */
  18922. WINDOWS = 2,
  18923. /**
  18924. * Samsung gear VR
  18925. */
  18926. GEAR_VR = 3,
  18927. /**
  18928. * Google Daydream
  18929. */
  18930. DAYDREAM = 4,
  18931. /**
  18932. * Generic
  18933. */
  18934. GENERIC = 5
  18935. }
  18936. /**
  18937. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18938. */
  18939. export interface MutableGamepadButton {
  18940. /**
  18941. * Value of the button/trigger
  18942. */
  18943. value: number;
  18944. /**
  18945. * If the button/trigger is currently touched
  18946. */
  18947. touched: boolean;
  18948. /**
  18949. * If the button/trigger is currently pressed
  18950. */
  18951. pressed: boolean;
  18952. }
  18953. /**
  18954. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18955. * @hidden
  18956. */
  18957. export interface ExtendedGamepadButton extends GamepadButton {
  18958. /**
  18959. * If the button/trigger is currently pressed
  18960. */
  18961. readonly pressed: boolean;
  18962. /**
  18963. * If the button/trigger is currently touched
  18964. */
  18965. readonly touched: boolean;
  18966. /**
  18967. * Value of the button/trigger
  18968. */
  18969. readonly value: number;
  18970. }
  18971. /** @hidden */
  18972. export interface _GamePadFactory {
  18973. /**
  18974. * Returns whether or not the current gamepad can be created for this type of controller.
  18975. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18976. * @returns true if it can be created, otherwise false
  18977. */
  18978. canCreate(gamepadInfo: any): boolean;
  18979. /**
  18980. * Creates a new instance of the Gamepad.
  18981. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18982. * @returns the new gamepad instance
  18983. */
  18984. create(gamepadInfo: any): Gamepad;
  18985. }
  18986. /**
  18987. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18988. */
  18989. export class PoseEnabledControllerHelper {
  18990. /** @hidden */
  18991. static _ControllerFactories: _GamePadFactory[];
  18992. /** @hidden */
  18993. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18994. /**
  18995. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18996. * @param vrGamepad the gamepad to initialized
  18997. * @returns a vr controller of the type the gamepad identified as
  18998. */
  18999. static InitiateController(vrGamepad: any): Gamepad;
  19000. }
  19001. /**
  19002. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19003. */
  19004. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19005. /**
  19006. * If the controller is used in a webXR session
  19007. */
  19008. isXR: boolean;
  19009. private _deviceRoomPosition;
  19010. private _deviceRoomRotationQuaternion;
  19011. /**
  19012. * The device position in babylon space
  19013. */
  19014. devicePosition: Vector3;
  19015. /**
  19016. * The device rotation in babylon space
  19017. */
  19018. deviceRotationQuaternion: Quaternion;
  19019. /**
  19020. * The scale factor of the device in babylon space
  19021. */
  19022. deviceScaleFactor: number;
  19023. /**
  19024. * (Likely devicePosition should be used instead) The device position in its room space
  19025. */
  19026. position: Vector3;
  19027. /**
  19028. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19029. */
  19030. rotationQuaternion: Quaternion;
  19031. /**
  19032. * The type of controller (Eg. Windows mixed reality)
  19033. */
  19034. controllerType: PoseEnabledControllerType;
  19035. protected _calculatedPosition: Vector3;
  19036. private _calculatedRotation;
  19037. /**
  19038. * The raw pose from the device
  19039. */
  19040. rawPose: DevicePose;
  19041. private _trackPosition;
  19042. private _maxRotationDistFromHeadset;
  19043. private _draggedRoomRotation;
  19044. /**
  19045. * @hidden
  19046. */
  19047. _disableTrackPosition(fixedPosition: Vector3): void;
  19048. /**
  19049. * Internal, the mesh attached to the controller
  19050. * @hidden
  19051. */
  19052. _mesh: Nullable<AbstractMesh>;
  19053. private _poseControlledCamera;
  19054. private _leftHandSystemQuaternion;
  19055. /**
  19056. * Internal, matrix used to convert room space to babylon space
  19057. * @hidden
  19058. */
  19059. _deviceToWorld: Matrix;
  19060. /**
  19061. * Node to be used when casting a ray from the controller
  19062. * @hidden
  19063. */
  19064. _pointingPoseNode: Nullable<TransformNode>;
  19065. /**
  19066. * Name of the child mesh that can be used to cast a ray from the controller
  19067. */
  19068. static readonly POINTING_POSE: string;
  19069. /**
  19070. * Creates a new PoseEnabledController from a gamepad
  19071. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19072. */
  19073. constructor(browserGamepad: any);
  19074. private _workingMatrix;
  19075. /**
  19076. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19077. */
  19078. update(): void;
  19079. /**
  19080. * Updates only the pose device and mesh without doing any button event checking
  19081. */
  19082. protected _updatePoseAndMesh(): void;
  19083. /**
  19084. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19085. * @param poseData raw pose fromthe device
  19086. */
  19087. updateFromDevice(poseData: DevicePose): void;
  19088. /**
  19089. * @hidden
  19090. */
  19091. _meshAttachedObservable: Observable<AbstractMesh>;
  19092. /**
  19093. * Attaches a mesh to the controller
  19094. * @param mesh the mesh to be attached
  19095. */
  19096. attachToMesh(mesh: AbstractMesh): void;
  19097. /**
  19098. * Attaches the controllers mesh to a camera
  19099. * @param camera the camera the mesh should be attached to
  19100. */
  19101. attachToPoseControlledCamera(camera: TargetCamera): void;
  19102. /**
  19103. * Disposes of the controller
  19104. */
  19105. dispose(): void;
  19106. /**
  19107. * The mesh that is attached to the controller
  19108. */
  19109. get mesh(): Nullable<AbstractMesh>;
  19110. /**
  19111. * Gets the ray of the controller in the direction the controller is pointing
  19112. * @param length the length the resulting ray should be
  19113. * @returns a ray in the direction the controller is pointing
  19114. */
  19115. getForwardRay(length?: number): Ray;
  19116. }
  19117. }
  19118. declare module BABYLON {
  19119. /**
  19120. * Defines the WebVRController object that represents controllers tracked in 3D space
  19121. */
  19122. export abstract class WebVRController extends PoseEnabledController {
  19123. /**
  19124. * Internal, the default controller model for the controller
  19125. */
  19126. protected _defaultModel: Nullable<AbstractMesh>;
  19127. /**
  19128. * Fired when the trigger state has changed
  19129. */
  19130. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19131. /**
  19132. * Fired when the main button state has changed
  19133. */
  19134. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19135. /**
  19136. * Fired when the secondary button state has changed
  19137. */
  19138. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19139. /**
  19140. * Fired when the pad state has changed
  19141. */
  19142. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19143. /**
  19144. * Fired when controllers stick values have changed
  19145. */
  19146. onPadValuesChangedObservable: Observable<StickValues>;
  19147. /**
  19148. * Array of button availible on the controller
  19149. */
  19150. protected _buttons: Array<MutableGamepadButton>;
  19151. private _onButtonStateChange;
  19152. /**
  19153. * Fired when a controller button's state has changed
  19154. * @param callback the callback containing the button that was modified
  19155. */
  19156. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19157. /**
  19158. * X and Y axis corresponding to the controllers joystick
  19159. */
  19160. pad: StickValues;
  19161. /**
  19162. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19163. */
  19164. hand: string;
  19165. /**
  19166. * The default controller model for the controller
  19167. */
  19168. get defaultModel(): Nullable<AbstractMesh>;
  19169. /**
  19170. * Creates a new WebVRController from a gamepad
  19171. * @param vrGamepad the gamepad that the WebVRController should be created from
  19172. */
  19173. constructor(vrGamepad: any);
  19174. /**
  19175. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19176. */
  19177. update(): void;
  19178. /**
  19179. * Function to be called when a button is modified
  19180. */
  19181. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19182. /**
  19183. * Loads a mesh and attaches it to the controller
  19184. * @param scene the scene the mesh should be added to
  19185. * @param meshLoaded callback for when the mesh has been loaded
  19186. */
  19187. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19188. private _setButtonValue;
  19189. private _changes;
  19190. private _checkChanges;
  19191. /**
  19192. * Disposes of th webVRCOntroller
  19193. */
  19194. dispose(): void;
  19195. }
  19196. }
  19197. declare module BABYLON {
  19198. /**
  19199. * The HemisphericLight simulates the ambient environment light,
  19200. * so the passed direction is the light reflection direction, not the incoming direction.
  19201. */
  19202. export class HemisphericLight extends Light {
  19203. /**
  19204. * The groundColor is the light in the opposite direction to the one specified during creation.
  19205. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19206. */
  19207. groundColor: Color3;
  19208. /**
  19209. * The light reflection direction, not the incoming direction.
  19210. */
  19211. direction: Vector3;
  19212. /**
  19213. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19214. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19215. * The HemisphericLight can't cast shadows.
  19216. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19217. * @param name The friendly name of the light
  19218. * @param direction The direction of the light reflection
  19219. * @param scene The scene the light belongs to
  19220. */
  19221. constructor(name: string, direction: Vector3, scene: Scene);
  19222. protected _buildUniformLayout(): void;
  19223. /**
  19224. * Returns the string "HemisphericLight".
  19225. * @return The class name
  19226. */
  19227. getClassName(): string;
  19228. /**
  19229. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19230. * Returns the updated direction.
  19231. * @param target The target the direction should point to
  19232. * @return The computed direction
  19233. */
  19234. setDirectionToTarget(target: Vector3): Vector3;
  19235. /**
  19236. * Returns the shadow generator associated to the light.
  19237. * @returns Always null for hemispheric lights because it does not support shadows.
  19238. */
  19239. getShadowGenerator(): Nullable<IShadowGenerator>;
  19240. /**
  19241. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19242. * @param effect The effect to update
  19243. * @param lightIndex The index of the light in the effect to update
  19244. * @returns The hemispheric light
  19245. */
  19246. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19247. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19248. /**
  19249. * Computes the world matrix of the node
  19250. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19251. * @param useWasUpdatedFlag defines a reserved property
  19252. * @returns the world matrix
  19253. */
  19254. computeWorldMatrix(): Matrix;
  19255. /**
  19256. * Returns the integer 3.
  19257. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19258. */
  19259. getTypeID(): number;
  19260. /**
  19261. * Prepares the list of defines specific to the light type.
  19262. * @param defines the list of defines
  19263. * @param lightIndex defines the index of the light for the effect
  19264. */
  19265. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19266. }
  19267. }
  19268. declare module BABYLON {
  19269. /** @hidden */
  19270. export var vrMultiviewToSingleviewPixelShader: {
  19271. name: string;
  19272. shader: string;
  19273. };
  19274. }
  19275. declare module BABYLON {
  19276. /**
  19277. * Renders to multiple views with a single draw call
  19278. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19279. */
  19280. export class MultiviewRenderTarget extends RenderTargetTexture {
  19281. /**
  19282. * Creates a multiview render target
  19283. * @param scene scene used with the render target
  19284. * @param size the size of the render target (used for each view)
  19285. */
  19286. constructor(scene: Scene, size?: number | {
  19287. width: number;
  19288. height: number;
  19289. } | {
  19290. ratio: number;
  19291. });
  19292. /**
  19293. * @hidden
  19294. * @param faceIndex the face index, if its a cube texture
  19295. */
  19296. _bindFrameBuffer(faceIndex?: number): void;
  19297. /**
  19298. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19299. * @returns the view count
  19300. */
  19301. getViewCount(): number;
  19302. }
  19303. }
  19304. declare module BABYLON {
  19305. /**
  19306. * Represents a camera frustum
  19307. */
  19308. export class Frustum {
  19309. /**
  19310. * Gets the planes representing the frustum
  19311. * @param transform matrix to be applied to the returned planes
  19312. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19313. */
  19314. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19315. /**
  19316. * Gets the near frustum plane transformed by the transform matrix
  19317. * @param transform transformation matrix to be applied to the resulting frustum plane
  19318. * @param frustumPlane the resuling frustum plane
  19319. */
  19320. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19321. /**
  19322. * Gets the far frustum plane transformed by the transform matrix
  19323. * @param transform transformation matrix to be applied to the resulting frustum plane
  19324. * @param frustumPlane the resuling frustum plane
  19325. */
  19326. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19327. /**
  19328. * Gets the left frustum plane transformed by the transform matrix
  19329. * @param transform transformation matrix to be applied to the resulting frustum plane
  19330. * @param frustumPlane the resuling frustum plane
  19331. */
  19332. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19333. /**
  19334. * Gets the right frustum plane transformed by the transform matrix
  19335. * @param transform transformation matrix to be applied to the resulting frustum plane
  19336. * @param frustumPlane the resuling frustum plane
  19337. */
  19338. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19339. /**
  19340. * Gets the top frustum plane transformed by the transform matrix
  19341. * @param transform transformation matrix to be applied to the resulting frustum plane
  19342. * @param frustumPlane the resuling frustum plane
  19343. */
  19344. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19345. /**
  19346. * Gets the bottom frustum plane transformed by the transform matrix
  19347. * @param transform transformation matrix to be applied to the resulting frustum plane
  19348. * @param frustumPlane the resuling frustum plane
  19349. */
  19350. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19351. /**
  19352. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19353. * @param transform transformation matrix to be applied to the resulting frustum planes
  19354. * @param frustumPlanes the resuling frustum planes
  19355. */
  19356. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19357. }
  19358. }
  19359. declare module BABYLON {
  19360. interface Engine {
  19361. /**
  19362. * Creates a new multiview render target
  19363. * @param width defines the width of the texture
  19364. * @param height defines the height of the texture
  19365. * @returns the created multiview texture
  19366. */
  19367. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19368. /**
  19369. * Binds a multiview framebuffer to be drawn to
  19370. * @param multiviewTexture texture to bind
  19371. */
  19372. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19373. }
  19374. interface Camera {
  19375. /**
  19376. * @hidden
  19377. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19378. */
  19379. _useMultiviewToSingleView: boolean;
  19380. /**
  19381. * @hidden
  19382. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19383. */
  19384. _multiviewTexture: Nullable<RenderTargetTexture>;
  19385. /**
  19386. * @hidden
  19387. * ensures the multiview texture of the camera exists and has the specified width/height
  19388. * @param width height to set on the multiview texture
  19389. * @param height width to set on the multiview texture
  19390. */
  19391. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19392. }
  19393. interface Scene {
  19394. /** @hidden */
  19395. _transformMatrixR: Matrix;
  19396. /** @hidden */
  19397. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19398. /** @hidden */
  19399. _createMultiviewUbo(): void;
  19400. /** @hidden */
  19401. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19402. /** @hidden */
  19403. _renderMultiviewToSingleView(camera: Camera): void;
  19404. }
  19405. }
  19406. declare module BABYLON {
  19407. /**
  19408. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19409. * This will not be used for webXR as it supports displaying texture arrays directly
  19410. */
  19411. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19412. /**
  19413. * Initializes a VRMultiviewToSingleview
  19414. * @param name name of the post process
  19415. * @param camera camera to be applied to
  19416. * @param scaleFactor scaling factor to the size of the output texture
  19417. */
  19418. constructor(name: string, camera: Camera, scaleFactor: number);
  19419. }
  19420. }
  19421. declare module BABYLON {
  19422. /**
  19423. * Interface used to define additional presentation attributes
  19424. */
  19425. export interface IVRPresentationAttributes {
  19426. /**
  19427. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19428. */
  19429. highRefreshRate: boolean;
  19430. /**
  19431. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19432. */
  19433. foveationLevel: number;
  19434. }
  19435. interface Engine {
  19436. /** @hidden */
  19437. _vrDisplay: any;
  19438. /** @hidden */
  19439. _vrSupported: boolean;
  19440. /** @hidden */
  19441. _oldSize: Size;
  19442. /** @hidden */
  19443. _oldHardwareScaleFactor: number;
  19444. /** @hidden */
  19445. _vrExclusivePointerMode: boolean;
  19446. /** @hidden */
  19447. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19448. /** @hidden */
  19449. _onVRDisplayPointerRestricted: () => void;
  19450. /** @hidden */
  19451. _onVRDisplayPointerUnrestricted: () => void;
  19452. /** @hidden */
  19453. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19454. /** @hidden */
  19455. _onVrDisplayDisconnect: Nullable<() => void>;
  19456. /** @hidden */
  19457. _onVrDisplayPresentChange: Nullable<() => void>;
  19458. /**
  19459. * Observable signaled when VR display mode changes
  19460. */
  19461. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19462. /**
  19463. * Observable signaled when VR request present is complete
  19464. */
  19465. onVRRequestPresentComplete: Observable<boolean>;
  19466. /**
  19467. * Observable signaled when VR request present starts
  19468. */
  19469. onVRRequestPresentStart: Observable<Engine>;
  19470. /**
  19471. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19472. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19473. */
  19474. isInVRExclusivePointerMode: boolean;
  19475. /**
  19476. * Gets a boolean indicating if a webVR device was detected
  19477. * @returns true if a webVR device was detected
  19478. */
  19479. isVRDevicePresent(): boolean;
  19480. /**
  19481. * Gets the current webVR device
  19482. * @returns the current webVR device (or null)
  19483. */
  19484. getVRDevice(): any;
  19485. /**
  19486. * Initializes a webVR display and starts listening to display change events
  19487. * The onVRDisplayChangedObservable will be notified upon these changes
  19488. * @returns A promise containing a VRDisplay and if vr is supported
  19489. */
  19490. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19491. /** @hidden */
  19492. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19493. /**
  19494. * Gets or sets the presentation attributes used to configure VR rendering
  19495. */
  19496. vrPresentationAttributes?: IVRPresentationAttributes;
  19497. /**
  19498. * Call this function to switch to webVR mode
  19499. * Will do nothing if webVR is not supported or if there is no webVR device
  19500. * @param options the webvr options provided to the camera. mainly used for multiview
  19501. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19502. */
  19503. enableVR(options: WebVROptions): void;
  19504. /** @hidden */
  19505. _onVRFullScreenTriggered(): void;
  19506. }
  19507. }
  19508. declare module BABYLON {
  19509. /**
  19510. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19511. * IMPORTANT!! The data is right-hand data.
  19512. * @export
  19513. * @interface DevicePose
  19514. */
  19515. export interface DevicePose {
  19516. /**
  19517. * The position of the device, values in array are [x,y,z].
  19518. */
  19519. readonly position: Nullable<Float32Array>;
  19520. /**
  19521. * The linearVelocity of the device, values in array are [x,y,z].
  19522. */
  19523. readonly linearVelocity: Nullable<Float32Array>;
  19524. /**
  19525. * The linearAcceleration of the device, values in array are [x,y,z].
  19526. */
  19527. readonly linearAcceleration: Nullable<Float32Array>;
  19528. /**
  19529. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19530. */
  19531. readonly orientation: Nullable<Float32Array>;
  19532. /**
  19533. * The angularVelocity of the device, values in array are [x,y,z].
  19534. */
  19535. readonly angularVelocity: Nullable<Float32Array>;
  19536. /**
  19537. * The angularAcceleration of the device, values in array are [x,y,z].
  19538. */
  19539. readonly angularAcceleration: Nullable<Float32Array>;
  19540. }
  19541. /**
  19542. * Interface representing a pose controlled object in Babylon.
  19543. * A pose controlled object has both regular pose values as well as pose values
  19544. * from an external device such as a VR head mounted display
  19545. */
  19546. export interface PoseControlled {
  19547. /**
  19548. * The position of the object in babylon space.
  19549. */
  19550. position: Vector3;
  19551. /**
  19552. * The rotation quaternion of the object in babylon space.
  19553. */
  19554. rotationQuaternion: Quaternion;
  19555. /**
  19556. * The position of the device in babylon space.
  19557. */
  19558. devicePosition?: Vector3;
  19559. /**
  19560. * The rotation quaternion of the device in babylon space.
  19561. */
  19562. deviceRotationQuaternion: Quaternion;
  19563. /**
  19564. * The raw pose coming from the device.
  19565. */
  19566. rawPose: Nullable<DevicePose>;
  19567. /**
  19568. * The scale of the device to be used when translating from device space to babylon space.
  19569. */
  19570. deviceScaleFactor: number;
  19571. /**
  19572. * Updates the poseControlled values based on the input device pose.
  19573. * @param poseData the pose data to update the object with
  19574. */
  19575. updateFromDevice(poseData: DevicePose): void;
  19576. }
  19577. /**
  19578. * Set of options to customize the webVRCamera
  19579. */
  19580. export interface WebVROptions {
  19581. /**
  19582. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19583. */
  19584. trackPosition?: boolean;
  19585. /**
  19586. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19587. */
  19588. positionScale?: number;
  19589. /**
  19590. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19591. */
  19592. displayName?: string;
  19593. /**
  19594. * Should the native controller meshes be initialized. (default: true)
  19595. */
  19596. controllerMeshes?: boolean;
  19597. /**
  19598. * Creating a default HemiLight only on controllers. (default: true)
  19599. */
  19600. defaultLightingOnControllers?: boolean;
  19601. /**
  19602. * If you don't want to use the default VR button of the helper. (default: false)
  19603. */
  19604. useCustomVRButton?: boolean;
  19605. /**
  19606. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19607. */
  19608. customVRButton?: HTMLButtonElement;
  19609. /**
  19610. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19611. */
  19612. rayLength?: number;
  19613. /**
  19614. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19615. */
  19616. defaultHeight?: number;
  19617. /**
  19618. * If multiview should be used if availible (default: false)
  19619. */
  19620. useMultiview?: boolean;
  19621. }
  19622. /**
  19623. * This represents a WebVR camera.
  19624. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19625. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19626. */
  19627. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19628. private webVROptions;
  19629. /**
  19630. * @hidden
  19631. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19632. */
  19633. _vrDevice: any;
  19634. /**
  19635. * The rawPose of the vrDevice.
  19636. */
  19637. rawPose: Nullable<DevicePose>;
  19638. private _onVREnabled;
  19639. private _specsVersion;
  19640. private _attached;
  19641. private _frameData;
  19642. protected _descendants: Array<Node>;
  19643. private _deviceRoomPosition;
  19644. /** @hidden */
  19645. _deviceRoomRotationQuaternion: Quaternion;
  19646. private _standingMatrix;
  19647. /**
  19648. * Represents device position in babylon space.
  19649. */
  19650. devicePosition: Vector3;
  19651. /**
  19652. * Represents device rotation in babylon space.
  19653. */
  19654. deviceRotationQuaternion: Quaternion;
  19655. /**
  19656. * The scale of the device to be used when translating from device space to babylon space.
  19657. */
  19658. deviceScaleFactor: number;
  19659. private _deviceToWorld;
  19660. private _worldToDevice;
  19661. /**
  19662. * References to the webVR controllers for the vrDevice.
  19663. */
  19664. controllers: Array<WebVRController>;
  19665. /**
  19666. * Emits an event when a controller is attached.
  19667. */
  19668. onControllersAttachedObservable: Observable<WebVRController[]>;
  19669. /**
  19670. * Emits an event when a controller's mesh has been loaded;
  19671. */
  19672. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19673. /**
  19674. * Emits an event when the HMD's pose has been updated.
  19675. */
  19676. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19677. private _poseSet;
  19678. /**
  19679. * If the rig cameras be used as parent instead of this camera.
  19680. */
  19681. rigParenting: boolean;
  19682. private _lightOnControllers;
  19683. private _defaultHeight?;
  19684. /**
  19685. * Instantiates a WebVRFreeCamera.
  19686. * @param name The name of the WebVRFreeCamera
  19687. * @param position The starting anchor position for the camera
  19688. * @param scene The scene the camera belongs to
  19689. * @param webVROptions a set of customizable options for the webVRCamera
  19690. */
  19691. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19692. /**
  19693. * Gets the device distance from the ground in meters.
  19694. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  19695. */
  19696. deviceDistanceToRoomGround(): number;
  19697. /**
  19698. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19699. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19700. */
  19701. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19702. /**
  19703. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19704. * @returns A promise with a boolean set to if the standing matrix is supported.
  19705. */
  19706. useStandingMatrixAsync(): Promise<boolean>;
  19707. /**
  19708. * Disposes the camera
  19709. */
  19710. dispose(): void;
  19711. /**
  19712. * Gets a vrController by name.
  19713. * @param name The name of the controller to retreive
  19714. * @returns the controller matching the name specified or null if not found
  19715. */
  19716. getControllerByName(name: string): Nullable<WebVRController>;
  19717. private _leftController;
  19718. /**
  19719. * The controller corresponding to the users left hand.
  19720. */
  19721. get leftController(): Nullable<WebVRController>;
  19722. private _rightController;
  19723. /**
  19724. * The controller corresponding to the users right hand.
  19725. */
  19726. get rightController(): Nullable<WebVRController>;
  19727. /**
  19728. * Casts a ray forward from the vrCamera's gaze.
  19729. * @param length Length of the ray (default: 100)
  19730. * @returns the ray corresponding to the gaze
  19731. */
  19732. getForwardRay(length?: number): Ray;
  19733. /**
  19734. * @hidden
  19735. * Updates the camera based on device's frame data
  19736. */
  19737. _checkInputs(): void;
  19738. /**
  19739. * Updates the poseControlled values based on the input device pose.
  19740. * @param poseData Pose coming from the device
  19741. */
  19742. updateFromDevice(poseData: DevicePose): void;
  19743. private _htmlElementAttached;
  19744. private _detachIfAttached;
  19745. /**
  19746. * WebVR's attach control will start broadcasting frames to the device.
  19747. * Note that in certain browsers (chrome for example) this function must be called
  19748. * within a user-interaction callback. Example:
  19749. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19750. *
  19751. * @param element html element to attach the vrDevice to
  19752. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19753. */
  19754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19755. /**
  19756. * Detaches the camera from the html element and disables VR
  19757. *
  19758. * @param element html element to detach from
  19759. */
  19760. detachControl(element: HTMLElement): void;
  19761. /**
  19762. * @returns the name of this class
  19763. */
  19764. getClassName(): string;
  19765. /**
  19766. * Calls resetPose on the vrDisplay
  19767. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19768. */
  19769. resetToCurrentRotation(): void;
  19770. /**
  19771. * @hidden
  19772. * Updates the rig cameras (left and right eye)
  19773. */
  19774. _updateRigCameras(): void;
  19775. private _workingVector;
  19776. private _oneVector;
  19777. private _workingMatrix;
  19778. private updateCacheCalled;
  19779. private _correctPositionIfNotTrackPosition;
  19780. /**
  19781. * @hidden
  19782. * Updates the cached values of the camera
  19783. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19784. */
  19785. _updateCache(ignoreParentClass?: boolean): void;
  19786. /**
  19787. * @hidden
  19788. * Get current device position in babylon world
  19789. */
  19790. _computeDevicePosition(): void;
  19791. /**
  19792. * Updates the current device position and rotation in the babylon world
  19793. */
  19794. update(): void;
  19795. /**
  19796. * @hidden
  19797. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19798. * @returns an identity matrix
  19799. */
  19800. _getViewMatrix(): Matrix;
  19801. private _tmpMatrix;
  19802. /**
  19803. * This function is called by the two RIG cameras.
  19804. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19805. * @hidden
  19806. */
  19807. _getWebVRViewMatrix(): Matrix;
  19808. /** @hidden */
  19809. _getWebVRProjectionMatrix(): Matrix;
  19810. private _onGamepadConnectedObserver;
  19811. private _onGamepadDisconnectedObserver;
  19812. private _updateCacheWhenTrackingDisabledObserver;
  19813. /**
  19814. * Initializes the controllers and their meshes
  19815. */
  19816. initControllers(): void;
  19817. }
  19818. }
  19819. declare module BABYLON {
  19820. /**
  19821. * Size options for a post process
  19822. */
  19823. export type PostProcessOptions = {
  19824. width: number;
  19825. height: number;
  19826. };
  19827. /**
  19828. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19829. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19830. */
  19831. export class PostProcess {
  19832. /** Name of the PostProcess. */
  19833. name: string;
  19834. /**
  19835. * Gets or sets the unique id of the post process
  19836. */
  19837. uniqueId: number;
  19838. /**
  19839. * Width of the texture to apply the post process on
  19840. */
  19841. width: number;
  19842. /**
  19843. * Height of the texture to apply the post process on
  19844. */
  19845. height: number;
  19846. /**
  19847. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19848. * @hidden
  19849. */
  19850. _outputTexture: Nullable<InternalTexture>;
  19851. /**
  19852. * Sampling mode used by the shader
  19853. * See https://doc.babylonjs.com/classes/3.1/texture
  19854. */
  19855. renderTargetSamplingMode: number;
  19856. /**
  19857. * Clear color to use when screen clearing
  19858. */
  19859. clearColor: Color4;
  19860. /**
  19861. * If the buffer needs to be cleared before applying the post process. (default: true)
  19862. * Should be set to false if shader will overwrite all previous pixels.
  19863. */
  19864. autoClear: boolean;
  19865. /**
  19866. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19867. */
  19868. alphaMode: number;
  19869. /**
  19870. * Sets the setAlphaBlendConstants of the babylon engine
  19871. */
  19872. alphaConstants: Color4;
  19873. /**
  19874. * Animations to be used for the post processing
  19875. */
  19876. animations: Animation[];
  19877. /**
  19878. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19879. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19880. */
  19881. enablePixelPerfectMode: boolean;
  19882. /**
  19883. * Force the postprocess to be applied without taking in account viewport
  19884. */
  19885. forceFullscreenViewport: boolean;
  19886. /**
  19887. * List of inspectable custom properties (used by the Inspector)
  19888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19889. */
  19890. inspectableCustomProperties: IInspectable[];
  19891. /**
  19892. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19893. *
  19894. * | Value | Type | Description |
  19895. * | ----- | ----------------------------------- | ----------- |
  19896. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19897. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19898. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19899. *
  19900. */
  19901. scaleMode: number;
  19902. /**
  19903. * Force textures to be a power of two (default: false)
  19904. */
  19905. alwaysForcePOT: boolean;
  19906. private _samples;
  19907. /**
  19908. * Number of sample textures (default: 1)
  19909. */
  19910. get samples(): number;
  19911. set samples(n: number);
  19912. /**
  19913. * Modify the scale of the post process to be the same as the viewport (default: false)
  19914. */
  19915. adaptScaleToCurrentViewport: boolean;
  19916. private _camera;
  19917. private _scene;
  19918. private _engine;
  19919. private _options;
  19920. private _reusable;
  19921. private _textureType;
  19922. private _textureFormat;
  19923. /**
  19924. * Smart array of input and output textures for the post process.
  19925. * @hidden
  19926. */
  19927. _textures: SmartArray<InternalTexture>;
  19928. /**
  19929. * The index in _textures that corresponds to the output texture.
  19930. * @hidden
  19931. */
  19932. _currentRenderTextureInd: number;
  19933. private _effect;
  19934. private _samplers;
  19935. private _fragmentUrl;
  19936. private _vertexUrl;
  19937. private _parameters;
  19938. private _scaleRatio;
  19939. protected _indexParameters: any;
  19940. private _shareOutputWithPostProcess;
  19941. private _texelSize;
  19942. private _forcedOutputTexture;
  19943. /**
  19944. * Returns the fragment url or shader name used in the post process.
  19945. * @returns the fragment url or name in the shader store.
  19946. */
  19947. getEffectName(): string;
  19948. /**
  19949. * An event triggered when the postprocess is activated.
  19950. */
  19951. onActivateObservable: Observable<Camera>;
  19952. private _onActivateObserver;
  19953. /**
  19954. * A function that is added to the onActivateObservable
  19955. */
  19956. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19957. /**
  19958. * An event triggered when the postprocess changes its size.
  19959. */
  19960. onSizeChangedObservable: Observable<PostProcess>;
  19961. private _onSizeChangedObserver;
  19962. /**
  19963. * A function that is added to the onSizeChangedObservable
  19964. */
  19965. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19966. /**
  19967. * An event triggered when the postprocess applies its effect.
  19968. */
  19969. onApplyObservable: Observable<Effect>;
  19970. private _onApplyObserver;
  19971. /**
  19972. * A function that is added to the onApplyObservable
  19973. */
  19974. set onApply(callback: (effect: Effect) => void);
  19975. /**
  19976. * An event triggered before rendering the postprocess
  19977. */
  19978. onBeforeRenderObservable: Observable<Effect>;
  19979. private _onBeforeRenderObserver;
  19980. /**
  19981. * A function that is added to the onBeforeRenderObservable
  19982. */
  19983. set onBeforeRender(callback: (effect: Effect) => void);
  19984. /**
  19985. * An event triggered after rendering the postprocess
  19986. */
  19987. onAfterRenderObservable: Observable<Effect>;
  19988. private _onAfterRenderObserver;
  19989. /**
  19990. * A function that is added to the onAfterRenderObservable
  19991. */
  19992. set onAfterRender(callback: (efect: Effect) => void);
  19993. /**
  19994. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  19995. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19996. */
  19997. get inputTexture(): InternalTexture;
  19998. set inputTexture(value: InternalTexture);
  19999. /**
  20000. * Gets the camera which post process is applied to.
  20001. * @returns The camera the post process is applied to.
  20002. */
  20003. getCamera(): Camera;
  20004. /**
  20005. * Gets the texel size of the postprocess.
  20006. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20007. */
  20008. get texelSize(): Vector2;
  20009. /**
  20010. * Creates a new instance PostProcess
  20011. * @param name The name of the PostProcess.
  20012. * @param fragmentUrl The url of the fragment shader to be used.
  20013. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20014. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20015. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20016. * @param camera The camera to apply the render pass to.
  20017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20018. * @param engine The engine which the post process will be applied. (default: current engine)
  20019. * @param reusable If the post process can be reused on the same frame. (default: false)
  20020. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20021. * @param textureType Type of textures used when performing the post process. (default: 0)
  20022. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20023. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20024. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20025. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20026. */
  20027. constructor(
  20028. /** Name of the PostProcess. */
  20029. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  20030. /**
  20031. * Gets a string idenfifying the name of the class
  20032. * @returns "PostProcess" string
  20033. */
  20034. getClassName(): string;
  20035. /**
  20036. * Gets the engine which this post process belongs to.
  20037. * @returns The engine the post process was enabled with.
  20038. */
  20039. getEngine(): Engine;
  20040. /**
  20041. * The effect that is created when initializing the post process.
  20042. * @returns The created effect corresponding the the postprocess.
  20043. */
  20044. getEffect(): Effect;
  20045. /**
  20046. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20047. * @param postProcess The post process to share the output with.
  20048. * @returns This post process.
  20049. */
  20050. shareOutputWith(postProcess: PostProcess): PostProcess;
  20051. /**
  20052. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20053. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20054. */
  20055. useOwnOutput(): void;
  20056. /**
  20057. * Updates the effect with the current post process compile time values and recompiles the shader.
  20058. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20059. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20060. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20061. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20062. * @param onCompiled Called when the shader has been compiled.
  20063. * @param onError Called if there is an error when compiling a shader.
  20064. */
  20065. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20066. /**
  20067. * The post process is reusable if it can be used multiple times within one frame.
  20068. * @returns If the post process is reusable
  20069. */
  20070. isReusable(): boolean;
  20071. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20072. markTextureDirty(): void;
  20073. /**
  20074. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20075. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  20076. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20077. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20078. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20079. * @returns The target texture that was bound to be written to.
  20080. */
  20081. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20082. /**
  20083. * If the post process is supported.
  20084. */
  20085. get isSupported(): boolean;
  20086. /**
  20087. * The aspect ratio of the output texture.
  20088. */
  20089. get aspectRatio(): number;
  20090. /**
  20091. * Get a value indicating if the post-process is ready to be used
  20092. * @returns true if the post-process is ready (shader is compiled)
  20093. */
  20094. isReady(): boolean;
  20095. /**
  20096. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20097. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20098. */
  20099. apply(): Nullable<Effect>;
  20100. private _disposeTextures;
  20101. /**
  20102. * Disposes the post process.
  20103. * @param camera The camera to dispose the post process on.
  20104. */
  20105. dispose(camera?: Camera): void;
  20106. }
  20107. }
  20108. declare module BABYLON {
  20109. /** @hidden */
  20110. export var kernelBlurVaryingDeclaration: {
  20111. name: string;
  20112. shader: string;
  20113. };
  20114. }
  20115. declare module BABYLON {
  20116. /** @hidden */
  20117. export var kernelBlurFragment: {
  20118. name: string;
  20119. shader: string;
  20120. };
  20121. }
  20122. declare module BABYLON {
  20123. /** @hidden */
  20124. export var kernelBlurFragment2: {
  20125. name: string;
  20126. shader: string;
  20127. };
  20128. }
  20129. declare module BABYLON {
  20130. /** @hidden */
  20131. export var kernelBlurPixelShader: {
  20132. name: string;
  20133. shader: string;
  20134. };
  20135. }
  20136. declare module BABYLON {
  20137. /** @hidden */
  20138. export var kernelBlurVertex: {
  20139. name: string;
  20140. shader: string;
  20141. };
  20142. }
  20143. declare module BABYLON {
  20144. /** @hidden */
  20145. export var kernelBlurVertexShader: {
  20146. name: string;
  20147. shader: string;
  20148. };
  20149. }
  20150. declare module BABYLON {
  20151. /**
  20152. * The Blur Post Process which blurs an image based on a kernel and direction.
  20153. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20154. */
  20155. export class BlurPostProcess extends PostProcess {
  20156. /** The direction in which to blur the image. */
  20157. direction: Vector2;
  20158. private blockCompilation;
  20159. protected _kernel: number;
  20160. protected _idealKernel: number;
  20161. protected _packedFloat: boolean;
  20162. private _staticDefines;
  20163. /**
  20164. * Sets the length in pixels of the blur sample region
  20165. */
  20166. set kernel(v: number);
  20167. /**
  20168. * Gets the length in pixels of the blur sample region
  20169. */
  20170. get kernel(): number;
  20171. /**
  20172. * Sets wether or not the blur needs to unpack/repack floats
  20173. */
  20174. set packedFloat(v: boolean);
  20175. /**
  20176. * Gets wether or not the blur is unpacking/repacking floats
  20177. */
  20178. get packedFloat(): boolean;
  20179. /**
  20180. * Creates a new instance BlurPostProcess
  20181. * @param name The name of the effect.
  20182. * @param direction The direction in which to blur the image.
  20183. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  20184. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20185. * @param camera The camera to apply the render pass to.
  20186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20187. * @param engine The engine which the post process will be applied. (default: current engine)
  20188. * @param reusable If the post process can be reused on the same frame. (default: false)
  20189. * @param textureType Type of textures used when performing the post process. (default: 0)
  20190. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20191. */
  20192. constructor(name: string,
  20193. /** The direction in which to blur the image. */
  20194. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20195. /**
  20196. * Updates the effect with the current post process compile time values and recompiles the shader.
  20197. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20198. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20199. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20200. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20201. * @param onCompiled Called when the shader has been compiled.
  20202. * @param onError Called if there is an error when compiling a shader.
  20203. */
  20204. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20205. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20206. /**
  20207. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20208. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20209. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20210. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20211. * The gaps between physical kernels are compensated for in the weighting of the samples
  20212. * @param idealKernel Ideal blur kernel.
  20213. * @return Nearest best kernel.
  20214. */
  20215. protected _nearestBestKernel(idealKernel: number): number;
  20216. /**
  20217. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20218. * @param x The point on the Gaussian distribution to sample.
  20219. * @return the value of the Gaussian function at x.
  20220. */
  20221. protected _gaussianWeight(x: number): number;
  20222. /**
  20223. * Generates a string that can be used as a floating point number in GLSL.
  20224. * @param x Value to print.
  20225. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20226. * @return GLSL float string.
  20227. */
  20228. protected _glslFloat(x: number, decimalFigures?: number): string;
  20229. }
  20230. }
  20231. declare module BABYLON {
  20232. /**
  20233. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20234. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20235. * You can then easily use it as a reflectionTexture on a flat surface.
  20236. * In case the surface is not a plane, please consider relying on reflection probes.
  20237. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20238. */
  20239. export class MirrorTexture extends RenderTargetTexture {
  20240. private scene;
  20241. /**
  20242. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20243. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  20244. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20245. */
  20246. mirrorPlane: Plane;
  20247. /**
  20248. * Define the blur ratio used to blur the reflection if needed.
  20249. */
  20250. set blurRatio(value: number);
  20251. get blurRatio(): number;
  20252. /**
  20253. * Define the adaptive blur kernel used to blur the reflection if needed.
  20254. * This will autocompute the closest best match for the `blurKernel`
  20255. */
  20256. set adaptiveBlurKernel(value: number);
  20257. /**
  20258. * Define the blur kernel used to blur the reflection if needed.
  20259. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20260. */
  20261. set blurKernel(value: number);
  20262. /**
  20263. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20264. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20265. */
  20266. set blurKernelX(value: number);
  20267. get blurKernelX(): number;
  20268. /**
  20269. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20270. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20271. */
  20272. set blurKernelY(value: number);
  20273. get blurKernelY(): number;
  20274. private _autoComputeBlurKernel;
  20275. protected _onRatioRescale(): void;
  20276. private _updateGammaSpace;
  20277. private _imageProcessingConfigChangeObserver;
  20278. private _transformMatrix;
  20279. private _mirrorMatrix;
  20280. private _savedViewMatrix;
  20281. private _blurX;
  20282. private _blurY;
  20283. private _adaptiveBlurKernel;
  20284. private _blurKernelX;
  20285. private _blurKernelY;
  20286. private _blurRatio;
  20287. /**
  20288. * Instantiates a Mirror Texture.
  20289. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20290. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20291. * You can then easily use it as a reflectionTexture on a flat surface.
  20292. * In case the surface is not a plane, please consider relying on reflection probes.
  20293. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20294. * @param name
  20295. * @param size
  20296. * @param scene
  20297. * @param generateMipMaps
  20298. * @param type
  20299. * @param samplingMode
  20300. * @param generateDepthBuffer
  20301. */
  20302. constructor(name: string, size: number | {
  20303. width: number;
  20304. height: number;
  20305. } | {
  20306. ratio: number;
  20307. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20308. private _preparePostProcesses;
  20309. /**
  20310. * Clone the mirror texture.
  20311. * @returns the cloned texture
  20312. */
  20313. clone(): MirrorTexture;
  20314. /**
  20315. * Serialize the texture to a JSON representation you could use in Parse later on
  20316. * @returns the serialized JSON representation
  20317. */
  20318. serialize(): any;
  20319. /**
  20320. * Dispose the texture and release its associated resources.
  20321. */
  20322. dispose(): void;
  20323. }
  20324. }
  20325. declare module BABYLON {
  20326. /**
  20327. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20328. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20329. */
  20330. export class Texture extends BaseTexture {
  20331. /**
  20332. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20333. */
  20334. static SerializeBuffers: boolean;
  20335. /** @hidden */
  20336. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20337. /** @hidden */
  20338. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20339. /** @hidden */
  20340. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20341. /** nearest is mag = nearest and min = nearest and mip = linear */
  20342. static readonly NEAREST_SAMPLINGMODE: number;
  20343. /** nearest is mag = nearest and min = nearest and mip = linear */
  20344. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20345. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20346. static readonly BILINEAR_SAMPLINGMODE: number;
  20347. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20348. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20349. /** Trilinear is mag = linear and min = linear and mip = linear */
  20350. static readonly TRILINEAR_SAMPLINGMODE: number;
  20351. /** Trilinear is mag = linear and min = linear and mip = linear */
  20352. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20353. /** mag = nearest and min = nearest and mip = nearest */
  20354. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20355. /** mag = nearest and min = linear and mip = nearest */
  20356. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20357. /** mag = nearest and min = linear and mip = linear */
  20358. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20359. /** mag = nearest and min = linear and mip = none */
  20360. static readonly NEAREST_LINEAR: number;
  20361. /** mag = nearest and min = nearest and mip = none */
  20362. static readonly NEAREST_NEAREST: number;
  20363. /** mag = linear and min = nearest and mip = nearest */
  20364. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20365. /** mag = linear and min = nearest and mip = linear */
  20366. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20367. /** mag = linear and min = linear and mip = none */
  20368. static readonly LINEAR_LINEAR: number;
  20369. /** mag = linear and min = nearest and mip = none */
  20370. static readonly LINEAR_NEAREST: number;
  20371. /** Explicit coordinates mode */
  20372. static readonly EXPLICIT_MODE: number;
  20373. /** Spherical coordinates mode */
  20374. static readonly SPHERICAL_MODE: number;
  20375. /** Planar coordinates mode */
  20376. static readonly PLANAR_MODE: number;
  20377. /** Cubic coordinates mode */
  20378. static readonly CUBIC_MODE: number;
  20379. /** Projection coordinates mode */
  20380. static readonly PROJECTION_MODE: number;
  20381. /** Inverse Cubic coordinates mode */
  20382. static readonly SKYBOX_MODE: number;
  20383. /** Inverse Cubic coordinates mode */
  20384. static readonly INVCUBIC_MODE: number;
  20385. /** Equirectangular coordinates mode */
  20386. static readonly EQUIRECTANGULAR_MODE: number;
  20387. /** Equirectangular Fixed coordinates mode */
  20388. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20389. /** Equirectangular Fixed Mirrored coordinates mode */
  20390. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20391. /** Texture is not repeating outside of 0..1 UVs */
  20392. static readonly CLAMP_ADDRESSMODE: number;
  20393. /** Texture is repeating outside of 0..1 UVs */
  20394. static readonly WRAP_ADDRESSMODE: number;
  20395. /** Texture is repeating and mirrored */
  20396. static readonly MIRROR_ADDRESSMODE: number;
  20397. /**
  20398. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  20399. */
  20400. static UseSerializedUrlIfAny: boolean;
  20401. /**
  20402. * Define the url of the texture.
  20403. */
  20404. url: Nullable<string>;
  20405. /**
  20406. * Define an offset on the texture to offset the u coordinates of the UVs
  20407. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20408. */
  20409. uOffset: number;
  20410. /**
  20411. * Define an offset on the texture to offset the v coordinates of the UVs
  20412. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20413. */
  20414. vOffset: number;
  20415. /**
  20416. * Define an offset on the texture to scale the u coordinates of the UVs
  20417. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20418. */
  20419. uScale: number;
  20420. /**
  20421. * Define an offset on the texture to scale the v coordinates of the UVs
  20422. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20423. */
  20424. vScale: number;
  20425. /**
  20426. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20427. * @see http://doc.babylonjs.com/how_to/more_materials
  20428. */
  20429. uAng: number;
  20430. /**
  20431. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20432. * @see http://doc.babylonjs.com/how_to/more_materials
  20433. */
  20434. vAng: number;
  20435. /**
  20436. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20437. * @see http://doc.babylonjs.com/how_to/more_materials
  20438. */
  20439. wAng: number;
  20440. /**
  20441. * Defines the center of rotation (U)
  20442. */
  20443. uRotationCenter: number;
  20444. /**
  20445. * Defines the center of rotation (V)
  20446. */
  20447. vRotationCenter: number;
  20448. /**
  20449. * Defines the center of rotation (W)
  20450. */
  20451. wRotationCenter: number;
  20452. /**
  20453. * Are mip maps generated for this texture or not.
  20454. */
  20455. get noMipmap(): boolean;
  20456. /**
  20457. * List of inspectable custom properties (used by the Inspector)
  20458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20459. */
  20460. inspectableCustomProperties: Nullable<IInspectable[]>;
  20461. private _noMipmap;
  20462. /** @hidden */
  20463. _invertY: boolean;
  20464. private _rowGenerationMatrix;
  20465. private _cachedTextureMatrix;
  20466. private _projectionModeMatrix;
  20467. private _t0;
  20468. private _t1;
  20469. private _t2;
  20470. private _cachedUOffset;
  20471. private _cachedVOffset;
  20472. private _cachedUScale;
  20473. private _cachedVScale;
  20474. private _cachedUAng;
  20475. private _cachedVAng;
  20476. private _cachedWAng;
  20477. private _cachedProjectionMatrixId;
  20478. private _cachedCoordinatesMode;
  20479. /** @hidden */
  20480. protected _initialSamplingMode: number;
  20481. /** @hidden */
  20482. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20483. private _deleteBuffer;
  20484. protected _format: Nullable<number>;
  20485. private _delayedOnLoad;
  20486. private _delayedOnError;
  20487. private _mimeType?;
  20488. /**
  20489. * Observable triggered once the texture has been loaded.
  20490. */
  20491. onLoadObservable: Observable<Texture>;
  20492. protected _isBlocking: boolean;
  20493. /**
  20494. * Is the texture preventing material to render while loading.
  20495. * If false, a default texture will be used instead of the loading one during the preparation step.
  20496. */
  20497. set isBlocking(value: boolean);
  20498. get isBlocking(): boolean;
  20499. /**
  20500. * Get the current sampling mode associated with the texture.
  20501. */
  20502. get samplingMode(): number;
  20503. /**
  20504. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20505. */
  20506. get invertY(): boolean;
  20507. /**
  20508. * Instantiates a new texture.
  20509. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20510. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20511. * @param url defines the url of the picture to load as a texture
  20512. * @param scene defines the scene or engine the texture will belong to
  20513. * @param noMipmap defines if the texture will require mip maps or not
  20514. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20515. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20516. * @param onLoad defines a callback triggered when the texture has been loaded
  20517. * @param onError defines a callback triggered when an error occurred during the loading session
  20518. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20519. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20520. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20521. * @param mimeType defines an optional mime type information
  20522. */
  20523. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20524. /**
  20525. * Update the url (and optional buffer) of this texture if url was null during construction.
  20526. * @param url the url of the texture
  20527. * @param buffer the buffer of the texture (defaults to null)
  20528. * @param onLoad callback called when the texture is loaded (defaults to null)
  20529. */
  20530. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20531. /**
  20532. * Finish the loading sequence of a texture flagged as delayed load.
  20533. * @hidden
  20534. */
  20535. delayLoad(): void;
  20536. private _prepareRowForTextureGeneration;
  20537. /**
  20538. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20539. * @returns the transform matrix of the texture.
  20540. */
  20541. getTextureMatrix(uBase?: number): Matrix;
  20542. /**
  20543. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20544. * @returns The reflection texture transform
  20545. */
  20546. getReflectionTextureMatrix(): Matrix;
  20547. /**
  20548. * Clones the texture.
  20549. * @returns the cloned texture
  20550. */
  20551. clone(): Texture;
  20552. /**
  20553. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20554. * @returns The JSON representation of the texture
  20555. */
  20556. serialize(): any;
  20557. /**
  20558. * Get the current class name of the texture useful for serialization or dynamic coding.
  20559. * @returns "Texture"
  20560. */
  20561. getClassName(): string;
  20562. /**
  20563. * Dispose the texture and release its associated resources.
  20564. */
  20565. dispose(): void;
  20566. /**
  20567. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20568. * @param parsedTexture Define the JSON representation of the texture
  20569. * @param scene Define the scene the parsed texture should be instantiated in
  20570. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20571. * @returns The parsed texture if successful
  20572. */
  20573. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20574. /**
  20575. * Creates a texture from its base 64 representation.
  20576. * @param data Define the base64 payload without the data: prefix
  20577. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20578. * @param scene Define the scene the texture should belong to
  20579. * @param noMipmap Forces the texture to not create mip map information if true
  20580. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20581. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20582. * @param onLoad define a callback triggered when the texture has been loaded
  20583. * @param onError define a callback triggered when an error occurred during the loading session
  20584. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20585. * @returns the created texture
  20586. */
  20587. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20588. /**
  20589. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20590. * @param data Define the base64 payload without the data: prefix
  20591. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20592. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20593. * @param scene Define the scene the texture should belong to
  20594. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20595. * @param noMipmap Forces the texture to not create mip map information if true
  20596. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20597. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20598. * @param onLoad define a callback triggered when the texture has been loaded
  20599. * @param onError define a callback triggered when an error occurred during the loading session
  20600. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20601. * @returns the created texture
  20602. */
  20603. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  20604. }
  20605. }
  20606. declare module BABYLON {
  20607. /**
  20608. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20609. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20610. */
  20611. export class PostProcessManager {
  20612. private _scene;
  20613. private _indexBuffer;
  20614. private _vertexBuffers;
  20615. /**
  20616. * Creates a new instance PostProcess
  20617. * @param scene The scene that the post process is associated with.
  20618. */
  20619. constructor(scene: Scene);
  20620. private _prepareBuffers;
  20621. private _buildIndexBuffer;
  20622. /**
  20623. * Rebuilds the vertex buffers of the manager.
  20624. * @hidden
  20625. */
  20626. _rebuild(): void;
  20627. /**
  20628. * Prepares a frame to be run through a post process.
  20629. * @param sourceTexture The input texture to the post procesess. (default: null)
  20630. * @param postProcesses An array of post processes to be run. (default: null)
  20631. * @returns True if the post processes were able to be run.
  20632. * @hidden
  20633. */
  20634. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20635. /**
  20636. * Manually render a set of post processes to a texture.
  20637. * @param postProcesses An array of post processes to be run.
  20638. * @param targetTexture The target texture to render to.
  20639. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20640. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20641. * @param lodLevel defines which lod of the texture to render to
  20642. */
  20643. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20644. /**
  20645. * Finalize the result of the output of the postprocesses.
  20646. * @param doNotPresent If true the result will not be displayed to the screen.
  20647. * @param targetTexture The target texture to render to.
  20648. * @param faceIndex The index of the face to bind the target texture to.
  20649. * @param postProcesses The array of post processes to render.
  20650. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20651. * @hidden
  20652. */
  20653. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20654. /**
  20655. * Disposes of the post process manager.
  20656. */
  20657. dispose(): void;
  20658. }
  20659. }
  20660. declare module BABYLON {
  20661. /**
  20662. * This Helps creating a texture that will be created from a camera in your scene.
  20663. * It is basically a dynamic texture that could be used to create special effects for instance.
  20664. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20665. */
  20666. export class RenderTargetTexture extends Texture {
  20667. isCube: boolean;
  20668. /**
  20669. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20670. */
  20671. static readonly REFRESHRATE_RENDER_ONCE: number;
  20672. /**
  20673. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20674. */
  20675. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20676. /**
  20677. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20678. * the central point of your effect and can save a lot of performances.
  20679. */
  20680. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20681. /**
  20682. * Use this predicate to dynamically define the list of mesh you want to render.
  20683. * If set, the renderList property will be overwritten.
  20684. */
  20685. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20686. private _renderList;
  20687. /**
  20688. * Use this list to define the list of mesh you want to render.
  20689. */
  20690. get renderList(): Nullable<Array<AbstractMesh>>;
  20691. set renderList(value: Nullable<Array<AbstractMesh>>);
  20692. /**
  20693. * Use this function to overload the renderList array at rendering time.
  20694. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20695. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20696. * the cube (if the RTT is a cube, else layerOrFace=0).
  20697. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20698. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20699. * hold dummy elements!
  20700. */
  20701. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20702. private _hookArray;
  20703. /**
  20704. * Define if particles should be rendered in your texture.
  20705. */
  20706. renderParticles: boolean;
  20707. /**
  20708. * Define if sprites should be rendered in your texture.
  20709. */
  20710. renderSprites: boolean;
  20711. /**
  20712. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20713. */
  20714. coordinatesMode: number;
  20715. /**
  20716. * Define the camera used to render the texture.
  20717. */
  20718. activeCamera: Nullable<Camera>;
  20719. /**
  20720. * Override the mesh isReady function with your own one.
  20721. */
  20722. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20723. /**
  20724. * Override the render function of the texture with your own one.
  20725. */
  20726. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20727. /**
  20728. * Define if camera post processes should be use while rendering the texture.
  20729. */
  20730. useCameraPostProcesses: boolean;
  20731. /**
  20732. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20733. */
  20734. ignoreCameraViewport: boolean;
  20735. private _postProcessManager;
  20736. private _postProcesses;
  20737. private _resizeObserver;
  20738. /**
  20739. * An event triggered when the texture is unbind.
  20740. */
  20741. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20742. /**
  20743. * An event triggered when the texture is unbind.
  20744. */
  20745. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20746. private _onAfterUnbindObserver;
  20747. /**
  20748. * Set a after unbind callback in the texture.
  20749. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20750. */
  20751. set onAfterUnbind(callback: () => void);
  20752. /**
  20753. * An event triggered before rendering the texture
  20754. */
  20755. onBeforeRenderObservable: Observable<number>;
  20756. private _onBeforeRenderObserver;
  20757. /**
  20758. * Set a before render callback in the texture.
  20759. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20760. */
  20761. set onBeforeRender(callback: (faceIndex: number) => void);
  20762. /**
  20763. * An event triggered after rendering the texture
  20764. */
  20765. onAfterRenderObservable: Observable<number>;
  20766. private _onAfterRenderObserver;
  20767. /**
  20768. * Set a after render callback in the texture.
  20769. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20770. */
  20771. set onAfterRender(callback: (faceIndex: number) => void);
  20772. /**
  20773. * An event triggered after the texture clear
  20774. */
  20775. onClearObservable: Observable<Engine>;
  20776. private _onClearObserver;
  20777. /**
  20778. * Set a clear callback in the texture.
  20779. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20780. */
  20781. set onClear(callback: (Engine: Engine) => void);
  20782. /**
  20783. * An event triggered when the texture is resized.
  20784. */
  20785. onResizeObservable: Observable<RenderTargetTexture>;
  20786. /**
  20787. * Define the clear color of the Render Target if it should be different from the scene.
  20788. */
  20789. clearColor: Color4;
  20790. protected _size: number | {
  20791. width: number;
  20792. height: number;
  20793. layers?: number;
  20794. };
  20795. protected _initialSizeParameter: number | {
  20796. width: number;
  20797. height: number;
  20798. } | {
  20799. ratio: number;
  20800. };
  20801. protected _sizeRatio: Nullable<number>;
  20802. /** @hidden */
  20803. _generateMipMaps: boolean;
  20804. protected _renderingManager: RenderingManager;
  20805. /** @hidden */
  20806. _waitingRenderList: string[];
  20807. protected _doNotChangeAspectRatio: boolean;
  20808. protected _currentRefreshId: number;
  20809. protected _refreshRate: number;
  20810. protected _textureMatrix: Matrix;
  20811. protected _samples: number;
  20812. protected _renderTargetOptions: RenderTargetCreationOptions;
  20813. /**
  20814. * Gets render target creation options that were used.
  20815. */
  20816. get renderTargetOptions(): RenderTargetCreationOptions;
  20817. protected _engine: Engine;
  20818. protected _onRatioRescale(): void;
  20819. /**
  20820. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20821. * It must define where the camera used to render the texture is set
  20822. */
  20823. boundingBoxPosition: Vector3;
  20824. private _boundingBoxSize;
  20825. /**
  20826. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20827. * When defined, the cubemap will switch to local mode
  20828. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20829. * @example https://www.babylonjs-playground.com/#RNASML
  20830. */
  20831. set boundingBoxSize(value: Vector3);
  20832. get boundingBoxSize(): Vector3;
  20833. /**
  20834. * In case the RTT has been created with a depth texture, get the associated
  20835. * depth texture.
  20836. * Otherwise, return null.
  20837. */
  20838. get depthStencilTexture(): Nullable<InternalTexture>;
  20839. /**
  20840. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20841. * or used a shadow, depth texture...
  20842. * @param name The friendly name of the texture
  20843. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20844. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20845. * @param generateMipMaps True if mip maps need to be generated after render.
  20846. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20847. * @param type The type of the buffer in the RTT (int, half float, float...)
  20848. * @param isCube True if a cube texture needs to be created
  20849. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20850. * @param generateDepthBuffer True to generate a depth buffer
  20851. * @param generateStencilBuffer True to generate a stencil buffer
  20852. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20853. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20854. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20855. */
  20856. constructor(name: string, size: number | {
  20857. width: number;
  20858. height: number;
  20859. layers?: number;
  20860. } | {
  20861. ratio: number;
  20862. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20863. /**
  20864. * Creates a depth stencil texture.
  20865. * This is only available in WebGL 2 or with the depth texture extension available.
  20866. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20867. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20868. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20869. */
  20870. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20871. private _processSizeParameter;
  20872. /**
  20873. * Define the number of samples to use in case of MSAA.
  20874. * It defaults to one meaning no MSAA has been enabled.
  20875. */
  20876. get samples(): number;
  20877. set samples(value: number);
  20878. /**
  20879. * Resets the refresh counter of the texture and start bak from scratch.
  20880. * Could be useful to regenerate the texture if it is setup to render only once.
  20881. */
  20882. resetRefreshCounter(): void;
  20883. /**
  20884. * Define the refresh rate of the texture or the rendering frequency.
  20885. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20886. */
  20887. get refreshRate(): number;
  20888. set refreshRate(value: number);
  20889. /**
  20890. * Adds a post process to the render target rendering passes.
  20891. * @param postProcess define the post process to add
  20892. */
  20893. addPostProcess(postProcess: PostProcess): void;
  20894. /**
  20895. * Clear all the post processes attached to the render target
  20896. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20897. */
  20898. clearPostProcesses(dispose?: boolean): void;
  20899. /**
  20900. * Remove one of the post process from the list of attached post processes to the texture
  20901. * @param postProcess define the post process to remove from the list
  20902. */
  20903. removePostProcess(postProcess: PostProcess): void;
  20904. /** @hidden */
  20905. _shouldRender(): boolean;
  20906. /**
  20907. * Gets the actual render size of the texture.
  20908. * @returns the width of the render size
  20909. */
  20910. getRenderSize(): number;
  20911. /**
  20912. * Gets the actual render width of the texture.
  20913. * @returns the width of the render size
  20914. */
  20915. getRenderWidth(): number;
  20916. /**
  20917. * Gets the actual render height of the texture.
  20918. * @returns the height of the render size
  20919. */
  20920. getRenderHeight(): number;
  20921. /**
  20922. * Gets the actual number of layers of the texture.
  20923. * @returns the number of layers
  20924. */
  20925. getRenderLayers(): number;
  20926. /**
  20927. * Get if the texture can be rescaled or not.
  20928. */
  20929. get canRescale(): boolean;
  20930. /**
  20931. * Resize the texture using a ratio.
  20932. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20933. */
  20934. scale(ratio: number): void;
  20935. /**
  20936. * Get the texture reflection matrix used to rotate/transform the reflection.
  20937. * @returns the reflection matrix
  20938. */
  20939. getReflectionTextureMatrix(): Matrix;
  20940. /**
  20941. * Resize the texture to a new desired size.
  20942. * Be carrefull as it will recreate all the data in the new texture.
  20943. * @param size Define the new size. It can be:
  20944. * - a number for squared texture,
  20945. * - an object containing { width: number, height: number }
  20946. * - or an object containing a ratio { ratio: number }
  20947. */
  20948. resize(size: number | {
  20949. width: number;
  20950. height: number;
  20951. } | {
  20952. ratio: number;
  20953. }): void;
  20954. private _defaultRenderListPrepared;
  20955. /**
  20956. * Renders all the objects from the render list into the texture.
  20957. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20958. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20959. */
  20960. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20961. private _bestReflectionRenderTargetDimension;
  20962. private _prepareRenderingManager;
  20963. /**
  20964. * @hidden
  20965. * @param faceIndex face index to bind to if this is a cubetexture
  20966. * @param layer defines the index of the texture to bind in the array
  20967. */
  20968. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20969. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20970. private renderToTarget;
  20971. /**
  20972. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20973. * This allowed control for front to back rendering or reversly depending of the special needs.
  20974. *
  20975. * @param renderingGroupId The rendering group id corresponding to its index
  20976. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20977. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20978. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20979. */
  20980. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20981. /**
  20982. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20983. *
  20984. * @param renderingGroupId The rendering group id corresponding to its index
  20985. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20986. */
  20987. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20988. /**
  20989. * Clones the texture.
  20990. * @returns the cloned texture
  20991. */
  20992. clone(): RenderTargetTexture;
  20993. /**
  20994. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20995. * @returns The JSON representation of the texture
  20996. */
  20997. serialize(): any;
  20998. /**
  20999. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21000. */
  21001. disposeFramebufferObjects(): void;
  21002. /**
  21003. * Dispose the texture and release its associated resources.
  21004. */
  21005. dispose(): void;
  21006. /** @hidden */
  21007. _rebuild(): void;
  21008. /**
  21009. * Clear the info related to rendering groups preventing retention point in material dispose.
  21010. */
  21011. freeRenderingGroups(): void;
  21012. /**
  21013. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21014. * @returns the view count
  21015. */
  21016. getViewCount(): number;
  21017. }
  21018. }
  21019. declare module BABYLON {
  21020. /**
  21021. * Class used to manipulate GUIDs
  21022. */
  21023. export class GUID {
  21024. /**
  21025. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21026. * Be aware Math.random() could cause collisions, but:
  21027. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21028. * @returns a pseudo random id
  21029. */
  21030. static RandomId(): string;
  21031. }
  21032. }
  21033. declare module BABYLON {
  21034. /**
  21035. * Options to be used when creating a shadow depth material
  21036. */
  21037. export interface IIOptionShadowDepthMaterial {
  21038. /** Variables in the vertex shader code that need to have their names remapped.
  21039. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21040. * "var_name" should be either: worldPos or vNormalW
  21041. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21042. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21043. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21044. */
  21045. remappedVariables?: string[];
  21046. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21047. standalone?: boolean;
  21048. }
  21049. /**
  21050. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21051. */
  21052. export class ShadowDepthWrapper {
  21053. private _scene;
  21054. private _options?;
  21055. private _baseMaterial;
  21056. private _onEffectCreatedObserver;
  21057. private _subMeshToEffect;
  21058. private _subMeshToDepthEffect;
  21059. private _meshes;
  21060. /** @hidden */
  21061. _matriceNames: any;
  21062. /** Gets the standalone status of the wrapper */
  21063. get standalone(): boolean;
  21064. /** Gets the base material the wrapper is built upon */
  21065. get baseMaterial(): Material;
  21066. /**
  21067. * Instantiate a new shadow depth wrapper.
  21068. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21069. * generate the shadow depth map. For more information, please refer to the documentation:
  21070. * https://doc.babylonjs.com/babylon101/shadows
  21071. * @param baseMaterial Material to wrap
  21072. * @param scene Define the scene the material belongs to
  21073. * @param options Options used to create the wrapper
  21074. */
  21075. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21076. /**
  21077. * Gets the effect to use to generate the depth map
  21078. * @param subMesh subMesh to get the effect for
  21079. * @param shadowGenerator shadow generator to get the effect for
  21080. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21081. */
  21082. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21083. /**
  21084. * Specifies that the submesh is ready to be used for depth rendering
  21085. * @param subMesh submesh to check
  21086. * @param defines the list of defines to take into account when checking the effect
  21087. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21088. * @param useInstances specifies that instances should be used
  21089. * @returns a boolean indicating that the submesh is ready or not
  21090. */
  21091. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21092. /**
  21093. * Disposes the resources
  21094. */
  21095. dispose(): void;
  21096. private _makeEffect;
  21097. }
  21098. }
  21099. declare module BABYLON {
  21100. /**
  21101. * Options for compiling materials.
  21102. */
  21103. export interface IMaterialCompilationOptions {
  21104. /**
  21105. * Defines whether clip planes are enabled.
  21106. */
  21107. clipPlane: boolean;
  21108. /**
  21109. * Defines whether instances are enabled.
  21110. */
  21111. useInstances: boolean;
  21112. }
  21113. /**
  21114. * Base class for the main features of a material in Babylon.js
  21115. */
  21116. export class Material implements IAnimatable {
  21117. /**
  21118. * Returns the triangle fill mode
  21119. */
  21120. static readonly TriangleFillMode: number;
  21121. /**
  21122. * Returns the wireframe mode
  21123. */
  21124. static readonly WireFrameFillMode: number;
  21125. /**
  21126. * Returns the point fill mode
  21127. */
  21128. static readonly PointFillMode: number;
  21129. /**
  21130. * Returns the point list draw mode
  21131. */
  21132. static readonly PointListDrawMode: number;
  21133. /**
  21134. * Returns the line list draw mode
  21135. */
  21136. static readonly LineListDrawMode: number;
  21137. /**
  21138. * Returns the line loop draw mode
  21139. */
  21140. static readonly LineLoopDrawMode: number;
  21141. /**
  21142. * Returns the line strip draw mode
  21143. */
  21144. static readonly LineStripDrawMode: number;
  21145. /**
  21146. * Returns the triangle strip draw mode
  21147. */
  21148. static readonly TriangleStripDrawMode: number;
  21149. /**
  21150. * Returns the triangle fan draw mode
  21151. */
  21152. static readonly TriangleFanDrawMode: number;
  21153. /**
  21154. * Stores the clock-wise side orientation
  21155. */
  21156. static readonly ClockWiseSideOrientation: number;
  21157. /**
  21158. * Stores the counter clock-wise side orientation
  21159. */
  21160. static readonly CounterClockWiseSideOrientation: number;
  21161. /**
  21162. * The dirty texture flag value
  21163. */
  21164. static readonly TextureDirtyFlag: number;
  21165. /**
  21166. * The dirty light flag value
  21167. */
  21168. static readonly LightDirtyFlag: number;
  21169. /**
  21170. * The dirty fresnel flag value
  21171. */
  21172. static readonly FresnelDirtyFlag: number;
  21173. /**
  21174. * The dirty attribute flag value
  21175. */
  21176. static readonly AttributesDirtyFlag: number;
  21177. /**
  21178. * The dirty misc flag value
  21179. */
  21180. static readonly MiscDirtyFlag: number;
  21181. /**
  21182. * The all dirty flag value
  21183. */
  21184. static readonly AllDirtyFlag: number;
  21185. /**
  21186. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21187. */
  21188. static readonly MATERIAL_OPAQUE: number;
  21189. /**
  21190. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21191. */
  21192. static readonly MATERIAL_ALPHATEST: number;
  21193. /**
  21194. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21195. */
  21196. static readonly MATERIAL_ALPHABLEND: number;
  21197. /**
  21198. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21199. * They are also discarded below the alpha cutoff threshold to improve performances.
  21200. */
  21201. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21202. /**
  21203. * Custom callback helping to override the default shader used in the material.
  21204. */
  21205. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21206. /**
  21207. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21208. */
  21209. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21210. /**
  21211. * The ID of the material
  21212. */
  21213. id: string;
  21214. /**
  21215. * Gets or sets the unique id of the material
  21216. */
  21217. uniqueId: number;
  21218. /**
  21219. * The name of the material
  21220. */
  21221. name: string;
  21222. /**
  21223. * Gets or sets user defined metadata
  21224. */
  21225. metadata: any;
  21226. /**
  21227. * For internal use only. Please do not use.
  21228. */
  21229. reservedDataStore: any;
  21230. /**
  21231. * Specifies if the ready state should be checked on each call
  21232. */
  21233. checkReadyOnEveryCall: boolean;
  21234. /**
  21235. * Specifies if the ready state should be checked once
  21236. */
  21237. checkReadyOnlyOnce: boolean;
  21238. /**
  21239. * The state of the material
  21240. */
  21241. state: string;
  21242. /**
  21243. * The alpha value of the material
  21244. */
  21245. protected _alpha: number;
  21246. /**
  21247. * List of inspectable custom properties (used by the Inspector)
  21248. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21249. */
  21250. inspectableCustomProperties: IInspectable[];
  21251. /**
  21252. * Sets the alpha value of the material
  21253. */
  21254. set alpha(value: number);
  21255. /**
  21256. * Gets the alpha value of the material
  21257. */
  21258. get alpha(): number;
  21259. /**
  21260. * Specifies if back face culling is enabled
  21261. */
  21262. protected _backFaceCulling: boolean;
  21263. /**
  21264. * Sets the back-face culling state
  21265. */
  21266. set backFaceCulling(value: boolean);
  21267. /**
  21268. * Gets the back-face culling state
  21269. */
  21270. get backFaceCulling(): boolean;
  21271. /**
  21272. * Stores the value for side orientation
  21273. */
  21274. sideOrientation: number;
  21275. /**
  21276. * Callback triggered when the material is compiled
  21277. */
  21278. onCompiled: Nullable<(effect: Effect) => void>;
  21279. /**
  21280. * Callback triggered when an error occurs
  21281. */
  21282. onError: Nullable<(effect: Effect, errors: string) => void>;
  21283. /**
  21284. * Callback triggered to get the render target textures
  21285. */
  21286. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21287. /**
  21288. * Gets a boolean indicating that current material needs to register RTT
  21289. */
  21290. get hasRenderTargetTextures(): boolean;
  21291. /**
  21292. * Specifies if the material should be serialized
  21293. */
  21294. doNotSerialize: boolean;
  21295. /**
  21296. * @hidden
  21297. */
  21298. _storeEffectOnSubMeshes: boolean;
  21299. /**
  21300. * Stores the animations for the material
  21301. */
  21302. animations: Nullable<Array<Animation>>;
  21303. /**
  21304. * An event triggered when the material is disposed
  21305. */
  21306. onDisposeObservable: Observable<Material>;
  21307. /**
  21308. * An observer which watches for dispose events
  21309. */
  21310. private _onDisposeObserver;
  21311. private _onUnBindObservable;
  21312. /**
  21313. * Called during a dispose event
  21314. */
  21315. set onDispose(callback: () => void);
  21316. private _onBindObservable;
  21317. /**
  21318. * An event triggered when the material is bound
  21319. */
  21320. get onBindObservable(): Observable<AbstractMesh>;
  21321. /**
  21322. * An observer which watches for bind events
  21323. */
  21324. private _onBindObserver;
  21325. /**
  21326. * Called during a bind event
  21327. */
  21328. set onBind(callback: (Mesh: AbstractMesh) => void);
  21329. /**
  21330. * An event triggered when the material is unbound
  21331. */
  21332. get onUnBindObservable(): Observable<Material>;
  21333. protected _onEffectCreatedObservable: Nullable<Observable<{
  21334. effect: Effect;
  21335. subMesh: Nullable<SubMesh>;
  21336. }>>;
  21337. /**
  21338. * An event triggered when the effect is (re)created
  21339. */
  21340. get onEffectCreatedObservable(): Observable<{
  21341. effect: Effect;
  21342. subMesh: Nullable<SubMesh>;
  21343. }>;
  21344. /**
  21345. * Stores the value of the alpha mode
  21346. */
  21347. private _alphaMode;
  21348. /**
  21349. * Sets the value of the alpha mode.
  21350. *
  21351. * | Value | Type | Description |
  21352. * | --- | --- | --- |
  21353. * | 0 | ALPHA_DISABLE | |
  21354. * | 1 | ALPHA_ADD | |
  21355. * | 2 | ALPHA_COMBINE | |
  21356. * | 3 | ALPHA_SUBTRACT | |
  21357. * | 4 | ALPHA_MULTIPLY | |
  21358. * | 5 | ALPHA_MAXIMIZED | |
  21359. * | 6 | ALPHA_ONEONE | |
  21360. * | 7 | ALPHA_PREMULTIPLIED | |
  21361. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21362. * | 9 | ALPHA_INTERPOLATE | |
  21363. * | 10 | ALPHA_SCREENMODE | |
  21364. *
  21365. */
  21366. set alphaMode(value: number);
  21367. /**
  21368. * Gets the value of the alpha mode
  21369. */
  21370. get alphaMode(): number;
  21371. /**
  21372. * Stores the state of the need depth pre-pass value
  21373. */
  21374. private _needDepthPrePass;
  21375. /**
  21376. * Sets the need depth pre-pass value
  21377. */
  21378. set needDepthPrePass(value: boolean);
  21379. /**
  21380. * Gets the depth pre-pass value
  21381. */
  21382. get needDepthPrePass(): boolean;
  21383. /**
  21384. * Specifies if depth writing should be disabled
  21385. */
  21386. disableDepthWrite: boolean;
  21387. /**
  21388. * Specifies if color writing should be disabled
  21389. */
  21390. disableColorWrite: boolean;
  21391. /**
  21392. * Specifies if depth writing should be forced
  21393. */
  21394. forceDepthWrite: boolean;
  21395. /**
  21396. * Specifies the depth function that should be used. 0 means the default engine function
  21397. */
  21398. depthFunction: number;
  21399. /**
  21400. * Specifies if there should be a separate pass for culling
  21401. */
  21402. separateCullingPass: boolean;
  21403. /**
  21404. * Stores the state specifing if fog should be enabled
  21405. */
  21406. private _fogEnabled;
  21407. /**
  21408. * Sets the state for enabling fog
  21409. */
  21410. set fogEnabled(value: boolean);
  21411. /**
  21412. * Gets the value of the fog enabled state
  21413. */
  21414. get fogEnabled(): boolean;
  21415. /**
  21416. * Stores the size of points
  21417. */
  21418. pointSize: number;
  21419. /**
  21420. * Stores the z offset value
  21421. */
  21422. zOffset: number;
  21423. /**
  21424. * Gets a value specifying if wireframe mode is enabled
  21425. */
  21426. get wireframe(): boolean;
  21427. /**
  21428. * Sets the state of wireframe mode
  21429. */
  21430. set wireframe(value: boolean);
  21431. /**
  21432. * Gets the value specifying if point clouds are enabled
  21433. */
  21434. get pointsCloud(): boolean;
  21435. /**
  21436. * Sets the state of point cloud mode
  21437. */
  21438. set pointsCloud(value: boolean);
  21439. /**
  21440. * Gets the material fill mode
  21441. */
  21442. get fillMode(): number;
  21443. /**
  21444. * Sets the material fill mode
  21445. */
  21446. set fillMode(value: number);
  21447. /**
  21448. * @hidden
  21449. * Stores the effects for the material
  21450. */
  21451. _effect: Nullable<Effect>;
  21452. /**
  21453. * Specifies if uniform buffers should be used
  21454. */
  21455. private _useUBO;
  21456. /**
  21457. * Stores a reference to the scene
  21458. */
  21459. private _scene;
  21460. /**
  21461. * Stores the fill mode state
  21462. */
  21463. private _fillMode;
  21464. /**
  21465. * Specifies if the depth write state should be cached
  21466. */
  21467. private _cachedDepthWriteState;
  21468. /**
  21469. * Specifies if the color write state should be cached
  21470. */
  21471. private _cachedColorWriteState;
  21472. /**
  21473. * Specifies if the depth function state should be cached
  21474. */
  21475. private _cachedDepthFunctionState;
  21476. /**
  21477. * Stores the uniform buffer
  21478. */
  21479. protected _uniformBuffer: UniformBuffer;
  21480. /** @hidden */
  21481. _indexInSceneMaterialArray: number;
  21482. /** @hidden */
  21483. meshMap: Nullable<{
  21484. [id: string]: AbstractMesh | undefined;
  21485. }>;
  21486. /**
  21487. * Creates a material instance
  21488. * @param name defines the name of the material
  21489. * @param scene defines the scene to reference
  21490. * @param doNotAdd specifies if the material should be added to the scene
  21491. */
  21492. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21493. /**
  21494. * Returns a string representation of the current material
  21495. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21496. * @returns a string with material information
  21497. */
  21498. toString(fullDetails?: boolean): string;
  21499. /**
  21500. * Gets the class name of the material
  21501. * @returns a string with the class name of the material
  21502. */
  21503. getClassName(): string;
  21504. /**
  21505. * Specifies if updates for the material been locked
  21506. */
  21507. get isFrozen(): boolean;
  21508. /**
  21509. * Locks updates for the material
  21510. */
  21511. freeze(): void;
  21512. /**
  21513. * Unlocks updates for the material
  21514. */
  21515. unfreeze(): void;
  21516. /**
  21517. * Specifies if the material is ready to be used
  21518. * @param mesh defines the mesh to check
  21519. * @param useInstances specifies if instances should be used
  21520. * @returns a boolean indicating if the material is ready to be used
  21521. */
  21522. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21523. /**
  21524. * Specifies that the submesh is ready to be used
  21525. * @param mesh defines the mesh to check
  21526. * @param subMesh defines which submesh to check
  21527. * @param useInstances specifies that instances should be used
  21528. * @returns a boolean indicating that the submesh is ready or not
  21529. */
  21530. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21531. /**
  21532. * Returns the material effect
  21533. * @returns the effect associated with the material
  21534. */
  21535. getEffect(): Nullable<Effect>;
  21536. /**
  21537. * Returns the current scene
  21538. * @returns a Scene
  21539. */
  21540. getScene(): Scene;
  21541. /**
  21542. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21543. */
  21544. protected _forceAlphaTest: boolean;
  21545. /**
  21546. * The transparency mode of the material.
  21547. */
  21548. protected _transparencyMode: Nullable<number>;
  21549. /**
  21550. * Gets the current transparency mode.
  21551. */
  21552. get transparencyMode(): Nullable<number>;
  21553. /**
  21554. * Sets the transparency mode of the material.
  21555. *
  21556. * | Value | Type | Description |
  21557. * | ----- | ----------------------------------- | ----------- |
  21558. * | 0 | OPAQUE | |
  21559. * | 1 | ALPHATEST | |
  21560. * | 2 | ALPHABLEND | |
  21561. * | 3 | ALPHATESTANDBLEND | |
  21562. *
  21563. */
  21564. set transparencyMode(value: Nullable<number>);
  21565. /**
  21566. * Returns true if alpha blending should be disabled.
  21567. */
  21568. protected get _disableAlphaBlending(): boolean;
  21569. /**
  21570. * Specifies whether or not this material should be rendered in alpha blend mode.
  21571. * @returns a boolean specifying if alpha blending is needed
  21572. */
  21573. needAlphaBlending(): boolean;
  21574. /**
  21575. * Specifies if the mesh will require alpha blending
  21576. * @param mesh defines the mesh to check
  21577. * @returns a boolean specifying if alpha blending is needed for the mesh
  21578. */
  21579. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21580. /**
  21581. * Specifies whether or not this material should be rendered in alpha test mode.
  21582. * @returns a boolean specifying if an alpha test is needed.
  21583. */
  21584. needAlphaTesting(): boolean;
  21585. /**
  21586. * Specifies if material alpha testing should be turned on for the mesh
  21587. * @param mesh defines the mesh to check
  21588. */
  21589. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21590. /**
  21591. * Gets the texture used for the alpha test
  21592. * @returns the texture to use for alpha testing
  21593. */
  21594. getAlphaTestTexture(): Nullable<BaseTexture>;
  21595. /**
  21596. * Marks the material to indicate that it needs to be re-calculated
  21597. */
  21598. markDirty(): void;
  21599. /** @hidden */
  21600. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21601. /**
  21602. * Binds the material to the mesh
  21603. * @param world defines the world transformation matrix
  21604. * @param mesh defines the mesh to bind the material to
  21605. */
  21606. bind(world: Matrix, mesh?: Mesh): void;
  21607. /**
  21608. * Binds the submesh to the material
  21609. * @param world defines the world transformation matrix
  21610. * @param mesh defines the mesh containing the submesh
  21611. * @param subMesh defines the submesh to bind the material to
  21612. */
  21613. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21614. /**
  21615. * Binds the world matrix to the material
  21616. * @param world defines the world transformation matrix
  21617. */
  21618. bindOnlyWorldMatrix(world: Matrix): void;
  21619. /**
  21620. * Binds the scene's uniform buffer to the effect.
  21621. * @param effect defines the effect to bind to the scene uniform buffer
  21622. * @param sceneUbo defines the uniform buffer storing scene data
  21623. */
  21624. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21625. /**
  21626. * Binds the view matrix to the effect
  21627. * @param effect defines the effect to bind the view matrix to
  21628. */
  21629. bindView(effect: Effect): void;
  21630. /**
  21631. * Binds the view projection matrix to the effect
  21632. * @param effect defines the effect to bind the view projection matrix to
  21633. */
  21634. bindViewProjection(effect: Effect): void;
  21635. /**
  21636. * Processes to execute after binding the material to a mesh
  21637. * @param mesh defines the rendered mesh
  21638. */
  21639. protected _afterBind(mesh?: Mesh): void;
  21640. /**
  21641. * Unbinds the material from the mesh
  21642. */
  21643. unbind(): void;
  21644. /**
  21645. * Gets the active textures from the material
  21646. * @returns an array of textures
  21647. */
  21648. getActiveTextures(): BaseTexture[];
  21649. /**
  21650. * Specifies if the material uses a texture
  21651. * @param texture defines the texture to check against the material
  21652. * @returns a boolean specifying if the material uses the texture
  21653. */
  21654. hasTexture(texture: BaseTexture): boolean;
  21655. /**
  21656. * Makes a duplicate of the material, and gives it a new name
  21657. * @param name defines the new name for the duplicated material
  21658. * @returns the cloned material
  21659. */
  21660. clone(name: string): Nullable<Material>;
  21661. /**
  21662. * Gets the meshes bound to the material
  21663. * @returns an array of meshes bound to the material
  21664. */
  21665. getBindedMeshes(): AbstractMesh[];
  21666. /**
  21667. * Force shader compilation
  21668. * @param mesh defines the mesh associated with this material
  21669. * @param onCompiled defines a function to execute once the material is compiled
  21670. * @param options defines the options to configure the compilation
  21671. * @param onError defines a function to execute if the material fails compiling
  21672. */
  21673. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21674. /**
  21675. * Force shader compilation
  21676. * @param mesh defines the mesh that will use this material
  21677. * @param options defines additional options for compiling the shaders
  21678. * @returns a promise that resolves when the compilation completes
  21679. */
  21680. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21681. private static readonly _AllDirtyCallBack;
  21682. private static readonly _ImageProcessingDirtyCallBack;
  21683. private static readonly _TextureDirtyCallBack;
  21684. private static readonly _FresnelDirtyCallBack;
  21685. private static readonly _MiscDirtyCallBack;
  21686. private static readonly _LightsDirtyCallBack;
  21687. private static readonly _AttributeDirtyCallBack;
  21688. private static _FresnelAndMiscDirtyCallBack;
  21689. private static _TextureAndMiscDirtyCallBack;
  21690. private static readonly _DirtyCallbackArray;
  21691. private static readonly _RunDirtyCallBacks;
  21692. /**
  21693. * Marks a define in the material to indicate that it needs to be re-computed
  21694. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21695. */
  21696. markAsDirty(flag: number): void;
  21697. /**
  21698. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21699. * @param func defines a function which checks material defines against the submeshes
  21700. */
  21701. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21702. /**
  21703. * Indicates that we need to re-calculated for all submeshes
  21704. */
  21705. protected _markAllSubMeshesAsAllDirty(): void;
  21706. /**
  21707. * Indicates that image processing needs to be re-calculated for all submeshes
  21708. */
  21709. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21710. /**
  21711. * Indicates that textures need to be re-calculated for all submeshes
  21712. */
  21713. protected _markAllSubMeshesAsTexturesDirty(): void;
  21714. /**
  21715. * Indicates that fresnel needs to be re-calculated for all submeshes
  21716. */
  21717. protected _markAllSubMeshesAsFresnelDirty(): void;
  21718. /**
  21719. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21720. */
  21721. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21722. /**
  21723. * Indicates that lights need to be re-calculated for all submeshes
  21724. */
  21725. protected _markAllSubMeshesAsLightsDirty(): void;
  21726. /**
  21727. * Indicates that attributes need to be re-calculated for all submeshes
  21728. */
  21729. protected _markAllSubMeshesAsAttributesDirty(): void;
  21730. /**
  21731. * Indicates that misc needs to be re-calculated for all submeshes
  21732. */
  21733. protected _markAllSubMeshesAsMiscDirty(): void;
  21734. /**
  21735. * Indicates that textures and misc need to be re-calculated for all submeshes
  21736. */
  21737. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21738. /**
  21739. * Disposes the material
  21740. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21741. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21742. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21743. */
  21744. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21745. /** @hidden */
  21746. private releaseVertexArrayObject;
  21747. /**
  21748. * Serializes this material
  21749. * @returns the serialized material object
  21750. */
  21751. serialize(): any;
  21752. /**
  21753. * Creates a material from parsed material data
  21754. * @param parsedMaterial defines parsed material data
  21755. * @param scene defines the hosting scene
  21756. * @param rootUrl defines the root URL to use to load textures
  21757. * @returns a new material
  21758. */
  21759. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21760. }
  21761. }
  21762. declare module BABYLON {
  21763. /**
  21764. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21765. * separate meshes. This can be use to improve performances.
  21766. * @see http://doc.babylonjs.com/how_to/multi_materials
  21767. */
  21768. export class MultiMaterial extends Material {
  21769. private _subMaterials;
  21770. /**
  21771. * Gets or Sets the list of Materials used within the multi material.
  21772. * They need to be ordered according to the submeshes order in the associated mesh
  21773. */
  21774. get subMaterials(): Nullable<Material>[];
  21775. set subMaterials(value: Nullable<Material>[]);
  21776. /**
  21777. * Function used to align with Node.getChildren()
  21778. * @returns the list of Materials used within the multi material
  21779. */
  21780. getChildren(): Nullable<Material>[];
  21781. /**
  21782. * Instantiates a new Multi Material
  21783. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21784. * separate meshes. This can be use to improve performances.
  21785. * @see http://doc.babylonjs.com/how_to/multi_materials
  21786. * @param name Define the name in the scene
  21787. * @param scene Define the scene the material belongs to
  21788. */
  21789. constructor(name: string, scene: Scene);
  21790. private _hookArray;
  21791. /**
  21792. * Get one of the submaterial by its index in the submaterials array
  21793. * @param index The index to look the sub material at
  21794. * @returns The Material if the index has been defined
  21795. */
  21796. getSubMaterial(index: number): Nullable<Material>;
  21797. /**
  21798. * Get the list of active textures for the whole sub materials list.
  21799. * @returns All the textures that will be used during the rendering
  21800. */
  21801. getActiveTextures(): BaseTexture[];
  21802. /**
  21803. * Gets the current class name of the material e.g. "MultiMaterial"
  21804. * Mainly use in serialization.
  21805. * @returns the class name
  21806. */
  21807. getClassName(): string;
  21808. /**
  21809. * Checks if the material is ready to render the requested sub mesh
  21810. * @param mesh Define the mesh the submesh belongs to
  21811. * @param subMesh Define the sub mesh to look readyness for
  21812. * @param useInstances Define whether or not the material is used with instances
  21813. * @returns true if ready, otherwise false
  21814. */
  21815. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21816. /**
  21817. * Clones the current material and its related sub materials
  21818. * @param name Define the name of the newly cloned material
  21819. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21820. * @returns the cloned material
  21821. */
  21822. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21823. /**
  21824. * Serializes the materials into a JSON representation.
  21825. * @returns the JSON representation
  21826. */
  21827. serialize(): any;
  21828. /**
  21829. * Dispose the material and release its associated resources
  21830. * @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)
  21831. * @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)
  21832. * @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)
  21833. */
  21834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21835. /**
  21836. * Creates a MultiMaterial from parsed MultiMaterial data.
  21837. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21838. * @param scene defines the hosting scene
  21839. * @returns a new MultiMaterial
  21840. */
  21841. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21842. }
  21843. }
  21844. declare module BABYLON {
  21845. /**
  21846. * Base class for submeshes
  21847. */
  21848. export class BaseSubMesh {
  21849. /** @hidden */
  21850. _materialDefines: Nullable<MaterialDefines>;
  21851. /** @hidden */
  21852. _materialEffect: Nullable<Effect>;
  21853. /** @hidden */
  21854. _effectOverride: Nullable<Effect>;
  21855. /**
  21856. * Gets material defines used by the effect associated to the sub mesh
  21857. */
  21858. get materialDefines(): Nullable<MaterialDefines>;
  21859. /**
  21860. * Sets material defines used by the effect associated to the sub mesh
  21861. */
  21862. set materialDefines(defines: Nullable<MaterialDefines>);
  21863. /**
  21864. * Gets associated effect
  21865. */
  21866. get effect(): Nullable<Effect>;
  21867. /**
  21868. * Sets associated effect (effect used to render this submesh)
  21869. * @param effect defines the effect to associate with
  21870. * @param defines defines the set of defines used to compile this effect
  21871. */
  21872. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21873. }
  21874. /**
  21875. * Defines a subdivision inside a mesh
  21876. */
  21877. export class SubMesh extends BaseSubMesh implements ICullable {
  21878. /** the material index to use */
  21879. materialIndex: number;
  21880. /** vertex index start */
  21881. verticesStart: number;
  21882. /** vertices count */
  21883. verticesCount: number;
  21884. /** index start */
  21885. indexStart: number;
  21886. /** indices count */
  21887. indexCount: number;
  21888. /** @hidden */
  21889. _linesIndexCount: number;
  21890. private _mesh;
  21891. private _renderingMesh;
  21892. private _boundingInfo;
  21893. private _linesIndexBuffer;
  21894. /** @hidden */
  21895. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21896. /** @hidden */
  21897. _trianglePlanes: Plane[];
  21898. /** @hidden */
  21899. _lastColliderTransformMatrix: Nullable<Matrix>;
  21900. /** @hidden */
  21901. _renderId: number;
  21902. /** @hidden */
  21903. _alphaIndex: number;
  21904. /** @hidden */
  21905. _distanceToCamera: number;
  21906. /** @hidden */
  21907. _id: number;
  21908. private _currentMaterial;
  21909. /**
  21910. * Add a new submesh to a mesh
  21911. * @param materialIndex defines the material index to use
  21912. * @param verticesStart defines vertex index start
  21913. * @param verticesCount defines vertices count
  21914. * @param indexStart defines index start
  21915. * @param indexCount defines indices count
  21916. * @param mesh defines the parent mesh
  21917. * @param renderingMesh defines an optional rendering mesh
  21918. * @param createBoundingBox defines if bounding box should be created for this submesh
  21919. * @returns the new submesh
  21920. */
  21921. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21922. /**
  21923. * Creates a new submesh
  21924. * @param materialIndex defines the material index to use
  21925. * @param verticesStart defines vertex index start
  21926. * @param verticesCount defines vertices count
  21927. * @param indexStart defines index start
  21928. * @param indexCount defines indices count
  21929. * @param mesh defines the parent mesh
  21930. * @param renderingMesh defines an optional rendering mesh
  21931. * @param createBoundingBox defines if bounding box should be created for this submesh
  21932. */
  21933. constructor(
  21934. /** the material index to use */
  21935. materialIndex: number,
  21936. /** vertex index start */
  21937. verticesStart: number,
  21938. /** vertices count */
  21939. verticesCount: number,
  21940. /** index start */
  21941. indexStart: number,
  21942. /** indices count */
  21943. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21944. /**
  21945. * Returns true if this submesh covers the entire parent mesh
  21946. * @ignorenaming
  21947. */
  21948. get IsGlobal(): boolean;
  21949. /**
  21950. * Returns the submesh BoudingInfo object
  21951. * @returns current bounding info (or mesh's one if the submesh is global)
  21952. */
  21953. getBoundingInfo(): BoundingInfo;
  21954. /**
  21955. * Sets the submesh BoundingInfo
  21956. * @param boundingInfo defines the new bounding info to use
  21957. * @returns the SubMesh
  21958. */
  21959. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21960. /**
  21961. * Returns the mesh of the current submesh
  21962. * @return the parent mesh
  21963. */
  21964. getMesh(): AbstractMesh;
  21965. /**
  21966. * Returns the rendering mesh of the submesh
  21967. * @returns the rendering mesh (could be different from parent mesh)
  21968. */
  21969. getRenderingMesh(): Mesh;
  21970. /**
  21971. * Returns the submesh material
  21972. * @returns null or the current material
  21973. */
  21974. getMaterial(): Nullable<Material>;
  21975. /**
  21976. * Sets a new updated BoundingInfo object to the submesh
  21977. * @param data defines an optional position array to use to determine the bounding info
  21978. * @returns the SubMesh
  21979. */
  21980. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21981. /** @hidden */
  21982. _checkCollision(collider: Collider): boolean;
  21983. /**
  21984. * Updates the submesh BoundingInfo
  21985. * @param world defines the world matrix to use to update the bounding info
  21986. * @returns the submesh
  21987. */
  21988. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21989. /**
  21990. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21991. * @param frustumPlanes defines the frustum planes
  21992. * @returns true if the submesh is intersecting with the frustum
  21993. */
  21994. isInFrustum(frustumPlanes: Plane[]): boolean;
  21995. /**
  21996. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21997. * @param frustumPlanes defines the frustum planes
  21998. * @returns true if the submesh is inside the frustum
  21999. */
  22000. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22001. /**
  22002. * Renders the submesh
  22003. * @param enableAlphaMode defines if alpha needs to be used
  22004. * @returns the submesh
  22005. */
  22006. render(enableAlphaMode: boolean): SubMesh;
  22007. /**
  22008. * @hidden
  22009. */
  22010. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22011. /**
  22012. * Checks if the submesh intersects with a ray
  22013. * @param ray defines the ray to test
  22014. * @returns true is the passed ray intersects the submesh bounding box
  22015. */
  22016. canIntersects(ray: Ray): boolean;
  22017. /**
  22018. * Intersects current submesh with a ray
  22019. * @param ray defines the ray to test
  22020. * @param positions defines mesh's positions array
  22021. * @param indices defines mesh's indices array
  22022. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22023. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22024. * @returns intersection info or null if no intersection
  22025. */
  22026. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22027. /** @hidden */
  22028. private _intersectLines;
  22029. /** @hidden */
  22030. private _intersectUnIndexedLines;
  22031. /** @hidden */
  22032. private _intersectTriangles;
  22033. /** @hidden */
  22034. private _intersectUnIndexedTriangles;
  22035. /** @hidden */
  22036. _rebuild(): void;
  22037. /**
  22038. * Creates a new submesh from the passed mesh
  22039. * @param newMesh defines the new hosting mesh
  22040. * @param newRenderingMesh defines an optional rendering mesh
  22041. * @returns the new submesh
  22042. */
  22043. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22044. /**
  22045. * Release associated resources
  22046. */
  22047. dispose(): void;
  22048. /**
  22049. * Gets the class name
  22050. * @returns the string "SubMesh".
  22051. */
  22052. getClassName(): string;
  22053. /**
  22054. * Creates a new submesh from indices data
  22055. * @param materialIndex the index of the main mesh material
  22056. * @param startIndex the index where to start the copy in the mesh indices array
  22057. * @param indexCount the number of indices to copy then from the startIndex
  22058. * @param mesh the main mesh to create the submesh from
  22059. * @param renderingMesh the optional rendering mesh
  22060. * @returns a new submesh
  22061. */
  22062. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22063. }
  22064. }
  22065. declare module BABYLON {
  22066. /**
  22067. * Class used to represent data loading progression
  22068. */
  22069. export class SceneLoaderFlags {
  22070. private static _ForceFullSceneLoadingForIncremental;
  22071. private static _ShowLoadingScreen;
  22072. private static _CleanBoneMatrixWeights;
  22073. private static _loggingLevel;
  22074. /**
  22075. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22076. */
  22077. static get ForceFullSceneLoadingForIncremental(): boolean;
  22078. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22079. /**
  22080. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22081. */
  22082. static get ShowLoadingScreen(): boolean;
  22083. static set ShowLoadingScreen(value: boolean);
  22084. /**
  22085. * Defines the current logging level (while loading the scene)
  22086. * @ignorenaming
  22087. */
  22088. static get loggingLevel(): number;
  22089. static set loggingLevel(value: number);
  22090. /**
  22091. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22092. */
  22093. static get CleanBoneMatrixWeights(): boolean;
  22094. static set CleanBoneMatrixWeights(value: boolean);
  22095. }
  22096. }
  22097. declare module BABYLON {
  22098. /**
  22099. * Class used to store geometry data (vertex buffers + index buffer)
  22100. */
  22101. export class Geometry implements IGetSetVerticesData {
  22102. /**
  22103. * Gets or sets the ID of the geometry
  22104. */
  22105. id: string;
  22106. /**
  22107. * Gets or sets the unique ID of the geometry
  22108. */
  22109. uniqueId: number;
  22110. /**
  22111. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22112. */
  22113. delayLoadState: number;
  22114. /**
  22115. * Gets the file containing the data to load when running in delay load state
  22116. */
  22117. delayLoadingFile: Nullable<string>;
  22118. /**
  22119. * Callback called when the geometry is updated
  22120. */
  22121. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22122. private _scene;
  22123. private _engine;
  22124. private _meshes;
  22125. private _totalVertices;
  22126. /** @hidden */
  22127. _indices: IndicesArray;
  22128. /** @hidden */
  22129. _vertexBuffers: {
  22130. [key: string]: VertexBuffer;
  22131. };
  22132. private _isDisposed;
  22133. private _extend;
  22134. private _boundingBias;
  22135. /** @hidden */
  22136. _delayInfo: Array<string>;
  22137. private _indexBuffer;
  22138. private _indexBufferIsUpdatable;
  22139. /** @hidden */
  22140. _boundingInfo: Nullable<BoundingInfo>;
  22141. /** @hidden */
  22142. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22143. /** @hidden */
  22144. _softwareSkinningFrameId: number;
  22145. private _vertexArrayObjects;
  22146. private _updatable;
  22147. /** @hidden */
  22148. _positions: Nullable<Vector3[]>;
  22149. /**
  22150. * 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
  22151. */
  22152. get boundingBias(): Vector2;
  22153. /**
  22154. * 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
  22155. */
  22156. set boundingBias(value: Vector2);
  22157. /**
  22158. * Static function used to attach a new empty geometry to a mesh
  22159. * @param mesh defines the mesh to attach the geometry to
  22160. * @returns the new Geometry
  22161. */
  22162. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22163. /** Get the list of meshes using this geometry */
  22164. get meshes(): Mesh[];
  22165. /**
  22166. * Creates a new geometry
  22167. * @param id defines the unique ID
  22168. * @param scene defines the hosting scene
  22169. * @param vertexData defines the VertexData used to get geometry data
  22170. * @param updatable defines if geometry must be updatable (false by default)
  22171. * @param mesh defines the mesh that will be associated with the geometry
  22172. */
  22173. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22174. /**
  22175. * Gets the current extend of the geometry
  22176. */
  22177. get extend(): {
  22178. minimum: Vector3;
  22179. maximum: Vector3;
  22180. };
  22181. /**
  22182. * Gets the hosting scene
  22183. * @returns the hosting Scene
  22184. */
  22185. getScene(): Scene;
  22186. /**
  22187. * Gets the hosting engine
  22188. * @returns the hosting Engine
  22189. */
  22190. getEngine(): Engine;
  22191. /**
  22192. * Defines if the geometry is ready to use
  22193. * @returns true if the geometry is ready to be used
  22194. */
  22195. isReady(): boolean;
  22196. /**
  22197. * Gets a value indicating that the geometry should not be serialized
  22198. */
  22199. get doNotSerialize(): boolean;
  22200. /** @hidden */
  22201. _rebuild(): void;
  22202. /**
  22203. * Affects all geometry data in one call
  22204. * @param vertexData defines the geometry data
  22205. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22206. */
  22207. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22208. /**
  22209. * Set specific vertex data
  22210. * @param kind defines the data kind (Position, normal, etc...)
  22211. * @param data defines the vertex data to use
  22212. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22213. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22214. */
  22215. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22216. /**
  22217. * Removes a specific vertex data
  22218. * @param kind defines the data kind (Position, normal, etc...)
  22219. */
  22220. removeVerticesData(kind: string): void;
  22221. /**
  22222. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22223. * @param buffer defines the vertex buffer to use
  22224. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22225. */
  22226. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22227. /**
  22228. * Update a specific vertex buffer
  22229. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22230. * It will do nothing if the buffer is not updatable
  22231. * @param kind defines the data kind (Position, normal, etc...)
  22232. * @param data defines the data to use
  22233. * @param offset defines the offset in the target buffer where to store the data
  22234. * @param useBytes set to true if the offset is in bytes
  22235. */
  22236. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22237. /**
  22238. * Update a specific vertex buffer
  22239. * This function will create a new buffer if the current one is not updatable
  22240. * @param kind defines the data kind (Position, normal, etc...)
  22241. * @param data defines the data to use
  22242. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22243. */
  22244. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22245. private _updateBoundingInfo;
  22246. /** @hidden */
  22247. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22248. /**
  22249. * Gets total number of vertices
  22250. * @returns the total number of vertices
  22251. */
  22252. getTotalVertices(): number;
  22253. /**
  22254. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22255. * @param kind defines the data kind (Position, normal, etc...)
  22256. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22257. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22258. * @returns a float array containing vertex data
  22259. */
  22260. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22261. /**
  22262. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22263. * @param kind defines the data kind (Position, normal, etc...)
  22264. * @returns true if the vertex buffer with the specified kind is updatable
  22265. */
  22266. isVertexBufferUpdatable(kind: string): boolean;
  22267. /**
  22268. * Gets a specific vertex buffer
  22269. * @param kind defines the data kind (Position, normal, etc...)
  22270. * @returns a VertexBuffer
  22271. */
  22272. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22273. /**
  22274. * Returns all vertex buffers
  22275. * @return an object holding all vertex buffers indexed by kind
  22276. */
  22277. getVertexBuffers(): Nullable<{
  22278. [key: string]: VertexBuffer;
  22279. }>;
  22280. /**
  22281. * Gets a boolean indicating if specific vertex buffer is present
  22282. * @param kind defines the data kind (Position, normal, etc...)
  22283. * @returns true if data is present
  22284. */
  22285. isVerticesDataPresent(kind: string): boolean;
  22286. /**
  22287. * Gets a list of all attached data kinds (Position, normal, etc...)
  22288. * @returns a list of string containing all kinds
  22289. */
  22290. getVerticesDataKinds(): string[];
  22291. /**
  22292. * Update index buffer
  22293. * @param indices defines the indices to store in the index buffer
  22294. * @param offset defines the offset in the target buffer where to store the data
  22295. * @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)
  22296. */
  22297. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22298. /**
  22299. * Creates a new index buffer
  22300. * @param indices defines the indices to store in the index buffer
  22301. * @param totalVertices defines the total number of vertices (could be null)
  22302. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22303. */
  22304. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22305. /**
  22306. * Return the total number of indices
  22307. * @returns the total number of indices
  22308. */
  22309. getTotalIndices(): number;
  22310. /**
  22311. * Gets the index buffer array
  22312. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22313. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22314. * @returns the index buffer array
  22315. */
  22316. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22317. /**
  22318. * Gets the index buffer
  22319. * @return the index buffer
  22320. */
  22321. getIndexBuffer(): Nullable<DataBuffer>;
  22322. /** @hidden */
  22323. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22324. /**
  22325. * Release the associated resources for a specific mesh
  22326. * @param mesh defines the source mesh
  22327. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22328. */
  22329. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22330. /**
  22331. * Apply current geometry to a given mesh
  22332. * @param mesh defines the mesh to apply geometry to
  22333. */
  22334. applyToMesh(mesh: Mesh): void;
  22335. private _updateExtend;
  22336. private _applyToMesh;
  22337. private notifyUpdate;
  22338. /**
  22339. * Load the geometry if it was flagged as delay loaded
  22340. * @param scene defines the hosting scene
  22341. * @param onLoaded defines a callback called when the geometry is loaded
  22342. */
  22343. load(scene: Scene, onLoaded?: () => void): void;
  22344. private _queueLoad;
  22345. /**
  22346. * Invert the geometry to move from a right handed system to a left handed one.
  22347. */
  22348. toLeftHanded(): void;
  22349. /** @hidden */
  22350. _resetPointsArrayCache(): void;
  22351. /** @hidden */
  22352. _generatePointsArray(): boolean;
  22353. /**
  22354. * Gets a value indicating if the geometry is disposed
  22355. * @returns true if the geometry was disposed
  22356. */
  22357. isDisposed(): boolean;
  22358. private _disposeVertexArrayObjects;
  22359. /**
  22360. * Free all associated resources
  22361. */
  22362. dispose(): void;
  22363. /**
  22364. * Clone the current geometry into a new geometry
  22365. * @param id defines the unique ID of the new geometry
  22366. * @returns a new geometry object
  22367. */
  22368. copy(id: string): Geometry;
  22369. /**
  22370. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22371. * @return a JSON representation of the current geometry data (without the vertices data)
  22372. */
  22373. serialize(): any;
  22374. private toNumberArray;
  22375. /**
  22376. * Serialize all vertices data into a JSON oject
  22377. * @returns a JSON representation of the current geometry data
  22378. */
  22379. serializeVerticeData(): any;
  22380. /**
  22381. * Extracts a clone of a mesh geometry
  22382. * @param mesh defines the source mesh
  22383. * @param id defines the unique ID of the new geometry object
  22384. * @returns the new geometry object
  22385. */
  22386. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22387. /**
  22388. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22389. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22390. * Be aware Math.random() could cause collisions, but:
  22391. * "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"
  22392. * @returns a string containing a new GUID
  22393. */
  22394. static RandomId(): string;
  22395. /** @hidden */
  22396. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22397. private static _CleanMatricesWeights;
  22398. /**
  22399. * Create a new geometry from persisted data (Using .babylon file format)
  22400. * @param parsedVertexData defines the persisted data
  22401. * @param scene defines the hosting scene
  22402. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22403. * @returns the new geometry object
  22404. */
  22405. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22406. }
  22407. }
  22408. declare module BABYLON {
  22409. /**
  22410. * Define an interface for all classes that will get and set the data on vertices
  22411. */
  22412. export interface IGetSetVerticesData {
  22413. /**
  22414. * Gets a boolean indicating if specific vertex data is present
  22415. * @param kind defines the vertex data kind to use
  22416. * @returns true is data kind is present
  22417. */
  22418. isVerticesDataPresent(kind: string): boolean;
  22419. /**
  22420. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22421. * @param kind defines the data kind (Position, normal, etc...)
  22422. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22423. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22424. * @returns a float array containing vertex data
  22425. */
  22426. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22427. /**
  22428. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22429. * @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.
  22430. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22431. * @returns the indices array or an empty array if the mesh has no geometry
  22432. */
  22433. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22434. /**
  22435. * Set specific vertex data
  22436. * @param kind defines the data kind (Position, normal, etc...)
  22437. * @param data defines the vertex data to use
  22438. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22439. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22440. */
  22441. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22442. /**
  22443. * Update a specific associated vertex buffer
  22444. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22445. * - VertexBuffer.PositionKind
  22446. * - VertexBuffer.UVKind
  22447. * - VertexBuffer.UV2Kind
  22448. * - VertexBuffer.UV3Kind
  22449. * - VertexBuffer.UV4Kind
  22450. * - VertexBuffer.UV5Kind
  22451. * - VertexBuffer.UV6Kind
  22452. * - VertexBuffer.ColorKind
  22453. * - VertexBuffer.MatricesIndicesKind
  22454. * - VertexBuffer.MatricesIndicesExtraKind
  22455. * - VertexBuffer.MatricesWeightsKind
  22456. * - VertexBuffer.MatricesWeightsExtraKind
  22457. * @param data defines the data source
  22458. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22459. * @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)
  22460. */
  22461. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22462. /**
  22463. * Creates a new index buffer
  22464. * @param indices defines the indices to store in the index buffer
  22465. * @param totalVertices defines the total number of vertices (could be null)
  22466. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22467. */
  22468. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22469. }
  22470. /**
  22471. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22472. */
  22473. export class VertexData {
  22474. /**
  22475. * Mesh side orientation : usually the external or front surface
  22476. */
  22477. static readonly FRONTSIDE: number;
  22478. /**
  22479. * Mesh side orientation : usually the internal or back surface
  22480. */
  22481. static readonly BACKSIDE: number;
  22482. /**
  22483. * Mesh side orientation : both internal and external or front and back surfaces
  22484. */
  22485. static readonly DOUBLESIDE: number;
  22486. /**
  22487. * Mesh side orientation : by default, `FRONTSIDE`
  22488. */
  22489. static readonly DEFAULTSIDE: number;
  22490. /**
  22491. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22492. */
  22493. positions: Nullable<FloatArray>;
  22494. /**
  22495. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22496. */
  22497. normals: Nullable<FloatArray>;
  22498. /**
  22499. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22500. */
  22501. tangents: Nullable<FloatArray>;
  22502. /**
  22503. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22504. */
  22505. uvs: Nullable<FloatArray>;
  22506. /**
  22507. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22508. */
  22509. uvs2: Nullable<FloatArray>;
  22510. /**
  22511. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22512. */
  22513. uvs3: Nullable<FloatArray>;
  22514. /**
  22515. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22516. */
  22517. uvs4: Nullable<FloatArray>;
  22518. /**
  22519. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22520. */
  22521. uvs5: Nullable<FloatArray>;
  22522. /**
  22523. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22524. */
  22525. uvs6: Nullable<FloatArray>;
  22526. /**
  22527. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22528. */
  22529. colors: Nullable<FloatArray>;
  22530. /**
  22531. * 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).
  22532. */
  22533. matricesIndices: Nullable<FloatArray>;
  22534. /**
  22535. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22536. */
  22537. matricesWeights: Nullable<FloatArray>;
  22538. /**
  22539. * An array extending the number of possible indices
  22540. */
  22541. matricesIndicesExtra: Nullable<FloatArray>;
  22542. /**
  22543. * An array extending the number of possible weights when the number of indices is extended
  22544. */
  22545. matricesWeightsExtra: Nullable<FloatArray>;
  22546. /**
  22547. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22548. */
  22549. indices: Nullable<IndicesArray>;
  22550. /**
  22551. * Uses the passed data array to set the set the values for the specified kind of data
  22552. * @param data a linear array of floating numbers
  22553. * @param kind the type of data that is being set, eg positions, colors etc
  22554. */
  22555. set(data: FloatArray, kind: string): void;
  22556. /**
  22557. * Associates the vertexData to the passed Mesh.
  22558. * Sets it as updatable or not (default `false`)
  22559. * @param mesh the mesh the vertexData is applied to
  22560. * @param updatable when used and having the value true allows new data to update the vertexData
  22561. * @returns the VertexData
  22562. */
  22563. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22564. /**
  22565. * Associates the vertexData to the passed Geometry.
  22566. * Sets it as updatable or not (default `false`)
  22567. * @param geometry the geometry the vertexData is applied to
  22568. * @param updatable when used and having the value true allows new data to update the vertexData
  22569. * @returns VertexData
  22570. */
  22571. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22572. /**
  22573. * Updates the associated mesh
  22574. * @param mesh the mesh to be updated
  22575. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22576. * @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
  22577. * @returns VertexData
  22578. */
  22579. updateMesh(mesh: Mesh): VertexData;
  22580. /**
  22581. * Updates the associated geometry
  22582. * @param geometry the geometry to be updated
  22583. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22584. * @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
  22585. * @returns VertexData.
  22586. */
  22587. updateGeometry(geometry: Geometry): VertexData;
  22588. private _applyTo;
  22589. private _update;
  22590. /**
  22591. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22592. * @param matrix the transforming matrix
  22593. * @returns the VertexData
  22594. */
  22595. transform(matrix: Matrix): VertexData;
  22596. /**
  22597. * Merges the passed VertexData into the current one
  22598. * @param other the VertexData to be merged into the current one
  22599. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22600. * @returns the modified VertexData
  22601. */
  22602. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22603. private _mergeElement;
  22604. private _validate;
  22605. /**
  22606. * Serializes the VertexData
  22607. * @returns a serialized object
  22608. */
  22609. serialize(): any;
  22610. /**
  22611. * Extracts the vertexData from a mesh
  22612. * @param mesh the mesh from which to extract the VertexData
  22613. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22614. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22615. * @returns the object VertexData associated to the passed mesh
  22616. */
  22617. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22618. /**
  22619. * Extracts the vertexData from the geometry
  22620. * @param geometry the geometry from which to extract the VertexData
  22621. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22622. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22623. * @returns the object VertexData associated to the passed mesh
  22624. */
  22625. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22626. private static _ExtractFrom;
  22627. /**
  22628. * Creates the VertexData for a Ribbon
  22629. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22630. * * pathArray array of paths, each of which an array of successive Vector3
  22631. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22632. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22633. * * 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
  22634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22635. * * 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)
  22636. * * 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)
  22637. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22638. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22639. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22640. * @returns the VertexData of the ribbon
  22641. */
  22642. static CreateRibbon(options: {
  22643. pathArray: Vector3[][];
  22644. closeArray?: boolean;
  22645. closePath?: boolean;
  22646. offset?: number;
  22647. sideOrientation?: number;
  22648. frontUVs?: Vector4;
  22649. backUVs?: Vector4;
  22650. invertUV?: boolean;
  22651. uvs?: Vector2[];
  22652. colors?: Color4[];
  22653. }): VertexData;
  22654. /**
  22655. * Creates the VertexData for a box
  22656. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22657. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22658. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22659. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22660. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22661. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22662. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22663. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22664. * * 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)
  22665. * * 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)
  22666. * @returns the VertexData of the box
  22667. */
  22668. static CreateBox(options: {
  22669. size?: number;
  22670. width?: number;
  22671. height?: number;
  22672. depth?: number;
  22673. faceUV?: Vector4[];
  22674. faceColors?: Color4[];
  22675. sideOrientation?: number;
  22676. frontUVs?: Vector4;
  22677. backUVs?: Vector4;
  22678. }): VertexData;
  22679. /**
  22680. * Creates the VertexData for a tiled box
  22681. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22682. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22683. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22684. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22686. * @returns the VertexData of the box
  22687. */
  22688. static CreateTiledBox(options: {
  22689. pattern?: number;
  22690. width?: number;
  22691. height?: number;
  22692. depth?: number;
  22693. tileSize?: number;
  22694. tileWidth?: number;
  22695. tileHeight?: number;
  22696. alignHorizontal?: number;
  22697. alignVertical?: number;
  22698. faceUV?: Vector4[];
  22699. faceColors?: Color4[];
  22700. sideOrientation?: number;
  22701. }): VertexData;
  22702. /**
  22703. * Creates the VertexData for a tiled plane
  22704. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22705. * * pattern a limited pattern arrangement depending on the number
  22706. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22707. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22708. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22710. * * 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)
  22711. * * 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)
  22712. * @returns the VertexData of the tiled plane
  22713. */
  22714. static CreateTiledPlane(options: {
  22715. pattern?: number;
  22716. tileSize?: number;
  22717. tileWidth?: number;
  22718. tileHeight?: number;
  22719. size?: number;
  22720. width?: number;
  22721. height?: number;
  22722. alignHorizontal?: number;
  22723. alignVertical?: number;
  22724. sideOrientation?: number;
  22725. frontUVs?: Vector4;
  22726. backUVs?: Vector4;
  22727. }): VertexData;
  22728. /**
  22729. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22730. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22731. * * segments sets the number of horizontal strips optional, default 32
  22732. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22733. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22734. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22735. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22736. * * 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
  22737. * * 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
  22738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22739. * * 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)
  22740. * * 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)
  22741. * @returns the VertexData of the ellipsoid
  22742. */
  22743. static CreateSphere(options: {
  22744. segments?: number;
  22745. diameter?: number;
  22746. diameterX?: number;
  22747. diameterY?: number;
  22748. diameterZ?: number;
  22749. arc?: number;
  22750. slice?: number;
  22751. sideOrientation?: number;
  22752. frontUVs?: Vector4;
  22753. backUVs?: Vector4;
  22754. }): VertexData;
  22755. /**
  22756. * Creates the VertexData for a cylinder, cone or prism
  22757. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22758. * * height sets the height (y direction) of the cylinder, optional, default 2
  22759. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22760. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22761. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22762. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22763. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22764. * * 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
  22765. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22766. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22767. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22768. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22770. * * 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)
  22771. * * 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)
  22772. * @returns the VertexData of the cylinder, cone or prism
  22773. */
  22774. static CreateCylinder(options: {
  22775. height?: number;
  22776. diameterTop?: number;
  22777. diameterBottom?: number;
  22778. diameter?: number;
  22779. tessellation?: number;
  22780. subdivisions?: number;
  22781. arc?: number;
  22782. faceColors?: Color4[];
  22783. faceUV?: Vector4[];
  22784. hasRings?: boolean;
  22785. enclose?: boolean;
  22786. sideOrientation?: number;
  22787. frontUVs?: Vector4;
  22788. backUVs?: Vector4;
  22789. }): VertexData;
  22790. /**
  22791. * Creates the VertexData for a torus
  22792. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22793. * * diameter the diameter of the torus, optional default 1
  22794. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22795. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22797. * * 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)
  22798. * * 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)
  22799. * @returns the VertexData of the torus
  22800. */
  22801. static CreateTorus(options: {
  22802. diameter?: number;
  22803. thickness?: number;
  22804. tessellation?: number;
  22805. sideOrientation?: number;
  22806. frontUVs?: Vector4;
  22807. backUVs?: Vector4;
  22808. }): VertexData;
  22809. /**
  22810. * Creates the VertexData of the LineSystem
  22811. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22812. * - lines an array of lines, each line being an array of successive Vector3
  22813. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22814. * @returns the VertexData of the LineSystem
  22815. */
  22816. static CreateLineSystem(options: {
  22817. lines: Vector3[][];
  22818. colors?: Nullable<Color4[][]>;
  22819. }): VertexData;
  22820. /**
  22821. * Create the VertexData for a DashedLines
  22822. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22823. * - points an array successive Vector3
  22824. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22825. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22826. * - dashNb the intended total number of dashes, optional, default 200
  22827. * @returns the VertexData for the DashedLines
  22828. */
  22829. static CreateDashedLines(options: {
  22830. points: Vector3[];
  22831. dashSize?: number;
  22832. gapSize?: number;
  22833. dashNb?: number;
  22834. }): VertexData;
  22835. /**
  22836. * Creates the VertexData for a Ground
  22837. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22838. * - width the width (x direction) of the ground, optional, default 1
  22839. * - height the height (z direction) of the ground, optional, default 1
  22840. * - subdivisions the number of subdivisions per side, optional, default 1
  22841. * @returns the VertexData of the Ground
  22842. */
  22843. static CreateGround(options: {
  22844. width?: number;
  22845. height?: number;
  22846. subdivisions?: number;
  22847. subdivisionsX?: number;
  22848. subdivisionsY?: number;
  22849. }): VertexData;
  22850. /**
  22851. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22852. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22853. * * xmin the ground minimum X coordinate, optional, default -1
  22854. * * zmin the ground minimum Z coordinate, optional, default -1
  22855. * * xmax the ground maximum X coordinate, optional, default 1
  22856. * * zmax the ground maximum Z coordinate, optional, default 1
  22857. * * 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}
  22858. * * 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}
  22859. * @returns the VertexData of the TiledGround
  22860. */
  22861. static CreateTiledGround(options: {
  22862. xmin: number;
  22863. zmin: number;
  22864. xmax: number;
  22865. zmax: number;
  22866. subdivisions?: {
  22867. w: number;
  22868. h: number;
  22869. };
  22870. precision?: {
  22871. w: number;
  22872. h: number;
  22873. };
  22874. }): VertexData;
  22875. /**
  22876. * Creates the VertexData of the Ground designed from a heightmap
  22877. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22878. * * width the width (x direction) of the ground
  22879. * * height the height (z direction) of the ground
  22880. * * subdivisions the number of subdivisions per side
  22881. * * minHeight the minimum altitude on the ground, optional, default 0
  22882. * * maxHeight the maximum altitude on the ground, optional default 1
  22883. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22884. * * buffer the array holding the image color data
  22885. * * bufferWidth the width of image
  22886. * * bufferHeight the height of image
  22887. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22888. * @returns the VertexData of the Ground designed from a heightmap
  22889. */
  22890. static CreateGroundFromHeightMap(options: {
  22891. width: number;
  22892. height: number;
  22893. subdivisions: number;
  22894. minHeight: number;
  22895. maxHeight: number;
  22896. colorFilter: Color3;
  22897. buffer: Uint8Array;
  22898. bufferWidth: number;
  22899. bufferHeight: number;
  22900. alphaFilter: number;
  22901. }): VertexData;
  22902. /**
  22903. * Creates the VertexData for a Plane
  22904. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22905. * * size sets the width and height of the plane to the value of size, optional default 1
  22906. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22907. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22908. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22909. * * 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)
  22910. * * 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)
  22911. * @returns the VertexData of the box
  22912. */
  22913. static CreatePlane(options: {
  22914. size?: number;
  22915. width?: number;
  22916. height?: number;
  22917. sideOrientation?: number;
  22918. frontUVs?: Vector4;
  22919. backUVs?: Vector4;
  22920. }): VertexData;
  22921. /**
  22922. * Creates the VertexData of the Disc or regular Polygon
  22923. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22924. * * radius the radius of the disc, optional default 0.5
  22925. * * tessellation the number of polygon sides, optional, default 64
  22926. * * 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
  22927. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22928. * * 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)
  22929. * * 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)
  22930. * @returns the VertexData of the box
  22931. */
  22932. static CreateDisc(options: {
  22933. radius?: number;
  22934. tessellation?: number;
  22935. arc?: number;
  22936. sideOrientation?: number;
  22937. frontUVs?: Vector4;
  22938. backUVs?: Vector4;
  22939. }): VertexData;
  22940. /**
  22941. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22942. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22943. * @param polygon a mesh built from polygonTriangulation.build()
  22944. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22945. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22946. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22947. * @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)
  22948. * @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)
  22949. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  22950. * @returns the VertexData of the Polygon
  22951. */
  22952. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  22953. /**
  22954. * Creates the VertexData of the IcoSphere
  22955. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22956. * * radius the radius of the IcoSphere, optional default 1
  22957. * * radiusX allows stretching in the x direction, optional, default radius
  22958. * * radiusY allows stretching in the y direction, optional, default radius
  22959. * * radiusZ allows stretching in the z direction, optional, default radius
  22960. * * flat when true creates a flat shaded mesh, optional, default true
  22961. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22963. * * 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)
  22964. * * 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)
  22965. * @returns the VertexData of the IcoSphere
  22966. */
  22967. static CreateIcoSphere(options: {
  22968. radius?: number;
  22969. radiusX?: number;
  22970. radiusY?: number;
  22971. radiusZ?: number;
  22972. flat?: boolean;
  22973. subdivisions?: number;
  22974. sideOrientation?: number;
  22975. frontUVs?: Vector4;
  22976. backUVs?: Vector4;
  22977. }): VertexData;
  22978. /**
  22979. * Creates the VertexData for a Polyhedron
  22980. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22981. * * type provided types are:
  22982. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22983. * * 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)
  22984. * * size the size of the IcoSphere, optional default 1
  22985. * * sizeX allows stretching in the x direction, optional, default size
  22986. * * sizeY allows stretching in the y direction, optional, default size
  22987. * * sizeZ allows stretching in the z direction, optional, default size
  22988. * * 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
  22989. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22990. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22991. * * flat when true creates a flat shaded mesh, optional, default true
  22992. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22993. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22994. * * 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)
  22995. * * 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)
  22996. * @returns the VertexData of the Polyhedron
  22997. */
  22998. static CreatePolyhedron(options: {
  22999. type?: number;
  23000. size?: number;
  23001. sizeX?: number;
  23002. sizeY?: number;
  23003. sizeZ?: number;
  23004. custom?: any;
  23005. faceUV?: Vector4[];
  23006. faceColors?: Color4[];
  23007. flat?: boolean;
  23008. sideOrientation?: number;
  23009. frontUVs?: Vector4;
  23010. backUVs?: Vector4;
  23011. }): VertexData;
  23012. /**
  23013. * Creates the VertexData for a TorusKnot
  23014. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23015. * * radius the radius of the torus knot, optional, default 2
  23016. * * tube the thickness of the tube, optional, default 0.5
  23017. * * radialSegments the number of sides on each tube segments, optional, default 32
  23018. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23019. * * p the number of windings around the z axis, optional, default 2
  23020. * * q the number of windings around the x axis, optional, default 3
  23021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23022. * * 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)
  23023. * * 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)
  23024. * @returns the VertexData of the Torus Knot
  23025. */
  23026. static CreateTorusKnot(options: {
  23027. radius?: number;
  23028. tube?: number;
  23029. radialSegments?: number;
  23030. tubularSegments?: number;
  23031. p?: number;
  23032. q?: number;
  23033. sideOrientation?: number;
  23034. frontUVs?: Vector4;
  23035. backUVs?: Vector4;
  23036. }): VertexData;
  23037. /**
  23038. * Compute normals for given positions and indices
  23039. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23040. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23041. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23042. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23043. * * facetNormals : optional array of facet normals (vector3)
  23044. * * facetPositions : optional array of facet positions (vector3)
  23045. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23046. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23047. * * bInfo : optional bounding info, required for facetPartitioning computation
  23048. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23049. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23050. * * useRightHandedSystem: optional boolean to for right handed system computation
  23051. * * depthSort : optional boolean to enable the facet depth sort computation
  23052. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23053. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23054. */
  23055. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23056. facetNormals?: any;
  23057. facetPositions?: any;
  23058. facetPartitioning?: any;
  23059. ratio?: number;
  23060. bInfo?: any;
  23061. bbSize?: Vector3;
  23062. subDiv?: any;
  23063. useRightHandedSystem?: boolean;
  23064. depthSort?: boolean;
  23065. distanceTo?: Vector3;
  23066. depthSortedFacets?: any;
  23067. }): void;
  23068. /** @hidden */
  23069. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23070. /**
  23071. * Applies VertexData created from the imported parameters to the geometry
  23072. * @param parsedVertexData the parsed data from an imported file
  23073. * @param geometry the geometry to apply the VertexData to
  23074. */
  23075. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23076. }
  23077. }
  23078. declare module BABYLON {
  23079. /**
  23080. * Defines a target to use with MorphTargetManager
  23081. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23082. */
  23083. export class MorphTarget implements IAnimatable {
  23084. /** defines the name of the target */
  23085. name: string;
  23086. /**
  23087. * Gets or sets the list of animations
  23088. */
  23089. animations: Animation[];
  23090. private _scene;
  23091. private _positions;
  23092. private _normals;
  23093. private _tangents;
  23094. private _uvs;
  23095. private _influence;
  23096. private _uniqueId;
  23097. /**
  23098. * Observable raised when the influence changes
  23099. */
  23100. onInfluenceChanged: Observable<boolean>;
  23101. /** @hidden */
  23102. _onDataLayoutChanged: Observable<void>;
  23103. /**
  23104. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23105. */
  23106. get influence(): number;
  23107. set influence(influence: number);
  23108. /**
  23109. * Gets or sets the id of the morph Target
  23110. */
  23111. id: string;
  23112. private _animationPropertiesOverride;
  23113. /**
  23114. * Gets or sets the animation properties override
  23115. */
  23116. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23117. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23118. /**
  23119. * Creates a new MorphTarget
  23120. * @param name defines the name of the target
  23121. * @param influence defines the influence to use
  23122. * @param scene defines the scene the morphtarget belongs to
  23123. */
  23124. constructor(
  23125. /** defines the name of the target */
  23126. name: string, influence?: number, scene?: Nullable<Scene>);
  23127. /**
  23128. * Gets the unique ID of this manager
  23129. */
  23130. get uniqueId(): number;
  23131. /**
  23132. * Gets a boolean defining if the target contains position data
  23133. */
  23134. get hasPositions(): boolean;
  23135. /**
  23136. * Gets a boolean defining if the target contains normal data
  23137. */
  23138. get hasNormals(): boolean;
  23139. /**
  23140. * Gets a boolean defining if the target contains tangent data
  23141. */
  23142. get hasTangents(): boolean;
  23143. /**
  23144. * Gets a boolean defining if the target contains texture coordinates data
  23145. */
  23146. get hasUVs(): boolean;
  23147. /**
  23148. * Affects position data to this target
  23149. * @param data defines the position data to use
  23150. */
  23151. setPositions(data: Nullable<FloatArray>): void;
  23152. /**
  23153. * Gets the position data stored in this target
  23154. * @returns a FloatArray containing the position data (or null if not present)
  23155. */
  23156. getPositions(): Nullable<FloatArray>;
  23157. /**
  23158. * Affects normal data to this target
  23159. * @param data defines the normal data to use
  23160. */
  23161. setNormals(data: Nullable<FloatArray>): void;
  23162. /**
  23163. * Gets the normal data stored in this target
  23164. * @returns a FloatArray containing the normal data (or null if not present)
  23165. */
  23166. getNormals(): Nullable<FloatArray>;
  23167. /**
  23168. * Affects tangent data to this target
  23169. * @param data defines the tangent data to use
  23170. */
  23171. setTangents(data: Nullable<FloatArray>): void;
  23172. /**
  23173. * Gets the tangent data stored in this target
  23174. * @returns a FloatArray containing the tangent data (or null if not present)
  23175. */
  23176. getTangents(): Nullable<FloatArray>;
  23177. /**
  23178. * Affects texture coordinates data to this target
  23179. * @param data defines the texture coordinates data to use
  23180. */
  23181. setUVs(data: Nullable<FloatArray>): void;
  23182. /**
  23183. * Gets the texture coordinates data stored in this target
  23184. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23185. */
  23186. getUVs(): Nullable<FloatArray>;
  23187. /**
  23188. * Clone the current target
  23189. * @returns a new MorphTarget
  23190. */
  23191. clone(): MorphTarget;
  23192. /**
  23193. * Serializes the current target into a Serialization object
  23194. * @returns the serialized object
  23195. */
  23196. serialize(): any;
  23197. /**
  23198. * Returns the string "MorphTarget"
  23199. * @returns "MorphTarget"
  23200. */
  23201. getClassName(): string;
  23202. /**
  23203. * Creates a new target from serialized data
  23204. * @param serializationObject defines the serialized data to use
  23205. * @returns a new MorphTarget
  23206. */
  23207. static Parse(serializationObject: any): MorphTarget;
  23208. /**
  23209. * Creates a MorphTarget from mesh data
  23210. * @param mesh defines the source mesh
  23211. * @param name defines the name to use for the new target
  23212. * @param influence defines the influence to attach to the target
  23213. * @returns a new MorphTarget
  23214. */
  23215. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23216. }
  23217. }
  23218. declare module BABYLON {
  23219. /**
  23220. * This class is used to deform meshes using morphing between different targets
  23221. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23222. */
  23223. export class MorphTargetManager {
  23224. private _targets;
  23225. private _targetInfluenceChangedObservers;
  23226. private _targetDataLayoutChangedObservers;
  23227. private _activeTargets;
  23228. private _scene;
  23229. private _influences;
  23230. private _supportsNormals;
  23231. private _supportsTangents;
  23232. private _supportsUVs;
  23233. private _vertexCount;
  23234. private _uniqueId;
  23235. private _tempInfluences;
  23236. /**
  23237. * Gets or sets a boolean indicating if normals must be morphed
  23238. */
  23239. enableNormalMorphing: boolean;
  23240. /**
  23241. * Gets or sets a boolean indicating if tangents must be morphed
  23242. */
  23243. enableTangentMorphing: boolean;
  23244. /**
  23245. * Gets or sets a boolean indicating if UV must be morphed
  23246. */
  23247. enableUVMorphing: boolean;
  23248. /**
  23249. * Creates a new MorphTargetManager
  23250. * @param scene defines the current scene
  23251. */
  23252. constructor(scene?: Nullable<Scene>);
  23253. /**
  23254. * Gets the unique ID of this manager
  23255. */
  23256. get uniqueId(): number;
  23257. /**
  23258. * Gets the number of vertices handled by this manager
  23259. */
  23260. get vertexCount(): number;
  23261. /**
  23262. * Gets a boolean indicating if this manager supports morphing of normals
  23263. */
  23264. get supportsNormals(): boolean;
  23265. /**
  23266. * Gets a boolean indicating if this manager supports morphing of tangents
  23267. */
  23268. get supportsTangents(): boolean;
  23269. /**
  23270. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23271. */
  23272. get supportsUVs(): boolean;
  23273. /**
  23274. * Gets the number of targets stored in this manager
  23275. */
  23276. get numTargets(): number;
  23277. /**
  23278. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23279. */
  23280. get numInfluencers(): number;
  23281. /**
  23282. * Gets the list of influences (one per target)
  23283. */
  23284. get influences(): Float32Array;
  23285. /**
  23286. * Gets the active target at specified index. An active target is a target with an influence > 0
  23287. * @param index defines the index to check
  23288. * @returns the requested target
  23289. */
  23290. getActiveTarget(index: number): MorphTarget;
  23291. /**
  23292. * Gets the target at specified index
  23293. * @param index defines the index to check
  23294. * @returns the requested target
  23295. */
  23296. getTarget(index: number): MorphTarget;
  23297. /**
  23298. * Add a new target to this manager
  23299. * @param target defines the target to add
  23300. */
  23301. addTarget(target: MorphTarget): void;
  23302. /**
  23303. * Removes a target from the manager
  23304. * @param target defines the target to remove
  23305. */
  23306. removeTarget(target: MorphTarget): void;
  23307. /**
  23308. * Clone the current manager
  23309. * @returns a new MorphTargetManager
  23310. */
  23311. clone(): MorphTargetManager;
  23312. /**
  23313. * Serializes the current manager into a Serialization object
  23314. * @returns the serialized object
  23315. */
  23316. serialize(): any;
  23317. private _syncActiveTargets;
  23318. /**
  23319. * Syncrhonize the targets with all the meshes using this morph target manager
  23320. */
  23321. synchronize(): void;
  23322. /**
  23323. * Creates a new MorphTargetManager from serialized data
  23324. * @param serializationObject defines the serialized data
  23325. * @param scene defines the hosting scene
  23326. * @returns the new MorphTargetManager
  23327. */
  23328. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23329. }
  23330. }
  23331. declare module BABYLON {
  23332. /**
  23333. * Class used to represent a specific level of detail of a mesh
  23334. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23335. */
  23336. export class MeshLODLevel {
  23337. /** Defines the distance where this level should start being displayed */
  23338. distance: number;
  23339. /** Defines the mesh to use to render this level */
  23340. mesh: Nullable<Mesh>;
  23341. /**
  23342. * Creates a new LOD level
  23343. * @param distance defines the distance where this level should star being displayed
  23344. * @param mesh defines the mesh to use to render this level
  23345. */
  23346. constructor(
  23347. /** Defines the distance where this level should start being displayed */
  23348. distance: number,
  23349. /** Defines the mesh to use to render this level */
  23350. mesh: Nullable<Mesh>);
  23351. }
  23352. }
  23353. declare module BABYLON {
  23354. /**
  23355. * Mesh representing the gorund
  23356. */
  23357. export class GroundMesh extends Mesh {
  23358. /** If octree should be generated */
  23359. generateOctree: boolean;
  23360. private _heightQuads;
  23361. /** @hidden */
  23362. _subdivisionsX: number;
  23363. /** @hidden */
  23364. _subdivisionsY: number;
  23365. /** @hidden */
  23366. _width: number;
  23367. /** @hidden */
  23368. _height: number;
  23369. /** @hidden */
  23370. _minX: number;
  23371. /** @hidden */
  23372. _maxX: number;
  23373. /** @hidden */
  23374. _minZ: number;
  23375. /** @hidden */
  23376. _maxZ: number;
  23377. constructor(name: string, scene: Scene);
  23378. /**
  23379. * "GroundMesh"
  23380. * @returns "GroundMesh"
  23381. */
  23382. getClassName(): string;
  23383. /**
  23384. * The minimum of x and y subdivisions
  23385. */
  23386. get subdivisions(): number;
  23387. /**
  23388. * X subdivisions
  23389. */
  23390. get subdivisionsX(): number;
  23391. /**
  23392. * Y subdivisions
  23393. */
  23394. get subdivisionsY(): number;
  23395. /**
  23396. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23397. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23398. * @param chunksCount the number of subdivisions for x and y
  23399. * @param octreeBlocksSize (Default: 32)
  23400. */
  23401. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23402. /**
  23403. * Returns a height (y) value in the Worl system :
  23404. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23405. * @param x x coordinate
  23406. * @param z z coordinate
  23407. * @returns the ground y position if (x, z) are outside the ground surface.
  23408. */
  23409. getHeightAtCoordinates(x: number, z: number): number;
  23410. /**
  23411. * Returns a normalized vector (Vector3) orthogonal to the ground
  23412. * at the ground coordinates (x, z) expressed in the World system.
  23413. * @param x x coordinate
  23414. * @param z z coordinate
  23415. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23416. */
  23417. getNormalAtCoordinates(x: number, z: number): Vector3;
  23418. /**
  23419. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23420. * at the ground coordinates (x, z) expressed in the World system.
  23421. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23422. * @param x x coordinate
  23423. * @param z z coordinate
  23424. * @param ref vector to store the result
  23425. * @returns the GroundMesh.
  23426. */
  23427. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23428. /**
  23429. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23430. * if the ground has been updated.
  23431. * This can be used in the render loop.
  23432. * @returns the GroundMesh.
  23433. */
  23434. updateCoordinateHeights(): GroundMesh;
  23435. private _getFacetAt;
  23436. private _initHeightQuads;
  23437. private _computeHeightQuads;
  23438. /**
  23439. * Serializes this ground mesh
  23440. * @param serializationObject object to write serialization to
  23441. */
  23442. serialize(serializationObject: any): void;
  23443. /**
  23444. * Parses a serialized ground mesh
  23445. * @param parsedMesh the serialized mesh
  23446. * @param scene the scene to create the ground mesh in
  23447. * @returns the created ground mesh
  23448. */
  23449. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23450. }
  23451. }
  23452. declare module BABYLON {
  23453. /**
  23454. * Interface for Physics-Joint data
  23455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23456. */
  23457. export interface PhysicsJointData {
  23458. /**
  23459. * The main pivot of the joint
  23460. */
  23461. mainPivot?: Vector3;
  23462. /**
  23463. * The connected pivot of the joint
  23464. */
  23465. connectedPivot?: Vector3;
  23466. /**
  23467. * The main axis of the joint
  23468. */
  23469. mainAxis?: Vector3;
  23470. /**
  23471. * The connected axis of the joint
  23472. */
  23473. connectedAxis?: Vector3;
  23474. /**
  23475. * The collision of the joint
  23476. */
  23477. collision?: boolean;
  23478. /**
  23479. * Native Oimo/Cannon/Energy data
  23480. */
  23481. nativeParams?: any;
  23482. }
  23483. /**
  23484. * This is a holder class for the physics joint created by the physics plugin
  23485. * It holds a set of functions to control the underlying joint
  23486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23487. */
  23488. export class PhysicsJoint {
  23489. /**
  23490. * The type of the physics joint
  23491. */
  23492. type: number;
  23493. /**
  23494. * The data for the physics joint
  23495. */
  23496. jointData: PhysicsJointData;
  23497. private _physicsJoint;
  23498. protected _physicsPlugin: IPhysicsEnginePlugin;
  23499. /**
  23500. * Initializes the physics joint
  23501. * @param type The type of the physics joint
  23502. * @param jointData The data for the physics joint
  23503. */
  23504. constructor(
  23505. /**
  23506. * The type of the physics joint
  23507. */
  23508. type: number,
  23509. /**
  23510. * The data for the physics joint
  23511. */
  23512. jointData: PhysicsJointData);
  23513. /**
  23514. * Gets the physics joint
  23515. */
  23516. get physicsJoint(): any;
  23517. /**
  23518. * Sets the physics joint
  23519. */
  23520. set physicsJoint(newJoint: any);
  23521. /**
  23522. * Sets the physics plugin
  23523. */
  23524. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23525. /**
  23526. * Execute a function that is physics-plugin specific.
  23527. * @param {Function} func the function that will be executed.
  23528. * It accepts two parameters: the physics world and the physics joint
  23529. */
  23530. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23531. /**
  23532. * Distance-Joint type
  23533. */
  23534. static DistanceJoint: number;
  23535. /**
  23536. * Hinge-Joint type
  23537. */
  23538. static HingeJoint: number;
  23539. /**
  23540. * Ball-and-Socket joint type
  23541. */
  23542. static BallAndSocketJoint: number;
  23543. /**
  23544. * Wheel-Joint type
  23545. */
  23546. static WheelJoint: number;
  23547. /**
  23548. * Slider-Joint type
  23549. */
  23550. static SliderJoint: number;
  23551. /**
  23552. * Prismatic-Joint type
  23553. */
  23554. static PrismaticJoint: number;
  23555. /**
  23556. * Universal-Joint type
  23557. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23558. */
  23559. static UniversalJoint: number;
  23560. /**
  23561. * Hinge-Joint 2 type
  23562. */
  23563. static Hinge2Joint: number;
  23564. /**
  23565. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23566. */
  23567. static PointToPointJoint: number;
  23568. /**
  23569. * Spring-Joint type
  23570. */
  23571. static SpringJoint: number;
  23572. /**
  23573. * Lock-Joint type
  23574. */
  23575. static LockJoint: number;
  23576. }
  23577. /**
  23578. * A class representing a physics distance joint
  23579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23580. */
  23581. export class DistanceJoint extends PhysicsJoint {
  23582. /**
  23583. *
  23584. * @param jointData The data for the Distance-Joint
  23585. */
  23586. constructor(jointData: DistanceJointData);
  23587. /**
  23588. * Update the predefined distance.
  23589. * @param maxDistance The maximum preferred distance
  23590. * @param minDistance The minimum preferred distance
  23591. */
  23592. updateDistance(maxDistance: number, minDistance?: number): void;
  23593. }
  23594. /**
  23595. * Represents a Motor-Enabled Joint
  23596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23597. */
  23598. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23599. /**
  23600. * Initializes the Motor-Enabled Joint
  23601. * @param type The type of the joint
  23602. * @param jointData The physica joint data for the joint
  23603. */
  23604. constructor(type: number, jointData: PhysicsJointData);
  23605. /**
  23606. * Set the motor values.
  23607. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23608. * @param force the force to apply
  23609. * @param maxForce max force for this motor.
  23610. */
  23611. setMotor(force?: number, maxForce?: number): void;
  23612. /**
  23613. * Set the motor's limits.
  23614. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23615. * @param upperLimit The upper limit of the motor
  23616. * @param lowerLimit The lower limit of the motor
  23617. */
  23618. setLimit(upperLimit: number, lowerLimit?: number): void;
  23619. }
  23620. /**
  23621. * This class represents a single physics Hinge-Joint
  23622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23623. */
  23624. export class HingeJoint extends MotorEnabledJoint {
  23625. /**
  23626. * Initializes the Hinge-Joint
  23627. * @param jointData The joint data for the Hinge-Joint
  23628. */
  23629. constructor(jointData: PhysicsJointData);
  23630. /**
  23631. * Set the motor values.
  23632. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23633. * @param {number} force the force to apply
  23634. * @param {number} maxForce max force for this motor.
  23635. */
  23636. setMotor(force?: number, maxForce?: number): void;
  23637. /**
  23638. * Set the motor's limits.
  23639. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23640. * @param upperLimit The upper limit of the motor
  23641. * @param lowerLimit The lower limit of the motor
  23642. */
  23643. setLimit(upperLimit: number, lowerLimit?: number): void;
  23644. }
  23645. /**
  23646. * This class represents a dual hinge physics joint (same as wheel joint)
  23647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23648. */
  23649. export class Hinge2Joint extends MotorEnabledJoint {
  23650. /**
  23651. * Initializes the Hinge2-Joint
  23652. * @param jointData The joint data for the Hinge2-Joint
  23653. */
  23654. constructor(jointData: PhysicsJointData);
  23655. /**
  23656. * Set the motor values.
  23657. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23658. * @param {number} targetSpeed the speed the motor is to reach
  23659. * @param {number} maxForce max force for this motor.
  23660. * @param {motorIndex} the motor's index, 0 or 1.
  23661. */
  23662. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23663. /**
  23664. * Set the motor limits.
  23665. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23666. * @param {number} upperLimit the upper limit
  23667. * @param {number} lowerLimit lower limit
  23668. * @param {motorIndex} the motor's index, 0 or 1.
  23669. */
  23670. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23671. }
  23672. /**
  23673. * Interface for a motor enabled joint
  23674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23675. */
  23676. export interface IMotorEnabledJoint {
  23677. /**
  23678. * Physics joint
  23679. */
  23680. physicsJoint: any;
  23681. /**
  23682. * Sets the motor of the motor-enabled joint
  23683. * @param force The force of the motor
  23684. * @param maxForce The maximum force of the motor
  23685. * @param motorIndex The index of the motor
  23686. */
  23687. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23688. /**
  23689. * Sets the limit of the motor
  23690. * @param upperLimit The upper limit of the motor
  23691. * @param lowerLimit The lower limit of the motor
  23692. * @param motorIndex The index of the motor
  23693. */
  23694. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23695. }
  23696. /**
  23697. * Joint data for a Distance-Joint
  23698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23699. */
  23700. export interface DistanceJointData extends PhysicsJointData {
  23701. /**
  23702. * Max distance the 2 joint objects can be apart
  23703. */
  23704. maxDistance: number;
  23705. }
  23706. /**
  23707. * Joint data from a spring joint
  23708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23709. */
  23710. export interface SpringJointData extends PhysicsJointData {
  23711. /**
  23712. * Length of the spring
  23713. */
  23714. length: number;
  23715. /**
  23716. * Stiffness of the spring
  23717. */
  23718. stiffness: number;
  23719. /**
  23720. * Damping of the spring
  23721. */
  23722. damping: number;
  23723. /** this callback will be called when applying the force to the impostors. */
  23724. forceApplicationCallback: () => void;
  23725. }
  23726. }
  23727. declare module BABYLON {
  23728. /**
  23729. * Holds the data for the raycast result
  23730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23731. */
  23732. export class PhysicsRaycastResult {
  23733. private _hasHit;
  23734. private _hitDistance;
  23735. private _hitNormalWorld;
  23736. private _hitPointWorld;
  23737. private _rayFromWorld;
  23738. private _rayToWorld;
  23739. /**
  23740. * Gets if there was a hit
  23741. */
  23742. get hasHit(): boolean;
  23743. /**
  23744. * Gets the distance from the hit
  23745. */
  23746. get hitDistance(): number;
  23747. /**
  23748. * Gets the hit normal/direction in the world
  23749. */
  23750. get hitNormalWorld(): Vector3;
  23751. /**
  23752. * Gets the hit point in the world
  23753. */
  23754. get hitPointWorld(): Vector3;
  23755. /**
  23756. * Gets the ray "start point" of the ray in the world
  23757. */
  23758. get rayFromWorld(): Vector3;
  23759. /**
  23760. * Gets the ray "end point" of the ray in the world
  23761. */
  23762. get rayToWorld(): Vector3;
  23763. /**
  23764. * Sets the hit data (normal & point in world space)
  23765. * @param hitNormalWorld defines the normal in world space
  23766. * @param hitPointWorld defines the point in world space
  23767. */
  23768. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23769. /**
  23770. * Sets the distance from the start point to the hit point
  23771. * @param distance
  23772. */
  23773. setHitDistance(distance: number): void;
  23774. /**
  23775. * Calculates the distance manually
  23776. */
  23777. calculateHitDistance(): void;
  23778. /**
  23779. * Resets all the values to default
  23780. * @param from The from point on world space
  23781. * @param to The to point on world space
  23782. */
  23783. reset(from?: Vector3, to?: Vector3): void;
  23784. }
  23785. /**
  23786. * Interface for the size containing width and height
  23787. */
  23788. interface IXYZ {
  23789. /**
  23790. * X
  23791. */
  23792. x: number;
  23793. /**
  23794. * Y
  23795. */
  23796. y: number;
  23797. /**
  23798. * Z
  23799. */
  23800. z: number;
  23801. }
  23802. }
  23803. declare module BABYLON {
  23804. /**
  23805. * Interface used to describe a physics joint
  23806. */
  23807. export interface PhysicsImpostorJoint {
  23808. /** Defines the main impostor to which the joint is linked */
  23809. mainImpostor: PhysicsImpostor;
  23810. /** Defines the impostor that is connected to the main impostor using this joint */
  23811. connectedImpostor: PhysicsImpostor;
  23812. /** Defines the joint itself */
  23813. joint: PhysicsJoint;
  23814. }
  23815. /** @hidden */
  23816. export interface IPhysicsEnginePlugin {
  23817. world: any;
  23818. name: string;
  23819. setGravity(gravity: Vector3): void;
  23820. setTimeStep(timeStep: number): void;
  23821. getTimeStep(): number;
  23822. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23823. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23824. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23825. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23826. removePhysicsBody(impostor: PhysicsImpostor): void;
  23827. generateJoint(joint: PhysicsImpostorJoint): void;
  23828. removeJoint(joint: PhysicsImpostorJoint): void;
  23829. isSupported(): boolean;
  23830. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23831. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23832. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23833. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23834. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23835. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23836. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23837. getBodyMass(impostor: PhysicsImpostor): number;
  23838. getBodyFriction(impostor: PhysicsImpostor): number;
  23839. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23840. getBodyRestitution(impostor: PhysicsImpostor): number;
  23841. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23842. getBodyPressure?(impostor: PhysicsImpostor): number;
  23843. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23844. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23845. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23846. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23847. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23848. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23849. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23850. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23851. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23852. sleepBody(impostor: PhysicsImpostor): void;
  23853. wakeUpBody(impostor: PhysicsImpostor): void;
  23854. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23855. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23856. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23857. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23858. getRadius(impostor: PhysicsImpostor): number;
  23859. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23860. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23861. dispose(): void;
  23862. }
  23863. /**
  23864. * Interface used to define a physics engine
  23865. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23866. */
  23867. export interface IPhysicsEngine {
  23868. /**
  23869. * Gets the gravity vector used by the simulation
  23870. */
  23871. gravity: Vector3;
  23872. /**
  23873. * Sets the gravity vector used by the simulation
  23874. * @param gravity defines the gravity vector to use
  23875. */
  23876. setGravity(gravity: Vector3): void;
  23877. /**
  23878. * Set the time step of the physics engine.
  23879. * Default is 1/60.
  23880. * To slow it down, enter 1/600 for example.
  23881. * To speed it up, 1/30
  23882. * @param newTimeStep the new timestep to apply to this world.
  23883. */
  23884. setTimeStep(newTimeStep: number): void;
  23885. /**
  23886. * Get the time step of the physics engine.
  23887. * @returns the current time step
  23888. */
  23889. getTimeStep(): number;
  23890. /**
  23891. * Set the sub time step of the physics engine.
  23892. * Default is 0 meaning there is no sub steps
  23893. * To increase physics resolution precision, set a small value (like 1 ms)
  23894. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23895. */
  23896. setSubTimeStep(subTimeStep: number): void;
  23897. /**
  23898. * Get the sub time step of the physics engine.
  23899. * @returns the current sub time step
  23900. */
  23901. getSubTimeStep(): number;
  23902. /**
  23903. * Release all resources
  23904. */
  23905. dispose(): void;
  23906. /**
  23907. * Gets the name of the current physics plugin
  23908. * @returns the name of the plugin
  23909. */
  23910. getPhysicsPluginName(): string;
  23911. /**
  23912. * Adding a new impostor for the impostor tracking.
  23913. * This will be done by the impostor itself.
  23914. * @param impostor the impostor to add
  23915. */
  23916. addImpostor(impostor: PhysicsImpostor): void;
  23917. /**
  23918. * Remove an impostor from the engine.
  23919. * This impostor and its mesh will not longer be updated by the physics engine.
  23920. * @param impostor the impostor to remove
  23921. */
  23922. removeImpostor(impostor: PhysicsImpostor): void;
  23923. /**
  23924. * Add a joint to the physics engine
  23925. * @param mainImpostor defines the main impostor to which the joint is added.
  23926. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23927. * @param joint defines the joint that will connect both impostors.
  23928. */
  23929. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23930. /**
  23931. * Removes a joint from the simulation
  23932. * @param mainImpostor defines the impostor used with the joint
  23933. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23934. * @param joint defines the joint to remove
  23935. */
  23936. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23937. /**
  23938. * Gets the current plugin used to run the simulation
  23939. * @returns current plugin
  23940. */
  23941. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23942. /**
  23943. * Gets the list of physic impostors
  23944. * @returns an array of PhysicsImpostor
  23945. */
  23946. getImpostors(): Array<PhysicsImpostor>;
  23947. /**
  23948. * Gets the impostor for a physics enabled object
  23949. * @param object defines the object impersonated by the impostor
  23950. * @returns the PhysicsImpostor or null if not found
  23951. */
  23952. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23953. /**
  23954. * Gets the impostor for a physics body object
  23955. * @param body defines physics body used by the impostor
  23956. * @returns the PhysicsImpostor or null if not found
  23957. */
  23958. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23959. /**
  23960. * Does a raycast in the physics world
  23961. * @param from when should the ray start?
  23962. * @param to when should the ray end?
  23963. * @returns PhysicsRaycastResult
  23964. */
  23965. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23966. /**
  23967. * Called by the scene. No need to call it.
  23968. * @param delta defines the timespam between frames
  23969. */
  23970. _step(delta: number): void;
  23971. }
  23972. }
  23973. declare module BABYLON {
  23974. /**
  23975. * The interface for the physics imposter parameters
  23976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23977. */
  23978. export interface PhysicsImpostorParameters {
  23979. /**
  23980. * The mass of the physics imposter
  23981. */
  23982. mass: number;
  23983. /**
  23984. * The friction of the physics imposter
  23985. */
  23986. friction?: number;
  23987. /**
  23988. * The coefficient of restitution of the physics imposter
  23989. */
  23990. restitution?: number;
  23991. /**
  23992. * The native options of the physics imposter
  23993. */
  23994. nativeOptions?: any;
  23995. /**
  23996. * Specifies if the parent should be ignored
  23997. */
  23998. ignoreParent?: boolean;
  23999. /**
  24000. * Specifies if bi-directional transformations should be disabled
  24001. */
  24002. disableBidirectionalTransformation?: boolean;
  24003. /**
  24004. * The pressure inside the physics imposter, soft object only
  24005. */
  24006. pressure?: number;
  24007. /**
  24008. * The stiffness the physics imposter, soft object only
  24009. */
  24010. stiffness?: number;
  24011. /**
  24012. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24013. */
  24014. velocityIterations?: number;
  24015. /**
  24016. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24017. */
  24018. positionIterations?: number;
  24019. /**
  24020. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24021. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24022. * Add to fix multiple points
  24023. */
  24024. fixedPoints?: number;
  24025. /**
  24026. * The collision margin around a soft object
  24027. */
  24028. margin?: number;
  24029. /**
  24030. * The collision margin around a soft object
  24031. */
  24032. damping?: number;
  24033. /**
  24034. * The path for a rope based on an extrusion
  24035. */
  24036. path?: any;
  24037. /**
  24038. * The shape of an extrusion used for a rope based on an extrusion
  24039. */
  24040. shape?: any;
  24041. }
  24042. /**
  24043. * Interface for a physics-enabled object
  24044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24045. */
  24046. export interface IPhysicsEnabledObject {
  24047. /**
  24048. * The position of the physics-enabled object
  24049. */
  24050. position: Vector3;
  24051. /**
  24052. * The rotation of the physics-enabled object
  24053. */
  24054. rotationQuaternion: Nullable<Quaternion>;
  24055. /**
  24056. * The scale of the physics-enabled object
  24057. */
  24058. scaling: Vector3;
  24059. /**
  24060. * The rotation of the physics-enabled object
  24061. */
  24062. rotation?: Vector3;
  24063. /**
  24064. * The parent of the physics-enabled object
  24065. */
  24066. parent?: any;
  24067. /**
  24068. * The bounding info of the physics-enabled object
  24069. * @returns The bounding info of the physics-enabled object
  24070. */
  24071. getBoundingInfo(): BoundingInfo;
  24072. /**
  24073. * Computes the world matrix
  24074. * @param force Specifies if the world matrix should be computed by force
  24075. * @returns A world matrix
  24076. */
  24077. computeWorldMatrix(force: boolean): Matrix;
  24078. /**
  24079. * Gets the world matrix
  24080. * @returns A world matrix
  24081. */
  24082. getWorldMatrix?(): Matrix;
  24083. /**
  24084. * Gets the child meshes
  24085. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24086. * @returns An array of abstract meshes
  24087. */
  24088. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24089. /**
  24090. * Gets the vertex data
  24091. * @param kind The type of vertex data
  24092. * @returns A nullable array of numbers, or a float32 array
  24093. */
  24094. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24095. /**
  24096. * Gets the indices from the mesh
  24097. * @returns A nullable array of index arrays
  24098. */
  24099. getIndices?(): Nullable<IndicesArray>;
  24100. /**
  24101. * Gets the scene from the mesh
  24102. * @returns the indices array or null
  24103. */
  24104. getScene?(): Scene;
  24105. /**
  24106. * Gets the absolute position from the mesh
  24107. * @returns the absolute position
  24108. */
  24109. getAbsolutePosition(): Vector3;
  24110. /**
  24111. * Gets the absolute pivot point from the mesh
  24112. * @returns the absolute pivot point
  24113. */
  24114. getAbsolutePivotPoint(): Vector3;
  24115. /**
  24116. * Rotates the mesh
  24117. * @param axis The axis of rotation
  24118. * @param amount The amount of rotation
  24119. * @param space The space of the rotation
  24120. * @returns The rotation transform node
  24121. */
  24122. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24123. /**
  24124. * Translates the mesh
  24125. * @param axis The axis of translation
  24126. * @param distance The distance of translation
  24127. * @param space The space of the translation
  24128. * @returns The transform node
  24129. */
  24130. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24131. /**
  24132. * Sets the absolute position of the mesh
  24133. * @param absolutePosition The absolute position of the mesh
  24134. * @returns The transform node
  24135. */
  24136. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24137. /**
  24138. * Gets the class name of the mesh
  24139. * @returns The class name
  24140. */
  24141. getClassName(): string;
  24142. }
  24143. /**
  24144. * Represents a physics imposter
  24145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24146. */
  24147. export class PhysicsImpostor {
  24148. /**
  24149. * The physics-enabled object used as the physics imposter
  24150. */
  24151. object: IPhysicsEnabledObject;
  24152. /**
  24153. * The type of the physics imposter
  24154. */
  24155. type: number;
  24156. private _options;
  24157. private _scene?;
  24158. /**
  24159. * The default object size of the imposter
  24160. */
  24161. static DEFAULT_OBJECT_SIZE: Vector3;
  24162. /**
  24163. * The identity quaternion of the imposter
  24164. */
  24165. static IDENTITY_QUATERNION: Quaternion;
  24166. /** @hidden */
  24167. _pluginData: any;
  24168. private _physicsEngine;
  24169. private _physicsBody;
  24170. private _bodyUpdateRequired;
  24171. private _onBeforePhysicsStepCallbacks;
  24172. private _onAfterPhysicsStepCallbacks;
  24173. /** @hidden */
  24174. _onPhysicsCollideCallbacks: Array<{
  24175. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24176. otherImpostors: Array<PhysicsImpostor>;
  24177. }>;
  24178. private _deltaPosition;
  24179. private _deltaRotation;
  24180. private _deltaRotationConjugated;
  24181. /** @hidden */
  24182. _isFromLine: boolean;
  24183. private _parent;
  24184. private _isDisposed;
  24185. private static _tmpVecs;
  24186. private static _tmpQuat;
  24187. /**
  24188. * Specifies if the physics imposter is disposed
  24189. */
  24190. get isDisposed(): boolean;
  24191. /**
  24192. * Gets the mass of the physics imposter
  24193. */
  24194. get mass(): number;
  24195. set mass(value: number);
  24196. /**
  24197. * Gets the coefficient of friction
  24198. */
  24199. get friction(): number;
  24200. /**
  24201. * Sets the coefficient of friction
  24202. */
  24203. set friction(value: number);
  24204. /**
  24205. * Gets the coefficient of restitution
  24206. */
  24207. get restitution(): number;
  24208. /**
  24209. * Sets the coefficient of restitution
  24210. */
  24211. set restitution(value: number);
  24212. /**
  24213. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24214. */
  24215. get pressure(): number;
  24216. /**
  24217. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24218. */
  24219. set pressure(value: number);
  24220. /**
  24221. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24222. */
  24223. get stiffness(): number;
  24224. /**
  24225. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24226. */
  24227. set stiffness(value: number);
  24228. /**
  24229. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24230. */
  24231. get velocityIterations(): number;
  24232. /**
  24233. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24234. */
  24235. set velocityIterations(value: number);
  24236. /**
  24237. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24238. */
  24239. get positionIterations(): number;
  24240. /**
  24241. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24242. */
  24243. set positionIterations(value: number);
  24244. /**
  24245. * The unique id of the physics imposter
  24246. * set by the physics engine when adding this impostor to the array
  24247. */
  24248. uniqueId: number;
  24249. /**
  24250. * @hidden
  24251. */
  24252. soft: boolean;
  24253. /**
  24254. * @hidden
  24255. */
  24256. segments: number;
  24257. private _joints;
  24258. /**
  24259. * Initializes the physics imposter
  24260. * @param object The physics-enabled object used as the physics imposter
  24261. * @param type The type of the physics imposter
  24262. * @param _options The options for the physics imposter
  24263. * @param _scene The Babylon scene
  24264. */
  24265. constructor(
  24266. /**
  24267. * The physics-enabled object used as the physics imposter
  24268. */
  24269. object: IPhysicsEnabledObject,
  24270. /**
  24271. * The type of the physics imposter
  24272. */
  24273. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24274. /**
  24275. * This function will completly initialize this impostor.
  24276. * It will create a new body - but only if this mesh has no parent.
  24277. * If it has, this impostor will not be used other than to define the impostor
  24278. * of the child mesh.
  24279. * @hidden
  24280. */
  24281. _init(): void;
  24282. private _getPhysicsParent;
  24283. /**
  24284. * Should a new body be generated.
  24285. * @returns boolean specifying if body initialization is required
  24286. */
  24287. isBodyInitRequired(): boolean;
  24288. /**
  24289. * Sets the updated scaling
  24290. * @param updated Specifies if the scaling is updated
  24291. */
  24292. setScalingUpdated(): void;
  24293. /**
  24294. * Force a regeneration of this or the parent's impostor's body.
  24295. * Use under cautious - This will remove all joints already implemented.
  24296. */
  24297. forceUpdate(): void;
  24298. /**
  24299. * Gets the body that holds this impostor. Either its own, or its parent.
  24300. */
  24301. get physicsBody(): any;
  24302. /**
  24303. * Get the parent of the physics imposter
  24304. * @returns Physics imposter or null
  24305. */
  24306. get parent(): Nullable<PhysicsImpostor>;
  24307. /**
  24308. * Sets the parent of the physics imposter
  24309. */
  24310. set parent(value: Nullable<PhysicsImpostor>);
  24311. /**
  24312. * Set the physics body. Used mainly by the physics engine/plugin
  24313. */
  24314. set physicsBody(physicsBody: any);
  24315. /**
  24316. * Resets the update flags
  24317. */
  24318. resetUpdateFlags(): void;
  24319. /**
  24320. * Gets the object extend size
  24321. * @returns the object extend size
  24322. */
  24323. getObjectExtendSize(): Vector3;
  24324. /**
  24325. * Gets the object center
  24326. * @returns The object center
  24327. */
  24328. getObjectCenter(): Vector3;
  24329. /**
  24330. * Get a specific parameter from the options parameters
  24331. * @param paramName The object parameter name
  24332. * @returns The object parameter
  24333. */
  24334. getParam(paramName: string): any;
  24335. /**
  24336. * Sets a specific parameter in the options given to the physics plugin
  24337. * @param paramName The parameter name
  24338. * @param value The value of the parameter
  24339. */
  24340. setParam(paramName: string, value: number): void;
  24341. /**
  24342. * Specifically change the body's mass option. Won't recreate the physics body object
  24343. * @param mass The mass of the physics imposter
  24344. */
  24345. setMass(mass: number): void;
  24346. /**
  24347. * Gets the linear velocity
  24348. * @returns linear velocity or null
  24349. */
  24350. getLinearVelocity(): Nullable<Vector3>;
  24351. /**
  24352. * Sets the linear velocity
  24353. * @param velocity linear velocity or null
  24354. */
  24355. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24356. /**
  24357. * Gets the angular velocity
  24358. * @returns angular velocity or null
  24359. */
  24360. getAngularVelocity(): Nullable<Vector3>;
  24361. /**
  24362. * Sets the angular velocity
  24363. * @param velocity The velocity or null
  24364. */
  24365. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24366. /**
  24367. * Execute a function with the physics plugin native code
  24368. * Provide a function the will have two variables - the world object and the physics body object
  24369. * @param func The function to execute with the physics plugin native code
  24370. */
  24371. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24372. /**
  24373. * Register a function that will be executed before the physics world is stepping forward
  24374. * @param func The function to execute before the physics world is stepped forward
  24375. */
  24376. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24377. /**
  24378. * Unregister a function that will be executed before the physics world is stepping forward
  24379. * @param func The function to execute before the physics world is stepped forward
  24380. */
  24381. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24382. /**
  24383. * Register a function that will be executed after the physics step
  24384. * @param func The function to execute after physics step
  24385. */
  24386. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24387. /**
  24388. * Unregisters a function that will be executed after the physics step
  24389. * @param func The function to execute after physics step
  24390. */
  24391. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24392. /**
  24393. * register a function that will be executed when this impostor collides against a different body
  24394. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24395. * @param func Callback that is executed on collision
  24396. */
  24397. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24398. /**
  24399. * Unregisters the physics imposter on contact
  24400. * @param collideAgainst The physics object to collide against
  24401. * @param func Callback to execute on collision
  24402. */
  24403. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24404. private _tmpQuat;
  24405. private _tmpQuat2;
  24406. /**
  24407. * Get the parent rotation
  24408. * @returns The parent rotation
  24409. */
  24410. getParentsRotation(): Quaternion;
  24411. /**
  24412. * this function is executed by the physics engine.
  24413. */
  24414. beforeStep: () => void;
  24415. /**
  24416. * this function is executed by the physics engine
  24417. */
  24418. afterStep: () => void;
  24419. /**
  24420. * Legacy collision detection event support
  24421. */
  24422. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24423. /**
  24424. * event and body object due to cannon's event-based architecture.
  24425. */
  24426. onCollide: (e: {
  24427. body: any;
  24428. }) => void;
  24429. /**
  24430. * Apply a force
  24431. * @param force The force to apply
  24432. * @param contactPoint The contact point for the force
  24433. * @returns The physics imposter
  24434. */
  24435. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24436. /**
  24437. * Apply an impulse
  24438. * @param force The impulse force
  24439. * @param contactPoint The contact point for the impulse force
  24440. * @returns The physics imposter
  24441. */
  24442. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24443. /**
  24444. * A help function to create a joint
  24445. * @param otherImpostor A physics imposter used to create a joint
  24446. * @param jointType The type of joint
  24447. * @param jointData The data for the joint
  24448. * @returns The physics imposter
  24449. */
  24450. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24451. /**
  24452. * Add a joint to this impostor with a different impostor
  24453. * @param otherImpostor A physics imposter used to add a joint
  24454. * @param joint The joint to add
  24455. * @returns The physics imposter
  24456. */
  24457. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24458. /**
  24459. * Add an anchor to a cloth impostor
  24460. * @param otherImpostor rigid impostor to anchor to
  24461. * @param width ratio across width from 0 to 1
  24462. * @param height ratio up height from 0 to 1
  24463. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24464. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24465. * @returns impostor the soft imposter
  24466. */
  24467. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24468. /**
  24469. * Add a hook to a rope impostor
  24470. * @param otherImpostor rigid impostor to anchor to
  24471. * @param length ratio across rope from 0 to 1
  24472. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24473. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24474. * @returns impostor the rope imposter
  24475. */
  24476. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24477. /**
  24478. * Will keep this body still, in a sleep mode.
  24479. * @returns the physics imposter
  24480. */
  24481. sleep(): PhysicsImpostor;
  24482. /**
  24483. * Wake the body up.
  24484. * @returns The physics imposter
  24485. */
  24486. wakeUp(): PhysicsImpostor;
  24487. /**
  24488. * Clones the physics imposter
  24489. * @param newObject The physics imposter clones to this physics-enabled object
  24490. * @returns A nullable physics imposter
  24491. */
  24492. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24493. /**
  24494. * Disposes the physics imposter
  24495. */
  24496. dispose(): void;
  24497. /**
  24498. * Sets the delta position
  24499. * @param position The delta position amount
  24500. */
  24501. setDeltaPosition(position: Vector3): void;
  24502. /**
  24503. * Sets the delta rotation
  24504. * @param rotation The delta rotation amount
  24505. */
  24506. setDeltaRotation(rotation: Quaternion): void;
  24507. /**
  24508. * Gets the box size of the physics imposter and stores the result in the input parameter
  24509. * @param result Stores the box size
  24510. * @returns The physics imposter
  24511. */
  24512. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24513. /**
  24514. * Gets the radius of the physics imposter
  24515. * @returns Radius of the physics imposter
  24516. */
  24517. getRadius(): number;
  24518. /**
  24519. * Sync a bone with this impostor
  24520. * @param bone The bone to sync to the impostor.
  24521. * @param boneMesh The mesh that the bone is influencing.
  24522. * @param jointPivot The pivot of the joint / bone in local space.
  24523. * @param distToJoint Optional distance from the impostor to the joint.
  24524. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24525. */
  24526. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24527. /**
  24528. * Sync impostor to a bone
  24529. * @param bone The bone that the impostor will be synced to.
  24530. * @param boneMesh The mesh that the bone is influencing.
  24531. * @param jointPivot The pivot of the joint / bone in local space.
  24532. * @param distToJoint Optional distance from the impostor to the joint.
  24533. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24534. * @param boneAxis Optional vector3 axis the bone is aligned with
  24535. */
  24536. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24537. /**
  24538. * No-Imposter type
  24539. */
  24540. static NoImpostor: number;
  24541. /**
  24542. * Sphere-Imposter type
  24543. */
  24544. static SphereImpostor: number;
  24545. /**
  24546. * Box-Imposter type
  24547. */
  24548. static BoxImpostor: number;
  24549. /**
  24550. * Plane-Imposter type
  24551. */
  24552. static PlaneImpostor: number;
  24553. /**
  24554. * Mesh-imposter type
  24555. */
  24556. static MeshImpostor: number;
  24557. /**
  24558. * Capsule-Impostor type (Ammo.js plugin only)
  24559. */
  24560. static CapsuleImpostor: number;
  24561. /**
  24562. * Cylinder-Imposter type
  24563. */
  24564. static CylinderImpostor: number;
  24565. /**
  24566. * Particle-Imposter type
  24567. */
  24568. static ParticleImpostor: number;
  24569. /**
  24570. * Heightmap-Imposter type
  24571. */
  24572. static HeightmapImpostor: number;
  24573. /**
  24574. * ConvexHull-Impostor type (Ammo.js plugin only)
  24575. */
  24576. static ConvexHullImpostor: number;
  24577. /**
  24578. * Custom-Imposter type (Ammo.js plugin only)
  24579. */
  24580. static CustomImpostor: number;
  24581. /**
  24582. * Rope-Imposter type
  24583. */
  24584. static RopeImpostor: number;
  24585. /**
  24586. * Cloth-Imposter type
  24587. */
  24588. static ClothImpostor: number;
  24589. /**
  24590. * Softbody-Imposter type
  24591. */
  24592. static SoftbodyImpostor: number;
  24593. }
  24594. }
  24595. declare module BABYLON {
  24596. /**
  24597. * @hidden
  24598. **/
  24599. export class _CreationDataStorage {
  24600. closePath?: boolean;
  24601. closeArray?: boolean;
  24602. idx: number[];
  24603. dashSize: number;
  24604. gapSize: number;
  24605. path3D: Path3D;
  24606. pathArray: Vector3[][];
  24607. arc: number;
  24608. radius: number;
  24609. cap: number;
  24610. tessellation: number;
  24611. }
  24612. /**
  24613. * @hidden
  24614. **/
  24615. class _InstanceDataStorage {
  24616. visibleInstances: any;
  24617. batchCache: _InstancesBatch;
  24618. instancesBufferSize: number;
  24619. instancesBuffer: Nullable<Buffer>;
  24620. instancesData: Float32Array;
  24621. overridenInstanceCount: number;
  24622. isFrozen: boolean;
  24623. previousBatch: Nullable<_InstancesBatch>;
  24624. hardwareInstancedRendering: boolean;
  24625. sideOrientation: number;
  24626. manualUpdate: boolean;
  24627. }
  24628. /**
  24629. * @hidden
  24630. **/
  24631. export class _InstancesBatch {
  24632. mustReturn: boolean;
  24633. visibleInstances: Nullable<InstancedMesh[]>[];
  24634. renderSelf: boolean[];
  24635. hardwareInstancedRendering: boolean[];
  24636. }
  24637. /**
  24638. * Class used to represent renderable models
  24639. */
  24640. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24641. /**
  24642. * Mesh side orientation : usually the external or front surface
  24643. */
  24644. static readonly FRONTSIDE: number;
  24645. /**
  24646. * Mesh side orientation : usually the internal or back surface
  24647. */
  24648. static readonly BACKSIDE: number;
  24649. /**
  24650. * Mesh side orientation : both internal and external or front and back surfaces
  24651. */
  24652. static readonly DOUBLESIDE: number;
  24653. /**
  24654. * Mesh side orientation : by default, `FRONTSIDE`
  24655. */
  24656. static readonly DEFAULTSIDE: number;
  24657. /**
  24658. * Mesh cap setting : no cap
  24659. */
  24660. static readonly NO_CAP: number;
  24661. /**
  24662. * Mesh cap setting : one cap at the beginning of the mesh
  24663. */
  24664. static readonly CAP_START: number;
  24665. /**
  24666. * Mesh cap setting : one cap at the end of the mesh
  24667. */
  24668. static readonly CAP_END: number;
  24669. /**
  24670. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24671. */
  24672. static readonly CAP_ALL: number;
  24673. /**
  24674. * Mesh pattern setting : no flip or rotate
  24675. */
  24676. static readonly NO_FLIP: number;
  24677. /**
  24678. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24679. */
  24680. static readonly FLIP_TILE: number;
  24681. /**
  24682. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24683. */
  24684. static readonly ROTATE_TILE: number;
  24685. /**
  24686. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24687. */
  24688. static readonly FLIP_ROW: number;
  24689. /**
  24690. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24691. */
  24692. static readonly ROTATE_ROW: number;
  24693. /**
  24694. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24695. */
  24696. static readonly FLIP_N_ROTATE_TILE: number;
  24697. /**
  24698. * Mesh pattern setting : rotate pattern and rotate
  24699. */
  24700. static readonly FLIP_N_ROTATE_ROW: number;
  24701. /**
  24702. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24703. */
  24704. static readonly CENTER: number;
  24705. /**
  24706. * Mesh tile positioning : part tiles on left
  24707. */
  24708. static readonly LEFT: number;
  24709. /**
  24710. * Mesh tile positioning : part tiles on right
  24711. */
  24712. static readonly RIGHT: number;
  24713. /**
  24714. * Mesh tile positioning : part tiles on top
  24715. */
  24716. static readonly TOP: number;
  24717. /**
  24718. * Mesh tile positioning : part tiles on bottom
  24719. */
  24720. static readonly BOTTOM: number;
  24721. /**
  24722. * Gets the default side orientation.
  24723. * @param orientation the orientation to value to attempt to get
  24724. * @returns the default orientation
  24725. * @hidden
  24726. */
  24727. static _GetDefaultSideOrientation(orientation?: number): number;
  24728. private _internalMeshDataInfo;
  24729. /**
  24730. * An event triggered before rendering the mesh
  24731. */
  24732. get onBeforeRenderObservable(): Observable<Mesh>;
  24733. /**
  24734. * An event triggered before binding the mesh
  24735. */
  24736. get onBeforeBindObservable(): Observable<Mesh>;
  24737. /**
  24738. * An event triggered after rendering the mesh
  24739. */
  24740. get onAfterRenderObservable(): Observable<Mesh>;
  24741. /**
  24742. * An event triggered before drawing the mesh
  24743. */
  24744. get onBeforeDrawObservable(): Observable<Mesh>;
  24745. private _onBeforeDrawObserver;
  24746. /**
  24747. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24748. */
  24749. set onBeforeDraw(callback: () => void);
  24750. get hasInstances(): boolean;
  24751. /**
  24752. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24753. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24754. */
  24755. delayLoadState: number;
  24756. /**
  24757. * Gets the list of instances created from this mesh
  24758. * it is not supposed to be modified manually.
  24759. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24760. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24761. */
  24762. instances: InstancedMesh[];
  24763. /**
  24764. * Gets the file containing delay loading data for this mesh
  24765. */
  24766. delayLoadingFile: string;
  24767. /** @hidden */
  24768. _binaryInfo: any;
  24769. /**
  24770. * User defined function used to change how LOD level selection is done
  24771. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24772. */
  24773. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24774. /**
  24775. * Gets or sets the morph target manager
  24776. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24777. */
  24778. get morphTargetManager(): Nullable<MorphTargetManager>;
  24779. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24780. /** @hidden */
  24781. _creationDataStorage: Nullable<_CreationDataStorage>;
  24782. /** @hidden */
  24783. _geometry: Nullable<Geometry>;
  24784. /** @hidden */
  24785. _delayInfo: Array<string>;
  24786. /** @hidden */
  24787. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24788. /** @hidden */
  24789. _instanceDataStorage: _InstanceDataStorage;
  24790. private _effectiveMaterial;
  24791. /** @hidden */
  24792. _shouldGenerateFlatShading: boolean;
  24793. /** @hidden */
  24794. _originalBuilderSideOrientation: number;
  24795. /**
  24796. * Use this property to change the original side orientation defined at construction time
  24797. */
  24798. overrideMaterialSideOrientation: Nullable<number>;
  24799. /**
  24800. * Gets the source mesh (the one used to clone this one from)
  24801. */
  24802. get source(): Nullable<Mesh>;
  24803. /**
  24804. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24805. */
  24806. get isUnIndexed(): boolean;
  24807. set isUnIndexed(value: boolean);
  24808. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24809. get worldMatrixInstancedBuffer(): Float32Array;
  24810. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24811. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24812. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24813. /**
  24814. * @constructor
  24815. * @param name The value used by scene.getMeshByName() to do a lookup.
  24816. * @param scene The scene to add this mesh to.
  24817. * @param parent The parent of this mesh, if it has one
  24818. * @param source An optional Mesh from which geometry is shared, cloned.
  24819. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24820. * When false, achieved by calling a clone(), also passing False.
  24821. * This will make creation of children, recursive.
  24822. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24823. */
  24824. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24825. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24826. doNotInstantiate: boolean;
  24827. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24828. /**
  24829. * Gets the class name
  24830. * @returns the string "Mesh".
  24831. */
  24832. getClassName(): string;
  24833. /** @hidden */
  24834. get _isMesh(): boolean;
  24835. /**
  24836. * Returns a description of this mesh
  24837. * @param fullDetails define if full details about this mesh must be used
  24838. * @returns a descriptive string representing this mesh
  24839. */
  24840. toString(fullDetails?: boolean): string;
  24841. /** @hidden */
  24842. _unBindEffect(): void;
  24843. /**
  24844. * Gets a boolean indicating if this mesh has LOD
  24845. */
  24846. get hasLODLevels(): boolean;
  24847. /**
  24848. * Gets the list of MeshLODLevel associated with the current mesh
  24849. * @returns an array of MeshLODLevel
  24850. */
  24851. getLODLevels(): MeshLODLevel[];
  24852. private _sortLODLevels;
  24853. /**
  24854. * Add a mesh as LOD level triggered at the given distance.
  24855. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24856. * @param distance The distance from the center of the object to show this level
  24857. * @param mesh The mesh to be added as LOD level (can be null)
  24858. * @return This mesh (for chaining)
  24859. */
  24860. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24861. /**
  24862. * Returns the LOD level mesh at the passed distance or null if not found.
  24863. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24864. * @param distance The distance from the center of the object to show this level
  24865. * @returns a Mesh or `null`
  24866. */
  24867. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24868. /**
  24869. * Remove a mesh from the LOD array
  24870. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24871. * @param mesh defines the mesh to be removed
  24872. * @return This mesh (for chaining)
  24873. */
  24874. removeLODLevel(mesh: Mesh): Mesh;
  24875. /**
  24876. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24877. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24878. * @param camera defines the camera to use to compute distance
  24879. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24880. * @return This mesh (for chaining)
  24881. */
  24882. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24883. /**
  24884. * Gets the mesh internal Geometry object
  24885. */
  24886. get geometry(): Nullable<Geometry>;
  24887. /**
  24888. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24889. * @returns the total number of vertices
  24890. */
  24891. getTotalVertices(): number;
  24892. /**
  24893. * Returns the content of an associated vertex buffer
  24894. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24895. * - VertexBuffer.PositionKind
  24896. * - VertexBuffer.UVKind
  24897. * - VertexBuffer.UV2Kind
  24898. * - VertexBuffer.UV3Kind
  24899. * - VertexBuffer.UV4Kind
  24900. * - VertexBuffer.UV5Kind
  24901. * - VertexBuffer.UV6Kind
  24902. * - VertexBuffer.ColorKind
  24903. * - VertexBuffer.MatricesIndicesKind
  24904. * - VertexBuffer.MatricesIndicesExtraKind
  24905. * - VertexBuffer.MatricesWeightsKind
  24906. * - VertexBuffer.MatricesWeightsExtraKind
  24907. * @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
  24908. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24909. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24910. */
  24911. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24912. /**
  24913. * Returns the mesh VertexBuffer object from the requested `kind`
  24914. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24915. * - VertexBuffer.PositionKind
  24916. * - VertexBuffer.NormalKind
  24917. * - VertexBuffer.UVKind
  24918. * - VertexBuffer.UV2Kind
  24919. * - VertexBuffer.UV3Kind
  24920. * - VertexBuffer.UV4Kind
  24921. * - VertexBuffer.UV5Kind
  24922. * - VertexBuffer.UV6Kind
  24923. * - VertexBuffer.ColorKind
  24924. * - VertexBuffer.MatricesIndicesKind
  24925. * - VertexBuffer.MatricesIndicesExtraKind
  24926. * - VertexBuffer.MatricesWeightsKind
  24927. * - VertexBuffer.MatricesWeightsExtraKind
  24928. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24929. */
  24930. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24931. /**
  24932. * Tests if a specific vertex buffer is associated with this mesh
  24933. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24934. * - VertexBuffer.PositionKind
  24935. * - VertexBuffer.NormalKind
  24936. * - VertexBuffer.UVKind
  24937. * - VertexBuffer.UV2Kind
  24938. * - VertexBuffer.UV3Kind
  24939. * - VertexBuffer.UV4Kind
  24940. * - VertexBuffer.UV5Kind
  24941. * - VertexBuffer.UV6Kind
  24942. * - VertexBuffer.ColorKind
  24943. * - VertexBuffer.MatricesIndicesKind
  24944. * - VertexBuffer.MatricesIndicesExtraKind
  24945. * - VertexBuffer.MatricesWeightsKind
  24946. * - VertexBuffer.MatricesWeightsExtraKind
  24947. * @returns a boolean
  24948. */
  24949. isVerticesDataPresent(kind: string): boolean;
  24950. /**
  24951. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24952. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24953. * - VertexBuffer.PositionKind
  24954. * - VertexBuffer.UVKind
  24955. * - VertexBuffer.UV2Kind
  24956. * - VertexBuffer.UV3Kind
  24957. * - VertexBuffer.UV4Kind
  24958. * - VertexBuffer.UV5Kind
  24959. * - VertexBuffer.UV6Kind
  24960. * - VertexBuffer.ColorKind
  24961. * - VertexBuffer.MatricesIndicesKind
  24962. * - VertexBuffer.MatricesIndicesExtraKind
  24963. * - VertexBuffer.MatricesWeightsKind
  24964. * - VertexBuffer.MatricesWeightsExtraKind
  24965. * @returns a boolean
  24966. */
  24967. isVertexBufferUpdatable(kind: string): boolean;
  24968. /**
  24969. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24970. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24971. * - VertexBuffer.PositionKind
  24972. * - VertexBuffer.NormalKind
  24973. * - VertexBuffer.UVKind
  24974. * - VertexBuffer.UV2Kind
  24975. * - VertexBuffer.UV3Kind
  24976. * - VertexBuffer.UV4Kind
  24977. * - VertexBuffer.UV5Kind
  24978. * - VertexBuffer.UV6Kind
  24979. * - VertexBuffer.ColorKind
  24980. * - VertexBuffer.MatricesIndicesKind
  24981. * - VertexBuffer.MatricesIndicesExtraKind
  24982. * - VertexBuffer.MatricesWeightsKind
  24983. * - VertexBuffer.MatricesWeightsExtraKind
  24984. * @returns an array of strings
  24985. */
  24986. getVerticesDataKinds(): string[];
  24987. /**
  24988. * Returns a positive integer : the total number of indices in this mesh geometry.
  24989. * @returns the numner of indices or zero if the mesh has no geometry.
  24990. */
  24991. getTotalIndices(): number;
  24992. /**
  24993. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24994. * @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.
  24995. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24996. * @returns the indices array or an empty array if the mesh has no geometry
  24997. */
  24998. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24999. get isBlocked(): boolean;
  25000. /**
  25001. * Determine if the current mesh is ready to be rendered
  25002. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25003. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25004. * @returns true if all associated assets are ready (material, textures, shaders)
  25005. */
  25006. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25007. /**
  25008. * 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.
  25009. */
  25010. get areNormalsFrozen(): boolean;
  25011. /**
  25012. * 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.
  25013. * @returns the current mesh
  25014. */
  25015. freezeNormals(): Mesh;
  25016. /**
  25017. * 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
  25018. * @returns the current mesh
  25019. */
  25020. unfreezeNormals(): Mesh;
  25021. /**
  25022. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25023. */
  25024. set overridenInstanceCount(count: number);
  25025. /** @hidden */
  25026. _preActivate(): Mesh;
  25027. /** @hidden */
  25028. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25029. /** @hidden */
  25030. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25031. /**
  25032. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25033. * This means the mesh underlying bounding box and sphere are recomputed.
  25034. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25035. * @returns the current mesh
  25036. */
  25037. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25038. /** @hidden */
  25039. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25040. /**
  25041. * This function will subdivide the mesh into multiple submeshes
  25042. * @param count defines the expected number of submeshes
  25043. */
  25044. subdivide(count: number): void;
  25045. /**
  25046. * Copy a FloatArray into a specific associated vertex buffer
  25047. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25048. * - VertexBuffer.PositionKind
  25049. * - VertexBuffer.UVKind
  25050. * - VertexBuffer.UV2Kind
  25051. * - VertexBuffer.UV3Kind
  25052. * - VertexBuffer.UV4Kind
  25053. * - VertexBuffer.UV5Kind
  25054. * - VertexBuffer.UV6Kind
  25055. * - VertexBuffer.ColorKind
  25056. * - VertexBuffer.MatricesIndicesKind
  25057. * - VertexBuffer.MatricesIndicesExtraKind
  25058. * - VertexBuffer.MatricesWeightsKind
  25059. * - VertexBuffer.MatricesWeightsExtraKind
  25060. * @param data defines the data source
  25061. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25062. * @param stride defines the data stride size (can be null)
  25063. * @returns the current mesh
  25064. */
  25065. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25066. /**
  25067. * Delete a vertex buffer associated with this mesh
  25068. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25069. * - VertexBuffer.PositionKind
  25070. * - VertexBuffer.UVKind
  25071. * - VertexBuffer.UV2Kind
  25072. * - VertexBuffer.UV3Kind
  25073. * - VertexBuffer.UV4Kind
  25074. * - VertexBuffer.UV5Kind
  25075. * - VertexBuffer.UV6Kind
  25076. * - VertexBuffer.ColorKind
  25077. * - VertexBuffer.MatricesIndicesKind
  25078. * - VertexBuffer.MatricesIndicesExtraKind
  25079. * - VertexBuffer.MatricesWeightsKind
  25080. * - VertexBuffer.MatricesWeightsExtraKind
  25081. */
  25082. removeVerticesData(kind: string): void;
  25083. /**
  25084. * Flags an associated vertex buffer as updatable
  25085. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25086. * - VertexBuffer.PositionKind
  25087. * - VertexBuffer.UVKind
  25088. * - VertexBuffer.UV2Kind
  25089. * - VertexBuffer.UV3Kind
  25090. * - VertexBuffer.UV4Kind
  25091. * - VertexBuffer.UV5Kind
  25092. * - VertexBuffer.UV6Kind
  25093. * - VertexBuffer.ColorKind
  25094. * - VertexBuffer.MatricesIndicesKind
  25095. * - VertexBuffer.MatricesIndicesExtraKind
  25096. * - VertexBuffer.MatricesWeightsKind
  25097. * - VertexBuffer.MatricesWeightsExtraKind
  25098. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25099. */
  25100. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25101. /**
  25102. * Sets the mesh global Vertex Buffer
  25103. * @param buffer defines the buffer to use
  25104. * @returns the current mesh
  25105. */
  25106. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25107. /**
  25108. * Update a specific associated vertex buffer
  25109. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25110. * - VertexBuffer.PositionKind
  25111. * - VertexBuffer.UVKind
  25112. * - VertexBuffer.UV2Kind
  25113. * - VertexBuffer.UV3Kind
  25114. * - VertexBuffer.UV4Kind
  25115. * - VertexBuffer.UV5Kind
  25116. * - VertexBuffer.UV6Kind
  25117. * - VertexBuffer.ColorKind
  25118. * - VertexBuffer.MatricesIndicesKind
  25119. * - VertexBuffer.MatricesIndicesExtraKind
  25120. * - VertexBuffer.MatricesWeightsKind
  25121. * - VertexBuffer.MatricesWeightsExtraKind
  25122. * @param data defines the data source
  25123. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25124. * @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)
  25125. * @returns the current mesh
  25126. */
  25127. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25128. /**
  25129. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25130. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25131. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25132. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25133. * @returns the current mesh
  25134. */
  25135. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25136. /**
  25137. * Creates a un-shared specific occurence of the geometry for the mesh.
  25138. * @returns the current mesh
  25139. */
  25140. makeGeometryUnique(): Mesh;
  25141. /**
  25142. * Set the index buffer of this mesh
  25143. * @param indices defines the source data
  25144. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25145. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25146. * @returns the current mesh
  25147. */
  25148. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25149. /**
  25150. * Update the current index buffer
  25151. * @param indices defines the source data
  25152. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25153. * @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)
  25154. * @returns the current mesh
  25155. */
  25156. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25157. /**
  25158. * Invert the geometry to move from a right handed system to a left handed one.
  25159. * @returns the current mesh
  25160. */
  25161. toLeftHanded(): Mesh;
  25162. /** @hidden */
  25163. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25164. /** @hidden */
  25165. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25166. /**
  25167. * Registers for this mesh a javascript function called just before the rendering process
  25168. * @param func defines the function to call before rendering this mesh
  25169. * @returns the current mesh
  25170. */
  25171. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25172. /**
  25173. * Disposes a previously registered javascript function called before the rendering
  25174. * @param func defines the function to remove
  25175. * @returns the current mesh
  25176. */
  25177. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25178. /**
  25179. * Registers for this mesh a javascript function called just after the rendering is complete
  25180. * @param func defines the function to call after rendering this mesh
  25181. * @returns the current mesh
  25182. */
  25183. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25184. /**
  25185. * Disposes a previously registered javascript function called after the rendering.
  25186. * @param func defines the function to remove
  25187. * @returns the current mesh
  25188. */
  25189. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25190. /** @hidden */
  25191. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25192. /** @hidden */
  25193. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25194. /** @hidden */
  25195. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25196. /** @hidden */
  25197. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25198. /** @hidden */
  25199. _rebuild(): void;
  25200. /** @hidden */
  25201. _freeze(): void;
  25202. /** @hidden */
  25203. _unFreeze(): void;
  25204. /**
  25205. * 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
  25206. * @param subMesh defines the subMesh to render
  25207. * @param enableAlphaMode defines if alpha mode can be changed
  25208. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25209. * @returns the current mesh
  25210. */
  25211. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25212. private _onBeforeDraw;
  25213. /**
  25214. * Renormalize the mesh and patch it up if there are no weights
  25215. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25216. * However in the case of zero weights then we set just a single influence to 1.
  25217. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25218. */
  25219. cleanMatrixWeights(): void;
  25220. private normalizeSkinFourWeights;
  25221. private normalizeSkinWeightsAndExtra;
  25222. /**
  25223. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25224. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25225. * the user know there was an issue with importing the mesh
  25226. * @returns a validation object with skinned, valid and report string
  25227. */
  25228. validateSkinning(): {
  25229. skinned: boolean;
  25230. valid: boolean;
  25231. report: string;
  25232. };
  25233. /** @hidden */
  25234. _checkDelayState(): Mesh;
  25235. private _queueLoad;
  25236. /**
  25237. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25238. * A mesh is in the frustum if its bounding box intersects the frustum
  25239. * @param frustumPlanes defines the frustum to test
  25240. * @returns true if the mesh is in the frustum planes
  25241. */
  25242. isInFrustum(frustumPlanes: Plane[]): boolean;
  25243. /**
  25244. * Sets the mesh material by the material or multiMaterial `id` property
  25245. * @param id is a string identifying the material or the multiMaterial
  25246. * @returns the current mesh
  25247. */
  25248. setMaterialByID(id: string): Mesh;
  25249. /**
  25250. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25251. * @returns an array of IAnimatable
  25252. */
  25253. getAnimatables(): IAnimatable[];
  25254. /**
  25255. * Modifies the mesh geometry according to the passed transformation matrix.
  25256. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25257. * The mesh normals are modified using the same transformation.
  25258. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25259. * @param transform defines the transform matrix to use
  25260. * @see http://doc.babylonjs.com/resources/baking_transformations
  25261. * @returns the current mesh
  25262. */
  25263. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25264. /**
  25265. * Modifies the mesh geometry according to its own current World Matrix.
  25266. * The mesh World Matrix is then reset.
  25267. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25268. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25269. * @see http://doc.babylonjs.com/resources/baking_transformations
  25270. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25271. * @returns the current mesh
  25272. */
  25273. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25274. /** @hidden */
  25275. get _positions(): Nullable<Vector3[]>;
  25276. /** @hidden */
  25277. _resetPointsArrayCache(): Mesh;
  25278. /** @hidden */
  25279. _generatePointsArray(): boolean;
  25280. /**
  25281. * Returns a new Mesh object generated from the current mesh properties.
  25282. * This method must not get confused with createInstance()
  25283. * @param name is a string, the name given to the new mesh
  25284. * @param newParent can be any Node object (default `null`)
  25285. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25286. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25287. * @returns a new mesh
  25288. */
  25289. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25290. /**
  25291. * Releases resources associated with this mesh.
  25292. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25293. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25294. */
  25295. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25296. /** @hidden */
  25297. _disposeInstanceSpecificData(): void;
  25298. /**
  25299. * Modifies the mesh geometry according to a displacement map.
  25300. * 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.
  25301. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25302. * @param url is a string, the URL from the image file is to be downloaded.
  25303. * @param minHeight is the lower limit of the displacement.
  25304. * @param maxHeight is the upper limit of the displacement.
  25305. * @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.
  25306. * @param uvOffset is an optional vector2 used to offset UV.
  25307. * @param uvScale is an optional vector2 used to scale UV.
  25308. * @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.
  25309. * @returns the Mesh.
  25310. */
  25311. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25312. /**
  25313. * Modifies the mesh geometry according to a displacementMap buffer.
  25314. * 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.
  25315. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25316. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25317. * @param heightMapWidth is the width of the buffer image.
  25318. * @param heightMapHeight is the height of the buffer image.
  25319. * @param minHeight is the lower limit of the displacement.
  25320. * @param maxHeight is the upper limit of the displacement.
  25321. * @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.
  25322. * @param uvOffset is an optional vector2 used to offset UV.
  25323. * @param uvScale is an optional vector2 used to scale UV.
  25324. * @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.
  25325. * @returns the Mesh.
  25326. */
  25327. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25328. /**
  25329. * Modify the mesh to get a flat shading rendering.
  25330. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25331. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25332. * @returns current mesh
  25333. */
  25334. convertToFlatShadedMesh(): Mesh;
  25335. /**
  25336. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25337. * In other words, more vertices, no more indices and a single bigger VBO.
  25338. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25339. * @returns current mesh
  25340. */
  25341. convertToUnIndexedMesh(): Mesh;
  25342. /**
  25343. * Inverses facet orientations.
  25344. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25345. * @param flipNormals will also inverts the normals
  25346. * @returns current mesh
  25347. */
  25348. flipFaces(flipNormals?: boolean): Mesh;
  25349. /**
  25350. * Increase the number of facets and hence vertices in a mesh
  25351. * Vertex normals are interpolated from existing vertex normals
  25352. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25353. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25354. */
  25355. increaseVertices(numberPerEdge: number): void;
  25356. /**
  25357. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25358. * This will undo any application of covertToFlatShadedMesh
  25359. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25360. */
  25361. forceSharedVertices(): void;
  25362. /** @hidden */
  25363. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25364. /** @hidden */
  25365. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25366. /**
  25367. * Creates a new InstancedMesh object from the mesh model.
  25368. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25369. * @param name defines the name of the new instance
  25370. * @returns a new InstancedMesh
  25371. */
  25372. createInstance(name: string): InstancedMesh;
  25373. /**
  25374. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25375. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25376. * @returns the current mesh
  25377. */
  25378. synchronizeInstances(): Mesh;
  25379. /**
  25380. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25381. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25382. * This should be used together with the simplification to avoid disappearing triangles.
  25383. * @param successCallback an optional success callback to be called after the optimization finished.
  25384. * @returns the current mesh
  25385. */
  25386. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25387. /**
  25388. * Serialize current mesh
  25389. * @param serializationObject defines the object which will receive the serialization data
  25390. */
  25391. serialize(serializationObject: any): void;
  25392. /** @hidden */
  25393. _syncGeometryWithMorphTargetManager(): void;
  25394. /** @hidden */
  25395. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25396. /**
  25397. * Returns a new Mesh object parsed from the source provided.
  25398. * @param parsedMesh is the source
  25399. * @param scene defines the hosting scene
  25400. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25401. * @returns a new Mesh
  25402. */
  25403. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25404. /**
  25405. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25406. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25407. * @param name defines the name of the mesh to create
  25408. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25409. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25410. * @param closePath creates a seam between the first and the last points of each path of the path array
  25411. * @param offset is taken in account only if the `pathArray` is containing a single path
  25412. * @param scene defines the hosting scene
  25413. * @param updatable defines if the mesh must be flagged as updatable
  25414. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25415. * @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)
  25416. * @returns a new Mesh
  25417. */
  25418. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25419. /**
  25420. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25421. * @param name defines the name of the mesh to create
  25422. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25423. * @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
  25424. * @param scene defines the hosting scene
  25425. * @param updatable defines if the mesh must be flagged as updatable
  25426. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25427. * @returns a new Mesh
  25428. */
  25429. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25430. /**
  25431. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25432. * @param name defines the name of the mesh to create
  25433. * @param size sets the size (float) of each box side (default 1)
  25434. * @param scene defines the hosting scene
  25435. * @param updatable defines if the mesh must be flagged as updatable
  25436. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25437. * @returns a new Mesh
  25438. */
  25439. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25440. /**
  25441. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25442. * @param name defines the name of the mesh to create
  25443. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25444. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25445. * @param scene defines the hosting scene
  25446. * @param updatable defines if the mesh must be flagged as updatable
  25447. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25448. * @returns a new Mesh
  25449. */
  25450. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25451. /**
  25452. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25453. * @param name defines the name of the mesh to create
  25454. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25455. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25456. * @param scene defines the hosting scene
  25457. * @returns a new Mesh
  25458. */
  25459. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25460. /**
  25461. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25462. * @param name defines the name of the mesh to create
  25463. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25464. * @param diameterTop set the top cap diameter (floats, default 1)
  25465. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25466. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25467. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25468. * @param scene defines the hosting scene
  25469. * @param updatable defines if the mesh must be flagged as updatable
  25470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25471. * @returns a new Mesh
  25472. */
  25473. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25474. /**
  25475. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25476. * @param name defines the name of the mesh to create
  25477. * @param diameter sets the diameter size (float) of the torus (default 1)
  25478. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25479. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25480. * @param scene defines the hosting scene
  25481. * @param updatable defines if the mesh must be flagged as updatable
  25482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25483. * @returns a new Mesh
  25484. */
  25485. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25486. /**
  25487. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25488. * @param name defines the name of the mesh to create
  25489. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25490. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25491. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25492. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25493. * @param p the number of windings on X axis (positive integers, default 2)
  25494. * @param q the number of windings on Y axis (positive integers, default 3)
  25495. * @param scene defines the hosting scene
  25496. * @param updatable defines if the mesh must be flagged as updatable
  25497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25498. * @returns a new Mesh
  25499. */
  25500. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25501. /**
  25502. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25503. * @param name defines the name of the mesh to create
  25504. * @param points is an array successive Vector3
  25505. * @param scene defines the hosting scene
  25506. * @param updatable defines if the mesh must be flagged as updatable
  25507. * @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).
  25508. * @returns a new Mesh
  25509. */
  25510. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25511. /**
  25512. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25513. * @param name defines the name of the mesh to create
  25514. * @param points is an array successive Vector3
  25515. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25516. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25517. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25518. * @param scene defines the hosting scene
  25519. * @param updatable defines if the mesh must be flagged as updatable
  25520. * @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)
  25521. * @returns a new Mesh
  25522. */
  25523. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25524. /**
  25525. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25526. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25527. * 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.
  25528. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25529. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25530. * Remember you can only change the shape positions, not their number when updating a polygon.
  25531. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25532. * @param name defines the name of the mesh to create
  25533. * @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
  25534. * @param scene defines the hosting scene
  25535. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25536. * @param updatable defines if the mesh must be flagged as updatable
  25537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25538. * @param earcutInjection can be used to inject your own earcut reference
  25539. * @returns a new Mesh
  25540. */
  25541. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25542. /**
  25543. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25544. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25545. * @param name defines the name of the mesh to create
  25546. * @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
  25547. * @param depth defines the height of extrusion
  25548. * @param scene defines the hosting scene
  25549. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25550. * @param updatable defines if the mesh must be flagged as updatable
  25551. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25552. * @param earcutInjection can be used to inject your own earcut reference
  25553. * @returns a new Mesh
  25554. */
  25555. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25556. /**
  25557. * Creates an extruded shape mesh.
  25558. * 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
  25559. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25560. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25561. * @param name defines the name of the mesh to create
  25562. * @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
  25563. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25564. * @param scale is the value to scale the shape
  25565. * @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
  25566. * @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
  25567. * @param scene defines the hosting scene
  25568. * @param updatable defines if the mesh must be flagged as updatable
  25569. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25570. * @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)
  25571. * @returns a new Mesh
  25572. */
  25573. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25574. /**
  25575. * Creates an custom extruded shape mesh.
  25576. * The custom extrusion is a parametric shape.
  25577. * It has no predefined shape. Its final shape will depend on the input parameters.
  25578. * Please consider using the same method from the MeshBuilder class instead
  25579. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25580. * @param name defines the name of the mesh to create
  25581. * @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
  25582. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25583. * @param scaleFunction is a custom Javascript function called on each path point
  25584. * @param rotationFunction is a custom Javascript function called on each path point
  25585. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25586. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25587. * @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
  25588. * @param scene defines the hosting scene
  25589. * @param updatable defines if the mesh must be flagged as updatable
  25590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25591. * @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)
  25592. * @returns a new Mesh
  25593. */
  25594. 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;
  25595. /**
  25596. * Creates lathe mesh.
  25597. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25598. * Please consider using the same method from the MeshBuilder class instead
  25599. * @param name defines the name of the mesh to create
  25600. * @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
  25601. * @param radius is the radius value of the lathe
  25602. * @param tessellation is the side number of the lathe.
  25603. * @param scene defines the hosting scene
  25604. * @param updatable defines if the mesh must be flagged as updatable
  25605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25606. * @returns a new Mesh
  25607. */
  25608. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25609. /**
  25610. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25611. * @param name defines the name of the mesh to create
  25612. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25613. * @param scene defines the hosting scene
  25614. * @param updatable defines if the mesh must be flagged as updatable
  25615. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25616. * @returns a new Mesh
  25617. */
  25618. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25619. /**
  25620. * Creates a ground mesh.
  25621. * Please consider using the same method from the MeshBuilder class instead
  25622. * @param name defines the name of the mesh to create
  25623. * @param width set the width of the ground
  25624. * @param height set the height of the ground
  25625. * @param subdivisions sets the number of subdivisions per side
  25626. * @param scene defines the hosting scene
  25627. * @param updatable defines if the mesh must be flagged as updatable
  25628. * @returns a new Mesh
  25629. */
  25630. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25631. /**
  25632. * Creates a tiled ground mesh.
  25633. * Please consider using the same method from the MeshBuilder class instead
  25634. * @param name defines the name of the mesh to create
  25635. * @param xmin set the ground minimum X coordinate
  25636. * @param zmin set the ground minimum Y coordinate
  25637. * @param xmax set the ground maximum X coordinate
  25638. * @param zmax set the ground maximum Z coordinate
  25639. * @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
  25640. * @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
  25641. * @param scene defines the hosting scene
  25642. * @param updatable defines if the mesh must be flagged as updatable
  25643. * @returns a new Mesh
  25644. */
  25645. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25646. w: number;
  25647. h: number;
  25648. }, precision: {
  25649. w: number;
  25650. h: number;
  25651. }, scene: Scene, updatable?: boolean): Mesh;
  25652. /**
  25653. * Creates a ground mesh from a height map.
  25654. * Please consider using the same method from the MeshBuilder class instead
  25655. * @see http://doc.babylonjs.com/babylon101/height_map
  25656. * @param name defines the name of the mesh to create
  25657. * @param url sets the URL of the height map image resource
  25658. * @param width set the ground width size
  25659. * @param height set the ground height size
  25660. * @param subdivisions sets the number of subdivision per side
  25661. * @param minHeight is the minimum altitude on the ground
  25662. * @param maxHeight is the maximum altitude on the ground
  25663. * @param scene defines the hosting scene
  25664. * @param updatable defines if the mesh must be flagged as updatable
  25665. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25666. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25667. * @returns a new Mesh
  25668. */
  25669. 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;
  25670. /**
  25671. * Creates a tube mesh.
  25672. * The tube is a parametric shape.
  25673. * It has no predefined shape. Its final shape will depend on the input parameters.
  25674. * Please consider using the same method from the MeshBuilder class instead
  25675. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25676. * @param name defines the name of the mesh to create
  25677. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25678. * @param radius sets the tube radius size
  25679. * @param tessellation is the number of sides on the tubular surface
  25680. * @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
  25681. * @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
  25682. * @param scene defines the hosting scene
  25683. * @param updatable defines if the mesh must be flagged as updatable
  25684. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25685. * @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)
  25686. * @returns a new Mesh
  25687. */
  25688. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25689. (i: number, distance: number): number;
  25690. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25691. /**
  25692. * Creates a polyhedron mesh.
  25693. * Please consider using the same method from the MeshBuilder class instead.
  25694. * * 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
  25695. * * The parameter `size` (positive float, default 1) sets the polygon size
  25696. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25697. * * 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`
  25698. * * 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
  25699. * * 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)`)
  25700. * * 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
  25701. * * 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
  25702. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25703. * * 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
  25704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25705. * @param name defines the name of the mesh to create
  25706. * @param options defines the options used to create the mesh
  25707. * @param scene defines the hosting scene
  25708. * @returns a new Mesh
  25709. */
  25710. static CreatePolyhedron(name: string, options: {
  25711. type?: number;
  25712. size?: number;
  25713. sizeX?: number;
  25714. sizeY?: number;
  25715. sizeZ?: number;
  25716. custom?: any;
  25717. faceUV?: Vector4[];
  25718. faceColors?: Color4[];
  25719. updatable?: boolean;
  25720. sideOrientation?: number;
  25721. }, scene: Scene): Mesh;
  25722. /**
  25723. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25724. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25725. * * 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`)
  25726. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25727. * * 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
  25728. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25729. * * 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
  25730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25731. * @param name defines the name of the mesh
  25732. * @param options defines the options used to create the mesh
  25733. * @param scene defines the hosting scene
  25734. * @returns a new Mesh
  25735. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25736. */
  25737. static CreateIcoSphere(name: string, options: {
  25738. radius?: number;
  25739. flat?: boolean;
  25740. subdivisions?: number;
  25741. sideOrientation?: number;
  25742. updatable?: boolean;
  25743. }, scene: Scene): Mesh;
  25744. /**
  25745. * Creates a decal mesh.
  25746. * Please consider using the same method from the MeshBuilder class instead.
  25747. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25748. * @param name defines the name of the mesh
  25749. * @param sourceMesh defines the mesh receiving the decal
  25750. * @param position sets the position of the decal in world coordinates
  25751. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25752. * @param size sets the decal scaling
  25753. * @param angle sets the angle to rotate the decal
  25754. * @returns a new Mesh
  25755. */
  25756. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25757. /**
  25758. * Prepare internal position array for software CPU skinning
  25759. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25760. */
  25761. setPositionsForCPUSkinning(): Float32Array;
  25762. /**
  25763. * Prepare internal normal array for software CPU skinning
  25764. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25765. */
  25766. setNormalsForCPUSkinning(): Float32Array;
  25767. /**
  25768. * Updates the vertex buffer by applying transformation from the bones
  25769. * @param skeleton defines the skeleton to apply to current mesh
  25770. * @returns the current mesh
  25771. */
  25772. applySkeleton(skeleton: Skeleton): Mesh;
  25773. /**
  25774. * 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
  25775. * @param meshes defines the list of meshes to scan
  25776. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25777. */
  25778. static MinMax(meshes: AbstractMesh[]): {
  25779. min: Vector3;
  25780. max: Vector3;
  25781. };
  25782. /**
  25783. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25784. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25785. * @returns a vector3
  25786. */
  25787. static Center(meshesOrMinMaxVector: {
  25788. min: Vector3;
  25789. max: Vector3;
  25790. } | AbstractMesh[]): Vector3;
  25791. /**
  25792. * Merge the array of meshes into a single mesh for performance reasons.
  25793. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25794. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25795. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25796. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25797. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25798. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25799. * @returns a new mesh
  25800. */
  25801. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25802. /** @hidden */
  25803. addInstance(instance: InstancedMesh): void;
  25804. /** @hidden */
  25805. removeInstance(instance: InstancedMesh): void;
  25806. }
  25807. }
  25808. declare module BABYLON {
  25809. /**
  25810. * This is the base class of all the camera used in the application.
  25811. * @see http://doc.babylonjs.com/features/cameras
  25812. */
  25813. export class Camera extends Node {
  25814. /** @hidden */
  25815. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25816. /**
  25817. * This is the default projection mode used by the cameras.
  25818. * It helps recreating a feeling of perspective and better appreciate depth.
  25819. * This is the best way to simulate real life cameras.
  25820. */
  25821. static readonly PERSPECTIVE_CAMERA: number;
  25822. /**
  25823. * This helps creating camera with an orthographic mode.
  25824. * 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.
  25825. */
  25826. static readonly ORTHOGRAPHIC_CAMERA: number;
  25827. /**
  25828. * This is the default FOV mode for perspective cameras.
  25829. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25830. */
  25831. static readonly FOVMODE_VERTICAL_FIXED: number;
  25832. /**
  25833. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25834. */
  25835. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25836. /**
  25837. * This specifies ther is no need for a camera rig.
  25838. * Basically only one eye is rendered corresponding to the camera.
  25839. */
  25840. static readonly RIG_MODE_NONE: number;
  25841. /**
  25842. * Simulates a camera Rig with one blue eye and one red eye.
  25843. * This can be use with 3d blue and red glasses.
  25844. */
  25845. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25846. /**
  25847. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25848. */
  25849. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25850. /**
  25851. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25852. */
  25853. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25854. /**
  25855. * Defines that both eyes of the camera will be rendered over under each other.
  25856. */
  25857. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25858. /**
  25859. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25860. */
  25861. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25862. /**
  25863. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25864. */
  25865. static readonly RIG_MODE_VR: number;
  25866. /**
  25867. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25868. */
  25869. static readonly RIG_MODE_WEBVR: number;
  25870. /**
  25871. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25872. */
  25873. static readonly RIG_MODE_CUSTOM: number;
  25874. /**
  25875. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25876. */
  25877. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25878. /**
  25879. * Define the input manager associated with the camera.
  25880. */
  25881. inputs: CameraInputsManager<Camera>;
  25882. /** @hidden */
  25883. _position: Vector3;
  25884. /**
  25885. * Define the current local position of the camera in the scene
  25886. */
  25887. get position(): Vector3;
  25888. set position(newPosition: Vector3);
  25889. /**
  25890. * The vector the camera should consider as up.
  25891. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25892. */
  25893. upVector: Vector3;
  25894. /**
  25895. * Define the current limit on the left side for an orthographic camera
  25896. * In scene unit
  25897. */
  25898. orthoLeft: Nullable<number>;
  25899. /**
  25900. * Define the current limit on the right side for an orthographic camera
  25901. * In scene unit
  25902. */
  25903. orthoRight: Nullable<number>;
  25904. /**
  25905. * Define the current limit on the bottom side for an orthographic camera
  25906. * In scene unit
  25907. */
  25908. orthoBottom: Nullable<number>;
  25909. /**
  25910. * Define the current limit on the top side for an orthographic camera
  25911. * In scene unit
  25912. */
  25913. orthoTop: Nullable<number>;
  25914. /**
  25915. * Field Of View is set in Radians. (default is 0.8)
  25916. */
  25917. fov: number;
  25918. /**
  25919. * Define the minimum distance the camera can see from.
  25920. * This is important to note that the depth buffer are not infinite and the closer it starts
  25921. * the more your scene might encounter depth fighting issue.
  25922. */
  25923. minZ: number;
  25924. /**
  25925. * Define the maximum distance the camera can see to.
  25926. * This is important to note that the depth buffer are not infinite and the further it end
  25927. * the more your scene might encounter depth fighting issue.
  25928. */
  25929. maxZ: number;
  25930. /**
  25931. * Define the default inertia of the camera.
  25932. * This helps giving a smooth feeling to the camera movement.
  25933. */
  25934. inertia: number;
  25935. /**
  25936. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25937. */
  25938. mode: number;
  25939. /**
  25940. * Define whether the camera is intermediate.
  25941. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25942. */
  25943. isIntermediate: boolean;
  25944. /**
  25945. * Define the viewport of the camera.
  25946. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25947. */
  25948. viewport: Viewport;
  25949. /**
  25950. * Restricts the camera to viewing objects with the same layerMask.
  25951. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25952. */
  25953. layerMask: number;
  25954. /**
  25955. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25956. */
  25957. fovMode: number;
  25958. /**
  25959. * Rig mode of the camera.
  25960. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25961. * This is normally controlled byt the camera themselves as internal use.
  25962. */
  25963. cameraRigMode: number;
  25964. /**
  25965. * Defines the distance between both "eyes" in case of a RIG
  25966. */
  25967. interaxialDistance: number;
  25968. /**
  25969. * Defines if stereoscopic rendering is done side by side or over under.
  25970. */
  25971. isStereoscopicSideBySide: boolean;
  25972. /**
  25973. * 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
  25974. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25975. * else in the scene. (Eg. security camera)
  25976. *
  25977. * 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)
  25978. */
  25979. customRenderTargets: RenderTargetTexture[];
  25980. /**
  25981. * When set, the camera will render to this render target instead of the default canvas
  25982. *
  25983. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25984. */
  25985. outputRenderTarget: Nullable<RenderTargetTexture>;
  25986. /**
  25987. * Observable triggered when the camera view matrix has changed.
  25988. */
  25989. onViewMatrixChangedObservable: Observable<Camera>;
  25990. /**
  25991. * Observable triggered when the camera Projection matrix has changed.
  25992. */
  25993. onProjectionMatrixChangedObservable: Observable<Camera>;
  25994. /**
  25995. * Observable triggered when the inputs have been processed.
  25996. */
  25997. onAfterCheckInputsObservable: Observable<Camera>;
  25998. /**
  25999. * Observable triggered when reset has been called and applied to the camera.
  26000. */
  26001. onRestoreStateObservable: Observable<Camera>;
  26002. /**
  26003. * Is this camera a part of a rig system?
  26004. */
  26005. isRigCamera: boolean;
  26006. /**
  26007. * If isRigCamera set to true this will be set with the parent camera.
  26008. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26009. */
  26010. rigParent?: Camera;
  26011. /** @hidden */
  26012. _cameraRigParams: any;
  26013. /** @hidden */
  26014. _rigCameras: Camera[];
  26015. /** @hidden */
  26016. _rigPostProcess: Nullable<PostProcess>;
  26017. protected _webvrViewMatrix: Matrix;
  26018. /** @hidden */
  26019. _skipRendering: boolean;
  26020. /** @hidden */
  26021. _projectionMatrix: Matrix;
  26022. /** @hidden */
  26023. _postProcesses: Nullable<PostProcess>[];
  26024. /** @hidden */
  26025. _activeMeshes: SmartArray<AbstractMesh>;
  26026. protected _globalPosition: Vector3;
  26027. /** @hidden */
  26028. _computedViewMatrix: Matrix;
  26029. private _doNotComputeProjectionMatrix;
  26030. private _transformMatrix;
  26031. private _frustumPlanes;
  26032. private _refreshFrustumPlanes;
  26033. private _storedFov;
  26034. private _stateStored;
  26035. /**
  26036. * Instantiates a new camera object.
  26037. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26038. * @see http://doc.babylonjs.com/features/cameras
  26039. * @param name Defines the name of the camera in the scene
  26040. * @param position Defines the position of the camera
  26041. * @param scene Defines the scene the camera belongs too
  26042. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26043. */
  26044. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26045. /**
  26046. * Store current camera state (fov, position, etc..)
  26047. * @returns the camera
  26048. */
  26049. storeState(): Camera;
  26050. /**
  26051. * Restores the camera state values if it has been stored. You must call storeState() first
  26052. */
  26053. protected _restoreStateValues(): boolean;
  26054. /**
  26055. * Restored camera state. You must call storeState() first.
  26056. * @returns true if restored and false otherwise
  26057. */
  26058. restoreState(): boolean;
  26059. /**
  26060. * Gets the class name of the camera.
  26061. * @returns the class name
  26062. */
  26063. getClassName(): string;
  26064. /** @hidden */
  26065. readonly _isCamera: boolean;
  26066. /**
  26067. * Gets a string representation of the camera useful for debug purpose.
  26068. * @param fullDetails Defines that a more verboe level of logging is required
  26069. * @returns the string representation
  26070. */
  26071. toString(fullDetails?: boolean): string;
  26072. /**
  26073. * Gets the current world space position of the camera.
  26074. */
  26075. get globalPosition(): Vector3;
  26076. /**
  26077. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26078. * @returns the active meshe list
  26079. */
  26080. getActiveMeshes(): SmartArray<AbstractMesh>;
  26081. /**
  26082. * Check whether a mesh is part of the current active mesh list of the camera
  26083. * @param mesh Defines the mesh to check
  26084. * @returns true if active, false otherwise
  26085. */
  26086. isActiveMesh(mesh: Mesh): boolean;
  26087. /**
  26088. * Is this camera ready to be used/rendered
  26089. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26090. * @return true if the camera is ready
  26091. */
  26092. isReady(completeCheck?: boolean): boolean;
  26093. /** @hidden */
  26094. _initCache(): void;
  26095. /** @hidden */
  26096. _updateCache(ignoreParentClass?: boolean): void;
  26097. /** @hidden */
  26098. _isSynchronized(): boolean;
  26099. /** @hidden */
  26100. _isSynchronizedViewMatrix(): boolean;
  26101. /** @hidden */
  26102. _isSynchronizedProjectionMatrix(): boolean;
  26103. /**
  26104. * Attach the input controls to a specific dom element to get the input from.
  26105. * @param element Defines the element the controls should be listened from
  26106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26107. */
  26108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26109. /**
  26110. * Detach the current controls from the specified dom element.
  26111. * @param element Defines the element to stop listening the inputs from
  26112. */
  26113. detachControl(element: HTMLElement): void;
  26114. /**
  26115. * Update the camera state according to the different inputs gathered during the frame.
  26116. */
  26117. update(): void;
  26118. /** @hidden */
  26119. _checkInputs(): void;
  26120. /** @hidden */
  26121. get rigCameras(): Camera[];
  26122. /**
  26123. * Gets the post process used by the rig cameras
  26124. */
  26125. get rigPostProcess(): Nullable<PostProcess>;
  26126. /**
  26127. * Internal, gets the first post proces.
  26128. * @returns the first post process to be run on this camera.
  26129. */
  26130. _getFirstPostProcess(): Nullable<PostProcess>;
  26131. private _cascadePostProcessesToRigCams;
  26132. /**
  26133. * Attach a post process to the camera.
  26134. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26135. * @param postProcess The post process to attach to the camera
  26136. * @param insertAt The position of the post process in case several of them are in use in the scene
  26137. * @returns the position the post process has been inserted at
  26138. */
  26139. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26140. /**
  26141. * Detach a post process to the camera.
  26142. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26143. * @param postProcess The post process to detach from the camera
  26144. */
  26145. detachPostProcess(postProcess: PostProcess): void;
  26146. /**
  26147. * Gets the current world matrix of the camera
  26148. */
  26149. getWorldMatrix(): Matrix;
  26150. /** @hidden */
  26151. _getViewMatrix(): Matrix;
  26152. /**
  26153. * Gets the current view matrix of the camera.
  26154. * @param force forces the camera to recompute the matrix without looking at the cached state
  26155. * @returns the view matrix
  26156. */
  26157. getViewMatrix(force?: boolean): Matrix;
  26158. /**
  26159. * Freeze the projection matrix.
  26160. * It will prevent the cache check of the camera projection compute and can speed up perf
  26161. * if no parameter of the camera are meant to change
  26162. * @param projection Defines manually a projection if necessary
  26163. */
  26164. freezeProjectionMatrix(projection?: Matrix): void;
  26165. /**
  26166. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26167. */
  26168. unfreezeProjectionMatrix(): void;
  26169. /**
  26170. * Gets the current projection matrix of the camera.
  26171. * @param force forces the camera to recompute the matrix without looking at the cached state
  26172. * @returns the projection matrix
  26173. */
  26174. getProjectionMatrix(force?: boolean): Matrix;
  26175. /**
  26176. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26177. * @returns a Matrix
  26178. */
  26179. getTransformationMatrix(): Matrix;
  26180. private _updateFrustumPlanes;
  26181. /**
  26182. * Checks if a cullable object (mesh...) is in the camera frustum
  26183. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26184. * @param target The object to check
  26185. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26186. * @returns true if the object is in frustum otherwise false
  26187. */
  26188. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26189. /**
  26190. * Checks if a cullable object (mesh...) is in the camera frustum
  26191. * Unlike isInFrustum this cheks the full bounding box
  26192. * @param target The object to check
  26193. * @returns true if the object is in frustum otherwise false
  26194. */
  26195. isCompletelyInFrustum(target: ICullable): boolean;
  26196. /**
  26197. * Gets a ray in the forward direction from the camera.
  26198. * @param length Defines the length of the ray to create
  26199. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26200. * @param origin Defines the start point of the ray which defaults to the camera position
  26201. * @returns the forward ray
  26202. */
  26203. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26204. /**
  26205. * Releases resources associated with this node.
  26206. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26207. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26208. */
  26209. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26210. /** @hidden */
  26211. _isLeftCamera: boolean;
  26212. /**
  26213. * Gets the left camera of a rig setup in case of Rigged Camera
  26214. */
  26215. get isLeftCamera(): boolean;
  26216. /** @hidden */
  26217. _isRightCamera: boolean;
  26218. /**
  26219. * Gets the right camera of a rig setup in case of Rigged Camera
  26220. */
  26221. get isRightCamera(): boolean;
  26222. /**
  26223. * Gets the left camera of a rig setup in case of Rigged Camera
  26224. */
  26225. get leftCamera(): Nullable<FreeCamera>;
  26226. /**
  26227. * Gets the right camera of a rig setup in case of Rigged Camera
  26228. */
  26229. get rightCamera(): Nullable<FreeCamera>;
  26230. /**
  26231. * Gets the left camera target of a rig setup in case of Rigged Camera
  26232. * @returns the target position
  26233. */
  26234. getLeftTarget(): Nullable<Vector3>;
  26235. /**
  26236. * Gets the right camera target of a rig setup in case of Rigged Camera
  26237. * @returns the target position
  26238. */
  26239. getRightTarget(): Nullable<Vector3>;
  26240. /**
  26241. * @hidden
  26242. */
  26243. setCameraRigMode(mode: number, rigParams: any): void;
  26244. /** @hidden */
  26245. static _setStereoscopicRigMode(camera: Camera): void;
  26246. /** @hidden */
  26247. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26248. /** @hidden */
  26249. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26250. /** @hidden */
  26251. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26252. /** @hidden */
  26253. _getVRProjectionMatrix(): Matrix;
  26254. protected _updateCameraRotationMatrix(): void;
  26255. protected _updateWebVRCameraRotationMatrix(): void;
  26256. /**
  26257. * This function MUST be overwritten by the different WebVR cameras available.
  26258. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26259. * @hidden
  26260. */
  26261. _getWebVRProjectionMatrix(): Matrix;
  26262. /**
  26263. * This function MUST be overwritten by the different WebVR cameras available.
  26264. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26265. * @hidden
  26266. */
  26267. _getWebVRViewMatrix(): Matrix;
  26268. /** @hidden */
  26269. setCameraRigParameter(name: string, value: any): void;
  26270. /**
  26271. * needs to be overridden by children so sub has required properties to be copied
  26272. * @hidden
  26273. */
  26274. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26275. /**
  26276. * May need to be overridden by children
  26277. * @hidden
  26278. */
  26279. _updateRigCameras(): void;
  26280. /** @hidden */
  26281. _setupInputs(): void;
  26282. /**
  26283. * Serialiaze the camera setup to a json represention
  26284. * @returns the JSON representation
  26285. */
  26286. serialize(): any;
  26287. /**
  26288. * Clones the current camera.
  26289. * @param name The cloned camera name
  26290. * @returns the cloned camera
  26291. */
  26292. clone(name: string): Camera;
  26293. /**
  26294. * Gets the direction of the camera relative to a given local axis.
  26295. * @param localAxis Defines the reference axis to provide a relative direction.
  26296. * @return the direction
  26297. */
  26298. getDirection(localAxis: Vector3): Vector3;
  26299. /**
  26300. * Returns the current camera absolute rotation
  26301. */
  26302. get absoluteRotation(): Quaternion;
  26303. /**
  26304. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26305. * @param localAxis Defines the reference axis to provide a relative direction.
  26306. * @param result Defines the vector to store the result in
  26307. */
  26308. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26309. /**
  26310. * Gets a camera constructor for a given camera type
  26311. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26312. * @param name The name of the camera the result will be able to instantiate
  26313. * @param scene The scene the result will construct the camera in
  26314. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26315. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26316. * @returns a factory method to construc the camera
  26317. */
  26318. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26319. /**
  26320. * Compute the world matrix of the camera.
  26321. * @returns the camera world matrix
  26322. */
  26323. computeWorldMatrix(): Matrix;
  26324. /**
  26325. * Parse a JSON and creates the camera from the parsed information
  26326. * @param parsedCamera The JSON to parse
  26327. * @param scene The scene to instantiate the camera in
  26328. * @returns the newly constructed camera
  26329. */
  26330. static Parse(parsedCamera: any, scene: Scene): Camera;
  26331. }
  26332. }
  26333. declare module BABYLON {
  26334. /**
  26335. * Class containing static functions to help procedurally build meshes
  26336. */
  26337. export class DiscBuilder {
  26338. /**
  26339. * Creates a plane polygonal mesh. By default, this is a disc
  26340. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26341. * * 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
  26342. * * 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
  26343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26344. * * 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
  26345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26346. * @param name defines the name of the mesh
  26347. * @param options defines the options used to create the mesh
  26348. * @param scene defines the hosting scene
  26349. * @returns the plane polygonal mesh
  26350. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26351. */
  26352. static CreateDisc(name: string, options: {
  26353. radius?: number;
  26354. tessellation?: number;
  26355. arc?: number;
  26356. updatable?: boolean;
  26357. sideOrientation?: number;
  26358. frontUVs?: Vector4;
  26359. backUVs?: Vector4;
  26360. }, scene?: Nullable<Scene>): Mesh;
  26361. }
  26362. }
  26363. declare module BABYLON {
  26364. /**
  26365. * Options to be used when creating a FresnelParameters.
  26366. */
  26367. export type IFresnelParametersCreationOptions = {
  26368. /**
  26369. * Define the color used on edges (grazing angle)
  26370. */
  26371. leftColor?: Color3;
  26372. /**
  26373. * Define the color used on center
  26374. */
  26375. rightColor?: Color3;
  26376. /**
  26377. * Define bias applied to computed fresnel term
  26378. */
  26379. bias?: number;
  26380. /**
  26381. * Defined the power exponent applied to fresnel term
  26382. */
  26383. power?: number;
  26384. /**
  26385. * Define if the fresnel effect is enable or not.
  26386. */
  26387. isEnabled?: boolean;
  26388. };
  26389. /**
  26390. * Serialized format for FresnelParameters.
  26391. */
  26392. export type IFresnelParametersSerialized = {
  26393. /**
  26394. * Define the color used on edges (grazing angle) [as an array]
  26395. */
  26396. leftColor: number[];
  26397. /**
  26398. * Define the color used on center [as an array]
  26399. */
  26400. rightColor: number[];
  26401. /**
  26402. * Define bias applied to computed fresnel term
  26403. */
  26404. bias: number;
  26405. /**
  26406. * Defined the power exponent applied to fresnel term
  26407. */
  26408. power?: number;
  26409. /**
  26410. * Define if the fresnel effect is enable or not.
  26411. */
  26412. isEnabled: boolean;
  26413. };
  26414. /**
  26415. * This represents all the required information to add a fresnel effect on a material:
  26416. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26417. */
  26418. export class FresnelParameters {
  26419. private _isEnabled;
  26420. /**
  26421. * Define if the fresnel effect is enable or not.
  26422. */
  26423. get isEnabled(): boolean;
  26424. set isEnabled(value: boolean);
  26425. /**
  26426. * Define the color used on edges (grazing angle)
  26427. */
  26428. leftColor: Color3;
  26429. /**
  26430. * Define the color used on center
  26431. */
  26432. rightColor: Color3;
  26433. /**
  26434. * Define bias applied to computed fresnel term
  26435. */
  26436. bias: number;
  26437. /**
  26438. * Defined the power exponent applied to fresnel term
  26439. */
  26440. power: number;
  26441. /**
  26442. * Creates a new FresnelParameters object.
  26443. *
  26444. * @param options provide your own settings to optionally to override defaults
  26445. */
  26446. constructor(options?: IFresnelParametersCreationOptions);
  26447. /**
  26448. * Clones the current fresnel and its valuues
  26449. * @returns a clone fresnel configuration
  26450. */
  26451. clone(): FresnelParameters;
  26452. /**
  26453. * Determines equality between FresnelParameters objects
  26454. * @param otherFresnelParameters defines the second operand
  26455. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26456. */
  26457. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26458. /**
  26459. * Serializes the current fresnel parameters to a JSON representation.
  26460. * @return the JSON serialization
  26461. */
  26462. serialize(): IFresnelParametersSerialized;
  26463. /**
  26464. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26465. * @param parsedFresnelParameters Define the JSON representation
  26466. * @returns the parsed parameters
  26467. */
  26468. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26469. }
  26470. }
  26471. declare module BABYLON {
  26472. /**
  26473. * Base class of materials working in push mode in babylon JS
  26474. * @hidden
  26475. */
  26476. export class PushMaterial extends Material {
  26477. protected _activeEffect: Effect;
  26478. protected _normalMatrix: Matrix;
  26479. /**
  26480. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26481. * This means that the material can keep using a previous shader while a new one is being compiled.
  26482. * This is mostly used when shader parallel compilation is supported (true by default)
  26483. */
  26484. allowShaderHotSwapping: boolean;
  26485. constructor(name: string, scene: Scene);
  26486. getEffect(): Effect;
  26487. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26488. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26489. /**
  26490. * Binds the given world matrix to the active effect
  26491. *
  26492. * @param world the matrix to bind
  26493. */
  26494. bindOnlyWorldMatrix(world: Matrix): void;
  26495. /**
  26496. * Binds the given normal matrix to the active effect
  26497. *
  26498. * @param normalMatrix the matrix to bind
  26499. */
  26500. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26501. bind(world: Matrix, mesh?: Mesh): void;
  26502. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26503. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26504. }
  26505. }
  26506. declare module BABYLON {
  26507. /**
  26508. * This groups all the flags used to control the materials channel.
  26509. */
  26510. export class MaterialFlags {
  26511. private static _DiffuseTextureEnabled;
  26512. /**
  26513. * Are diffuse textures enabled in the application.
  26514. */
  26515. static get DiffuseTextureEnabled(): boolean;
  26516. static set DiffuseTextureEnabled(value: boolean);
  26517. private static _AmbientTextureEnabled;
  26518. /**
  26519. * Are ambient textures enabled in the application.
  26520. */
  26521. static get AmbientTextureEnabled(): boolean;
  26522. static set AmbientTextureEnabled(value: boolean);
  26523. private static _OpacityTextureEnabled;
  26524. /**
  26525. * Are opacity textures enabled in the application.
  26526. */
  26527. static get OpacityTextureEnabled(): boolean;
  26528. static set OpacityTextureEnabled(value: boolean);
  26529. private static _ReflectionTextureEnabled;
  26530. /**
  26531. * Are reflection textures enabled in the application.
  26532. */
  26533. static get ReflectionTextureEnabled(): boolean;
  26534. static set ReflectionTextureEnabled(value: boolean);
  26535. private static _EmissiveTextureEnabled;
  26536. /**
  26537. * Are emissive textures enabled in the application.
  26538. */
  26539. static get EmissiveTextureEnabled(): boolean;
  26540. static set EmissiveTextureEnabled(value: boolean);
  26541. private static _SpecularTextureEnabled;
  26542. /**
  26543. * Are specular textures enabled in the application.
  26544. */
  26545. static get SpecularTextureEnabled(): boolean;
  26546. static set SpecularTextureEnabled(value: boolean);
  26547. private static _BumpTextureEnabled;
  26548. /**
  26549. * Are bump textures enabled in the application.
  26550. */
  26551. static get BumpTextureEnabled(): boolean;
  26552. static set BumpTextureEnabled(value: boolean);
  26553. private static _LightmapTextureEnabled;
  26554. /**
  26555. * Are lightmap textures enabled in the application.
  26556. */
  26557. static get LightmapTextureEnabled(): boolean;
  26558. static set LightmapTextureEnabled(value: boolean);
  26559. private static _RefractionTextureEnabled;
  26560. /**
  26561. * Are refraction textures enabled in the application.
  26562. */
  26563. static get RefractionTextureEnabled(): boolean;
  26564. static set RefractionTextureEnabled(value: boolean);
  26565. private static _ColorGradingTextureEnabled;
  26566. /**
  26567. * Are color grading textures enabled in the application.
  26568. */
  26569. static get ColorGradingTextureEnabled(): boolean;
  26570. static set ColorGradingTextureEnabled(value: boolean);
  26571. private static _FresnelEnabled;
  26572. /**
  26573. * Are fresnels enabled in the application.
  26574. */
  26575. static get FresnelEnabled(): boolean;
  26576. static set FresnelEnabled(value: boolean);
  26577. private static _ClearCoatTextureEnabled;
  26578. /**
  26579. * Are clear coat textures enabled in the application.
  26580. */
  26581. static get ClearCoatTextureEnabled(): boolean;
  26582. static set ClearCoatTextureEnabled(value: boolean);
  26583. private static _ClearCoatBumpTextureEnabled;
  26584. /**
  26585. * Are clear coat bump textures enabled in the application.
  26586. */
  26587. static get ClearCoatBumpTextureEnabled(): boolean;
  26588. static set ClearCoatBumpTextureEnabled(value: boolean);
  26589. private static _ClearCoatTintTextureEnabled;
  26590. /**
  26591. * Are clear coat tint textures enabled in the application.
  26592. */
  26593. static get ClearCoatTintTextureEnabled(): boolean;
  26594. static set ClearCoatTintTextureEnabled(value: boolean);
  26595. private static _SheenTextureEnabled;
  26596. /**
  26597. * Are sheen textures enabled in the application.
  26598. */
  26599. static get SheenTextureEnabled(): boolean;
  26600. static set SheenTextureEnabled(value: boolean);
  26601. private static _AnisotropicTextureEnabled;
  26602. /**
  26603. * Are anisotropic textures enabled in the application.
  26604. */
  26605. static get AnisotropicTextureEnabled(): boolean;
  26606. static set AnisotropicTextureEnabled(value: boolean);
  26607. private static _ThicknessTextureEnabled;
  26608. /**
  26609. * Are thickness textures enabled in the application.
  26610. */
  26611. static get ThicknessTextureEnabled(): boolean;
  26612. static set ThicknessTextureEnabled(value: boolean);
  26613. }
  26614. }
  26615. declare module BABYLON {
  26616. /** @hidden */
  26617. export var defaultFragmentDeclaration: {
  26618. name: string;
  26619. shader: string;
  26620. };
  26621. }
  26622. declare module BABYLON {
  26623. /** @hidden */
  26624. export var defaultUboDeclaration: {
  26625. name: string;
  26626. shader: string;
  26627. };
  26628. }
  26629. declare module BABYLON {
  26630. /** @hidden */
  26631. export var lightFragmentDeclaration: {
  26632. name: string;
  26633. shader: string;
  26634. };
  26635. }
  26636. declare module BABYLON {
  26637. /** @hidden */
  26638. export var lightUboDeclaration: {
  26639. name: string;
  26640. shader: string;
  26641. };
  26642. }
  26643. declare module BABYLON {
  26644. /** @hidden */
  26645. export var lightsFragmentFunctions: {
  26646. name: string;
  26647. shader: string;
  26648. };
  26649. }
  26650. declare module BABYLON {
  26651. /** @hidden */
  26652. export var shadowsFragmentFunctions: {
  26653. name: string;
  26654. shader: string;
  26655. };
  26656. }
  26657. declare module BABYLON {
  26658. /** @hidden */
  26659. export var fresnelFunction: {
  26660. name: string;
  26661. shader: string;
  26662. };
  26663. }
  26664. declare module BABYLON {
  26665. /** @hidden */
  26666. export var reflectionFunction: {
  26667. name: string;
  26668. shader: string;
  26669. };
  26670. }
  26671. declare module BABYLON {
  26672. /** @hidden */
  26673. export var bumpFragmentFunctions: {
  26674. name: string;
  26675. shader: string;
  26676. };
  26677. }
  26678. declare module BABYLON {
  26679. /** @hidden */
  26680. export var logDepthDeclaration: {
  26681. name: string;
  26682. shader: string;
  26683. };
  26684. }
  26685. declare module BABYLON {
  26686. /** @hidden */
  26687. export var bumpFragment: {
  26688. name: string;
  26689. shader: string;
  26690. };
  26691. }
  26692. declare module BABYLON {
  26693. /** @hidden */
  26694. export var depthPrePass: {
  26695. name: string;
  26696. shader: string;
  26697. };
  26698. }
  26699. declare module BABYLON {
  26700. /** @hidden */
  26701. export var lightFragment: {
  26702. name: string;
  26703. shader: string;
  26704. };
  26705. }
  26706. declare module BABYLON {
  26707. /** @hidden */
  26708. export var logDepthFragment: {
  26709. name: string;
  26710. shader: string;
  26711. };
  26712. }
  26713. declare module BABYLON {
  26714. /** @hidden */
  26715. export var defaultPixelShader: {
  26716. name: string;
  26717. shader: string;
  26718. };
  26719. }
  26720. declare module BABYLON {
  26721. /** @hidden */
  26722. export var defaultVertexDeclaration: {
  26723. name: string;
  26724. shader: string;
  26725. };
  26726. }
  26727. declare module BABYLON {
  26728. /** @hidden */
  26729. export var bumpVertexDeclaration: {
  26730. name: string;
  26731. shader: string;
  26732. };
  26733. }
  26734. declare module BABYLON {
  26735. /** @hidden */
  26736. export var bumpVertex: {
  26737. name: string;
  26738. shader: string;
  26739. };
  26740. }
  26741. declare module BABYLON {
  26742. /** @hidden */
  26743. export var fogVertex: {
  26744. name: string;
  26745. shader: string;
  26746. };
  26747. }
  26748. declare module BABYLON {
  26749. /** @hidden */
  26750. export var shadowsVertex: {
  26751. name: string;
  26752. shader: string;
  26753. };
  26754. }
  26755. declare module BABYLON {
  26756. /** @hidden */
  26757. export var pointCloudVertex: {
  26758. name: string;
  26759. shader: string;
  26760. };
  26761. }
  26762. declare module BABYLON {
  26763. /** @hidden */
  26764. export var logDepthVertex: {
  26765. name: string;
  26766. shader: string;
  26767. };
  26768. }
  26769. declare module BABYLON {
  26770. /** @hidden */
  26771. export var defaultVertexShader: {
  26772. name: string;
  26773. shader: string;
  26774. };
  26775. }
  26776. declare module BABYLON {
  26777. /** @hidden */
  26778. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26779. MAINUV1: boolean;
  26780. MAINUV2: boolean;
  26781. DIFFUSE: boolean;
  26782. DIFFUSEDIRECTUV: number;
  26783. AMBIENT: boolean;
  26784. AMBIENTDIRECTUV: number;
  26785. OPACITY: boolean;
  26786. OPACITYDIRECTUV: number;
  26787. OPACITYRGB: boolean;
  26788. REFLECTION: boolean;
  26789. EMISSIVE: boolean;
  26790. EMISSIVEDIRECTUV: number;
  26791. SPECULAR: boolean;
  26792. SPECULARDIRECTUV: number;
  26793. BUMP: boolean;
  26794. BUMPDIRECTUV: number;
  26795. PARALLAX: boolean;
  26796. PARALLAXOCCLUSION: boolean;
  26797. SPECULAROVERALPHA: boolean;
  26798. CLIPPLANE: boolean;
  26799. CLIPPLANE2: boolean;
  26800. CLIPPLANE3: boolean;
  26801. CLIPPLANE4: boolean;
  26802. CLIPPLANE5: boolean;
  26803. CLIPPLANE6: boolean;
  26804. ALPHATEST: boolean;
  26805. DEPTHPREPASS: boolean;
  26806. ALPHAFROMDIFFUSE: boolean;
  26807. POINTSIZE: boolean;
  26808. FOG: boolean;
  26809. SPECULARTERM: boolean;
  26810. DIFFUSEFRESNEL: boolean;
  26811. OPACITYFRESNEL: boolean;
  26812. REFLECTIONFRESNEL: boolean;
  26813. REFRACTIONFRESNEL: boolean;
  26814. EMISSIVEFRESNEL: boolean;
  26815. FRESNEL: boolean;
  26816. NORMAL: boolean;
  26817. UV1: boolean;
  26818. UV2: boolean;
  26819. VERTEXCOLOR: boolean;
  26820. VERTEXALPHA: boolean;
  26821. NUM_BONE_INFLUENCERS: number;
  26822. BonesPerMesh: number;
  26823. BONETEXTURE: boolean;
  26824. INSTANCES: boolean;
  26825. GLOSSINESS: boolean;
  26826. ROUGHNESS: boolean;
  26827. EMISSIVEASILLUMINATION: boolean;
  26828. LINKEMISSIVEWITHDIFFUSE: boolean;
  26829. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26830. LIGHTMAP: boolean;
  26831. LIGHTMAPDIRECTUV: number;
  26832. OBJECTSPACE_NORMALMAP: boolean;
  26833. USELIGHTMAPASSHADOWMAP: boolean;
  26834. REFLECTIONMAP_3D: boolean;
  26835. REFLECTIONMAP_SPHERICAL: boolean;
  26836. REFLECTIONMAP_PLANAR: boolean;
  26837. REFLECTIONMAP_CUBIC: boolean;
  26838. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26839. REFLECTIONMAP_PROJECTION: boolean;
  26840. REFLECTIONMAP_SKYBOX: boolean;
  26841. REFLECTIONMAP_EXPLICIT: boolean;
  26842. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26843. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26844. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26845. INVERTCUBICMAP: boolean;
  26846. LOGARITHMICDEPTH: boolean;
  26847. REFRACTION: boolean;
  26848. REFRACTIONMAP_3D: boolean;
  26849. REFLECTIONOVERALPHA: boolean;
  26850. TWOSIDEDLIGHTING: boolean;
  26851. SHADOWFLOAT: boolean;
  26852. MORPHTARGETS: boolean;
  26853. MORPHTARGETS_NORMAL: boolean;
  26854. MORPHTARGETS_TANGENT: boolean;
  26855. MORPHTARGETS_UV: boolean;
  26856. NUM_MORPH_INFLUENCERS: number;
  26857. NONUNIFORMSCALING: boolean;
  26858. PREMULTIPLYALPHA: boolean;
  26859. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26860. ALPHABLEND: boolean;
  26861. IMAGEPROCESSING: boolean;
  26862. VIGNETTE: boolean;
  26863. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26864. VIGNETTEBLENDMODEOPAQUE: boolean;
  26865. TONEMAPPING: boolean;
  26866. TONEMAPPING_ACES: boolean;
  26867. CONTRAST: boolean;
  26868. COLORCURVES: boolean;
  26869. COLORGRADING: boolean;
  26870. COLORGRADING3D: boolean;
  26871. SAMPLER3DGREENDEPTH: boolean;
  26872. SAMPLER3DBGRMAP: boolean;
  26873. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26874. MULTIVIEW: boolean;
  26875. /**
  26876. * If the reflection texture on this material is in linear color space
  26877. * @hidden
  26878. */
  26879. IS_REFLECTION_LINEAR: boolean;
  26880. /**
  26881. * If the refraction texture on this material is in linear color space
  26882. * @hidden
  26883. */
  26884. IS_REFRACTION_LINEAR: boolean;
  26885. EXPOSURE: boolean;
  26886. constructor();
  26887. setReflectionMode(modeToEnable: string): void;
  26888. }
  26889. /**
  26890. * This is the default material used in Babylon. It is the best trade off between quality
  26891. * and performances.
  26892. * @see http://doc.babylonjs.com/babylon101/materials
  26893. */
  26894. export class StandardMaterial extends PushMaterial {
  26895. private _diffuseTexture;
  26896. /**
  26897. * The basic texture of the material as viewed under a light.
  26898. */
  26899. diffuseTexture: Nullable<BaseTexture>;
  26900. private _ambientTexture;
  26901. /**
  26902. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26903. */
  26904. ambientTexture: Nullable<BaseTexture>;
  26905. private _opacityTexture;
  26906. /**
  26907. * Define the transparency of the material from a texture.
  26908. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26909. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26910. */
  26911. opacityTexture: Nullable<BaseTexture>;
  26912. private _reflectionTexture;
  26913. /**
  26914. * Define the texture used to display the reflection.
  26915. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26916. */
  26917. reflectionTexture: Nullable<BaseTexture>;
  26918. private _emissiveTexture;
  26919. /**
  26920. * Define texture of the material as if self lit.
  26921. * This will be mixed in the final result even in the absence of light.
  26922. */
  26923. emissiveTexture: Nullable<BaseTexture>;
  26924. private _specularTexture;
  26925. /**
  26926. * Define how the color and intensity of the highlight given by the light in the material.
  26927. */
  26928. specularTexture: Nullable<BaseTexture>;
  26929. private _bumpTexture;
  26930. /**
  26931. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26932. * 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.
  26933. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26934. */
  26935. bumpTexture: Nullable<BaseTexture>;
  26936. private _lightmapTexture;
  26937. /**
  26938. * Complex lighting can be computationally expensive to compute at runtime.
  26939. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26940. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26941. */
  26942. lightmapTexture: Nullable<BaseTexture>;
  26943. private _refractionTexture;
  26944. /**
  26945. * Define the texture used to display the refraction.
  26946. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26947. */
  26948. refractionTexture: Nullable<BaseTexture>;
  26949. /**
  26950. * The color of the material lit by the environmental background lighting.
  26951. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26952. */
  26953. ambientColor: Color3;
  26954. /**
  26955. * The basic color of the material as viewed under a light.
  26956. */
  26957. diffuseColor: Color3;
  26958. /**
  26959. * Define how the color and intensity of the highlight given by the light in the material.
  26960. */
  26961. specularColor: Color3;
  26962. /**
  26963. * Define the color of the material as if self lit.
  26964. * This will be mixed in the final result even in the absence of light.
  26965. */
  26966. emissiveColor: Color3;
  26967. /**
  26968. * Defines how sharp are the highlights in the material.
  26969. * The bigger the value the sharper giving a more glossy feeling to the result.
  26970. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26971. */
  26972. specularPower: number;
  26973. private _useAlphaFromDiffuseTexture;
  26974. /**
  26975. * Does the transparency come from the diffuse texture alpha channel.
  26976. */
  26977. useAlphaFromDiffuseTexture: boolean;
  26978. private _useEmissiveAsIllumination;
  26979. /**
  26980. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26981. */
  26982. useEmissiveAsIllumination: boolean;
  26983. private _linkEmissiveWithDiffuse;
  26984. /**
  26985. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26986. * the emissive level when the final color is close to one.
  26987. */
  26988. linkEmissiveWithDiffuse: boolean;
  26989. private _useSpecularOverAlpha;
  26990. /**
  26991. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26992. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26993. */
  26994. useSpecularOverAlpha: boolean;
  26995. private _useReflectionOverAlpha;
  26996. /**
  26997. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26998. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26999. */
  27000. useReflectionOverAlpha: boolean;
  27001. private _disableLighting;
  27002. /**
  27003. * Does lights from the scene impacts this material.
  27004. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27005. */
  27006. disableLighting: boolean;
  27007. private _useObjectSpaceNormalMap;
  27008. /**
  27009. * Allows using an object space normal map (instead of tangent space).
  27010. */
  27011. useObjectSpaceNormalMap: boolean;
  27012. private _useParallax;
  27013. /**
  27014. * Is parallax enabled or not.
  27015. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27016. */
  27017. useParallax: boolean;
  27018. private _useParallaxOcclusion;
  27019. /**
  27020. * Is parallax occlusion enabled or not.
  27021. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27022. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27023. */
  27024. useParallaxOcclusion: boolean;
  27025. /**
  27026. * 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.
  27027. */
  27028. parallaxScaleBias: number;
  27029. private _roughness;
  27030. /**
  27031. * Helps to define how blurry the reflections should appears in the material.
  27032. */
  27033. roughness: number;
  27034. /**
  27035. * In case of refraction, define the value of the index of refraction.
  27036. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27037. */
  27038. indexOfRefraction: number;
  27039. /**
  27040. * Invert the refraction texture alongside the y axis.
  27041. * It can be useful with procedural textures or probe for instance.
  27042. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27043. */
  27044. invertRefractionY: boolean;
  27045. /**
  27046. * Defines the alpha limits in alpha test mode.
  27047. */
  27048. alphaCutOff: number;
  27049. private _useLightmapAsShadowmap;
  27050. /**
  27051. * In case of light mapping, define whether the map contains light or shadow informations.
  27052. */
  27053. useLightmapAsShadowmap: boolean;
  27054. private _diffuseFresnelParameters;
  27055. /**
  27056. * Define the diffuse fresnel parameters of the material.
  27057. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27058. */
  27059. diffuseFresnelParameters: FresnelParameters;
  27060. private _opacityFresnelParameters;
  27061. /**
  27062. * Define the opacity fresnel parameters of the material.
  27063. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27064. */
  27065. opacityFresnelParameters: FresnelParameters;
  27066. private _reflectionFresnelParameters;
  27067. /**
  27068. * Define the reflection fresnel parameters of the material.
  27069. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27070. */
  27071. reflectionFresnelParameters: FresnelParameters;
  27072. private _refractionFresnelParameters;
  27073. /**
  27074. * Define the refraction fresnel parameters of the material.
  27075. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27076. */
  27077. refractionFresnelParameters: FresnelParameters;
  27078. private _emissiveFresnelParameters;
  27079. /**
  27080. * Define the emissive fresnel parameters of the material.
  27081. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27082. */
  27083. emissiveFresnelParameters: FresnelParameters;
  27084. private _useReflectionFresnelFromSpecular;
  27085. /**
  27086. * If true automatically deducts the fresnels values from the material specularity.
  27087. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27088. */
  27089. useReflectionFresnelFromSpecular: boolean;
  27090. private _useGlossinessFromSpecularMapAlpha;
  27091. /**
  27092. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27093. */
  27094. useGlossinessFromSpecularMapAlpha: boolean;
  27095. private _maxSimultaneousLights;
  27096. /**
  27097. * Defines the maximum number of lights that can be used in the material
  27098. */
  27099. maxSimultaneousLights: number;
  27100. private _invertNormalMapX;
  27101. /**
  27102. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27103. */
  27104. invertNormalMapX: boolean;
  27105. private _invertNormalMapY;
  27106. /**
  27107. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27108. */
  27109. invertNormalMapY: boolean;
  27110. private _twoSidedLighting;
  27111. /**
  27112. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27113. */
  27114. twoSidedLighting: boolean;
  27115. /**
  27116. * Default configuration related to image processing available in the standard Material.
  27117. */
  27118. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27119. /**
  27120. * Gets the image processing configuration used either in this material.
  27121. */
  27122. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27123. /**
  27124. * Sets the Default image processing configuration used either in the this material.
  27125. *
  27126. * If sets to null, the scene one is in use.
  27127. */
  27128. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27129. /**
  27130. * Keep track of the image processing observer to allow dispose and replace.
  27131. */
  27132. private _imageProcessingObserver;
  27133. /**
  27134. * Attaches a new image processing configuration to the Standard Material.
  27135. * @param configuration
  27136. */
  27137. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27138. /**
  27139. * Gets wether the color curves effect is enabled.
  27140. */
  27141. get cameraColorCurvesEnabled(): boolean;
  27142. /**
  27143. * Sets wether the color curves effect is enabled.
  27144. */
  27145. set cameraColorCurvesEnabled(value: boolean);
  27146. /**
  27147. * Gets wether the color grading effect is enabled.
  27148. */
  27149. get cameraColorGradingEnabled(): boolean;
  27150. /**
  27151. * Gets wether the color grading effect is enabled.
  27152. */
  27153. set cameraColorGradingEnabled(value: boolean);
  27154. /**
  27155. * Gets wether tonemapping is enabled or not.
  27156. */
  27157. get cameraToneMappingEnabled(): boolean;
  27158. /**
  27159. * Sets wether tonemapping is enabled or not
  27160. */
  27161. set cameraToneMappingEnabled(value: boolean);
  27162. /**
  27163. * The camera exposure used on this material.
  27164. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27165. * This corresponds to a photographic exposure.
  27166. */
  27167. get cameraExposure(): number;
  27168. /**
  27169. * The camera exposure used on this material.
  27170. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27171. * This corresponds to a photographic exposure.
  27172. */
  27173. set cameraExposure(value: number);
  27174. /**
  27175. * Gets The camera contrast used on this material.
  27176. */
  27177. get cameraContrast(): number;
  27178. /**
  27179. * Sets The camera contrast used on this material.
  27180. */
  27181. set cameraContrast(value: number);
  27182. /**
  27183. * Gets the Color Grading 2D Lookup Texture.
  27184. */
  27185. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27186. /**
  27187. * Sets the Color Grading 2D Lookup Texture.
  27188. */
  27189. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27190. /**
  27191. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27192. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27193. * 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;
  27194. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27195. */
  27196. get cameraColorCurves(): Nullable<ColorCurves>;
  27197. /**
  27198. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27199. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27200. * 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;
  27201. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27202. */
  27203. set cameraColorCurves(value: Nullable<ColorCurves>);
  27204. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27205. protected _worldViewProjectionMatrix: Matrix;
  27206. protected _globalAmbientColor: Color3;
  27207. protected _useLogarithmicDepth: boolean;
  27208. protected _rebuildInParallel: boolean;
  27209. /**
  27210. * Instantiates a new standard material.
  27211. * This is the default material used in Babylon. It is the best trade off between quality
  27212. * and performances.
  27213. * @see http://doc.babylonjs.com/babylon101/materials
  27214. * @param name Define the name of the material in the scene
  27215. * @param scene Define the scene the material belong to
  27216. */
  27217. constructor(name: string, scene: Scene);
  27218. /**
  27219. * Gets a boolean indicating that current material needs to register RTT
  27220. */
  27221. get hasRenderTargetTextures(): boolean;
  27222. /**
  27223. * Gets the current class name of the material e.g. "StandardMaterial"
  27224. * Mainly use in serialization.
  27225. * @returns the class name
  27226. */
  27227. getClassName(): string;
  27228. /**
  27229. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27230. * You can try switching to logarithmic depth.
  27231. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27232. */
  27233. get useLogarithmicDepth(): boolean;
  27234. set useLogarithmicDepth(value: boolean);
  27235. /**
  27236. * Specifies if the material will require alpha blending
  27237. * @returns a boolean specifying if alpha blending is needed
  27238. */
  27239. needAlphaBlending(): boolean;
  27240. /**
  27241. * Specifies if this material should be rendered in alpha test mode
  27242. * @returns a boolean specifying if an alpha test is needed.
  27243. */
  27244. needAlphaTesting(): boolean;
  27245. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27246. /**
  27247. * Get the texture used for alpha test purpose.
  27248. * @returns the diffuse texture in case of the standard material.
  27249. */
  27250. getAlphaTestTexture(): Nullable<BaseTexture>;
  27251. /**
  27252. * Get if the submesh is ready to be used and all its information available.
  27253. * Child classes can use it to update shaders
  27254. * @param mesh defines the mesh to check
  27255. * @param subMesh defines which submesh to check
  27256. * @param useInstances specifies that instances should be used
  27257. * @returns a boolean indicating that the submesh is ready or not
  27258. */
  27259. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27260. /**
  27261. * Builds the material UBO layouts.
  27262. * Used internally during the effect preparation.
  27263. */
  27264. buildUniformLayout(): void;
  27265. /**
  27266. * Unbinds the material from the mesh
  27267. */
  27268. unbind(): void;
  27269. /**
  27270. * Binds the submesh to this material by preparing the effect and shader to draw
  27271. * @param world defines the world transformation matrix
  27272. * @param mesh defines the mesh containing the submesh
  27273. * @param subMesh defines the submesh to bind the material to
  27274. */
  27275. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27276. /**
  27277. * Get the list of animatables in the material.
  27278. * @returns the list of animatables object used in the material
  27279. */
  27280. getAnimatables(): IAnimatable[];
  27281. /**
  27282. * Gets the active textures from the material
  27283. * @returns an array of textures
  27284. */
  27285. getActiveTextures(): BaseTexture[];
  27286. /**
  27287. * Specifies if the material uses a texture
  27288. * @param texture defines the texture to check against the material
  27289. * @returns a boolean specifying if the material uses the texture
  27290. */
  27291. hasTexture(texture: BaseTexture): boolean;
  27292. /**
  27293. * Disposes the material
  27294. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27295. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27296. */
  27297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27298. /**
  27299. * Makes a duplicate of the material, and gives it a new name
  27300. * @param name defines the new name for the duplicated material
  27301. * @returns the cloned material
  27302. */
  27303. clone(name: string): StandardMaterial;
  27304. /**
  27305. * Serializes this material in a JSON representation
  27306. * @returns the serialized material object
  27307. */
  27308. serialize(): any;
  27309. /**
  27310. * Creates a standard material from parsed material data
  27311. * @param source defines the JSON representation of the material
  27312. * @param scene defines the hosting scene
  27313. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27314. * @returns a new standard material
  27315. */
  27316. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27317. /**
  27318. * Are diffuse textures enabled in the application.
  27319. */
  27320. static get DiffuseTextureEnabled(): boolean;
  27321. static set DiffuseTextureEnabled(value: boolean);
  27322. /**
  27323. * Are ambient textures enabled in the application.
  27324. */
  27325. static get AmbientTextureEnabled(): boolean;
  27326. static set AmbientTextureEnabled(value: boolean);
  27327. /**
  27328. * Are opacity textures enabled in the application.
  27329. */
  27330. static get OpacityTextureEnabled(): boolean;
  27331. static set OpacityTextureEnabled(value: boolean);
  27332. /**
  27333. * Are reflection textures enabled in the application.
  27334. */
  27335. static get ReflectionTextureEnabled(): boolean;
  27336. static set ReflectionTextureEnabled(value: boolean);
  27337. /**
  27338. * Are emissive textures enabled in the application.
  27339. */
  27340. static get EmissiveTextureEnabled(): boolean;
  27341. static set EmissiveTextureEnabled(value: boolean);
  27342. /**
  27343. * Are specular textures enabled in the application.
  27344. */
  27345. static get SpecularTextureEnabled(): boolean;
  27346. static set SpecularTextureEnabled(value: boolean);
  27347. /**
  27348. * Are bump textures enabled in the application.
  27349. */
  27350. static get BumpTextureEnabled(): boolean;
  27351. static set BumpTextureEnabled(value: boolean);
  27352. /**
  27353. * Are lightmap textures enabled in the application.
  27354. */
  27355. static get LightmapTextureEnabled(): boolean;
  27356. static set LightmapTextureEnabled(value: boolean);
  27357. /**
  27358. * Are refraction textures enabled in the application.
  27359. */
  27360. static get RefractionTextureEnabled(): boolean;
  27361. static set RefractionTextureEnabled(value: boolean);
  27362. /**
  27363. * Are color grading textures enabled in the application.
  27364. */
  27365. static get ColorGradingTextureEnabled(): boolean;
  27366. static set ColorGradingTextureEnabled(value: boolean);
  27367. /**
  27368. * Are fresnels enabled in the application.
  27369. */
  27370. static get FresnelEnabled(): boolean;
  27371. static set FresnelEnabled(value: boolean);
  27372. }
  27373. }
  27374. declare module BABYLON {
  27375. /**
  27376. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27377. *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.
  27378. * The SPS is also a particle system. It provides some methods to manage the particles.
  27379. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27380. *
  27381. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27382. */
  27383. export class SolidParticleSystem implements IDisposable {
  27384. /**
  27385. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27386. * Example : var p = SPS.particles[i];
  27387. */
  27388. particles: SolidParticle[];
  27389. /**
  27390. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27391. */
  27392. nbParticles: number;
  27393. /**
  27394. * If the particles must ever face the camera (default false). Useful for planar particles.
  27395. */
  27396. billboard: boolean;
  27397. /**
  27398. * Recompute normals when adding a shape
  27399. */
  27400. recomputeNormals: boolean;
  27401. /**
  27402. * This a counter ofr your own usage. It's not set by any SPS functions.
  27403. */
  27404. counter: number;
  27405. /**
  27406. * The SPS name. This name is also given to the underlying mesh.
  27407. */
  27408. name: string;
  27409. /**
  27410. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27411. */
  27412. mesh: Mesh;
  27413. /**
  27414. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27415. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27416. */
  27417. vars: any;
  27418. /**
  27419. * This array is populated when the SPS is set as 'pickable'.
  27420. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27421. * Each element of this array is an object `{idx: int, faceId: int}`.
  27422. * `idx` is the picked particle index in the `SPS.particles` array
  27423. * `faceId` is the picked face index counted within this particle.
  27424. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27425. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27426. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27427. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27428. */
  27429. pickedParticles: {
  27430. idx: number;
  27431. faceId: number;
  27432. }[];
  27433. /**
  27434. * This array is populated when the SPS is set as 'pickable'
  27435. * Each key of this array is a submesh index.
  27436. * Each element of this array is a second array defined like this :
  27437. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27438. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27439. * `idx` is the picked particle index in the `SPS.particles` array
  27440. * `faceId` is the picked face index counted within this particle.
  27441. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27442. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27443. */
  27444. pickedBySubMesh: {
  27445. idx: number;
  27446. faceId: number;
  27447. }[][];
  27448. /**
  27449. * This array is populated when `enableDepthSort` is set to true.
  27450. * Each element of this array is an instance of the class DepthSortedParticle.
  27451. */
  27452. depthSortedParticles: DepthSortedParticle[];
  27453. /**
  27454. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27455. * @hidden
  27456. */
  27457. _bSphereOnly: boolean;
  27458. /**
  27459. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27460. * @hidden
  27461. */
  27462. _bSphereRadiusFactor: number;
  27463. private _scene;
  27464. private _positions;
  27465. private _indices;
  27466. private _normals;
  27467. private _colors;
  27468. private _uvs;
  27469. private _indices32;
  27470. private _positions32;
  27471. private _normals32;
  27472. private _fixedNormal32;
  27473. private _colors32;
  27474. private _uvs32;
  27475. private _index;
  27476. private _updatable;
  27477. private _pickable;
  27478. private _isVisibilityBoxLocked;
  27479. private _alwaysVisible;
  27480. private _depthSort;
  27481. private _expandable;
  27482. private _shapeCounter;
  27483. private _copy;
  27484. private _color;
  27485. private _computeParticleColor;
  27486. private _computeParticleTexture;
  27487. private _computeParticleRotation;
  27488. private _computeParticleVertex;
  27489. private _computeBoundingBox;
  27490. private _depthSortParticles;
  27491. private _camera;
  27492. private _mustUnrotateFixedNormals;
  27493. private _particlesIntersect;
  27494. private _needs32Bits;
  27495. private _isNotBuilt;
  27496. private _lastParticleId;
  27497. private _idxOfId;
  27498. private _multimaterialEnabled;
  27499. private _useModelMaterial;
  27500. private _indicesByMaterial;
  27501. private _materialIndexes;
  27502. private _depthSortFunction;
  27503. private _materialSortFunction;
  27504. private _materials;
  27505. private _multimaterial;
  27506. private _materialIndexesById;
  27507. private _defaultMaterial;
  27508. private _autoUpdateSubMeshes;
  27509. /**
  27510. * Creates a SPS (Solid Particle System) object.
  27511. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27512. * @param scene (Scene) is the scene in which the SPS is added.
  27513. * @param options defines the options of the sps e.g.
  27514. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27515. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27516. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27517. * * 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.
  27518. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27519. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27520. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27521. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27522. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27523. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27524. */
  27525. constructor(name: string, scene: Scene, options?: {
  27526. updatable?: boolean;
  27527. isPickable?: boolean;
  27528. enableDepthSort?: boolean;
  27529. particleIntersection?: boolean;
  27530. boundingSphereOnly?: boolean;
  27531. bSphereRadiusFactor?: number;
  27532. expandable?: boolean;
  27533. useModelMaterial?: boolean;
  27534. enableMultiMaterial?: boolean;
  27535. });
  27536. /**
  27537. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27538. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27539. * @returns the created mesh
  27540. */
  27541. buildMesh(): Mesh;
  27542. /**
  27543. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27544. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27545. * Thus the particles generated from `digest()` have their property `position` set yet.
  27546. * @param mesh ( Mesh ) is the mesh to be digested
  27547. * @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
  27548. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27549. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27550. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27551. * @returns the current SPS
  27552. */
  27553. digest(mesh: Mesh, options?: {
  27554. facetNb?: number;
  27555. number?: number;
  27556. delta?: number;
  27557. storage?: [];
  27558. }): SolidParticleSystem;
  27559. /**
  27560. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27561. * @hidden
  27562. */
  27563. private _unrotateFixedNormals;
  27564. /**
  27565. * Resets the temporary working copy particle
  27566. * @hidden
  27567. */
  27568. private _resetCopy;
  27569. /**
  27570. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27571. * @param p the current index in the positions array to be updated
  27572. * @param ind the current index in the indices array
  27573. * @param shape a Vector3 array, the shape geometry
  27574. * @param positions the positions array to be updated
  27575. * @param meshInd the shape indices array
  27576. * @param indices the indices array to be updated
  27577. * @param meshUV the shape uv array
  27578. * @param uvs the uv array to be updated
  27579. * @param meshCol the shape color array
  27580. * @param colors the color array to be updated
  27581. * @param meshNor the shape normals array
  27582. * @param normals the normals array to be updated
  27583. * @param idx the particle index
  27584. * @param idxInShape the particle index in its shape
  27585. * @param options the addShape() method passed options
  27586. * @model the particle model
  27587. * @hidden
  27588. */
  27589. private _meshBuilder;
  27590. /**
  27591. * Returns a shape Vector3 array from positions float array
  27592. * @param positions float array
  27593. * @returns a vector3 array
  27594. * @hidden
  27595. */
  27596. private _posToShape;
  27597. /**
  27598. * Returns a shapeUV array from a float uvs (array deep copy)
  27599. * @param uvs as a float array
  27600. * @returns a shapeUV array
  27601. * @hidden
  27602. */
  27603. private _uvsToShapeUV;
  27604. /**
  27605. * Adds a new particle object in the particles array
  27606. * @param idx particle index in particles array
  27607. * @param id particle id
  27608. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27609. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27610. * @param model particle ModelShape object
  27611. * @param shapeId model shape identifier
  27612. * @param idxInShape index of the particle in the current model
  27613. * @param bInfo model bounding info object
  27614. * @param storage target storage array, if any
  27615. * @hidden
  27616. */
  27617. private _addParticle;
  27618. /**
  27619. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27620. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27621. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27622. * @param nb (positive integer) the number of particles to be created from this model
  27623. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27624. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27625. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27626. * @returns the number of shapes in the system
  27627. */
  27628. addShape(mesh: Mesh, nb: number, options?: {
  27629. positionFunction?: any;
  27630. vertexFunction?: any;
  27631. storage?: [];
  27632. }): number;
  27633. /**
  27634. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27635. * @hidden
  27636. */
  27637. private _rebuildParticle;
  27638. /**
  27639. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27640. * @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.
  27641. * @returns the SPS.
  27642. */
  27643. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27644. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27645. * Returns an array with the removed particles.
  27646. * 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.
  27647. * The SPS can't be empty so at least one particle needs to remain in place.
  27648. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27649. * @param start index of the first particle to remove
  27650. * @param end index of the last particle to remove (included)
  27651. * @returns an array populated with the removed particles
  27652. */
  27653. removeParticles(start: number, end: number): SolidParticle[];
  27654. /**
  27655. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27656. * @param solidParticleArray an array populated with Solid Particles objects
  27657. * @returns the SPS
  27658. */
  27659. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27660. /**
  27661. * Creates a new particle and modifies the SPS mesh geometry :
  27662. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27663. * - calls _addParticle() to populate the particle array
  27664. * factorized code from addShape() and insertParticlesFromArray()
  27665. * @param idx particle index in the particles array
  27666. * @param i particle index in its shape
  27667. * @param modelShape particle ModelShape object
  27668. * @param shape shape vertex array
  27669. * @param meshInd shape indices array
  27670. * @param meshUV shape uv array
  27671. * @param meshCol shape color array
  27672. * @param meshNor shape normals array
  27673. * @param bbInfo shape bounding info
  27674. * @param storage target particle storage
  27675. * @options addShape() passed options
  27676. * @hidden
  27677. */
  27678. private _insertNewParticle;
  27679. /**
  27680. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27681. * This method calls `updateParticle()` for each particle of the SPS.
  27682. * For an animated SPS, it is usually called within the render loop.
  27683. * 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.
  27684. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27685. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27686. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27687. * @returns the SPS.
  27688. */
  27689. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27690. /**
  27691. * Disposes the SPS.
  27692. */
  27693. dispose(): void;
  27694. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27695. * idx is the particle index in the SPS
  27696. * faceId is the picked face index counted within this particle.
  27697. * Returns null if the pickInfo can't identify a picked particle.
  27698. * @param pickingInfo (PickingInfo object)
  27699. * @returns {idx: number, faceId: number} or null
  27700. */
  27701. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27702. idx: number;
  27703. faceId: number;
  27704. }>;
  27705. /**
  27706. * Returns a SolidParticle object from its identifier : particle.id
  27707. * @param id (integer) the particle Id
  27708. * @returns the searched particle or null if not found in the SPS.
  27709. */
  27710. getParticleById(id: number): Nullable<SolidParticle>;
  27711. /**
  27712. * Returns a new array populated with the particles having the passed shapeId.
  27713. * @param shapeId (integer) the shape identifier
  27714. * @returns a new solid particle array
  27715. */
  27716. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27717. /**
  27718. * Populates the passed array "ref" with the particles having the passed shapeId.
  27719. * @param shapeId the shape identifier
  27720. * @returns the SPS
  27721. * @param ref
  27722. */
  27723. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27724. /**
  27725. * Computes the required SubMeshes according the materials assigned to the particles.
  27726. * @returns the solid particle system.
  27727. * Does nothing if called before the SPS mesh is built.
  27728. */
  27729. computeSubMeshes(): SolidParticleSystem;
  27730. /**
  27731. * Sorts the solid particles by material when MultiMaterial is enabled.
  27732. * Updates the indices32 array.
  27733. * Updates the indicesByMaterial array.
  27734. * Updates the mesh indices array.
  27735. * @returns the SPS
  27736. * @hidden
  27737. */
  27738. private _sortParticlesByMaterial;
  27739. /**
  27740. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27741. * @hidden
  27742. */
  27743. private _setMaterialIndexesById;
  27744. /**
  27745. * Returns an array with unique values of Materials from the passed array
  27746. * @param array the material array to be checked and filtered
  27747. * @hidden
  27748. */
  27749. private _filterUniqueMaterialId;
  27750. /**
  27751. * Sets a new Standard Material as _defaultMaterial if not already set.
  27752. * @hidden
  27753. */
  27754. private _setDefaultMaterial;
  27755. /**
  27756. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27757. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27758. * @returns the SPS.
  27759. */
  27760. refreshVisibleSize(): SolidParticleSystem;
  27761. /**
  27762. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27763. * @param size the size (float) of the visibility box
  27764. * note : this doesn't lock the SPS mesh bounding box.
  27765. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27766. */
  27767. setVisibilityBox(size: number): void;
  27768. /**
  27769. * Gets whether the SPS as always visible or not
  27770. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27771. */
  27772. get isAlwaysVisible(): boolean;
  27773. /**
  27774. * Sets the SPS as always visible or not
  27775. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27776. */
  27777. set isAlwaysVisible(val: boolean);
  27778. /**
  27779. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27780. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27781. */
  27782. set isVisibilityBoxLocked(val: boolean);
  27783. /**
  27784. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27785. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27786. */
  27787. get isVisibilityBoxLocked(): boolean;
  27788. /**
  27789. * Tells to `setParticles()` to compute the particle rotations or not.
  27790. * Default value : true. The SPS is faster when it's set to false.
  27791. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27792. */
  27793. set computeParticleRotation(val: boolean);
  27794. /**
  27795. * Tells to `setParticles()` to compute the particle colors or not.
  27796. * Default value : true. The SPS is faster when it's set to false.
  27797. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27798. */
  27799. set computeParticleColor(val: boolean);
  27800. set computeParticleTexture(val: boolean);
  27801. /**
  27802. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27803. * Default value : false. The SPS is faster when it's set to false.
  27804. * Note : the particle custom vertex positions aren't stored values.
  27805. */
  27806. set computeParticleVertex(val: boolean);
  27807. /**
  27808. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27809. */
  27810. set computeBoundingBox(val: boolean);
  27811. /**
  27812. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27813. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27814. * Default : `true`
  27815. */
  27816. set depthSortParticles(val: boolean);
  27817. /**
  27818. * Gets if `setParticles()` computes the particle rotations or not.
  27819. * Default value : true. The SPS is faster when it's set to false.
  27820. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27821. */
  27822. get computeParticleRotation(): boolean;
  27823. /**
  27824. * Gets if `setParticles()` computes the particle colors or not.
  27825. * Default value : true. The SPS is faster when it's set to false.
  27826. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27827. */
  27828. get computeParticleColor(): boolean;
  27829. /**
  27830. * Gets if `setParticles()` computes the particle textures or not.
  27831. * Default value : true. The SPS is faster when it's set to false.
  27832. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27833. */
  27834. get computeParticleTexture(): boolean;
  27835. /**
  27836. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27837. * Default value : false. The SPS is faster when it's set to false.
  27838. * Note : the particle custom vertex positions aren't stored values.
  27839. */
  27840. get computeParticleVertex(): boolean;
  27841. /**
  27842. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27843. */
  27844. get computeBoundingBox(): boolean;
  27845. /**
  27846. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27847. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27848. * Default : `true`
  27849. */
  27850. get depthSortParticles(): boolean;
  27851. /**
  27852. * Gets if the SPS is created as expandable at construction time.
  27853. * Default : `false`
  27854. */
  27855. get expandable(): boolean;
  27856. /**
  27857. * Gets if the SPS supports the Multi Materials
  27858. */
  27859. get multimaterialEnabled(): boolean;
  27860. /**
  27861. * Gets if the SPS uses the model materials for its own multimaterial.
  27862. */
  27863. get useModelMaterial(): boolean;
  27864. /**
  27865. * The SPS used material array.
  27866. */
  27867. get materials(): Material[];
  27868. /**
  27869. * Sets the SPS MultiMaterial from the passed materials.
  27870. * Note : the passed array is internally copied and not used then by reference.
  27871. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27872. */
  27873. setMultiMaterial(materials: Material[]): void;
  27874. /**
  27875. * The SPS computed multimaterial object
  27876. */
  27877. get multimaterial(): MultiMaterial;
  27878. set multimaterial(mm: MultiMaterial);
  27879. /**
  27880. * If the subMeshes must be updated on the next call to setParticles()
  27881. */
  27882. get autoUpdateSubMeshes(): boolean;
  27883. set autoUpdateSubMeshes(val: boolean);
  27884. /**
  27885. * This function does nothing. It may be overwritten to set all the particle first values.
  27886. * The SPS doesn't call this function, you may have to call it by your own.
  27887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27888. */
  27889. initParticles(): void;
  27890. /**
  27891. * This function does nothing. It may be overwritten to recycle a particle.
  27892. * The SPS doesn't call this function, you may have to call it by your own.
  27893. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27894. * @param particle The particle to recycle
  27895. * @returns the recycled particle
  27896. */
  27897. recycleParticle(particle: SolidParticle): SolidParticle;
  27898. /**
  27899. * Updates a particle : this function should be overwritten by the user.
  27900. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27901. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27902. * @example : just set a particle position or velocity and recycle conditions
  27903. * @param particle The particle to update
  27904. * @returns the updated particle
  27905. */
  27906. updateParticle(particle: SolidParticle): SolidParticle;
  27907. /**
  27908. * Updates a vertex of a particle : it can be overwritten by the user.
  27909. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27910. * @param particle the current particle
  27911. * @param vertex the current index of the current particle
  27912. * @param pt the index of the current vertex in the particle shape
  27913. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27914. * @example : just set a vertex particle position
  27915. * @returns the updated vertex
  27916. */
  27917. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27918. /**
  27919. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27920. * This does nothing and may be overwritten by the user.
  27921. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27922. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27923. * @param update the boolean update value actually passed to setParticles()
  27924. */
  27925. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27926. /**
  27927. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27928. * This will be passed three parameters.
  27929. * This does nothing and may be overwritten by the user.
  27930. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27931. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27932. * @param update the boolean update value actually passed to setParticles()
  27933. */
  27934. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27935. }
  27936. }
  27937. declare module BABYLON {
  27938. /**
  27939. * Represents one particle of a solid particle system.
  27940. */
  27941. export class SolidParticle {
  27942. /**
  27943. * particle global index
  27944. */
  27945. idx: number;
  27946. /**
  27947. * particle identifier
  27948. */
  27949. id: number;
  27950. /**
  27951. * The color of the particle
  27952. */
  27953. color: Nullable<Color4>;
  27954. /**
  27955. * The world space position of the particle.
  27956. */
  27957. position: Vector3;
  27958. /**
  27959. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27960. */
  27961. rotation: Vector3;
  27962. /**
  27963. * The world space rotation quaternion of the particle.
  27964. */
  27965. rotationQuaternion: Nullable<Quaternion>;
  27966. /**
  27967. * The scaling of the particle.
  27968. */
  27969. scaling: Vector3;
  27970. /**
  27971. * The uvs of the particle.
  27972. */
  27973. uvs: Vector4;
  27974. /**
  27975. * The current speed of the particle.
  27976. */
  27977. velocity: Vector3;
  27978. /**
  27979. * The pivot point in the particle local space.
  27980. */
  27981. pivot: Vector3;
  27982. /**
  27983. * Must the particle be translated from its pivot point in its local space ?
  27984. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27985. * Default : false
  27986. */
  27987. translateFromPivot: boolean;
  27988. /**
  27989. * Is the particle active or not ?
  27990. */
  27991. alive: boolean;
  27992. /**
  27993. * Is the particle visible or not ?
  27994. */
  27995. isVisible: boolean;
  27996. /**
  27997. * Index of this particle in the global "positions" array (Internal use)
  27998. * @hidden
  27999. */
  28000. _pos: number;
  28001. /**
  28002. * @hidden Index of this particle in the global "indices" array (Internal use)
  28003. */
  28004. _ind: number;
  28005. /**
  28006. * @hidden ModelShape of this particle (Internal use)
  28007. */
  28008. _model: ModelShape;
  28009. /**
  28010. * ModelShape id of this particle
  28011. */
  28012. shapeId: number;
  28013. /**
  28014. * Index of the particle in its shape id
  28015. */
  28016. idxInShape: number;
  28017. /**
  28018. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28019. */
  28020. _modelBoundingInfo: BoundingInfo;
  28021. /**
  28022. * @hidden Particle BoundingInfo object (Internal use)
  28023. */
  28024. _boundingInfo: BoundingInfo;
  28025. /**
  28026. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28027. */
  28028. _sps: SolidParticleSystem;
  28029. /**
  28030. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28031. */
  28032. _stillInvisible: boolean;
  28033. /**
  28034. * @hidden Last computed particle rotation matrix
  28035. */
  28036. _rotationMatrix: number[];
  28037. /**
  28038. * Parent particle Id, if any.
  28039. * Default null.
  28040. */
  28041. parentId: Nullable<number>;
  28042. /**
  28043. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28044. */
  28045. materialIndex: Nullable<number>;
  28046. /**
  28047. * Custom object or properties.
  28048. */
  28049. props: Nullable<any>;
  28050. /**
  28051. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28052. * The possible values are :
  28053. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28054. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28055. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28056. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28057. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28058. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28059. * */
  28060. cullingStrategy: number;
  28061. /**
  28062. * @hidden Internal global position in the SPS.
  28063. */
  28064. _globalPosition: Vector3;
  28065. /**
  28066. * Creates a Solid Particle object.
  28067. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28068. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28069. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28070. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28071. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28072. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28073. * @param shapeId (integer) is the model shape identifier in the SPS.
  28074. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28075. * @param sps defines the sps it is associated to
  28076. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28077. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28078. */
  28079. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28080. /**
  28081. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28082. * @param target the particle target
  28083. * @returns the current particle
  28084. */
  28085. copyToRef(target: SolidParticle): SolidParticle;
  28086. /**
  28087. * Legacy support, changed scale to scaling
  28088. */
  28089. get scale(): Vector3;
  28090. /**
  28091. * Legacy support, changed scale to scaling
  28092. */
  28093. set scale(scale: Vector3);
  28094. /**
  28095. * Legacy support, changed quaternion to rotationQuaternion
  28096. */
  28097. get quaternion(): Nullable<Quaternion>;
  28098. /**
  28099. * Legacy support, changed quaternion to rotationQuaternion
  28100. */
  28101. set quaternion(q: Nullable<Quaternion>);
  28102. /**
  28103. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28104. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28105. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28106. * @returns true if it intersects
  28107. */
  28108. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28109. /**
  28110. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28111. * A particle is in the frustum if its bounding box intersects the frustum
  28112. * @param frustumPlanes defines the frustum to test
  28113. * @returns true if the particle is in the frustum planes
  28114. */
  28115. isInFrustum(frustumPlanes: Plane[]): boolean;
  28116. /**
  28117. * get the rotation matrix of the particle
  28118. * @hidden
  28119. */
  28120. getRotationMatrix(m: Matrix): void;
  28121. }
  28122. /**
  28123. * Represents the shape of the model used by one particle of a solid particle system.
  28124. * SPS internal tool, don't use it manually.
  28125. */
  28126. export class ModelShape {
  28127. /**
  28128. * The shape id
  28129. * @hidden
  28130. */
  28131. shapeID: number;
  28132. /**
  28133. * flat array of model positions (internal use)
  28134. * @hidden
  28135. */
  28136. _shape: Vector3[];
  28137. /**
  28138. * flat array of model UVs (internal use)
  28139. * @hidden
  28140. */
  28141. _shapeUV: number[];
  28142. /**
  28143. * color array of the model
  28144. * @hidden
  28145. */
  28146. _shapeColors: number[];
  28147. /**
  28148. * indices array of the model
  28149. * @hidden
  28150. */
  28151. _indices: number[];
  28152. /**
  28153. * normals array of the model
  28154. * @hidden
  28155. */
  28156. _normals: number[];
  28157. /**
  28158. * length of the shape in the model indices array (internal use)
  28159. * @hidden
  28160. */
  28161. _indicesLength: number;
  28162. /**
  28163. * Custom position function (internal use)
  28164. * @hidden
  28165. */
  28166. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28167. /**
  28168. * Custom vertex function (internal use)
  28169. * @hidden
  28170. */
  28171. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28172. /**
  28173. * Model material (internal use)
  28174. * @hidden
  28175. */
  28176. _material: Nullable<Material>;
  28177. /**
  28178. * 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.
  28179. * SPS internal tool, don't use it manually.
  28180. * @hidden
  28181. */
  28182. 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>);
  28183. }
  28184. /**
  28185. * Represents a Depth Sorted Particle in the solid particle system.
  28186. * @hidden
  28187. */
  28188. export class DepthSortedParticle {
  28189. /**
  28190. * Particle index
  28191. */
  28192. idx: number;
  28193. /**
  28194. * Index of the particle in the "indices" array
  28195. */
  28196. ind: number;
  28197. /**
  28198. * Length of the particle shape in the "indices" array
  28199. */
  28200. indicesLength: number;
  28201. /**
  28202. * Squared distance from the particle to the camera
  28203. */
  28204. sqDistance: number;
  28205. /**
  28206. * Material index when used with MultiMaterials
  28207. */
  28208. materialIndex: number;
  28209. /**
  28210. * Creates a new sorted particle
  28211. * @param materialIndex
  28212. */
  28213. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28214. }
  28215. }
  28216. declare module BABYLON {
  28217. /**
  28218. * @hidden
  28219. */
  28220. export class _MeshCollisionData {
  28221. _checkCollisions: boolean;
  28222. _collisionMask: number;
  28223. _collisionGroup: number;
  28224. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28225. _collider: Nullable<Collider>;
  28226. _oldPositionForCollisions: Vector3;
  28227. _diffPositionForCollisions: Vector3;
  28228. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28229. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28230. }
  28231. }
  28232. declare module BABYLON {
  28233. /** @hidden */
  28234. class _FacetDataStorage {
  28235. facetPositions: Vector3[];
  28236. facetNormals: Vector3[];
  28237. facetPartitioning: number[][];
  28238. facetNb: number;
  28239. partitioningSubdivisions: number;
  28240. partitioningBBoxRatio: number;
  28241. facetDataEnabled: boolean;
  28242. facetParameters: any;
  28243. bbSize: Vector3;
  28244. subDiv: {
  28245. max: number;
  28246. X: number;
  28247. Y: number;
  28248. Z: number;
  28249. };
  28250. facetDepthSort: boolean;
  28251. facetDepthSortEnabled: boolean;
  28252. depthSortedIndices: IndicesArray;
  28253. depthSortedFacets: {
  28254. ind: number;
  28255. sqDistance: number;
  28256. }[];
  28257. facetDepthSortFunction: (f1: {
  28258. ind: number;
  28259. sqDistance: number;
  28260. }, f2: {
  28261. ind: number;
  28262. sqDistance: number;
  28263. }) => number;
  28264. facetDepthSortFrom: Vector3;
  28265. facetDepthSortOrigin: Vector3;
  28266. invertedMatrix: Matrix;
  28267. }
  28268. /**
  28269. * @hidden
  28270. **/
  28271. class _InternalAbstractMeshDataInfo {
  28272. _hasVertexAlpha: boolean;
  28273. _useVertexColors: boolean;
  28274. _numBoneInfluencers: number;
  28275. _applyFog: boolean;
  28276. _receiveShadows: boolean;
  28277. _facetData: _FacetDataStorage;
  28278. _visibility: number;
  28279. _skeleton: Nullable<Skeleton>;
  28280. _layerMask: number;
  28281. _computeBonesUsingShaders: boolean;
  28282. _isActive: boolean;
  28283. _onlyForInstances: boolean;
  28284. _isActiveIntermediate: boolean;
  28285. _onlyForInstancesIntermediate: boolean;
  28286. _actAsRegularMesh: boolean;
  28287. }
  28288. /**
  28289. * Class used to store all common mesh properties
  28290. */
  28291. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28292. /** No occlusion */
  28293. static OCCLUSION_TYPE_NONE: number;
  28294. /** Occlusion set to optimisitic */
  28295. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28296. /** Occlusion set to strict */
  28297. static OCCLUSION_TYPE_STRICT: number;
  28298. /** Use an accurante occlusion algorithm */
  28299. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28300. /** Use a conservative occlusion algorithm */
  28301. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28302. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28303. * Test order :
  28304. * Is the bounding sphere outside the frustum ?
  28305. * If not, are the bounding box vertices outside the frustum ?
  28306. * It not, then the cullable object is in the frustum.
  28307. */
  28308. static readonly CULLINGSTRATEGY_STANDARD: number;
  28309. /** Culling strategy : Bounding Sphere Only.
  28310. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28311. * It's also less accurate than the standard because some not visible objects can still be selected.
  28312. * Test : is the bounding sphere outside the frustum ?
  28313. * If not, then the cullable object is in the frustum.
  28314. */
  28315. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28316. /** Culling strategy : Optimistic Inclusion.
  28317. * This in an inclusion test first, then the standard exclusion test.
  28318. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28319. * 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.
  28320. * Anyway, it's as accurate as the standard strategy.
  28321. * Test :
  28322. * Is the cullable object bounding sphere center in the frustum ?
  28323. * If not, apply the default culling strategy.
  28324. */
  28325. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28326. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28327. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28328. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28329. * 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.
  28330. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28331. * Test :
  28332. * Is the cullable object bounding sphere center in the frustum ?
  28333. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28334. */
  28335. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28336. /**
  28337. * No billboard
  28338. */
  28339. static get BILLBOARDMODE_NONE(): number;
  28340. /** Billboard on X axis */
  28341. static get BILLBOARDMODE_X(): number;
  28342. /** Billboard on Y axis */
  28343. static get BILLBOARDMODE_Y(): number;
  28344. /** Billboard on Z axis */
  28345. static get BILLBOARDMODE_Z(): number;
  28346. /** Billboard on all axes */
  28347. static get BILLBOARDMODE_ALL(): number;
  28348. /** Billboard on using position instead of orientation */
  28349. static get BILLBOARDMODE_USE_POSITION(): number;
  28350. /** @hidden */
  28351. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28352. /**
  28353. * The culling strategy to use to check whether the mesh must be rendered or not.
  28354. * This value can be changed at any time and will be used on the next render mesh selection.
  28355. * The possible values are :
  28356. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28357. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28358. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28359. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28360. * Please read each static variable documentation to get details about the culling process.
  28361. * */
  28362. cullingStrategy: number;
  28363. /**
  28364. * Gets the number of facets in the mesh
  28365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28366. */
  28367. get facetNb(): number;
  28368. /**
  28369. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28371. */
  28372. get partitioningSubdivisions(): number;
  28373. set partitioningSubdivisions(nb: number);
  28374. /**
  28375. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28376. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28378. */
  28379. get partitioningBBoxRatio(): number;
  28380. set partitioningBBoxRatio(ratio: number);
  28381. /**
  28382. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28383. * Works only for updatable meshes.
  28384. * Doesn't work with multi-materials
  28385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28386. */
  28387. get mustDepthSortFacets(): boolean;
  28388. set mustDepthSortFacets(sort: boolean);
  28389. /**
  28390. * The location (Vector3) where the facet depth sort must be computed from.
  28391. * By default, the active camera position.
  28392. * Used only when facet depth sort is enabled
  28393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28394. */
  28395. get facetDepthSortFrom(): Vector3;
  28396. set facetDepthSortFrom(location: Vector3);
  28397. /**
  28398. * gets a boolean indicating if facetData is enabled
  28399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28400. */
  28401. get isFacetDataEnabled(): boolean;
  28402. /** @hidden */
  28403. _updateNonUniformScalingState(value: boolean): boolean;
  28404. /**
  28405. * An event triggered when this mesh collides with another one
  28406. */
  28407. onCollideObservable: Observable<AbstractMesh>;
  28408. /** Set a function to call when this mesh collides with another one */
  28409. set onCollide(callback: () => void);
  28410. /**
  28411. * An event triggered when the collision's position changes
  28412. */
  28413. onCollisionPositionChangeObservable: Observable<Vector3>;
  28414. /** Set a function to call when the collision's position changes */
  28415. set onCollisionPositionChange(callback: () => void);
  28416. /**
  28417. * An event triggered when material is changed
  28418. */
  28419. onMaterialChangedObservable: Observable<AbstractMesh>;
  28420. /**
  28421. * Gets or sets the orientation for POV movement & rotation
  28422. */
  28423. definedFacingForward: boolean;
  28424. /** @hidden */
  28425. _occlusionQuery: Nullable<WebGLQuery>;
  28426. /** @hidden */
  28427. _renderingGroup: Nullable<RenderingGroup>;
  28428. /**
  28429. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28430. */
  28431. get visibility(): number;
  28432. /**
  28433. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28434. */
  28435. set visibility(value: number);
  28436. /** Gets or sets the alpha index used to sort transparent meshes
  28437. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28438. */
  28439. alphaIndex: number;
  28440. /**
  28441. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28442. */
  28443. isVisible: boolean;
  28444. /**
  28445. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28446. */
  28447. isPickable: boolean;
  28448. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28449. showSubMeshesBoundingBox: boolean;
  28450. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28451. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28452. */
  28453. isBlocker: boolean;
  28454. /**
  28455. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28456. */
  28457. enablePointerMoveEvents: boolean;
  28458. /**
  28459. * Specifies the rendering group id for this mesh (0 by default)
  28460. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28461. */
  28462. renderingGroupId: number;
  28463. private _material;
  28464. /** Gets or sets current material */
  28465. get material(): Nullable<Material>;
  28466. set material(value: Nullable<Material>);
  28467. /**
  28468. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28469. * @see http://doc.babylonjs.com/babylon101/shadows
  28470. */
  28471. get receiveShadows(): boolean;
  28472. set receiveShadows(value: boolean);
  28473. /** Defines color to use when rendering outline */
  28474. outlineColor: Color3;
  28475. /** Define width to use when rendering outline */
  28476. outlineWidth: number;
  28477. /** Defines color to use when rendering overlay */
  28478. overlayColor: Color3;
  28479. /** Defines alpha to use when rendering overlay */
  28480. overlayAlpha: number;
  28481. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28482. get hasVertexAlpha(): boolean;
  28483. set hasVertexAlpha(value: boolean);
  28484. /** 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) */
  28485. get useVertexColors(): boolean;
  28486. set useVertexColors(value: boolean);
  28487. /**
  28488. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28489. */
  28490. get computeBonesUsingShaders(): boolean;
  28491. set computeBonesUsingShaders(value: boolean);
  28492. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28493. get numBoneInfluencers(): number;
  28494. set numBoneInfluencers(value: number);
  28495. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28496. get applyFog(): boolean;
  28497. set applyFog(value: boolean);
  28498. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28499. useOctreeForRenderingSelection: boolean;
  28500. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28501. useOctreeForPicking: boolean;
  28502. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28503. useOctreeForCollisions: boolean;
  28504. /**
  28505. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28506. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28507. */
  28508. get layerMask(): number;
  28509. set layerMask(value: number);
  28510. /**
  28511. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28512. */
  28513. alwaysSelectAsActiveMesh: boolean;
  28514. /**
  28515. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28516. */
  28517. doNotSyncBoundingInfo: boolean;
  28518. /**
  28519. * Gets or sets the current action manager
  28520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28521. */
  28522. actionManager: Nullable<AbstractActionManager>;
  28523. private _meshCollisionData;
  28524. /**
  28525. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28526. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28527. */
  28528. ellipsoid: Vector3;
  28529. /**
  28530. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28531. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28532. */
  28533. ellipsoidOffset: Vector3;
  28534. /**
  28535. * Gets or sets a collision mask used to mask collisions (default is -1).
  28536. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28537. */
  28538. get collisionMask(): number;
  28539. set collisionMask(mask: number);
  28540. /**
  28541. * Gets or sets the current collision group mask (-1 by default).
  28542. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28543. */
  28544. get collisionGroup(): number;
  28545. set collisionGroup(mask: number);
  28546. /**
  28547. * Gets or sets current surrounding meshes (null by default).
  28548. *
  28549. * By default collision detection is tested against every mesh in the scene.
  28550. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28551. * meshes will be tested for the collision.
  28552. *
  28553. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28554. */
  28555. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28556. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28557. /**
  28558. * Defines edge width used when edgesRenderer is enabled
  28559. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28560. */
  28561. edgesWidth: number;
  28562. /**
  28563. * Defines edge color used when edgesRenderer is enabled
  28564. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28565. */
  28566. edgesColor: Color4;
  28567. /** @hidden */
  28568. _edgesRenderer: Nullable<IEdgesRenderer>;
  28569. /** @hidden */
  28570. _masterMesh: Nullable<AbstractMesh>;
  28571. /** @hidden */
  28572. _boundingInfo: Nullable<BoundingInfo>;
  28573. /** @hidden */
  28574. _renderId: number;
  28575. /**
  28576. * Gets or sets the list of subMeshes
  28577. * @see http://doc.babylonjs.com/how_to/multi_materials
  28578. */
  28579. subMeshes: SubMesh[];
  28580. /** @hidden */
  28581. _intersectionsInProgress: AbstractMesh[];
  28582. /** @hidden */
  28583. _unIndexed: boolean;
  28584. /** @hidden */
  28585. _lightSources: Light[];
  28586. /** Gets the list of lights affecting that mesh */
  28587. get lightSources(): Light[];
  28588. /** @hidden */
  28589. get _positions(): Nullable<Vector3[]>;
  28590. /** @hidden */
  28591. _waitingData: {
  28592. lods: Nullable<any>;
  28593. actions: Nullable<any>;
  28594. freezeWorldMatrix: Nullable<boolean>;
  28595. };
  28596. /** @hidden */
  28597. _bonesTransformMatrices: Nullable<Float32Array>;
  28598. /** @hidden */
  28599. _transformMatrixTexture: Nullable<RawTexture>;
  28600. /**
  28601. * Gets or sets a skeleton to apply skining transformations
  28602. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28603. */
  28604. set skeleton(value: Nullable<Skeleton>);
  28605. get skeleton(): Nullable<Skeleton>;
  28606. /**
  28607. * An event triggered when the mesh is rebuilt.
  28608. */
  28609. onRebuildObservable: Observable<AbstractMesh>;
  28610. /**
  28611. * Creates a new AbstractMesh
  28612. * @param name defines the name of the mesh
  28613. * @param scene defines the hosting scene
  28614. */
  28615. constructor(name: string, scene?: Nullable<Scene>);
  28616. /**
  28617. * Returns the string "AbstractMesh"
  28618. * @returns "AbstractMesh"
  28619. */
  28620. getClassName(): string;
  28621. /**
  28622. * Gets a string representation of the current mesh
  28623. * @param fullDetails defines a boolean indicating if full details must be included
  28624. * @returns a string representation of the current mesh
  28625. */
  28626. toString(fullDetails?: boolean): string;
  28627. /**
  28628. * @hidden
  28629. */
  28630. protected _getEffectiveParent(): Nullable<Node>;
  28631. /** @hidden */
  28632. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28633. /** @hidden */
  28634. _rebuild(): void;
  28635. /** @hidden */
  28636. _resyncLightSources(): void;
  28637. /** @hidden */
  28638. _resyncLightSource(light: Light): void;
  28639. /** @hidden */
  28640. _unBindEffect(): void;
  28641. /** @hidden */
  28642. _removeLightSource(light: Light, dispose: boolean): void;
  28643. private _markSubMeshesAsDirty;
  28644. /** @hidden */
  28645. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28646. /** @hidden */
  28647. _markSubMeshesAsAttributesDirty(): void;
  28648. /** @hidden */
  28649. _markSubMeshesAsMiscDirty(): void;
  28650. /**
  28651. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28652. */
  28653. get scaling(): Vector3;
  28654. set scaling(newScaling: Vector3);
  28655. /**
  28656. * Returns true if the mesh is blocked. Implemented by child classes
  28657. */
  28658. get isBlocked(): boolean;
  28659. /**
  28660. * Returns the mesh itself by default. Implemented by child classes
  28661. * @param camera defines the camera to use to pick the right LOD level
  28662. * @returns the currentAbstractMesh
  28663. */
  28664. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28665. /**
  28666. * Returns 0 by default. Implemented by child classes
  28667. * @returns an integer
  28668. */
  28669. getTotalVertices(): number;
  28670. /**
  28671. * Returns a positive integer : the total number of indices in this mesh geometry.
  28672. * @returns the numner of indices or zero if the mesh has no geometry.
  28673. */
  28674. getTotalIndices(): number;
  28675. /**
  28676. * Returns null by default. Implemented by child classes
  28677. * @returns null
  28678. */
  28679. getIndices(): Nullable<IndicesArray>;
  28680. /**
  28681. * Returns the array of the requested vertex data kind. Implemented by child classes
  28682. * @param kind defines the vertex data kind to use
  28683. * @returns null
  28684. */
  28685. getVerticesData(kind: string): Nullable<FloatArray>;
  28686. /**
  28687. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28688. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28689. * Note that a new underlying VertexBuffer object is created each call.
  28690. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28691. * @param kind defines vertex data kind:
  28692. * * VertexBuffer.PositionKind
  28693. * * VertexBuffer.UVKind
  28694. * * VertexBuffer.UV2Kind
  28695. * * VertexBuffer.UV3Kind
  28696. * * VertexBuffer.UV4Kind
  28697. * * VertexBuffer.UV5Kind
  28698. * * VertexBuffer.UV6Kind
  28699. * * VertexBuffer.ColorKind
  28700. * * VertexBuffer.MatricesIndicesKind
  28701. * * VertexBuffer.MatricesIndicesExtraKind
  28702. * * VertexBuffer.MatricesWeightsKind
  28703. * * VertexBuffer.MatricesWeightsExtraKind
  28704. * @param data defines the data source
  28705. * @param updatable defines if the data must be flagged as updatable (or static)
  28706. * @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
  28707. * @returns the current mesh
  28708. */
  28709. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28710. /**
  28711. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28712. * If the mesh has no geometry, it is simply returned as it is.
  28713. * @param kind defines vertex data kind:
  28714. * * VertexBuffer.PositionKind
  28715. * * VertexBuffer.UVKind
  28716. * * VertexBuffer.UV2Kind
  28717. * * VertexBuffer.UV3Kind
  28718. * * VertexBuffer.UV4Kind
  28719. * * VertexBuffer.UV5Kind
  28720. * * VertexBuffer.UV6Kind
  28721. * * VertexBuffer.ColorKind
  28722. * * VertexBuffer.MatricesIndicesKind
  28723. * * VertexBuffer.MatricesIndicesExtraKind
  28724. * * VertexBuffer.MatricesWeightsKind
  28725. * * VertexBuffer.MatricesWeightsExtraKind
  28726. * @param data defines the data source
  28727. * @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
  28728. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28729. * @returns the current mesh
  28730. */
  28731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28732. /**
  28733. * Sets the mesh indices,
  28734. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28735. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28736. * @param totalVertices Defines the total number of vertices
  28737. * @returns the current mesh
  28738. */
  28739. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28740. /**
  28741. * Gets a boolean indicating if specific vertex data is present
  28742. * @param kind defines the vertex data kind to use
  28743. * @returns true is data kind is present
  28744. */
  28745. isVerticesDataPresent(kind: string): boolean;
  28746. /**
  28747. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28748. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28749. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28750. * @returns a BoundingInfo
  28751. */
  28752. getBoundingInfo(): BoundingInfo;
  28753. /**
  28754. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28755. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28756. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28757. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28758. * @returns the current mesh
  28759. */
  28760. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28761. /**
  28762. * Overwrite the current bounding info
  28763. * @param boundingInfo defines the new bounding info
  28764. * @returns the current mesh
  28765. */
  28766. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28767. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28768. get useBones(): boolean;
  28769. /** @hidden */
  28770. _preActivate(): void;
  28771. /** @hidden */
  28772. _preActivateForIntermediateRendering(renderId: number): void;
  28773. /** @hidden */
  28774. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28775. /** @hidden */
  28776. _postActivate(): void;
  28777. /** @hidden */
  28778. _freeze(): void;
  28779. /** @hidden */
  28780. _unFreeze(): void;
  28781. /**
  28782. * Gets the current world matrix
  28783. * @returns a Matrix
  28784. */
  28785. getWorldMatrix(): Matrix;
  28786. /** @hidden */
  28787. _getWorldMatrixDeterminant(): number;
  28788. /**
  28789. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28790. */
  28791. get isAnInstance(): boolean;
  28792. /**
  28793. * Gets a boolean indicating if this mesh has instances
  28794. */
  28795. get hasInstances(): boolean;
  28796. /**
  28797. * Perform relative position change from the point of view of behind the front of the mesh.
  28798. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28799. * Supports definition of mesh facing forward or backward
  28800. * @param amountRight defines the distance on the right axis
  28801. * @param amountUp defines the distance on the up axis
  28802. * @param amountForward defines the distance on the forward axis
  28803. * @returns the current mesh
  28804. */
  28805. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28806. /**
  28807. * Calculate relative position change from the point of view of behind the front of the mesh.
  28808. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28809. * Supports definition of mesh facing forward or backward
  28810. * @param amountRight defines the distance on the right axis
  28811. * @param amountUp defines the distance on the up axis
  28812. * @param amountForward defines the distance on the forward axis
  28813. * @returns the new displacement vector
  28814. */
  28815. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28816. /**
  28817. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28818. * Supports definition of mesh facing forward or backward
  28819. * @param flipBack defines the flip
  28820. * @param twirlClockwise defines the twirl
  28821. * @param tiltRight defines the tilt
  28822. * @returns the current mesh
  28823. */
  28824. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28825. /**
  28826. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28827. * Supports definition of mesh facing forward or backward.
  28828. * @param flipBack defines the flip
  28829. * @param twirlClockwise defines the twirl
  28830. * @param tiltRight defines the tilt
  28831. * @returns the new rotation vector
  28832. */
  28833. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28834. /**
  28835. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28836. * This means the mesh underlying bounding box and sphere are recomputed.
  28837. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28838. * @returns the current mesh
  28839. */
  28840. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28841. /** @hidden */
  28842. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28843. /** @hidden */
  28844. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28845. /** @hidden */
  28846. _updateBoundingInfo(): AbstractMesh;
  28847. /** @hidden */
  28848. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28849. /** @hidden */
  28850. protected _afterComputeWorldMatrix(): void;
  28851. /** @hidden */
  28852. get _effectiveMesh(): AbstractMesh;
  28853. /**
  28854. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28855. * A mesh is in the frustum if its bounding box intersects the frustum
  28856. * @param frustumPlanes defines the frustum to test
  28857. * @returns true if the mesh is in the frustum planes
  28858. */
  28859. isInFrustum(frustumPlanes: Plane[]): boolean;
  28860. /**
  28861. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28862. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28863. * @param frustumPlanes defines the frustum to test
  28864. * @returns true if the mesh is completely in the frustum planes
  28865. */
  28866. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28867. /**
  28868. * True if the mesh intersects another mesh or a SolidParticle object
  28869. * @param mesh defines a target mesh or SolidParticle to test
  28870. * @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)
  28871. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28872. * @returns true if there is an intersection
  28873. */
  28874. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28875. /**
  28876. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28877. * @param point defines the point to test
  28878. * @returns true if there is an intersection
  28879. */
  28880. intersectsPoint(point: Vector3): boolean;
  28881. /**
  28882. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28884. */
  28885. get checkCollisions(): boolean;
  28886. set checkCollisions(collisionEnabled: boolean);
  28887. /**
  28888. * Gets Collider object used to compute collisions (not physics)
  28889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28890. */
  28891. get collider(): Nullable<Collider>;
  28892. /**
  28893. * Move the mesh using collision engine
  28894. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28895. * @param displacement defines the requested displacement vector
  28896. * @returns the current mesh
  28897. */
  28898. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28899. private _onCollisionPositionChange;
  28900. /** @hidden */
  28901. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28902. /** @hidden */
  28903. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28904. /** @hidden */
  28905. _checkCollision(collider: Collider): AbstractMesh;
  28906. /** @hidden */
  28907. _generatePointsArray(): boolean;
  28908. /**
  28909. * Checks if the passed Ray intersects with the mesh
  28910. * @param ray defines the ray to use
  28911. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28912. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28913. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  28914. * @returns the picking info
  28915. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28916. */
  28917. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  28918. /**
  28919. * Clones the current mesh
  28920. * @param name defines the mesh name
  28921. * @param newParent defines the new mesh parent
  28922. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28923. * @returns the new mesh
  28924. */
  28925. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28926. /**
  28927. * Disposes all the submeshes of the current meshnp
  28928. * @returns the current mesh
  28929. */
  28930. releaseSubMeshes(): AbstractMesh;
  28931. /**
  28932. * Releases resources associated with this abstract mesh.
  28933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28935. */
  28936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28937. /**
  28938. * Adds the passed mesh as a child to the current mesh
  28939. * @param mesh defines the child mesh
  28940. * @returns the current mesh
  28941. */
  28942. addChild(mesh: AbstractMesh): AbstractMesh;
  28943. /**
  28944. * Removes the passed mesh from the current mesh children list
  28945. * @param mesh defines the child mesh
  28946. * @returns the current mesh
  28947. */
  28948. removeChild(mesh: AbstractMesh): AbstractMesh;
  28949. /** @hidden */
  28950. private _initFacetData;
  28951. /**
  28952. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28953. * This method can be called within the render loop.
  28954. * 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
  28955. * @returns the current mesh
  28956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28957. */
  28958. updateFacetData(): AbstractMesh;
  28959. /**
  28960. * Returns the facetLocalNormals array.
  28961. * The normals are expressed in the mesh local spac
  28962. * @returns an array of Vector3
  28963. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28964. */
  28965. getFacetLocalNormals(): Vector3[];
  28966. /**
  28967. * Returns the facetLocalPositions array.
  28968. * The facet positions are expressed in the mesh local space
  28969. * @returns an array of Vector3
  28970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28971. */
  28972. getFacetLocalPositions(): Vector3[];
  28973. /**
  28974. * Returns the facetLocalPartioning array
  28975. * @returns an array of array of numbers
  28976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28977. */
  28978. getFacetLocalPartitioning(): number[][];
  28979. /**
  28980. * Returns the i-th facet position in the world system.
  28981. * This method allocates a new Vector3 per call
  28982. * @param i defines the facet index
  28983. * @returns a new Vector3
  28984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28985. */
  28986. getFacetPosition(i: number): Vector3;
  28987. /**
  28988. * Sets the reference Vector3 with the i-th facet position in the world system
  28989. * @param i defines the facet index
  28990. * @param ref defines the target vector
  28991. * @returns the current mesh
  28992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28993. */
  28994. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28995. /**
  28996. * Returns the i-th facet normal in the world system.
  28997. * This method allocates a new Vector3 per call
  28998. * @param i defines the facet index
  28999. * @returns a new Vector3
  29000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29001. */
  29002. getFacetNormal(i: number): Vector3;
  29003. /**
  29004. * Sets the reference Vector3 with the i-th facet normal in the world system
  29005. * @param i defines the facet index
  29006. * @param ref defines the target vector
  29007. * @returns the current mesh
  29008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29009. */
  29010. getFacetNormalToRef(i: number, ref: Vector3): this;
  29011. /**
  29012. * 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)
  29013. * @param x defines x coordinate
  29014. * @param y defines y coordinate
  29015. * @param z defines z coordinate
  29016. * @returns the array of facet indexes
  29017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29018. */
  29019. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29020. /**
  29021. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29022. * @param projected sets as the (x,y,z) world projection on the facet
  29023. * @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
  29024. * @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
  29025. * @param x defines x coordinate
  29026. * @param y defines y coordinate
  29027. * @param z defines z coordinate
  29028. * @returns the face index if found (or null instead)
  29029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29030. */
  29031. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29032. /**
  29033. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29034. * @param projected sets as the (x,y,z) local projection on the facet
  29035. * @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
  29036. * @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
  29037. * @param x defines x coordinate
  29038. * @param y defines y coordinate
  29039. * @param z defines z coordinate
  29040. * @returns the face index if found (or null instead)
  29041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29042. */
  29043. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29044. /**
  29045. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29046. * @returns the parameters
  29047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29048. */
  29049. getFacetDataParameters(): any;
  29050. /**
  29051. * Disables the feature FacetData and frees the related memory
  29052. * @returns the current mesh
  29053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29054. */
  29055. disableFacetData(): AbstractMesh;
  29056. /**
  29057. * Updates the AbstractMesh indices array
  29058. * @param indices defines the data source
  29059. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29060. * @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)
  29061. * @returns the current mesh
  29062. */
  29063. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29064. /**
  29065. * Creates new normals data for the mesh
  29066. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29067. * @returns the current mesh
  29068. */
  29069. createNormals(updatable: boolean): AbstractMesh;
  29070. /**
  29071. * Align the mesh with a normal
  29072. * @param normal defines the normal to use
  29073. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29074. * @returns the current mesh
  29075. */
  29076. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29077. /** @hidden */
  29078. _checkOcclusionQuery(): boolean;
  29079. /**
  29080. * Disables the mesh edge rendering mode
  29081. * @returns the currentAbstractMesh
  29082. */
  29083. disableEdgesRendering(): AbstractMesh;
  29084. /**
  29085. * Enables the edge rendering mode on the mesh.
  29086. * This mode makes the mesh edges visible
  29087. * @param epsilon defines the maximal distance between two angles to detect a face
  29088. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29089. * @returns the currentAbstractMesh
  29090. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29091. */
  29092. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29093. }
  29094. }
  29095. declare module BABYLON {
  29096. /**
  29097. * Interface used to define ActionEvent
  29098. */
  29099. export interface IActionEvent {
  29100. /** The mesh or sprite that triggered the action */
  29101. source: any;
  29102. /** The X mouse cursor position at the time of the event */
  29103. pointerX: number;
  29104. /** The Y mouse cursor position at the time of the event */
  29105. pointerY: number;
  29106. /** The mesh that is currently pointed at (can be null) */
  29107. meshUnderPointer: Nullable<AbstractMesh>;
  29108. /** the original (browser) event that triggered the ActionEvent */
  29109. sourceEvent?: any;
  29110. /** additional data for the event */
  29111. additionalData?: any;
  29112. }
  29113. /**
  29114. * ActionEvent is the event being sent when an action is triggered.
  29115. */
  29116. export class ActionEvent implements IActionEvent {
  29117. /** The mesh or sprite that triggered the action */
  29118. source: any;
  29119. /** The X mouse cursor position at the time of the event */
  29120. pointerX: number;
  29121. /** The Y mouse cursor position at the time of the event */
  29122. pointerY: number;
  29123. /** The mesh that is currently pointed at (can be null) */
  29124. meshUnderPointer: Nullable<AbstractMesh>;
  29125. /** the original (browser) event that triggered the ActionEvent */
  29126. sourceEvent?: any;
  29127. /** additional data for the event */
  29128. additionalData?: any;
  29129. /**
  29130. * Creates a new ActionEvent
  29131. * @param source The mesh or sprite that triggered the action
  29132. * @param pointerX The X mouse cursor position at the time of the event
  29133. * @param pointerY The Y mouse cursor position at the time of the event
  29134. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29135. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29136. * @param additionalData additional data for the event
  29137. */
  29138. constructor(
  29139. /** The mesh or sprite that triggered the action */
  29140. source: any,
  29141. /** The X mouse cursor position at the time of the event */
  29142. pointerX: number,
  29143. /** The Y mouse cursor position at the time of the event */
  29144. pointerY: number,
  29145. /** The mesh that is currently pointed at (can be null) */
  29146. meshUnderPointer: Nullable<AbstractMesh>,
  29147. /** the original (browser) event that triggered the ActionEvent */
  29148. sourceEvent?: any,
  29149. /** additional data for the event */
  29150. additionalData?: any);
  29151. /**
  29152. * Helper function to auto-create an ActionEvent from a source mesh.
  29153. * @param source The source mesh that triggered the event
  29154. * @param evt The original (browser) event
  29155. * @param additionalData additional data for the event
  29156. * @returns the new ActionEvent
  29157. */
  29158. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29159. /**
  29160. * Helper function to auto-create an ActionEvent from a source sprite
  29161. * @param source The source sprite that triggered the event
  29162. * @param scene Scene associated with the sprite
  29163. * @param evt The original (browser) event
  29164. * @param additionalData additional data for the event
  29165. * @returns the new ActionEvent
  29166. */
  29167. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29168. /**
  29169. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29170. * @param scene the scene where the event occurred
  29171. * @param evt The original (browser) event
  29172. * @returns the new ActionEvent
  29173. */
  29174. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29175. /**
  29176. * Helper function to auto-create an ActionEvent from a primitive
  29177. * @param prim defines the target primitive
  29178. * @param pointerPos defines the pointer position
  29179. * @param evt The original (browser) event
  29180. * @param additionalData additional data for the event
  29181. * @returns the new ActionEvent
  29182. */
  29183. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29184. }
  29185. }
  29186. declare module BABYLON {
  29187. /**
  29188. * Abstract class used to decouple action Manager from scene and meshes.
  29189. * Do not instantiate.
  29190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29191. */
  29192. export abstract class AbstractActionManager implements IDisposable {
  29193. /** Gets the list of active triggers */
  29194. static Triggers: {
  29195. [key: string]: number;
  29196. };
  29197. /** Gets the cursor to use when hovering items */
  29198. hoverCursor: string;
  29199. /** Gets the list of actions */
  29200. actions: IAction[];
  29201. /**
  29202. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29203. */
  29204. isRecursive: boolean;
  29205. /**
  29206. * Releases all associated resources
  29207. */
  29208. abstract dispose(): void;
  29209. /**
  29210. * Does this action manager has pointer triggers
  29211. */
  29212. abstract get hasPointerTriggers(): boolean;
  29213. /**
  29214. * Does this action manager has pick triggers
  29215. */
  29216. abstract get hasPickTriggers(): boolean;
  29217. /**
  29218. * Process a specific trigger
  29219. * @param trigger defines the trigger to process
  29220. * @param evt defines the event details to be processed
  29221. */
  29222. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29223. /**
  29224. * Does this action manager handles actions of any of the given triggers
  29225. * @param triggers defines the triggers to be tested
  29226. * @return a boolean indicating whether one (or more) of the triggers is handled
  29227. */
  29228. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29229. /**
  29230. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29231. * speed.
  29232. * @param triggerA defines the trigger to be tested
  29233. * @param triggerB defines the trigger to be tested
  29234. * @return a boolean indicating whether one (or more) of the triggers is handled
  29235. */
  29236. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29237. /**
  29238. * Does this action manager handles actions of a given trigger
  29239. * @param trigger defines the trigger to be tested
  29240. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29241. * @return whether the trigger is handled
  29242. */
  29243. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29244. /**
  29245. * Serialize this manager to a JSON object
  29246. * @param name defines the property name to store this manager
  29247. * @returns a JSON representation of this manager
  29248. */
  29249. abstract serialize(name: string): any;
  29250. /**
  29251. * Registers an action to this action manager
  29252. * @param action defines the action to be registered
  29253. * @return the action amended (prepared) after registration
  29254. */
  29255. abstract registerAction(action: IAction): Nullable<IAction>;
  29256. /**
  29257. * Unregisters an action to this action manager
  29258. * @param action defines the action to be unregistered
  29259. * @return a boolean indicating whether the action has been unregistered
  29260. */
  29261. abstract unregisterAction(action: IAction): Boolean;
  29262. /**
  29263. * Does exist one action manager with at least one trigger
  29264. **/
  29265. static get HasTriggers(): boolean;
  29266. /**
  29267. * Does exist one action manager with at least one pick trigger
  29268. **/
  29269. static get HasPickTriggers(): boolean;
  29270. /**
  29271. * Does exist one action manager that handles actions of a given trigger
  29272. * @param trigger defines the trigger to be tested
  29273. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29274. **/
  29275. static HasSpecificTrigger(trigger: number): boolean;
  29276. }
  29277. }
  29278. declare module BABYLON {
  29279. /**
  29280. * Defines how a node can be built from a string name.
  29281. */
  29282. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29283. /**
  29284. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29285. */
  29286. export class Node implements IBehaviorAware<Node> {
  29287. /** @hidden */
  29288. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29289. private static _NodeConstructors;
  29290. /**
  29291. * Add a new node constructor
  29292. * @param type defines the type name of the node to construct
  29293. * @param constructorFunc defines the constructor function
  29294. */
  29295. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29296. /**
  29297. * Returns a node constructor based on type name
  29298. * @param type defines the type name
  29299. * @param name defines the new node name
  29300. * @param scene defines the hosting scene
  29301. * @param options defines optional options to transmit to constructors
  29302. * @returns the new constructor or null
  29303. */
  29304. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29305. /**
  29306. * Gets or sets the name of the node
  29307. */
  29308. name: string;
  29309. /**
  29310. * Gets or sets the id of the node
  29311. */
  29312. id: string;
  29313. /**
  29314. * Gets or sets the unique id of the node
  29315. */
  29316. uniqueId: number;
  29317. /**
  29318. * Gets or sets a string used to store user defined state for the node
  29319. */
  29320. state: string;
  29321. /**
  29322. * Gets or sets an object used to store user defined information for the node
  29323. */
  29324. metadata: any;
  29325. /**
  29326. * For internal use only. Please do not use.
  29327. */
  29328. reservedDataStore: any;
  29329. /**
  29330. * List of inspectable custom properties (used by the Inspector)
  29331. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29332. */
  29333. inspectableCustomProperties: IInspectable[];
  29334. private _doNotSerialize;
  29335. /**
  29336. * Gets or sets a boolean used to define if the node must be serialized
  29337. */
  29338. get doNotSerialize(): boolean;
  29339. set doNotSerialize(value: boolean);
  29340. /** @hidden */
  29341. _isDisposed: boolean;
  29342. /**
  29343. * Gets a list of Animations associated with the node
  29344. */
  29345. animations: Animation[];
  29346. protected _ranges: {
  29347. [name: string]: Nullable<AnimationRange>;
  29348. };
  29349. /**
  29350. * Callback raised when the node is ready to be used
  29351. */
  29352. onReady: Nullable<(node: Node) => void>;
  29353. private _isEnabled;
  29354. private _isParentEnabled;
  29355. private _isReady;
  29356. /** @hidden */
  29357. _currentRenderId: number;
  29358. private _parentUpdateId;
  29359. /** @hidden */
  29360. _childUpdateId: number;
  29361. /** @hidden */
  29362. _waitingParentId: Nullable<string>;
  29363. /** @hidden */
  29364. _scene: Scene;
  29365. /** @hidden */
  29366. _cache: any;
  29367. private _parentNode;
  29368. private _children;
  29369. /** @hidden */
  29370. _worldMatrix: Matrix;
  29371. /** @hidden */
  29372. _worldMatrixDeterminant: number;
  29373. /** @hidden */
  29374. _worldMatrixDeterminantIsDirty: boolean;
  29375. /** @hidden */
  29376. private _sceneRootNodesIndex;
  29377. /**
  29378. * Gets a boolean indicating if the node has been disposed
  29379. * @returns true if the node was disposed
  29380. */
  29381. isDisposed(): boolean;
  29382. /**
  29383. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29384. * @see https://doc.babylonjs.com/how_to/parenting
  29385. */
  29386. set parent(parent: Nullable<Node>);
  29387. get parent(): Nullable<Node>;
  29388. /** @hidden */
  29389. _addToSceneRootNodes(): void;
  29390. /** @hidden */
  29391. _removeFromSceneRootNodes(): void;
  29392. private _animationPropertiesOverride;
  29393. /**
  29394. * Gets or sets the animation properties override
  29395. */
  29396. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29397. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29398. /**
  29399. * Gets a string idenfifying the name of the class
  29400. * @returns "Node" string
  29401. */
  29402. getClassName(): string;
  29403. /** @hidden */
  29404. readonly _isNode: boolean;
  29405. /**
  29406. * An event triggered when the mesh is disposed
  29407. */
  29408. onDisposeObservable: Observable<Node>;
  29409. private _onDisposeObserver;
  29410. /**
  29411. * Sets a callback that will be raised when the node will be disposed
  29412. */
  29413. set onDispose(callback: () => void);
  29414. /**
  29415. * Creates a new Node
  29416. * @param name the name and id to be given to this node
  29417. * @param scene the scene this node will be added to
  29418. */
  29419. constructor(name: string, scene?: Nullable<Scene>);
  29420. /**
  29421. * Gets the scene of the node
  29422. * @returns a scene
  29423. */
  29424. getScene(): Scene;
  29425. /**
  29426. * Gets the engine of the node
  29427. * @returns a Engine
  29428. */
  29429. getEngine(): Engine;
  29430. private _behaviors;
  29431. /**
  29432. * Attach a behavior to the node
  29433. * @see http://doc.babylonjs.com/features/behaviour
  29434. * @param behavior defines the behavior to attach
  29435. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29436. * @returns the current Node
  29437. */
  29438. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29439. /**
  29440. * Remove an attached behavior
  29441. * @see http://doc.babylonjs.com/features/behaviour
  29442. * @param behavior defines the behavior to attach
  29443. * @returns the current Node
  29444. */
  29445. removeBehavior(behavior: Behavior<Node>): Node;
  29446. /**
  29447. * Gets the list of attached behaviors
  29448. * @see http://doc.babylonjs.com/features/behaviour
  29449. */
  29450. get behaviors(): Behavior<Node>[];
  29451. /**
  29452. * Gets an attached behavior by name
  29453. * @param name defines the name of the behavior to look for
  29454. * @see http://doc.babylonjs.com/features/behaviour
  29455. * @returns null if behavior was not found else the requested behavior
  29456. */
  29457. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29458. /**
  29459. * Returns the latest update of the World matrix
  29460. * @returns a Matrix
  29461. */
  29462. getWorldMatrix(): Matrix;
  29463. /** @hidden */
  29464. _getWorldMatrixDeterminant(): number;
  29465. /**
  29466. * Returns directly the latest state of the mesh World matrix.
  29467. * A Matrix is returned.
  29468. */
  29469. get worldMatrixFromCache(): Matrix;
  29470. /** @hidden */
  29471. _initCache(): void;
  29472. /** @hidden */
  29473. updateCache(force?: boolean): void;
  29474. /** @hidden */
  29475. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29476. /** @hidden */
  29477. _updateCache(ignoreParentClass?: boolean): void;
  29478. /** @hidden */
  29479. _isSynchronized(): boolean;
  29480. /** @hidden */
  29481. _markSyncedWithParent(): void;
  29482. /** @hidden */
  29483. isSynchronizedWithParent(): boolean;
  29484. /** @hidden */
  29485. isSynchronized(): boolean;
  29486. /**
  29487. * Is this node ready to be used/rendered
  29488. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29489. * @return true if the node is ready
  29490. */
  29491. isReady(completeCheck?: boolean): boolean;
  29492. /**
  29493. * Is this node enabled?
  29494. * 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
  29495. * @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
  29496. * @return whether this node (and its parent) is enabled
  29497. */
  29498. isEnabled(checkAncestors?: boolean): boolean;
  29499. /** @hidden */
  29500. protected _syncParentEnabledState(): void;
  29501. /**
  29502. * Set the enabled state of this node
  29503. * @param value defines the new enabled state
  29504. */
  29505. setEnabled(value: boolean): void;
  29506. /**
  29507. * Is this node a descendant of the given node?
  29508. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29509. * @param ancestor defines the parent node to inspect
  29510. * @returns a boolean indicating if this node is a descendant of the given node
  29511. */
  29512. isDescendantOf(ancestor: Node): boolean;
  29513. /** @hidden */
  29514. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29515. /**
  29516. * Will return all nodes that have this node as ascendant
  29517. * @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
  29518. * @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
  29519. * @return all children nodes of all types
  29520. */
  29521. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29522. /**
  29523. * Get all child-meshes of this node
  29524. * @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)
  29525. * @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
  29526. * @returns an array of AbstractMesh
  29527. */
  29528. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29529. /**
  29530. * Get all direct children of this node
  29531. * @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
  29532. * @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)
  29533. * @returns an array of Node
  29534. */
  29535. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29536. /** @hidden */
  29537. _setReady(state: boolean): void;
  29538. /**
  29539. * Get an animation by name
  29540. * @param name defines the name of the animation to look for
  29541. * @returns null if not found else the requested animation
  29542. */
  29543. getAnimationByName(name: string): Nullable<Animation>;
  29544. /**
  29545. * Creates an animation range for this node
  29546. * @param name defines the name of the range
  29547. * @param from defines the starting key
  29548. * @param to defines the end key
  29549. */
  29550. createAnimationRange(name: string, from: number, to: number): void;
  29551. /**
  29552. * Delete a specific animation range
  29553. * @param name defines the name of the range to delete
  29554. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29555. */
  29556. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29557. /**
  29558. * Get an animation range by name
  29559. * @param name defines the name of the animation range to look for
  29560. * @returns null if not found else the requested animation range
  29561. */
  29562. getAnimationRange(name: string): Nullable<AnimationRange>;
  29563. /**
  29564. * Gets the list of all animation ranges defined on this node
  29565. * @returns an array
  29566. */
  29567. getAnimationRanges(): Nullable<AnimationRange>[];
  29568. /**
  29569. * Will start the animation sequence
  29570. * @param name defines the range frames for animation sequence
  29571. * @param loop defines if the animation should loop (false by default)
  29572. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29573. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29574. * @returns the object created for this animation. If range does not exist, it will return null
  29575. */
  29576. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29577. /**
  29578. * Serialize animation ranges into a JSON compatible object
  29579. * @returns serialization object
  29580. */
  29581. serializeAnimationRanges(): any;
  29582. /**
  29583. * Computes the world matrix of the node
  29584. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29585. * @returns the world matrix
  29586. */
  29587. computeWorldMatrix(force?: boolean): Matrix;
  29588. /**
  29589. * Releases resources associated with this node.
  29590. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29591. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29592. */
  29593. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29594. /**
  29595. * Parse animation range data from a serialization object and store them into a given node
  29596. * @param node defines where to store the animation ranges
  29597. * @param parsedNode defines the serialization object to read data from
  29598. * @param scene defines the hosting scene
  29599. */
  29600. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29601. /**
  29602. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29603. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29604. * @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
  29605. * @returns the new bounding vectors
  29606. */
  29607. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29608. min: Vector3;
  29609. max: Vector3;
  29610. };
  29611. }
  29612. }
  29613. declare module BABYLON {
  29614. /**
  29615. * @hidden
  29616. */
  29617. export class _IAnimationState {
  29618. key: number;
  29619. repeatCount: number;
  29620. workValue?: any;
  29621. loopMode?: number;
  29622. offsetValue?: any;
  29623. highLimitValue?: any;
  29624. }
  29625. /**
  29626. * Class used to store any kind of animation
  29627. */
  29628. export class Animation {
  29629. /**Name of the animation */
  29630. name: string;
  29631. /**Property to animate */
  29632. targetProperty: string;
  29633. /**The frames per second of the animation */
  29634. framePerSecond: number;
  29635. /**The data type of the animation */
  29636. dataType: number;
  29637. /**The loop mode of the animation */
  29638. loopMode?: number | undefined;
  29639. /**Specifies if blending should be enabled */
  29640. enableBlending?: boolean | undefined;
  29641. /**
  29642. * Use matrix interpolation instead of using direct key value when animating matrices
  29643. */
  29644. static AllowMatricesInterpolation: boolean;
  29645. /**
  29646. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29647. */
  29648. static AllowMatrixDecomposeForInterpolation: boolean;
  29649. /**
  29650. * Stores the key frames of the animation
  29651. */
  29652. private _keys;
  29653. /**
  29654. * Stores the easing function of the animation
  29655. */
  29656. private _easingFunction;
  29657. /**
  29658. * @hidden Internal use only
  29659. */
  29660. _runtimeAnimations: RuntimeAnimation[];
  29661. /**
  29662. * The set of event that will be linked to this animation
  29663. */
  29664. private _events;
  29665. /**
  29666. * Stores an array of target property paths
  29667. */
  29668. targetPropertyPath: string[];
  29669. /**
  29670. * Stores the blending speed of the animation
  29671. */
  29672. blendingSpeed: number;
  29673. /**
  29674. * Stores the animation ranges for the animation
  29675. */
  29676. private _ranges;
  29677. /**
  29678. * @hidden Internal use
  29679. */
  29680. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29681. /**
  29682. * Sets up an animation
  29683. * @param property The property to animate
  29684. * @param animationType The animation type to apply
  29685. * @param framePerSecond The frames per second of the animation
  29686. * @param easingFunction The easing function used in the animation
  29687. * @returns The created animation
  29688. */
  29689. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29690. /**
  29691. * Create and start an animation on a node
  29692. * @param name defines the name of the global animation that will be run on all nodes
  29693. * @param node defines the root node where the animation will take place
  29694. * @param targetProperty defines property to animate
  29695. * @param framePerSecond defines the number of frame per second yo use
  29696. * @param totalFrame defines the number of frames in total
  29697. * @param from defines the initial value
  29698. * @param to defines the final value
  29699. * @param loopMode defines which loop mode you want to use (off by default)
  29700. * @param easingFunction defines the easing function to use (linear by default)
  29701. * @param onAnimationEnd defines the callback to call when animation end
  29702. * @returns the animatable created for this animation
  29703. */
  29704. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29705. /**
  29706. * Create and start an animation on a node and its descendants
  29707. * @param name defines the name of the global animation that will be run on all nodes
  29708. * @param node defines the root node where the animation will take place
  29709. * @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
  29710. * @param targetProperty defines property to animate
  29711. * @param framePerSecond defines the number of frame per second to use
  29712. * @param totalFrame defines the number of frames in total
  29713. * @param from defines the initial value
  29714. * @param to defines the final value
  29715. * @param loopMode defines which loop mode you want to use (off by default)
  29716. * @param easingFunction defines the easing function to use (linear by default)
  29717. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29718. * @returns the list of animatables created for all nodes
  29719. * @example https://www.babylonjs-playground.com/#MH0VLI
  29720. */
  29721. 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[]>;
  29722. /**
  29723. * Creates a new animation, merges it with the existing animations and starts it
  29724. * @param name Name of the animation
  29725. * @param node Node which contains the scene that begins the animations
  29726. * @param targetProperty Specifies which property to animate
  29727. * @param framePerSecond The frames per second of the animation
  29728. * @param totalFrame The total number of frames
  29729. * @param from The frame at the beginning of the animation
  29730. * @param to The frame at the end of the animation
  29731. * @param loopMode Specifies the loop mode of the animation
  29732. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29733. * @param onAnimationEnd Callback to run once the animation is complete
  29734. * @returns Nullable animation
  29735. */
  29736. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29737. /**
  29738. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29739. * @param sourceAnimation defines the Animation containing keyframes to convert
  29740. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29741. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29742. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29743. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29744. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29745. */
  29746. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29747. /**
  29748. * Transition property of an host to the target Value
  29749. * @param property The property to transition
  29750. * @param targetValue The target Value of the property
  29751. * @param host The object where the property to animate belongs
  29752. * @param scene Scene used to run the animation
  29753. * @param frameRate Framerate (in frame/s) to use
  29754. * @param transition The transition type we want to use
  29755. * @param duration The duration of the animation, in milliseconds
  29756. * @param onAnimationEnd Callback trigger at the end of the animation
  29757. * @returns Nullable animation
  29758. */
  29759. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29760. /**
  29761. * Return the array of runtime animations currently using this animation
  29762. */
  29763. get runtimeAnimations(): RuntimeAnimation[];
  29764. /**
  29765. * Specifies if any of the runtime animations are currently running
  29766. */
  29767. get hasRunningRuntimeAnimations(): boolean;
  29768. /**
  29769. * Initializes the animation
  29770. * @param name Name of the animation
  29771. * @param targetProperty Property to animate
  29772. * @param framePerSecond The frames per second of the animation
  29773. * @param dataType The data type of the animation
  29774. * @param loopMode The loop mode of the animation
  29775. * @param enableBlending Specifies if blending should be enabled
  29776. */
  29777. constructor(
  29778. /**Name of the animation */
  29779. name: string,
  29780. /**Property to animate */
  29781. targetProperty: string,
  29782. /**The frames per second of the animation */
  29783. framePerSecond: number,
  29784. /**The data type of the animation */
  29785. dataType: number,
  29786. /**The loop mode of the animation */
  29787. loopMode?: number | undefined,
  29788. /**Specifies if blending should be enabled */
  29789. enableBlending?: boolean | undefined);
  29790. /**
  29791. * Converts the animation to a string
  29792. * @param fullDetails support for multiple levels of logging within scene loading
  29793. * @returns String form of the animation
  29794. */
  29795. toString(fullDetails?: boolean): string;
  29796. /**
  29797. * Add an event to this animation
  29798. * @param event Event to add
  29799. */
  29800. addEvent(event: AnimationEvent): void;
  29801. /**
  29802. * Remove all events found at the given frame
  29803. * @param frame The frame to remove events from
  29804. */
  29805. removeEvents(frame: number): void;
  29806. /**
  29807. * Retrieves all the events from the animation
  29808. * @returns Events from the animation
  29809. */
  29810. getEvents(): AnimationEvent[];
  29811. /**
  29812. * Creates an animation range
  29813. * @param name Name of the animation range
  29814. * @param from Starting frame of the animation range
  29815. * @param to Ending frame of the animation
  29816. */
  29817. createRange(name: string, from: number, to: number): void;
  29818. /**
  29819. * Deletes an animation range by name
  29820. * @param name Name of the animation range to delete
  29821. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29822. */
  29823. deleteRange(name: string, deleteFrames?: boolean): void;
  29824. /**
  29825. * Gets the animation range by name, or null if not defined
  29826. * @param name Name of the animation range
  29827. * @returns Nullable animation range
  29828. */
  29829. getRange(name: string): Nullable<AnimationRange>;
  29830. /**
  29831. * Gets the key frames from the animation
  29832. * @returns The key frames of the animation
  29833. */
  29834. getKeys(): Array<IAnimationKey>;
  29835. /**
  29836. * Gets the highest frame rate of the animation
  29837. * @returns Highest frame rate of the animation
  29838. */
  29839. getHighestFrame(): number;
  29840. /**
  29841. * Gets the easing function of the animation
  29842. * @returns Easing function of the animation
  29843. */
  29844. getEasingFunction(): IEasingFunction;
  29845. /**
  29846. * Sets the easing function of the animation
  29847. * @param easingFunction A custom mathematical formula for animation
  29848. */
  29849. setEasingFunction(easingFunction: EasingFunction): void;
  29850. /**
  29851. * Interpolates a scalar linearly
  29852. * @param startValue Start value of the animation curve
  29853. * @param endValue End value of the animation curve
  29854. * @param gradient Scalar amount to interpolate
  29855. * @returns Interpolated scalar value
  29856. */
  29857. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29858. /**
  29859. * Interpolates a scalar cubically
  29860. * @param startValue Start value of the animation curve
  29861. * @param outTangent End tangent of the animation
  29862. * @param endValue End value of the animation curve
  29863. * @param inTangent Start tangent of the animation curve
  29864. * @param gradient Scalar amount to interpolate
  29865. * @returns Interpolated scalar value
  29866. */
  29867. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29868. /**
  29869. * Interpolates a quaternion using a spherical linear interpolation
  29870. * @param startValue Start value of the animation curve
  29871. * @param endValue End value of the animation curve
  29872. * @param gradient Scalar amount to interpolate
  29873. * @returns Interpolated quaternion value
  29874. */
  29875. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29876. /**
  29877. * Interpolates a quaternion cubically
  29878. * @param startValue Start value of the animation curve
  29879. * @param outTangent End tangent of the animation curve
  29880. * @param endValue End value of the animation curve
  29881. * @param inTangent Start tangent of the animation curve
  29882. * @param gradient Scalar amount to interpolate
  29883. * @returns Interpolated quaternion value
  29884. */
  29885. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29886. /**
  29887. * Interpolates a Vector3 linearl
  29888. * @param startValue Start value of the animation curve
  29889. * @param endValue End value of the animation curve
  29890. * @param gradient Scalar amount to interpolate
  29891. * @returns Interpolated scalar value
  29892. */
  29893. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29894. /**
  29895. * Interpolates a Vector3 cubically
  29896. * @param startValue Start value of the animation curve
  29897. * @param outTangent End tangent of the animation
  29898. * @param endValue End value of the animation curve
  29899. * @param inTangent Start tangent of the animation curve
  29900. * @param gradient Scalar amount to interpolate
  29901. * @returns InterpolatedVector3 value
  29902. */
  29903. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29904. /**
  29905. * Interpolates a Vector2 linearly
  29906. * @param startValue Start value of the animation curve
  29907. * @param endValue End value of the animation curve
  29908. * @param gradient Scalar amount to interpolate
  29909. * @returns Interpolated Vector2 value
  29910. */
  29911. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29912. /**
  29913. * Interpolates a Vector2 cubically
  29914. * @param startValue Start value of the animation curve
  29915. * @param outTangent End tangent of the animation
  29916. * @param endValue End value of the animation curve
  29917. * @param inTangent Start tangent of the animation curve
  29918. * @param gradient Scalar amount to interpolate
  29919. * @returns Interpolated Vector2 value
  29920. */
  29921. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29922. /**
  29923. * Interpolates a size linearly
  29924. * @param startValue Start value of the animation curve
  29925. * @param endValue End value of the animation curve
  29926. * @param gradient Scalar amount to interpolate
  29927. * @returns Interpolated Size value
  29928. */
  29929. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29930. /**
  29931. * Interpolates a Color3 linearly
  29932. * @param startValue Start value of the animation curve
  29933. * @param endValue End value of the animation curve
  29934. * @param gradient Scalar amount to interpolate
  29935. * @returns Interpolated Color3 value
  29936. */
  29937. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29938. /**
  29939. * Interpolates a Color4 linearly
  29940. * @param startValue Start value of the animation curve
  29941. * @param endValue End value of the animation curve
  29942. * @param gradient Scalar amount to interpolate
  29943. * @returns Interpolated Color3 value
  29944. */
  29945. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29946. /**
  29947. * @hidden Internal use only
  29948. */
  29949. _getKeyValue(value: any): any;
  29950. /**
  29951. * @hidden Internal use only
  29952. */
  29953. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29954. /**
  29955. * Defines the function to use to interpolate matrices
  29956. * @param startValue defines the start matrix
  29957. * @param endValue defines the end matrix
  29958. * @param gradient defines the gradient between both matrices
  29959. * @param result defines an optional target matrix where to store the interpolation
  29960. * @returns the interpolated matrix
  29961. */
  29962. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29963. /**
  29964. * Makes a copy of the animation
  29965. * @returns Cloned animation
  29966. */
  29967. clone(): Animation;
  29968. /**
  29969. * Sets the key frames of the animation
  29970. * @param values The animation key frames to set
  29971. */
  29972. setKeys(values: Array<IAnimationKey>): void;
  29973. /**
  29974. * Serializes the animation to an object
  29975. * @returns Serialized object
  29976. */
  29977. serialize(): any;
  29978. /**
  29979. * Float animation type
  29980. */
  29981. static readonly ANIMATIONTYPE_FLOAT: number;
  29982. /**
  29983. * Vector3 animation type
  29984. */
  29985. static readonly ANIMATIONTYPE_VECTOR3: number;
  29986. /**
  29987. * Quaternion animation type
  29988. */
  29989. static readonly ANIMATIONTYPE_QUATERNION: number;
  29990. /**
  29991. * Matrix animation type
  29992. */
  29993. static readonly ANIMATIONTYPE_MATRIX: number;
  29994. /**
  29995. * Color3 animation type
  29996. */
  29997. static readonly ANIMATIONTYPE_COLOR3: number;
  29998. /**
  29999. * Color3 animation type
  30000. */
  30001. static readonly ANIMATIONTYPE_COLOR4: number;
  30002. /**
  30003. * Vector2 animation type
  30004. */
  30005. static readonly ANIMATIONTYPE_VECTOR2: number;
  30006. /**
  30007. * Size animation type
  30008. */
  30009. static readonly ANIMATIONTYPE_SIZE: number;
  30010. /**
  30011. * Relative Loop Mode
  30012. */
  30013. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30014. /**
  30015. * Cycle Loop Mode
  30016. */
  30017. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30018. /**
  30019. * Constant Loop Mode
  30020. */
  30021. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30022. /** @hidden */
  30023. static _UniversalLerp(left: any, right: any, amount: number): any;
  30024. /**
  30025. * Parses an animation object and creates an animation
  30026. * @param parsedAnimation Parsed animation object
  30027. * @returns Animation object
  30028. */
  30029. static Parse(parsedAnimation: any): Animation;
  30030. /**
  30031. * Appends the serialized animations from the source animations
  30032. * @param source Source containing the animations
  30033. * @param destination Target to store the animations
  30034. */
  30035. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30036. }
  30037. }
  30038. declare module BABYLON {
  30039. /**
  30040. * Interface containing an array of animations
  30041. */
  30042. export interface IAnimatable {
  30043. /**
  30044. * Array of animations
  30045. */
  30046. animations: Nullable<Array<Animation>>;
  30047. }
  30048. }
  30049. declare module BABYLON {
  30050. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30051. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30052. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30053. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30054. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30055. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30056. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30057. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30058. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30059. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30060. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30061. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30062. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30063. /**
  30064. * Decorator used to define property that can be serialized as reference to a camera
  30065. * @param sourceName defines the name of the property to decorate
  30066. */
  30067. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30068. /**
  30069. * Class used to help serialization objects
  30070. */
  30071. export class SerializationHelper {
  30072. /** @hidden */
  30073. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30074. /** @hidden */
  30075. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30076. /** @hidden */
  30077. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30078. /** @hidden */
  30079. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30080. /**
  30081. * Appends the serialized animations from the source animations
  30082. * @param source Source containing the animations
  30083. * @param destination Target to store the animations
  30084. */
  30085. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30086. /**
  30087. * Static function used to serialized a specific entity
  30088. * @param entity defines the entity to serialize
  30089. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30090. * @returns a JSON compatible object representing the serialization of the entity
  30091. */
  30092. static Serialize<T>(entity: T, serializationObject?: any): any;
  30093. /**
  30094. * Creates a new entity from a serialization data object
  30095. * @param creationFunction defines a function used to instanciated the new entity
  30096. * @param source defines the source serialization data
  30097. * @param scene defines the hosting scene
  30098. * @param rootUrl defines the root url for resources
  30099. * @returns a new entity
  30100. */
  30101. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30102. /**
  30103. * Clones an object
  30104. * @param creationFunction defines the function used to instanciate the new object
  30105. * @param source defines the source object
  30106. * @returns the cloned object
  30107. */
  30108. static Clone<T>(creationFunction: () => T, source: T): T;
  30109. /**
  30110. * Instanciates a new object based on a source one (some data will be shared between both object)
  30111. * @param creationFunction defines the function used to instanciate the new object
  30112. * @param source defines the source object
  30113. * @returns the new object
  30114. */
  30115. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30116. }
  30117. }
  30118. declare module BABYLON {
  30119. /**
  30120. * Base class of all the textures in babylon.
  30121. * It groups all the common properties the materials, post process, lights... might need
  30122. * in order to make a correct use of the texture.
  30123. */
  30124. export class BaseTexture implements IAnimatable {
  30125. /**
  30126. * Default anisotropic filtering level for the application.
  30127. * It is set to 4 as a good tradeoff between perf and quality.
  30128. */
  30129. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30130. /**
  30131. * Gets or sets the unique id of the texture
  30132. */
  30133. uniqueId: number;
  30134. /**
  30135. * Define the name of the texture.
  30136. */
  30137. name: string;
  30138. /**
  30139. * Gets or sets an object used to store user defined information.
  30140. */
  30141. metadata: any;
  30142. /**
  30143. * For internal use only. Please do not use.
  30144. */
  30145. reservedDataStore: any;
  30146. private _hasAlpha;
  30147. /**
  30148. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30149. */
  30150. set hasAlpha(value: boolean);
  30151. get hasAlpha(): boolean;
  30152. /**
  30153. * Defines if the alpha value should be determined via the rgb values.
  30154. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30155. */
  30156. getAlphaFromRGB: boolean;
  30157. /**
  30158. * Intensity or strength of the texture.
  30159. * It is commonly used by materials to fine tune the intensity of the texture
  30160. */
  30161. level: number;
  30162. /**
  30163. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30164. * This is part of the texture as textures usually maps to one uv set.
  30165. */
  30166. coordinatesIndex: number;
  30167. private _coordinatesMode;
  30168. /**
  30169. * How a texture is mapped.
  30170. *
  30171. * | Value | Type | Description |
  30172. * | ----- | ----------------------------------- | ----------- |
  30173. * | 0 | EXPLICIT_MODE | |
  30174. * | 1 | SPHERICAL_MODE | |
  30175. * | 2 | PLANAR_MODE | |
  30176. * | 3 | CUBIC_MODE | |
  30177. * | 4 | PROJECTION_MODE | |
  30178. * | 5 | SKYBOX_MODE | |
  30179. * | 6 | INVCUBIC_MODE | |
  30180. * | 7 | EQUIRECTANGULAR_MODE | |
  30181. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30182. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30183. */
  30184. set coordinatesMode(value: number);
  30185. get coordinatesMode(): number;
  30186. /**
  30187. * | Value | Type | Description |
  30188. * | ----- | ------------------ | ----------- |
  30189. * | 0 | CLAMP_ADDRESSMODE | |
  30190. * | 1 | WRAP_ADDRESSMODE | |
  30191. * | 2 | MIRROR_ADDRESSMODE | |
  30192. */
  30193. wrapU: number;
  30194. /**
  30195. * | Value | Type | Description |
  30196. * | ----- | ------------------ | ----------- |
  30197. * | 0 | CLAMP_ADDRESSMODE | |
  30198. * | 1 | WRAP_ADDRESSMODE | |
  30199. * | 2 | MIRROR_ADDRESSMODE | |
  30200. */
  30201. wrapV: number;
  30202. /**
  30203. * | Value | Type | Description |
  30204. * | ----- | ------------------ | ----------- |
  30205. * | 0 | CLAMP_ADDRESSMODE | |
  30206. * | 1 | WRAP_ADDRESSMODE | |
  30207. * | 2 | MIRROR_ADDRESSMODE | |
  30208. */
  30209. wrapR: number;
  30210. /**
  30211. * With compliant hardware and browser (supporting anisotropic filtering)
  30212. * this defines the level of anisotropic filtering in the texture.
  30213. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30214. */
  30215. anisotropicFilteringLevel: number;
  30216. /**
  30217. * Define if the texture is a cube texture or if false a 2d texture.
  30218. */
  30219. get isCube(): boolean;
  30220. set isCube(value: boolean);
  30221. /**
  30222. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30223. */
  30224. get is3D(): boolean;
  30225. set is3D(value: boolean);
  30226. /**
  30227. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30228. */
  30229. get is2DArray(): boolean;
  30230. set is2DArray(value: boolean);
  30231. /**
  30232. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30233. * HDR texture are usually stored in linear space.
  30234. * This only impacts the PBR and Background materials
  30235. */
  30236. gammaSpace: boolean;
  30237. /**
  30238. * Gets or sets whether or not the texture contains RGBD data.
  30239. */
  30240. get isRGBD(): boolean;
  30241. set isRGBD(value: boolean);
  30242. /**
  30243. * Is Z inverted in the texture (useful in a cube texture).
  30244. */
  30245. invertZ: boolean;
  30246. /**
  30247. * Are mip maps generated for this texture or not.
  30248. */
  30249. get noMipmap(): boolean;
  30250. /**
  30251. * @hidden
  30252. */
  30253. lodLevelInAlpha: boolean;
  30254. /**
  30255. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30256. */
  30257. get lodGenerationOffset(): number;
  30258. set lodGenerationOffset(value: number);
  30259. /**
  30260. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30261. */
  30262. get lodGenerationScale(): number;
  30263. set lodGenerationScale(value: number);
  30264. /**
  30265. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30266. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30267. * average roughness values.
  30268. */
  30269. get linearSpecularLOD(): boolean;
  30270. set linearSpecularLOD(value: boolean);
  30271. /**
  30272. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30273. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30274. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30275. */
  30276. get irradianceTexture(): Nullable<BaseTexture>;
  30277. set irradianceTexture(value: Nullable<BaseTexture>);
  30278. /**
  30279. * Define if the texture is a render target.
  30280. */
  30281. isRenderTarget: boolean;
  30282. /**
  30283. * Define the unique id of the texture in the scene.
  30284. */
  30285. get uid(): string;
  30286. /**
  30287. * Return a string representation of the texture.
  30288. * @returns the texture as a string
  30289. */
  30290. toString(): string;
  30291. /**
  30292. * Get the class name of the texture.
  30293. * @returns "BaseTexture"
  30294. */
  30295. getClassName(): string;
  30296. /**
  30297. * Define the list of animation attached to the texture.
  30298. */
  30299. animations: Animation[];
  30300. /**
  30301. * An event triggered when the texture is disposed.
  30302. */
  30303. onDisposeObservable: Observable<BaseTexture>;
  30304. private _onDisposeObserver;
  30305. /**
  30306. * Callback triggered when the texture has been disposed.
  30307. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30308. */
  30309. set onDispose(callback: () => void);
  30310. /**
  30311. * Define the current state of the loading sequence when in delayed load mode.
  30312. */
  30313. delayLoadState: number;
  30314. private _scene;
  30315. /** @hidden */
  30316. _texture: Nullable<InternalTexture>;
  30317. private _uid;
  30318. /**
  30319. * Define if the texture is preventinga material to render or not.
  30320. * If not and the texture is not ready, the engine will use a default black texture instead.
  30321. */
  30322. get isBlocking(): boolean;
  30323. /**
  30324. * Instantiates a new BaseTexture.
  30325. * Base class of all the textures in babylon.
  30326. * It groups all the common properties the materials, post process, lights... might need
  30327. * in order to make a correct use of the texture.
  30328. * @param scene Define the scene the texture blongs to
  30329. */
  30330. constructor(scene: Nullable<Scene>);
  30331. /**
  30332. * Get the scene the texture belongs to.
  30333. * @returns the scene or null if undefined
  30334. */
  30335. getScene(): Nullable<Scene>;
  30336. /**
  30337. * Get the texture transform matrix used to offset tile the texture for istance.
  30338. * @returns the transformation matrix
  30339. */
  30340. getTextureMatrix(): Matrix;
  30341. /**
  30342. * Get the texture reflection matrix used to rotate/transform the reflection.
  30343. * @returns the reflection matrix
  30344. */
  30345. getReflectionTextureMatrix(): Matrix;
  30346. /**
  30347. * Get the underlying lower level texture from Babylon.
  30348. * @returns the insternal texture
  30349. */
  30350. getInternalTexture(): Nullable<InternalTexture>;
  30351. /**
  30352. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30353. * @returns true if ready or not blocking
  30354. */
  30355. isReadyOrNotBlocking(): boolean;
  30356. /**
  30357. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30358. * @returns true if fully ready
  30359. */
  30360. isReady(): boolean;
  30361. private _cachedSize;
  30362. /**
  30363. * Get the size of the texture.
  30364. * @returns the texture size.
  30365. */
  30366. getSize(): ISize;
  30367. /**
  30368. * Get the base size of the texture.
  30369. * It can be different from the size if the texture has been resized for POT for instance
  30370. * @returns the base size
  30371. */
  30372. getBaseSize(): ISize;
  30373. /**
  30374. * Update the sampling mode of the texture.
  30375. * Default is Trilinear mode.
  30376. *
  30377. * | Value | Type | Description |
  30378. * | ----- | ------------------ | ----------- |
  30379. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30380. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30381. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30382. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30383. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30384. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30385. * | 7 | NEAREST_LINEAR | |
  30386. * | 8 | NEAREST_NEAREST | |
  30387. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30388. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30389. * | 11 | LINEAR_LINEAR | |
  30390. * | 12 | LINEAR_NEAREST | |
  30391. *
  30392. * > _mag_: magnification filter (close to the viewer)
  30393. * > _min_: minification filter (far from the viewer)
  30394. * > _mip_: filter used between mip map levels
  30395. *@param samplingMode Define the new sampling mode of the texture
  30396. */
  30397. updateSamplingMode(samplingMode: number): void;
  30398. /**
  30399. * Scales the texture if is `canRescale()`
  30400. * @param ratio the resize factor we want to use to rescale
  30401. */
  30402. scale(ratio: number): void;
  30403. /**
  30404. * Get if the texture can rescale.
  30405. */
  30406. get canRescale(): boolean;
  30407. /** @hidden */
  30408. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30409. /** @hidden */
  30410. _rebuild(): void;
  30411. /**
  30412. * Triggers the load sequence in delayed load mode.
  30413. */
  30414. delayLoad(): void;
  30415. /**
  30416. * Clones the texture.
  30417. * @returns the cloned texture
  30418. */
  30419. clone(): Nullable<BaseTexture>;
  30420. /**
  30421. * Get the texture underlying type (INT, FLOAT...)
  30422. */
  30423. get textureType(): number;
  30424. /**
  30425. * Get the texture underlying format (RGB, RGBA...)
  30426. */
  30427. get textureFormat(): number;
  30428. /**
  30429. * Indicates that textures need to be re-calculated for all materials
  30430. */
  30431. protected _markAllSubMeshesAsTexturesDirty(): void;
  30432. /**
  30433. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30434. * This will returns an RGBA array buffer containing either in values (0-255) or
  30435. * float values (0-1) depending of the underlying buffer type.
  30436. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30437. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30438. * @param buffer defines a user defined buffer to fill with data (can be null)
  30439. * @returns The Array buffer containing the pixels data.
  30440. */
  30441. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30442. /**
  30443. * Release and destroy the underlying lower level texture aka internalTexture.
  30444. */
  30445. releaseInternalTexture(): void;
  30446. /** @hidden */
  30447. get _lodTextureHigh(): Nullable<BaseTexture>;
  30448. /** @hidden */
  30449. get _lodTextureMid(): Nullable<BaseTexture>;
  30450. /** @hidden */
  30451. get _lodTextureLow(): Nullable<BaseTexture>;
  30452. /**
  30453. * Dispose the texture and release its associated resources.
  30454. */
  30455. dispose(): void;
  30456. /**
  30457. * Serialize the texture into a JSON representation that can be parsed later on.
  30458. * @returns the JSON representation of the texture
  30459. */
  30460. serialize(): any;
  30461. /**
  30462. * Helper function to be called back once a list of texture contains only ready textures.
  30463. * @param textures Define the list of textures to wait for
  30464. * @param callback Define the callback triggered once the entire list will be ready
  30465. */
  30466. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30467. }
  30468. }
  30469. declare module BABYLON {
  30470. /**
  30471. * Options to be used when creating an effect.
  30472. */
  30473. export interface IEffectCreationOptions {
  30474. /**
  30475. * Atrributes that will be used in the shader.
  30476. */
  30477. attributes: string[];
  30478. /**
  30479. * Uniform varible names that will be set in the shader.
  30480. */
  30481. uniformsNames: string[];
  30482. /**
  30483. * Uniform buffer variable names that will be set in the shader.
  30484. */
  30485. uniformBuffersNames: string[];
  30486. /**
  30487. * Sampler texture variable names that will be set in the shader.
  30488. */
  30489. samplers: string[];
  30490. /**
  30491. * Define statements that will be set in the shader.
  30492. */
  30493. defines: any;
  30494. /**
  30495. * Possible fallbacks for this effect to improve performance when needed.
  30496. */
  30497. fallbacks: Nullable<IEffectFallbacks>;
  30498. /**
  30499. * Callback that will be called when the shader is compiled.
  30500. */
  30501. onCompiled: Nullable<(effect: Effect) => void>;
  30502. /**
  30503. * Callback that will be called if an error occurs during shader compilation.
  30504. */
  30505. onError: Nullable<(effect: Effect, errors: string) => void>;
  30506. /**
  30507. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30508. */
  30509. indexParameters?: any;
  30510. /**
  30511. * Max number of lights that can be used in the shader.
  30512. */
  30513. maxSimultaneousLights?: number;
  30514. /**
  30515. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30516. */
  30517. transformFeedbackVaryings?: Nullable<string[]>;
  30518. }
  30519. /**
  30520. * Effect containing vertex and fragment shader that can be executed on an object.
  30521. */
  30522. export class Effect implements IDisposable {
  30523. /**
  30524. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30525. */
  30526. static ShadersRepository: string;
  30527. /**
  30528. * Enable logging of the shader code when a compilation error occurs
  30529. */
  30530. static LogShaderCodeOnCompilationError: boolean;
  30531. /**
  30532. * Name of the effect.
  30533. */
  30534. name: any;
  30535. /**
  30536. * String container all the define statements that should be set on the shader.
  30537. */
  30538. defines: string;
  30539. /**
  30540. * Callback that will be called when the shader is compiled.
  30541. */
  30542. onCompiled: Nullable<(effect: Effect) => void>;
  30543. /**
  30544. * Callback that will be called if an error occurs during shader compilation.
  30545. */
  30546. onError: Nullable<(effect: Effect, errors: string) => void>;
  30547. /**
  30548. * Callback that will be called when effect is bound.
  30549. */
  30550. onBind: Nullable<(effect: Effect) => void>;
  30551. /**
  30552. * Unique ID of the effect.
  30553. */
  30554. uniqueId: number;
  30555. /**
  30556. * Observable that will be called when the shader is compiled.
  30557. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30558. */
  30559. onCompileObservable: Observable<Effect>;
  30560. /**
  30561. * Observable that will be called if an error occurs during shader compilation.
  30562. */
  30563. onErrorObservable: Observable<Effect>;
  30564. /** @hidden */
  30565. _onBindObservable: Nullable<Observable<Effect>>;
  30566. /**
  30567. * @hidden
  30568. * Specifies if the effect was previously ready
  30569. */
  30570. _wasPreviouslyReady: boolean;
  30571. /**
  30572. * Observable that will be called when effect is bound.
  30573. */
  30574. get onBindObservable(): Observable<Effect>;
  30575. /** @hidden */
  30576. _bonesComputationForcedToCPU: boolean;
  30577. private static _uniqueIdSeed;
  30578. private _engine;
  30579. private _uniformBuffersNames;
  30580. private _uniformBuffersNamesList;
  30581. private _uniformsNames;
  30582. private _samplerList;
  30583. private _samplers;
  30584. private _isReady;
  30585. private _compilationError;
  30586. private _allFallbacksProcessed;
  30587. private _attributesNames;
  30588. private _attributes;
  30589. private _attributeLocationByName;
  30590. private _uniforms;
  30591. /**
  30592. * Key for the effect.
  30593. * @hidden
  30594. */
  30595. _key: string;
  30596. private _indexParameters;
  30597. private _fallbacks;
  30598. private _vertexSourceCode;
  30599. private _fragmentSourceCode;
  30600. private _vertexSourceCodeOverride;
  30601. private _fragmentSourceCodeOverride;
  30602. private _transformFeedbackVaryings;
  30603. /**
  30604. * Compiled shader to webGL program.
  30605. * @hidden
  30606. */
  30607. _pipelineContext: Nullable<IPipelineContext>;
  30608. private _valueCache;
  30609. private static _baseCache;
  30610. /**
  30611. * Instantiates an effect.
  30612. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30613. * @param baseName Name of the effect.
  30614. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30615. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30616. * @param samplers List of sampler variables that will be passed to the shader.
  30617. * @param engine Engine to be used to render the effect
  30618. * @param defines Define statements to be added to the shader.
  30619. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30620. * @param onCompiled Callback that will be called when the shader is compiled.
  30621. * @param onError Callback that will be called if an error occurs during shader compilation.
  30622. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30623. */
  30624. 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);
  30625. private _useFinalCode;
  30626. /**
  30627. * Unique key for this effect
  30628. */
  30629. get key(): string;
  30630. /**
  30631. * If the effect has been compiled and prepared.
  30632. * @returns if the effect is compiled and prepared.
  30633. */
  30634. isReady(): boolean;
  30635. private _isReadyInternal;
  30636. /**
  30637. * The engine the effect was initialized with.
  30638. * @returns the engine.
  30639. */
  30640. getEngine(): Engine;
  30641. /**
  30642. * The pipeline context for this effect
  30643. * @returns the associated pipeline context
  30644. */
  30645. getPipelineContext(): Nullable<IPipelineContext>;
  30646. /**
  30647. * The set of names of attribute variables for the shader.
  30648. * @returns An array of attribute names.
  30649. */
  30650. getAttributesNames(): string[];
  30651. /**
  30652. * Returns the attribute at the given index.
  30653. * @param index The index of the attribute.
  30654. * @returns The location of the attribute.
  30655. */
  30656. getAttributeLocation(index: number): number;
  30657. /**
  30658. * Returns the attribute based on the name of the variable.
  30659. * @param name of the attribute to look up.
  30660. * @returns the attribute location.
  30661. */
  30662. getAttributeLocationByName(name: string): number;
  30663. /**
  30664. * The number of attributes.
  30665. * @returns the numnber of attributes.
  30666. */
  30667. getAttributesCount(): number;
  30668. /**
  30669. * Gets the index of a uniform variable.
  30670. * @param uniformName of the uniform to look up.
  30671. * @returns the index.
  30672. */
  30673. getUniformIndex(uniformName: string): number;
  30674. /**
  30675. * Returns the attribute based on the name of the variable.
  30676. * @param uniformName of the uniform to look up.
  30677. * @returns the location of the uniform.
  30678. */
  30679. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30680. /**
  30681. * Returns an array of sampler variable names
  30682. * @returns The array of sampler variable names.
  30683. */
  30684. getSamplers(): string[];
  30685. /**
  30686. * Returns an array of uniform variable names
  30687. * @returns The array of uniform variable names.
  30688. */
  30689. getUniformNames(): string[];
  30690. /**
  30691. * Returns an array of uniform buffer variable names
  30692. * @returns The array of uniform buffer variable names.
  30693. */
  30694. getUniformBuffersNames(): string[];
  30695. /**
  30696. * Returns the index parameters used to create the effect
  30697. * @returns The index parameters object
  30698. */
  30699. getIndexParameters(): any;
  30700. /**
  30701. * The error from the last compilation.
  30702. * @returns the error string.
  30703. */
  30704. getCompilationError(): string;
  30705. /**
  30706. * Gets a boolean indicating that all fallbacks were used during compilation
  30707. * @returns true if all fallbacks were used
  30708. */
  30709. allFallbacksProcessed(): boolean;
  30710. /**
  30711. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30712. * @param func The callback to be used.
  30713. */
  30714. executeWhenCompiled(func: (effect: Effect) => void): void;
  30715. private _checkIsReady;
  30716. private _loadShader;
  30717. /**
  30718. * Gets the vertex shader source code of this effect
  30719. */
  30720. get vertexSourceCode(): string;
  30721. /**
  30722. * Gets the fragment shader source code of this effect
  30723. */
  30724. get fragmentSourceCode(): string;
  30725. /**
  30726. * Recompiles the webGL program
  30727. * @param vertexSourceCode The source code for the vertex shader.
  30728. * @param fragmentSourceCode The source code for the fragment shader.
  30729. * @param onCompiled Callback called when completed.
  30730. * @param onError Callback called on error.
  30731. * @hidden
  30732. */
  30733. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30734. /**
  30735. * Prepares the effect
  30736. * @hidden
  30737. */
  30738. _prepareEffect(): void;
  30739. private _getShaderCodeAndErrorLine;
  30740. private _processCompilationErrors;
  30741. /**
  30742. * Checks if the effect is supported. (Must be called after compilation)
  30743. */
  30744. get isSupported(): boolean;
  30745. /**
  30746. * Binds a texture to the engine to be used as output of the shader.
  30747. * @param channel Name of the output variable.
  30748. * @param texture Texture to bind.
  30749. * @hidden
  30750. */
  30751. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30752. /**
  30753. * Sets a texture on the engine to be used in the shader.
  30754. * @param channel Name of the sampler variable.
  30755. * @param texture Texture to set.
  30756. */
  30757. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30758. /**
  30759. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30760. * @param channel Name of the sampler variable.
  30761. * @param texture Texture to set.
  30762. */
  30763. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30764. /**
  30765. * Sets an array of textures on the engine to be used in the shader.
  30766. * @param channel Name of the variable.
  30767. * @param textures Textures to set.
  30768. */
  30769. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30770. /**
  30771. * 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)
  30772. * @param channel Name of the sampler variable.
  30773. * @param postProcess Post process to get the input texture from.
  30774. */
  30775. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30776. /**
  30777. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30778. * 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)
  30779. * @param channel Name of the sampler variable.
  30780. * @param postProcess Post process to get the output texture from.
  30781. */
  30782. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30783. /** @hidden */
  30784. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30785. /** @hidden */
  30786. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30787. /** @hidden */
  30788. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30789. /** @hidden */
  30790. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30791. /**
  30792. * Binds a buffer to a uniform.
  30793. * @param buffer Buffer to bind.
  30794. * @param name Name of the uniform variable to bind to.
  30795. */
  30796. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30797. /**
  30798. * Binds block to a uniform.
  30799. * @param blockName Name of the block to bind.
  30800. * @param index Index to bind.
  30801. */
  30802. bindUniformBlock(blockName: string, index: number): void;
  30803. /**
  30804. * Sets an interger value on a uniform variable.
  30805. * @param uniformName Name of the variable.
  30806. * @param value Value to be set.
  30807. * @returns this effect.
  30808. */
  30809. setInt(uniformName: string, value: number): Effect;
  30810. /**
  30811. * Sets an int array on a uniform variable.
  30812. * @param uniformName Name of the variable.
  30813. * @param array array to be set.
  30814. * @returns this effect.
  30815. */
  30816. setIntArray(uniformName: string, array: Int32Array): Effect;
  30817. /**
  30818. * 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)
  30819. * @param uniformName Name of the variable.
  30820. * @param array array to be set.
  30821. * @returns this effect.
  30822. */
  30823. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30824. /**
  30825. * 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)
  30826. * @param uniformName Name of the variable.
  30827. * @param array array to be set.
  30828. * @returns this effect.
  30829. */
  30830. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30831. /**
  30832. * 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)
  30833. * @param uniformName Name of the variable.
  30834. * @param array array to be set.
  30835. * @returns this effect.
  30836. */
  30837. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30838. /**
  30839. * Sets an float array on a uniform variable.
  30840. * @param uniformName Name of the variable.
  30841. * @param array array to be set.
  30842. * @returns this effect.
  30843. */
  30844. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30845. /**
  30846. * 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)
  30847. * @param uniformName Name of the variable.
  30848. * @param array array to be set.
  30849. * @returns this effect.
  30850. */
  30851. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30852. /**
  30853. * 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)
  30854. * @param uniformName Name of the variable.
  30855. * @param array array to be set.
  30856. * @returns this effect.
  30857. */
  30858. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30859. /**
  30860. * 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)
  30861. * @param uniformName Name of the variable.
  30862. * @param array array to be set.
  30863. * @returns this effect.
  30864. */
  30865. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30866. /**
  30867. * Sets an array on a uniform variable.
  30868. * @param uniformName Name of the variable.
  30869. * @param array array to be set.
  30870. * @returns this effect.
  30871. */
  30872. setArray(uniformName: string, array: number[]): Effect;
  30873. /**
  30874. * 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)
  30875. * @param uniformName Name of the variable.
  30876. * @param array array to be set.
  30877. * @returns this effect.
  30878. */
  30879. setArray2(uniformName: string, array: number[]): Effect;
  30880. /**
  30881. * 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)
  30882. * @param uniformName Name of the variable.
  30883. * @param array array to be set.
  30884. * @returns this effect.
  30885. */
  30886. setArray3(uniformName: string, array: number[]): Effect;
  30887. /**
  30888. * 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)
  30889. * @param uniformName Name of the variable.
  30890. * @param array array to be set.
  30891. * @returns this effect.
  30892. */
  30893. setArray4(uniformName: string, array: number[]): Effect;
  30894. /**
  30895. * Sets matrices on a uniform variable.
  30896. * @param uniformName Name of the variable.
  30897. * @param matrices matrices to be set.
  30898. * @returns this effect.
  30899. */
  30900. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30901. /**
  30902. * Sets matrix on a uniform variable.
  30903. * @param uniformName Name of the variable.
  30904. * @param matrix matrix to be set.
  30905. * @returns this effect.
  30906. */
  30907. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30908. /**
  30909. * 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)
  30910. * @param uniformName Name of the variable.
  30911. * @param matrix matrix to be set.
  30912. * @returns this effect.
  30913. */
  30914. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30915. /**
  30916. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30917. * @param uniformName Name of the variable.
  30918. * @param matrix matrix to be set.
  30919. * @returns this effect.
  30920. */
  30921. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30922. /**
  30923. * Sets a float on a uniform variable.
  30924. * @param uniformName Name of the variable.
  30925. * @param value value to be set.
  30926. * @returns this effect.
  30927. */
  30928. setFloat(uniformName: string, value: number): Effect;
  30929. /**
  30930. * Sets a boolean on a uniform variable.
  30931. * @param uniformName Name of the variable.
  30932. * @param bool value to be set.
  30933. * @returns this effect.
  30934. */
  30935. setBool(uniformName: string, bool: boolean): Effect;
  30936. /**
  30937. * Sets a Vector2 on a uniform variable.
  30938. * @param uniformName Name of the variable.
  30939. * @param vector2 vector2 to be set.
  30940. * @returns this effect.
  30941. */
  30942. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30943. /**
  30944. * Sets a float2 on a uniform variable.
  30945. * @param uniformName Name of the variable.
  30946. * @param x First float in float2.
  30947. * @param y Second float in float2.
  30948. * @returns this effect.
  30949. */
  30950. setFloat2(uniformName: string, x: number, y: number): Effect;
  30951. /**
  30952. * Sets a Vector3 on a uniform variable.
  30953. * @param uniformName Name of the variable.
  30954. * @param vector3 Value to be set.
  30955. * @returns this effect.
  30956. */
  30957. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30958. /**
  30959. * Sets a float3 on a uniform variable.
  30960. * @param uniformName Name of the variable.
  30961. * @param x First float in float3.
  30962. * @param y Second float in float3.
  30963. * @param z Third float in float3.
  30964. * @returns this effect.
  30965. */
  30966. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30967. /**
  30968. * Sets a Vector4 on a uniform variable.
  30969. * @param uniformName Name of the variable.
  30970. * @param vector4 Value to be set.
  30971. * @returns this effect.
  30972. */
  30973. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30974. /**
  30975. * Sets a float4 on a uniform variable.
  30976. * @param uniformName Name of the variable.
  30977. * @param x First float in float4.
  30978. * @param y Second float in float4.
  30979. * @param z Third float in float4.
  30980. * @param w Fourth float in float4.
  30981. * @returns this effect.
  30982. */
  30983. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30984. /**
  30985. * Sets a Color3 on a uniform variable.
  30986. * @param uniformName Name of the variable.
  30987. * @param color3 Value to be set.
  30988. * @returns this effect.
  30989. */
  30990. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30991. /**
  30992. * Sets a Color4 on a uniform variable.
  30993. * @param uniformName Name of the variable.
  30994. * @param color3 Value to be set.
  30995. * @param alpha Alpha value to be set.
  30996. * @returns this effect.
  30997. */
  30998. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30999. /**
  31000. * Sets a Color4 on a uniform variable
  31001. * @param uniformName defines the name of the variable
  31002. * @param color4 defines the value to be set
  31003. * @returns this effect.
  31004. */
  31005. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31006. /** Release all associated resources */
  31007. dispose(): void;
  31008. /**
  31009. * This function will add a new shader to the shader store
  31010. * @param name the name of the shader
  31011. * @param pixelShader optional pixel shader content
  31012. * @param vertexShader optional vertex shader content
  31013. */
  31014. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31015. /**
  31016. * Store of each shader (The can be looked up using effect.key)
  31017. */
  31018. static ShadersStore: {
  31019. [key: string]: string;
  31020. };
  31021. /**
  31022. * Store of each included file for a shader (The can be looked up using effect.key)
  31023. */
  31024. static IncludesShadersStore: {
  31025. [key: string]: string;
  31026. };
  31027. /**
  31028. * Resets the cache of effects.
  31029. */
  31030. static ResetCache(): void;
  31031. }
  31032. }
  31033. declare module BABYLON {
  31034. /**
  31035. * Interface used to describe the capabilities of the engine relatively to the current browser
  31036. */
  31037. export interface EngineCapabilities {
  31038. /** Maximum textures units per fragment shader */
  31039. maxTexturesImageUnits: number;
  31040. /** Maximum texture units per vertex shader */
  31041. maxVertexTextureImageUnits: number;
  31042. /** Maximum textures units in the entire pipeline */
  31043. maxCombinedTexturesImageUnits: number;
  31044. /** Maximum texture size */
  31045. maxTextureSize: number;
  31046. /** Maximum texture samples */
  31047. maxSamples?: number;
  31048. /** Maximum cube texture size */
  31049. maxCubemapTextureSize: number;
  31050. /** Maximum render texture size */
  31051. maxRenderTextureSize: number;
  31052. /** Maximum number of vertex attributes */
  31053. maxVertexAttribs: number;
  31054. /** Maximum number of varyings */
  31055. maxVaryingVectors: number;
  31056. /** Maximum number of uniforms per vertex shader */
  31057. maxVertexUniformVectors: number;
  31058. /** Maximum number of uniforms per fragment shader */
  31059. maxFragmentUniformVectors: number;
  31060. /** Defines if standard derivates (dx/dy) are supported */
  31061. standardDerivatives: boolean;
  31062. /** Defines if s3tc texture compression is supported */
  31063. s3tc?: WEBGL_compressed_texture_s3tc;
  31064. /** Defines if pvrtc texture compression is supported */
  31065. pvrtc: any;
  31066. /** Defines if etc1 texture compression is supported */
  31067. etc1: any;
  31068. /** Defines if etc2 texture compression is supported */
  31069. etc2: any;
  31070. /** Defines if astc texture compression is supported */
  31071. astc: any;
  31072. /** Defines if float textures are supported */
  31073. textureFloat: boolean;
  31074. /** Defines if vertex array objects are supported */
  31075. vertexArrayObject: boolean;
  31076. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31077. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31078. /** Gets the maximum level of anisotropy supported */
  31079. maxAnisotropy: number;
  31080. /** Defines if instancing is supported */
  31081. instancedArrays: boolean;
  31082. /** Defines if 32 bits indices are supported */
  31083. uintIndices: boolean;
  31084. /** Defines if high precision shaders are supported */
  31085. highPrecisionShaderSupported: boolean;
  31086. /** Defines if depth reading in the fragment shader is supported */
  31087. fragmentDepthSupported: boolean;
  31088. /** Defines if float texture linear filtering is supported*/
  31089. textureFloatLinearFiltering: boolean;
  31090. /** Defines if rendering to float textures is supported */
  31091. textureFloatRender: boolean;
  31092. /** Defines if half float textures are supported*/
  31093. textureHalfFloat: boolean;
  31094. /** Defines if half float texture linear filtering is supported*/
  31095. textureHalfFloatLinearFiltering: boolean;
  31096. /** Defines if rendering to half float textures is supported */
  31097. textureHalfFloatRender: boolean;
  31098. /** Defines if textureLOD shader command is supported */
  31099. textureLOD: boolean;
  31100. /** Defines if draw buffers extension is supported */
  31101. drawBuffersExtension: boolean;
  31102. /** Defines if depth textures are supported */
  31103. depthTextureExtension: boolean;
  31104. /** Defines if float color buffer are supported */
  31105. colorBufferFloat: boolean;
  31106. /** Gets disjoint timer query extension (null if not supported) */
  31107. timerQuery?: EXT_disjoint_timer_query;
  31108. /** Defines if timestamp can be used with timer query */
  31109. canUseTimestampForTimerQuery: boolean;
  31110. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31111. multiview?: any;
  31112. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31113. oculusMultiview?: any;
  31114. /** Function used to let the system compiles shaders in background */
  31115. parallelShaderCompile?: {
  31116. COMPLETION_STATUS_KHR: number;
  31117. };
  31118. /** Max number of texture samples for MSAA */
  31119. maxMSAASamples: number;
  31120. /** Defines if the blend min max extension is supported */
  31121. blendMinMax: boolean;
  31122. }
  31123. }
  31124. declare module BABYLON {
  31125. /**
  31126. * @hidden
  31127. **/
  31128. export class DepthCullingState {
  31129. private _isDepthTestDirty;
  31130. private _isDepthMaskDirty;
  31131. private _isDepthFuncDirty;
  31132. private _isCullFaceDirty;
  31133. private _isCullDirty;
  31134. private _isZOffsetDirty;
  31135. private _isFrontFaceDirty;
  31136. private _depthTest;
  31137. private _depthMask;
  31138. private _depthFunc;
  31139. private _cull;
  31140. private _cullFace;
  31141. private _zOffset;
  31142. private _frontFace;
  31143. /**
  31144. * Initializes the state.
  31145. */
  31146. constructor();
  31147. get isDirty(): boolean;
  31148. get zOffset(): number;
  31149. set zOffset(value: number);
  31150. get cullFace(): Nullable<number>;
  31151. set cullFace(value: Nullable<number>);
  31152. get cull(): Nullable<boolean>;
  31153. set cull(value: Nullable<boolean>);
  31154. get depthFunc(): Nullable<number>;
  31155. set depthFunc(value: Nullable<number>);
  31156. get depthMask(): boolean;
  31157. set depthMask(value: boolean);
  31158. get depthTest(): boolean;
  31159. set depthTest(value: boolean);
  31160. get frontFace(): Nullable<number>;
  31161. set frontFace(value: Nullable<number>);
  31162. reset(): void;
  31163. apply(gl: WebGLRenderingContext): void;
  31164. }
  31165. }
  31166. declare module BABYLON {
  31167. /**
  31168. * @hidden
  31169. **/
  31170. export class StencilState {
  31171. /** 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 */
  31172. static readonly ALWAYS: number;
  31173. /** Passed to stencilOperation to specify that stencil value must be kept */
  31174. static readonly KEEP: number;
  31175. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31176. static readonly REPLACE: number;
  31177. private _isStencilTestDirty;
  31178. private _isStencilMaskDirty;
  31179. private _isStencilFuncDirty;
  31180. private _isStencilOpDirty;
  31181. private _stencilTest;
  31182. private _stencilMask;
  31183. private _stencilFunc;
  31184. private _stencilFuncRef;
  31185. private _stencilFuncMask;
  31186. private _stencilOpStencilFail;
  31187. private _stencilOpDepthFail;
  31188. private _stencilOpStencilDepthPass;
  31189. get isDirty(): boolean;
  31190. get stencilFunc(): number;
  31191. set stencilFunc(value: number);
  31192. get stencilFuncRef(): number;
  31193. set stencilFuncRef(value: number);
  31194. get stencilFuncMask(): number;
  31195. set stencilFuncMask(value: number);
  31196. get stencilOpStencilFail(): number;
  31197. set stencilOpStencilFail(value: number);
  31198. get stencilOpDepthFail(): number;
  31199. set stencilOpDepthFail(value: number);
  31200. get stencilOpStencilDepthPass(): number;
  31201. set stencilOpStencilDepthPass(value: number);
  31202. get stencilMask(): number;
  31203. set stencilMask(value: number);
  31204. get stencilTest(): boolean;
  31205. set stencilTest(value: boolean);
  31206. constructor();
  31207. reset(): void;
  31208. apply(gl: WebGLRenderingContext): void;
  31209. }
  31210. }
  31211. declare module BABYLON {
  31212. /**
  31213. * @hidden
  31214. **/
  31215. export class AlphaState {
  31216. private _isAlphaBlendDirty;
  31217. private _isBlendFunctionParametersDirty;
  31218. private _isBlendEquationParametersDirty;
  31219. private _isBlendConstantsDirty;
  31220. private _alphaBlend;
  31221. private _blendFunctionParameters;
  31222. private _blendEquationParameters;
  31223. private _blendConstants;
  31224. /**
  31225. * Initializes the state.
  31226. */
  31227. constructor();
  31228. get isDirty(): boolean;
  31229. get alphaBlend(): boolean;
  31230. set alphaBlend(value: boolean);
  31231. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31232. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31233. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31234. reset(): void;
  31235. apply(gl: WebGLRenderingContext): void;
  31236. }
  31237. }
  31238. declare module BABYLON {
  31239. /** @hidden */
  31240. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31241. attributeProcessor(attribute: string): string;
  31242. varyingProcessor(varying: string, isFragment: boolean): string;
  31243. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31244. }
  31245. }
  31246. declare module BABYLON {
  31247. /**
  31248. * Interface for attribute information associated with buffer instanciation
  31249. */
  31250. export interface InstancingAttributeInfo {
  31251. /**
  31252. * Name of the GLSL attribute
  31253. * if attribute index is not specified, this is used to retrieve the index from the effect
  31254. */
  31255. attributeName: string;
  31256. /**
  31257. * Index/offset of the attribute in the vertex shader
  31258. * if not specified, this will be computes from the name.
  31259. */
  31260. index?: number;
  31261. /**
  31262. * size of the attribute, 1, 2, 3 or 4
  31263. */
  31264. attributeSize: number;
  31265. /**
  31266. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31267. */
  31268. offset: number;
  31269. /**
  31270. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31271. * default to 1
  31272. */
  31273. divisor?: number;
  31274. /**
  31275. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31276. * default is FLOAT
  31277. */
  31278. attributeType?: number;
  31279. /**
  31280. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31281. */
  31282. normalized?: boolean;
  31283. }
  31284. }
  31285. declare module BABYLON {
  31286. interface ThinEngine {
  31287. /**
  31288. * Update a video texture
  31289. * @param texture defines the texture to update
  31290. * @param video defines the video element to use
  31291. * @param invertY defines if data must be stored with Y axis inverted
  31292. */
  31293. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31294. }
  31295. }
  31296. declare module BABYLON {
  31297. /**
  31298. * Settings for finer control over video usage
  31299. */
  31300. export interface VideoTextureSettings {
  31301. /**
  31302. * Applies `autoplay` to video, if specified
  31303. */
  31304. autoPlay?: boolean;
  31305. /**
  31306. * Applies `loop` to video, if specified
  31307. */
  31308. loop?: boolean;
  31309. /**
  31310. * Automatically updates internal texture from video at every frame in the render loop
  31311. */
  31312. autoUpdateTexture: boolean;
  31313. /**
  31314. * Image src displayed during the video loading or until the user interacts with the video.
  31315. */
  31316. poster?: string;
  31317. }
  31318. /**
  31319. * If you want to display a video in your scene, this is the special texture for that.
  31320. * This special texture works similar to other textures, with the exception of a few parameters.
  31321. * @see https://doc.babylonjs.com/how_to/video_texture
  31322. */
  31323. export class VideoTexture extends Texture {
  31324. /**
  31325. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31326. */
  31327. readonly autoUpdateTexture: boolean;
  31328. /**
  31329. * The video instance used by the texture internally
  31330. */
  31331. readonly video: HTMLVideoElement;
  31332. private _onUserActionRequestedObservable;
  31333. /**
  31334. * Event triggerd when a dom action is required by the user to play the video.
  31335. * This happens due to recent changes in browser policies preventing video to auto start.
  31336. */
  31337. get onUserActionRequestedObservable(): Observable<Texture>;
  31338. private _generateMipMaps;
  31339. private _engine;
  31340. private _stillImageCaptured;
  31341. private _displayingPosterTexture;
  31342. private _settings;
  31343. private _createInternalTextureOnEvent;
  31344. private _frameId;
  31345. private _currentSrc;
  31346. /**
  31347. * Creates a video texture.
  31348. * If you want to display a video in your scene, this is the special texture for that.
  31349. * This special texture works similar to other textures, with the exception of a few parameters.
  31350. * @see https://doc.babylonjs.com/how_to/video_texture
  31351. * @param name optional name, will detect from video source, if not defined
  31352. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31353. * @param scene is obviously the current scene.
  31354. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31355. * @param invertY is false by default but can be used to invert video on Y axis
  31356. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31357. * @param settings allows finer control over video usage
  31358. */
  31359. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31360. private _getName;
  31361. private _getVideo;
  31362. private _createInternalTexture;
  31363. private reset;
  31364. /**
  31365. * @hidden Internal method to initiate `update`.
  31366. */
  31367. _rebuild(): void;
  31368. /**
  31369. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31370. */
  31371. update(): void;
  31372. /**
  31373. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31374. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31375. */
  31376. updateTexture(isVisible: boolean): void;
  31377. protected _updateInternalTexture: () => void;
  31378. /**
  31379. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31380. * @param url New url.
  31381. */
  31382. updateURL(url: string): void;
  31383. /**
  31384. * Clones the texture.
  31385. * @returns the cloned texture
  31386. */
  31387. clone(): VideoTexture;
  31388. /**
  31389. * Dispose the texture and release its associated resources.
  31390. */
  31391. dispose(): void;
  31392. /**
  31393. * Creates a video texture straight from a stream.
  31394. * @param scene Define the scene the texture should be created in
  31395. * @param stream Define the stream the texture should be created from
  31396. * @returns The created video texture as a promise
  31397. */
  31398. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31399. /**
  31400. * Creates a video texture straight from your WebCam video feed.
  31401. * @param scene Define the scene the texture should be created in
  31402. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31403. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31404. * @returns The created video texture as a promise
  31405. */
  31406. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31407. minWidth: number;
  31408. maxWidth: number;
  31409. minHeight: number;
  31410. maxHeight: number;
  31411. deviceId: string;
  31412. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31413. /**
  31414. * Creates a video texture straight from your WebCam video feed.
  31415. * @param scene Define the scene the texture should be created in
  31416. * @param onReady Define a callback to triggered once the texture will be ready
  31417. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31418. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31419. */
  31420. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31421. minWidth: number;
  31422. maxWidth: number;
  31423. minHeight: number;
  31424. maxHeight: number;
  31425. deviceId: string;
  31426. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31427. }
  31428. }
  31429. declare module BABYLON {
  31430. /**
  31431. * Defines the interface used by objects working like Scene
  31432. * @hidden
  31433. */
  31434. export interface ISceneLike {
  31435. _addPendingData(data: any): void;
  31436. _removePendingData(data: any): void;
  31437. offlineProvider: IOfflineProvider;
  31438. }
  31439. /** Interface defining initialization parameters for Engine class */
  31440. export interface EngineOptions extends WebGLContextAttributes {
  31441. /**
  31442. * Defines if the engine should no exceed a specified device ratio
  31443. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31444. */
  31445. limitDeviceRatio?: number;
  31446. /**
  31447. * Defines if webvr should be enabled automatically
  31448. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31449. */
  31450. autoEnableWebVR?: boolean;
  31451. /**
  31452. * Defines if webgl2 should be turned off even if supported
  31453. * @see http://doc.babylonjs.com/features/webgl2
  31454. */
  31455. disableWebGL2Support?: boolean;
  31456. /**
  31457. * Defines if webaudio should be initialized as well
  31458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31459. */
  31460. audioEngine?: boolean;
  31461. /**
  31462. * Defines if animations should run using a deterministic lock step
  31463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31464. */
  31465. deterministicLockstep?: boolean;
  31466. /** Defines the maximum steps to use with deterministic lock step mode */
  31467. lockstepMaxSteps?: number;
  31468. /** Defines the seconds between each deterministic lock step */
  31469. timeStep?: number;
  31470. /**
  31471. * Defines that engine should ignore context lost events
  31472. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31473. */
  31474. doNotHandleContextLost?: boolean;
  31475. /**
  31476. * Defines that engine should ignore modifying touch action attribute and style
  31477. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31478. */
  31479. doNotHandleTouchAction?: boolean;
  31480. /**
  31481. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31482. */
  31483. useHighPrecisionFloats?: boolean;
  31484. }
  31485. /**
  31486. * The base engine class (root of all engines)
  31487. */
  31488. export class ThinEngine {
  31489. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31490. static ExceptionList: ({
  31491. key: string;
  31492. capture: string;
  31493. captureConstraint: number;
  31494. targets: string[];
  31495. } | {
  31496. key: string;
  31497. capture: null;
  31498. captureConstraint: null;
  31499. targets: string[];
  31500. })[];
  31501. /** @hidden */
  31502. static _TextureLoaders: IInternalTextureLoader[];
  31503. /**
  31504. * Returns the current npm package of the sdk
  31505. */
  31506. static get NpmPackage(): string;
  31507. /**
  31508. * Returns the current version of the framework
  31509. */
  31510. static get Version(): string;
  31511. /**
  31512. * Returns a string describing the current engine
  31513. */
  31514. get description(): string;
  31515. /**
  31516. * Gets or sets the epsilon value used by collision engine
  31517. */
  31518. static CollisionsEpsilon: number;
  31519. /**
  31520. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31521. */
  31522. static get ShadersRepository(): string;
  31523. static set ShadersRepository(value: string);
  31524. /** @hidden */
  31525. _shaderProcessor: IShaderProcessor;
  31526. /**
  31527. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31528. */
  31529. forcePOTTextures: boolean;
  31530. /**
  31531. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31532. */
  31533. isFullscreen: boolean;
  31534. /**
  31535. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31536. */
  31537. cullBackFaces: boolean;
  31538. /**
  31539. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31540. */
  31541. renderEvenInBackground: boolean;
  31542. /**
  31543. * Gets or sets a boolean indicating that cache can be kept between frames
  31544. */
  31545. preventCacheWipeBetweenFrames: boolean;
  31546. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31547. validateShaderPrograms: boolean;
  31548. /**
  31549. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31550. * This can provide greater z depth for distant objects.
  31551. */
  31552. useReverseDepthBuffer: boolean;
  31553. /**
  31554. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31555. */
  31556. disableUniformBuffers: boolean;
  31557. /** @hidden */
  31558. _uniformBuffers: UniformBuffer[];
  31559. /**
  31560. * Gets a boolean indicating that the engine supports uniform buffers
  31561. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31562. */
  31563. get supportsUniformBuffers(): boolean;
  31564. /** @hidden */
  31565. _gl: WebGLRenderingContext;
  31566. /** @hidden */
  31567. _webGLVersion: number;
  31568. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31569. protected _windowIsBackground: boolean;
  31570. protected _creationOptions: EngineOptions;
  31571. protected _highPrecisionShadersAllowed: boolean;
  31572. /** @hidden */
  31573. get _shouldUseHighPrecisionShader(): boolean;
  31574. /**
  31575. * Gets a boolean indicating that only power of 2 textures are supported
  31576. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31577. */
  31578. get needPOTTextures(): boolean;
  31579. /** @hidden */
  31580. _badOS: boolean;
  31581. /** @hidden */
  31582. _badDesktopOS: boolean;
  31583. private _hardwareScalingLevel;
  31584. /** @hidden */
  31585. _caps: EngineCapabilities;
  31586. private _isStencilEnable;
  31587. private _glVersion;
  31588. private _glRenderer;
  31589. private _glVendor;
  31590. /** @hidden */
  31591. _videoTextureSupported: boolean;
  31592. protected _renderingQueueLaunched: boolean;
  31593. protected _activeRenderLoops: (() => void)[];
  31594. /**
  31595. * Observable signaled when a context lost event is raised
  31596. */
  31597. onContextLostObservable: Observable<ThinEngine>;
  31598. /**
  31599. * Observable signaled when a context restored event is raised
  31600. */
  31601. onContextRestoredObservable: Observable<ThinEngine>;
  31602. private _onContextLost;
  31603. private _onContextRestored;
  31604. protected _contextWasLost: boolean;
  31605. /** @hidden */
  31606. _doNotHandleContextLost: boolean;
  31607. /**
  31608. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31610. */
  31611. get doNotHandleContextLost(): boolean;
  31612. set doNotHandleContextLost(value: boolean);
  31613. /**
  31614. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31615. */
  31616. disableVertexArrayObjects: boolean;
  31617. /** @hidden */
  31618. protected _colorWrite: boolean;
  31619. /** @hidden */
  31620. protected _colorWriteChanged: boolean;
  31621. /** @hidden */
  31622. protected _depthCullingState: DepthCullingState;
  31623. /** @hidden */
  31624. protected _stencilState: StencilState;
  31625. /** @hidden */
  31626. _alphaState: AlphaState;
  31627. /** @hidden */
  31628. _alphaMode: number;
  31629. /** @hidden */
  31630. _alphaEquation: number;
  31631. /** @hidden */
  31632. _internalTexturesCache: InternalTexture[];
  31633. /** @hidden */
  31634. protected _activeChannel: number;
  31635. private _currentTextureChannel;
  31636. /** @hidden */
  31637. protected _boundTexturesCache: {
  31638. [key: string]: Nullable<InternalTexture>;
  31639. };
  31640. /** @hidden */
  31641. protected _currentEffect: Nullable<Effect>;
  31642. /** @hidden */
  31643. protected _currentProgram: Nullable<WebGLProgram>;
  31644. private _compiledEffects;
  31645. private _vertexAttribArraysEnabled;
  31646. /** @hidden */
  31647. protected _cachedViewport: Nullable<IViewportLike>;
  31648. private _cachedVertexArrayObject;
  31649. /** @hidden */
  31650. protected _cachedVertexBuffers: any;
  31651. /** @hidden */
  31652. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31653. /** @hidden */
  31654. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31655. /** @hidden */
  31656. _currentRenderTarget: Nullable<InternalTexture>;
  31657. private _uintIndicesCurrentlySet;
  31658. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31659. /** @hidden */
  31660. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31661. private _currentBufferPointers;
  31662. private _currentInstanceLocations;
  31663. private _currentInstanceBuffers;
  31664. private _textureUnits;
  31665. /** @hidden */
  31666. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31667. /** @hidden */
  31668. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31669. /** @hidden */
  31670. _boundRenderFunction: any;
  31671. private _vaoRecordInProgress;
  31672. private _mustWipeVertexAttributes;
  31673. private _emptyTexture;
  31674. private _emptyCubeTexture;
  31675. private _emptyTexture3D;
  31676. private _emptyTexture2DArray;
  31677. /** @hidden */
  31678. _frameHandler: number;
  31679. private _nextFreeTextureSlots;
  31680. private _maxSimultaneousTextures;
  31681. private _activeRequests;
  31682. /** @hidden */
  31683. _transformTextureUrl: Nullable<(url: string) => string>;
  31684. protected get _supportsHardwareTextureRescaling(): boolean;
  31685. private _framebufferDimensionsObject;
  31686. /**
  31687. * sets the object from which width and height will be taken from when getting render width and height
  31688. * Will fallback to the gl object
  31689. * @param dimensions the framebuffer width and height that will be used.
  31690. */
  31691. set framebufferDimensionsObject(dimensions: Nullable<{
  31692. framebufferWidth: number;
  31693. framebufferHeight: number;
  31694. }>);
  31695. /**
  31696. * Gets the current viewport
  31697. */
  31698. get currentViewport(): Nullable<IViewportLike>;
  31699. /**
  31700. * Gets the default empty texture
  31701. */
  31702. get emptyTexture(): InternalTexture;
  31703. /**
  31704. * Gets the default empty 3D texture
  31705. */
  31706. get emptyTexture3D(): InternalTexture;
  31707. /**
  31708. * Gets the default empty 2D array texture
  31709. */
  31710. get emptyTexture2DArray(): InternalTexture;
  31711. /**
  31712. * Gets the default empty cube texture
  31713. */
  31714. get emptyCubeTexture(): InternalTexture;
  31715. /**
  31716. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31717. */
  31718. readonly premultipliedAlpha: boolean;
  31719. /**
  31720. * Observable event triggered before each texture is initialized
  31721. */
  31722. onBeforeTextureInitObservable: Observable<Texture>;
  31723. /**
  31724. * Creates a new engine
  31725. * @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
  31726. * @param antialias defines enable antialiasing (default: false)
  31727. * @param options defines further options to be sent to the getContext() function
  31728. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31729. */
  31730. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31731. private _rebuildInternalTextures;
  31732. private _rebuildEffects;
  31733. /**
  31734. * Gets a boolean indicating if all created effects are ready
  31735. * @returns true if all effects are ready
  31736. */
  31737. areAllEffectsReady(): boolean;
  31738. protected _rebuildBuffers(): void;
  31739. protected _initGLContext(): void;
  31740. /**
  31741. * Gets version of the current webGL context
  31742. */
  31743. get webGLVersion(): number;
  31744. /**
  31745. * Gets a string idenfifying the name of the class
  31746. * @returns "Engine" string
  31747. */
  31748. getClassName(): string;
  31749. /**
  31750. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31751. */
  31752. get isStencilEnable(): boolean;
  31753. /** @hidden */
  31754. _prepareWorkingCanvas(): void;
  31755. /**
  31756. * Reset the texture cache to empty state
  31757. */
  31758. resetTextureCache(): void;
  31759. /**
  31760. * Gets an object containing information about the current webGL context
  31761. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31762. */
  31763. getGlInfo(): {
  31764. vendor: string;
  31765. renderer: string;
  31766. version: string;
  31767. };
  31768. /**
  31769. * Defines the hardware scaling level.
  31770. * By default the hardware scaling level is computed from the window device ratio.
  31771. * 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.
  31772. * @param level defines the level to use
  31773. */
  31774. setHardwareScalingLevel(level: number): void;
  31775. /**
  31776. * Gets the current hardware scaling level.
  31777. * By default the hardware scaling level is computed from the window device ratio.
  31778. * 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.
  31779. * @returns a number indicating the current hardware scaling level
  31780. */
  31781. getHardwareScalingLevel(): number;
  31782. /**
  31783. * Gets the list of loaded textures
  31784. * @returns an array containing all loaded textures
  31785. */
  31786. getLoadedTexturesCache(): InternalTexture[];
  31787. /**
  31788. * Gets the object containing all engine capabilities
  31789. * @returns the EngineCapabilities object
  31790. */
  31791. getCaps(): EngineCapabilities;
  31792. /**
  31793. * stop executing a render loop function and remove it from the execution array
  31794. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31795. */
  31796. stopRenderLoop(renderFunction?: () => void): void;
  31797. /** @hidden */
  31798. _renderLoop(): void;
  31799. /**
  31800. * Gets the HTML canvas attached with the current webGL context
  31801. * @returns a HTML canvas
  31802. */
  31803. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31804. /**
  31805. * Gets host window
  31806. * @returns the host window object
  31807. */
  31808. getHostWindow(): Nullable<Window>;
  31809. /**
  31810. * Gets the current render width
  31811. * @param useScreen defines if screen size must be used (or the current render target if any)
  31812. * @returns a number defining the current render width
  31813. */
  31814. getRenderWidth(useScreen?: boolean): number;
  31815. /**
  31816. * Gets the current render height
  31817. * @param useScreen defines if screen size must be used (or the current render target if any)
  31818. * @returns a number defining the current render height
  31819. */
  31820. getRenderHeight(useScreen?: boolean): number;
  31821. /**
  31822. * Can be used to override the current requestAnimationFrame requester.
  31823. * @hidden
  31824. */
  31825. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31826. /**
  31827. * Register and execute a render loop. The engine can have more than one render function
  31828. * @param renderFunction defines the function to continuously execute
  31829. */
  31830. runRenderLoop(renderFunction: () => void): void;
  31831. /**
  31832. * Clear the current render buffer or the current render target (if any is set up)
  31833. * @param color defines the color to use
  31834. * @param backBuffer defines if the back buffer must be cleared
  31835. * @param depth defines if the depth buffer must be cleared
  31836. * @param stencil defines if the stencil buffer must be cleared
  31837. */
  31838. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31839. private _viewportCached;
  31840. /** @hidden */
  31841. _viewport(x: number, y: number, width: number, height: number): void;
  31842. /**
  31843. * Set the WebGL's viewport
  31844. * @param viewport defines the viewport element to be used
  31845. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31846. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31847. */
  31848. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31849. /**
  31850. * Begin a new frame
  31851. */
  31852. beginFrame(): void;
  31853. /**
  31854. * Enf the current frame
  31855. */
  31856. endFrame(): void;
  31857. /**
  31858. * Resize the view according to the canvas' size
  31859. */
  31860. resize(): void;
  31861. /**
  31862. * Force a specific size of the canvas
  31863. * @param width defines the new canvas' width
  31864. * @param height defines the new canvas' height
  31865. */
  31866. setSize(width: number, height: number): void;
  31867. /**
  31868. * Binds the frame buffer to the specified texture.
  31869. * @param texture The texture to render to or null for the default canvas
  31870. * @param faceIndex The face of the texture to render to in case of cube texture
  31871. * @param requiredWidth The width of the target to render to
  31872. * @param requiredHeight The height of the target to render to
  31873. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31874. * @param lodLevel defines the lod level to bind to the frame buffer
  31875. * @param layer defines the 2d array index to bind to frame buffer to
  31876. */
  31877. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31878. /** @hidden */
  31879. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31880. /**
  31881. * Unbind the current render target texture from the webGL context
  31882. * @param texture defines the render target texture to unbind
  31883. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31884. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31885. */
  31886. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31887. /**
  31888. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31889. */
  31890. flushFramebuffer(): void;
  31891. /**
  31892. * Unbind the current render target and bind the default framebuffer
  31893. */
  31894. restoreDefaultFramebuffer(): void;
  31895. /** @hidden */
  31896. protected _resetVertexBufferBinding(): void;
  31897. /**
  31898. * Creates a vertex buffer
  31899. * @param data the data for the vertex buffer
  31900. * @returns the new WebGL static buffer
  31901. */
  31902. createVertexBuffer(data: DataArray): DataBuffer;
  31903. private _createVertexBuffer;
  31904. /**
  31905. * Creates a dynamic vertex buffer
  31906. * @param data the data for the dynamic vertex buffer
  31907. * @returns the new WebGL dynamic buffer
  31908. */
  31909. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31910. protected _resetIndexBufferBinding(): void;
  31911. /**
  31912. * Creates a new index buffer
  31913. * @param indices defines the content of the index buffer
  31914. * @param updatable defines if the index buffer must be updatable
  31915. * @returns a new webGL buffer
  31916. */
  31917. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31918. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31919. /**
  31920. * Bind a webGL buffer to the webGL context
  31921. * @param buffer defines the buffer to bind
  31922. */
  31923. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31924. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31925. private bindBuffer;
  31926. /**
  31927. * update the bound buffer with the given data
  31928. * @param data defines the data to update
  31929. */
  31930. updateArrayBuffer(data: Float32Array): void;
  31931. private _vertexAttribPointer;
  31932. /** @hidden */
  31933. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31934. private _bindVertexBuffersAttributes;
  31935. /**
  31936. * Records a vertex array object
  31937. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31938. * @param vertexBuffers defines the list of vertex buffers to store
  31939. * @param indexBuffer defines the index buffer to store
  31940. * @param effect defines the effect to store
  31941. * @returns the new vertex array object
  31942. */
  31943. recordVertexArrayObject(vertexBuffers: {
  31944. [key: string]: VertexBuffer;
  31945. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31946. /**
  31947. * Bind a specific vertex array object
  31948. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31949. * @param vertexArrayObject defines the vertex array object to bind
  31950. * @param indexBuffer defines the index buffer to bind
  31951. */
  31952. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31953. /**
  31954. * Bind webGl buffers directly to the webGL context
  31955. * @param vertexBuffer defines the vertex buffer to bind
  31956. * @param indexBuffer defines the index buffer to bind
  31957. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31958. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31959. * @param effect defines the effect associated with the vertex buffer
  31960. */
  31961. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31962. private _unbindVertexArrayObject;
  31963. /**
  31964. * Bind a list of vertex buffers to the webGL context
  31965. * @param vertexBuffers defines the list of vertex buffers to bind
  31966. * @param indexBuffer defines the index buffer to bind
  31967. * @param effect defines the effect associated with the vertex buffers
  31968. */
  31969. bindBuffers(vertexBuffers: {
  31970. [key: string]: Nullable<VertexBuffer>;
  31971. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31972. /**
  31973. * Unbind all instance attributes
  31974. */
  31975. unbindInstanceAttributes(): void;
  31976. /**
  31977. * Release and free the memory of a vertex array object
  31978. * @param vao defines the vertex array object to delete
  31979. */
  31980. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31981. /** @hidden */
  31982. _releaseBuffer(buffer: DataBuffer): boolean;
  31983. protected _deleteBuffer(buffer: DataBuffer): void;
  31984. /**
  31985. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31986. * @param instancesBuffer defines the webGL buffer to update and bind
  31987. * @param data defines the data to store in the buffer
  31988. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31989. */
  31990. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31991. /**
  31992. * Bind the content of a webGL buffer used with instantiation
  31993. * @param instancesBuffer defines the webGL buffer to bind
  31994. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31995. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31996. */
  31997. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31998. /**
  31999. * Disable the instance attribute corresponding to the name in parameter
  32000. * @param name defines the name of the attribute to disable
  32001. */
  32002. disableInstanceAttributeByName(name: string): void;
  32003. /**
  32004. * Disable the instance attribute corresponding to the location in parameter
  32005. * @param attributeLocation defines the attribute location of the attribute to disable
  32006. */
  32007. disableInstanceAttribute(attributeLocation: number): void;
  32008. /**
  32009. * Disable the attribute corresponding to the location in parameter
  32010. * @param attributeLocation defines the attribute location of the attribute to disable
  32011. */
  32012. disableAttributeByIndex(attributeLocation: number): void;
  32013. /**
  32014. * Send a draw order
  32015. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32016. * @param indexStart defines the starting index
  32017. * @param indexCount defines the number of index to draw
  32018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32019. */
  32020. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32021. /**
  32022. * Draw a list of points
  32023. * @param verticesStart defines the index of first vertex to draw
  32024. * @param verticesCount defines the count of vertices to draw
  32025. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32026. */
  32027. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32028. /**
  32029. * Draw a list of unindexed primitives
  32030. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32031. * @param verticesStart defines the index of first vertex to draw
  32032. * @param verticesCount defines the count of vertices to draw
  32033. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32034. */
  32035. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32036. /**
  32037. * Draw a list of indexed primitives
  32038. * @param fillMode defines the primitive to use
  32039. * @param indexStart defines the starting index
  32040. * @param indexCount defines the number of index to draw
  32041. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32042. */
  32043. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32044. /**
  32045. * Draw a list of unindexed primitives
  32046. * @param fillMode defines the primitive to use
  32047. * @param verticesStart defines the index of first vertex to draw
  32048. * @param verticesCount defines the count of vertices to draw
  32049. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32050. */
  32051. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32052. private _drawMode;
  32053. /** @hidden */
  32054. protected _reportDrawCall(): void;
  32055. /** @hidden */
  32056. _releaseEffect(effect: Effect): void;
  32057. /** @hidden */
  32058. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32059. /**
  32060. * Create a new effect (used to store vertex/fragment shaders)
  32061. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32062. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32063. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32064. * @param samplers defines an array of string used to represent textures
  32065. * @param defines defines the string containing the defines to use to compile the shaders
  32066. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32067. * @param onCompiled defines a function to call when the effect creation is successful
  32068. * @param onError defines a function to call when the effect creation has failed
  32069. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32070. * @returns the new Effect
  32071. */
  32072. 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;
  32073. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32074. private _compileShader;
  32075. private _compileRawShader;
  32076. /** @hidden */
  32077. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32078. /**
  32079. * Directly creates a webGL program
  32080. * @param pipelineContext defines the pipeline context to attach to
  32081. * @param vertexCode defines the vertex shader code to use
  32082. * @param fragmentCode defines the fragment shader code to use
  32083. * @param context defines the webGL context to use (if not set, the current one will be used)
  32084. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32085. * @returns the new webGL program
  32086. */
  32087. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32088. /**
  32089. * Creates a webGL program
  32090. * @param pipelineContext defines the pipeline context to attach to
  32091. * @param vertexCode defines the vertex shader code to use
  32092. * @param fragmentCode defines the fragment shader code to use
  32093. * @param defines defines the string containing the defines to use to compile the shaders
  32094. * @param context defines the webGL context to use (if not set, the current one will be used)
  32095. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32096. * @returns the new webGL program
  32097. */
  32098. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32099. /**
  32100. * Creates a new pipeline context
  32101. * @returns the new pipeline
  32102. */
  32103. createPipelineContext(): IPipelineContext;
  32104. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32105. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32106. /** @hidden */
  32107. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32108. /** @hidden */
  32109. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32110. /** @hidden */
  32111. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32112. /**
  32113. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32114. * @param pipelineContext defines the pipeline context to use
  32115. * @param uniformsNames defines the list of uniform names
  32116. * @returns an array of webGL uniform locations
  32117. */
  32118. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32119. /**
  32120. * Gets the lsit of active attributes for a given webGL program
  32121. * @param pipelineContext defines the pipeline context to use
  32122. * @param attributesNames defines the list of attribute names to get
  32123. * @returns an array of indices indicating the offset of each attribute
  32124. */
  32125. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32126. /**
  32127. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32128. * @param effect defines the effect to activate
  32129. */
  32130. enableEffect(effect: Nullable<Effect>): void;
  32131. /**
  32132. * Set the value of an uniform to a number (int)
  32133. * @param uniform defines the webGL uniform location where to store the value
  32134. * @param value defines the int number to store
  32135. */
  32136. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32137. /**
  32138. * Set the value of an uniform to an array of int32
  32139. * @param uniform defines the webGL uniform location where to store the value
  32140. * @param array defines the array of int32 to store
  32141. */
  32142. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32143. /**
  32144. * Set the value of an uniform to an array of int32 (stored as vec2)
  32145. * @param uniform defines the webGL uniform location where to store the value
  32146. * @param array defines the array of int32 to store
  32147. */
  32148. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32149. /**
  32150. * Set the value of an uniform to an array of int32 (stored as vec3)
  32151. * @param uniform defines the webGL uniform location where to store the value
  32152. * @param array defines the array of int32 to store
  32153. */
  32154. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32155. /**
  32156. * Set the value of an uniform to an array of int32 (stored as vec4)
  32157. * @param uniform defines the webGL uniform location where to store the value
  32158. * @param array defines the array of int32 to store
  32159. */
  32160. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32161. /**
  32162. * Set the value of an uniform to an array of number
  32163. * @param uniform defines the webGL uniform location where to store the value
  32164. * @param array defines the array of number to store
  32165. */
  32166. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32167. /**
  32168. * Set the value of an uniform to an array of number (stored as vec2)
  32169. * @param uniform defines the webGL uniform location where to store the value
  32170. * @param array defines the array of number to store
  32171. */
  32172. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32173. /**
  32174. * Set the value of an uniform to an array of number (stored as vec3)
  32175. * @param uniform defines the webGL uniform location where to store the value
  32176. * @param array defines the array of number to store
  32177. */
  32178. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32179. /**
  32180. * Set the value of an uniform to an array of number (stored as vec4)
  32181. * @param uniform defines the webGL uniform location where to store the value
  32182. * @param array defines the array of number to store
  32183. */
  32184. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32185. /**
  32186. * Set the value of an uniform to an array of float32 (stored as matrices)
  32187. * @param uniform defines the webGL uniform location where to store the value
  32188. * @param matrices defines the array of float32 to store
  32189. */
  32190. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32191. /**
  32192. * Set the value of an uniform to a matrix (3x3)
  32193. * @param uniform defines the webGL uniform location where to store the value
  32194. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32195. */
  32196. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32197. /**
  32198. * Set the value of an uniform to a matrix (2x2)
  32199. * @param uniform defines the webGL uniform location where to store the value
  32200. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32201. */
  32202. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32203. /**
  32204. * Set the value of an uniform to a number (float)
  32205. * @param uniform defines the webGL uniform location where to store the value
  32206. * @param value defines the float number to store
  32207. */
  32208. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32209. /**
  32210. * Set the value of an uniform to a vec2
  32211. * @param uniform defines the webGL uniform location where to store the value
  32212. * @param x defines the 1st component of the value
  32213. * @param y defines the 2nd component of the value
  32214. */
  32215. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32216. /**
  32217. * Set the value of an uniform to a vec3
  32218. * @param uniform defines the webGL uniform location where to store the value
  32219. * @param x defines the 1st component of the value
  32220. * @param y defines the 2nd component of the value
  32221. * @param z defines the 3rd component of the value
  32222. */
  32223. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32224. /**
  32225. * Set the value of an uniform to a vec4
  32226. * @param uniform defines the webGL uniform location where to store the value
  32227. * @param x defines the 1st component of the value
  32228. * @param y defines the 2nd component of the value
  32229. * @param z defines the 3rd component of the value
  32230. * @param w defines the 4th component of the value
  32231. */
  32232. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32233. /**
  32234. * Apply all cached states (depth, culling, stencil and alpha)
  32235. */
  32236. applyStates(): void;
  32237. /**
  32238. * Enable or disable color writing
  32239. * @param enable defines the state to set
  32240. */
  32241. setColorWrite(enable: boolean): void;
  32242. /**
  32243. * Gets a boolean indicating if color writing is enabled
  32244. * @returns the current color writing state
  32245. */
  32246. getColorWrite(): boolean;
  32247. /**
  32248. * Gets the depth culling state manager
  32249. */
  32250. get depthCullingState(): DepthCullingState;
  32251. /**
  32252. * Gets the alpha state manager
  32253. */
  32254. get alphaState(): AlphaState;
  32255. /**
  32256. * Gets the stencil state manager
  32257. */
  32258. get stencilState(): StencilState;
  32259. /**
  32260. * Clears the list of texture accessible through engine.
  32261. * This can help preventing texture load conflict due to name collision.
  32262. */
  32263. clearInternalTexturesCache(): void;
  32264. /**
  32265. * Force the entire cache to be cleared
  32266. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32267. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32268. */
  32269. wipeCaches(bruteForce?: boolean): void;
  32270. /** @hidden */
  32271. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32272. min: number;
  32273. mag: number;
  32274. };
  32275. /** @hidden */
  32276. _createTexture(): WebGLTexture;
  32277. /**
  32278. * Usually called from Texture.ts.
  32279. * Passed information to create a WebGLTexture
  32280. * @param url defines a value which contains one of the following:
  32281. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32282. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32283. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32284. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32285. * @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)
  32286. * @param scene needed for loading to the correct scene
  32287. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32288. * @param onLoad optional callback to be called upon successful completion
  32289. * @param onError optional callback to be called upon failure
  32290. * @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
  32291. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32292. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32293. * @param forcedExtension defines the extension to use to pick the right loader
  32294. * @param mimeType defines an optional mime type
  32295. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32296. */
  32297. 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;
  32298. /**
  32299. * Loads an image as an HTMLImageElement.
  32300. * @param input url string, ArrayBuffer, or Blob to load
  32301. * @param onLoad callback called when the image successfully loads
  32302. * @param onError callback called when the image fails to load
  32303. * @param offlineProvider offline provider for caching
  32304. * @param mimeType optional mime type
  32305. * @returns the HTMLImageElement of the loaded image
  32306. * @hidden
  32307. */
  32308. 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>;
  32309. /**
  32310. * @hidden
  32311. */
  32312. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32313. private _unpackFlipYCached;
  32314. /**
  32315. * In case you are sharing the context with other applications, it might
  32316. * be interested to not cache the unpack flip y state to ensure a consistent
  32317. * value would be set.
  32318. */
  32319. enableUnpackFlipYCached: boolean;
  32320. /** @hidden */
  32321. _unpackFlipY(value: boolean): void;
  32322. /** @hidden */
  32323. _getUnpackAlignement(): number;
  32324. private _getTextureTarget;
  32325. /**
  32326. * Update the sampling mode of a given texture
  32327. * @param samplingMode defines the required sampling mode
  32328. * @param texture defines the texture to update
  32329. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32330. */
  32331. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32332. /**
  32333. * Update the sampling mode of a given texture
  32334. * @param texture defines the texture to update
  32335. * @param wrapU defines the texture wrap mode of the u coordinates
  32336. * @param wrapV defines the texture wrap mode of the v coordinates
  32337. * @param wrapR defines the texture wrap mode of the r coordinates
  32338. */
  32339. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32340. /** @hidden */
  32341. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32342. width: number;
  32343. height: number;
  32344. layers?: number;
  32345. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32346. /** @hidden */
  32347. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32348. /** @hidden */
  32349. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32350. /**
  32351. * Update a portion of an internal texture
  32352. * @param texture defines the texture to update
  32353. * @param imageData defines the data to store into the texture
  32354. * @param xOffset defines the x coordinates of the update rectangle
  32355. * @param yOffset defines the y coordinates of the update rectangle
  32356. * @param width defines the width of the update rectangle
  32357. * @param height defines the height of the update rectangle
  32358. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32359. * @param lod defines the lod level to update (0 by default)
  32360. */
  32361. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32362. /** @hidden */
  32363. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32364. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32365. private _prepareWebGLTexture;
  32366. /** @hidden */
  32367. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32368. private _getDepthStencilBuffer;
  32369. /** @hidden */
  32370. _releaseFramebufferObjects(texture: InternalTexture): void;
  32371. /** @hidden */
  32372. _releaseTexture(texture: InternalTexture): void;
  32373. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32374. protected _setProgram(program: WebGLProgram): void;
  32375. protected _boundUniforms: {
  32376. [key: number]: WebGLUniformLocation;
  32377. };
  32378. /**
  32379. * Binds an effect to the webGL context
  32380. * @param effect defines the effect to bind
  32381. */
  32382. bindSamplers(effect: Effect): void;
  32383. private _activateCurrentTexture;
  32384. /** @hidden */
  32385. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32386. /** @hidden */
  32387. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32388. /**
  32389. * Unbind all textures from the webGL context
  32390. */
  32391. unbindAllTextures(): void;
  32392. /**
  32393. * Sets a texture to the according uniform.
  32394. * @param channel The texture channel
  32395. * @param uniform The uniform to set
  32396. * @param texture The texture to apply
  32397. */
  32398. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32399. private _bindSamplerUniformToChannel;
  32400. private _getTextureWrapMode;
  32401. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32402. /**
  32403. * Sets an array of texture to the webGL context
  32404. * @param channel defines the channel where the texture array must be set
  32405. * @param uniform defines the associated uniform location
  32406. * @param textures defines the array of textures to bind
  32407. */
  32408. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32409. /** @hidden */
  32410. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32411. private _setTextureParameterFloat;
  32412. private _setTextureParameterInteger;
  32413. /**
  32414. * Unbind all vertex attributes from the webGL context
  32415. */
  32416. unbindAllAttributes(): void;
  32417. /**
  32418. * 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
  32419. */
  32420. releaseEffects(): void;
  32421. /**
  32422. * Dispose and release all associated resources
  32423. */
  32424. dispose(): void;
  32425. /**
  32426. * Attach a new callback raised when context lost event is fired
  32427. * @param callback defines the callback to call
  32428. */
  32429. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32430. /**
  32431. * Attach a new callback raised when context restored event is fired
  32432. * @param callback defines the callback to call
  32433. */
  32434. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32435. /**
  32436. * Get the current error code of the webGL context
  32437. * @returns the error code
  32438. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32439. */
  32440. getError(): number;
  32441. private _canRenderToFloatFramebuffer;
  32442. private _canRenderToHalfFloatFramebuffer;
  32443. private _canRenderToFramebuffer;
  32444. /** @hidden */
  32445. _getWebGLTextureType(type: number): number;
  32446. /** @hidden */
  32447. _getInternalFormat(format: number): number;
  32448. /** @hidden */
  32449. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32450. /** @hidden */
  32451. _getRGBAMultiSampleBufferFormat(type: number): number;
  32452. /** @hidden */
  32453. _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;
  32454. /**
  32455. * Loads a file from a url
  32456. * @param url url to load
  32457. * @param onSuccess callback called when the file successfully loads
  32458. * @param onProgress callback called while file is loading (if the server supports this mode)
  32459. * @param offlineProvider defines the offline provider for caching
  32460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32461. * @param onError callback called when the file fails to load
  32462. * @returns a file request object
  32463. * @hidden
  32464. */
  32465. 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;
  32466. /**
  32467. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32468. * @param x defines the x coordinate of the rectangle where pixels must be read
  32469. * @param y defines the y coordinate of the rectangle where pixels must be read
  32470. * @param width defines the width of the rectangle where pixels must be read
  32471. * @param height defines the height of the rectangle where pixels must be read
  32472. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32473. * @returns a Uint8Array containing RGBA colors
  32474. */
  32475. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32476. private static _isSupported;
  32477. /**
  32478. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32479. * @returns true if the engine can be created
  32480. * @ignorenaming
  32481. */
  32482. static isSupported(): boolean;
  32483. /**
  32484. * Find the next highest power of two.
  32485. * @param x Number to start search from.
  32486. * @return Next highest power of two.
  32487. */
  32488. static CeilingPOT(x: number): number;
  32489. /**
  32490. * Find the next lowest power of two.
  32491. * @param x Number to start search from.
  32492. * @return Next lowest power of two.
  32493. */
  32494. static FloorPOT(x: number): number;
  32495. /**
  32496. * Find the nearest power of two.
  32497. * @param x Number to start search from.
  32498. * @return Next nearest power of two.
  32499. */
  32500. static NearestPOT(x: number): number;
  32501. /**
  32502. * Get the closest exponent of two
  32503. * @param value defines the value to approximate
  32504. * @param max defines the maximum value to return
  32505. * @param mode defines how to define the closest value
  32506. * @returns closest exponent of two of the given value
  32507. */
  32508. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32509. /**
  32510. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32511. * @param func - the function to be called
  32512. * @param requester - the object that will request the next frame. Falls back to window.
  32513. * @returns frame number
  32514. */
  32515. static QueueNewFrame(func: () => void, requester?: any): number;
  32516. /**
  32517. * Gets host document
  32518. * @returns the host document object
  32519. */
  32520. getHostDocument(): Nullable<Document>;
  32521. }
  32522. }
  32523. declare module BABYLON {
  32524. /**
  32525. * Class representing spherical harmonics coefficients to the 3rd degree
  32526. */
  32527. export class SphericalHarmonics {
  32528. /**
  32529. * Defines whether or not the harmonics have been prescaled for rendering.
  32530. */
  32531. preScaled: boolean;
  32532. /**
  32533. * The l0,0 coefficients of the spherical harmonics
  32534. */
  32535. l00: Vector3;
  32536. /**
  32537. * The l1,-1 coefficients of the spherical harmonics
  32538. */
  32539. l1_1: Vector3;
  32540. /**
  32541. * The l1,0 coefficients of the spherical harmonics
  32542. */
  32543. l10: Vector3;
  32544. /**
  32545. * The l1,1 coefficients of the spherical harmonics
  32546. */
  32547. l11: Vector3;
  32548. /**
  32549. * The l2,-2 coefficients of the spherical harmonics
  32550. */
  32551. l2_2: Vector3;
  32552. /**
  32553. * The l2,-1 coefficients of the spherical harmonics
  32554. */
  32555. l2_1: Vector3;
  32556. /**
  32557. * The l2,0 coefficients of the spherical harmonics
  32558. */
  32559. l20: Vector3;
  32560. /**
  32561. * The l2,1 coefficients of the spherical harmonics
  32562. */
  32563. l21: Vector3;
  32564. /**
  32565. * The l2,2 coefficients of the spherical harmonics
  32566. */
  32567. l22: Vector3;
  32568. /**
  32569. * Adds a light to the spherical harmonics
  32570. * @param direction the direction of the light
  32571. * @param color the color of the light
  32572. * @param deltaSolidAngle the delta solid angle of the light
  32573. */
  32574. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32575. /**
  32576. * Scales the spherical harmonics by the given amount
  32577. * @param scale the amount to scale
  32578. */
  32579. scaleInPlace(scale: number): void;
  32580. /**
  32581. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32582. *
  32583. * ```
  32584. * E_lm = A_l * L_lm
  32585. * ```
  32586. *
  32587. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32588. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32589. * the scaling factors are given in equation 9.
  32590. */
  32591. convertIncidentRadianceToIrradiance(): void;
  32592. /**
  32593. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32594. *
  32595. * ```
  32596. * L = (1/pi) * E * rho
  32597. * ```
  32598. *
  32599. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32600. */
  32601. convertIrradianceToLambertianRadiance(): void;
  32602. /**
  32603. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32604. * required operations at run time.
  32605. *
  32606. * This is simply done by scaling back the SH with Ylm constants parameter.
  32607. * The trigonometric part being applied by the shader at run time.
  32608. */
  32609. preScaleForRendering(): void;
  32610. /**
  32611. * Constructs a spherical harmonics from an array.
  32612. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32613. * @returns the spherical harmonics
  32614. */
  32615. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32616. /**
  32617. * Gets the spherical harmonics from polynomial
  32618. * @param polynomial the spherical polynomial
  32619. * @returns the spherical harmonics
  32620. */
  32621. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32622. }
  32623. /**
  32624. * Class representing spherical polynomial coefficients to the 3rd degree
  32625. */
  32626. export class SphericalPolynomial {
  32627. private _harmonics;
  32628. /**
  32629. * The spherical harmonics used to create the polynomials.
  32630. */
  32631. get preScaledHarmonics(): SphericalHarmonics;
  32632. /**
  32633. * The x coefficients of the spherical polynomial
  32634. */
  32635. x: Vector3;
  32636. /**
  32637. * The y coefficients of the spherical polynomial
  32638. */
  32639. y: Vector3;
  32640. /**
  32641. * The z coefficients of the spherical polynomial
  32642. */
  32643. z: Vector3;
  32644. /**
  32645. * The xx coefficients of the spherical polynomial
  32646. */
  32647. xx: Vector3;
  32648. /**
  32649. * The yy coefficients of the spherical polynomial
  32650. */
  32651. yy: Vector3;
  32652. /**
  32653. * The zz coefficients of the spherical polynomial
  32654. */
  32655. zz: Vector3;
  32656. /**
  32657. * The xy coefficients of the spherical polynomial
  32658. */
  32659. xy: Vector3;
  32660. /**
  32661. * The yz coefficients of the spherical polynomial
  32662. */
  32663. yz: Vector3;
  32664. /**
  32665. * The zx coefficients of the spherical polynomial
  32666. */
  32667. zx: Vector3;
  32668. /**
  32669. * Adds an ambient color to the spherical polynomial
  32670. * @param color the color to add
  32671. */
  32672. addAmbient(color: Color3): void;
  32673. /**
  32674. * Scales the spherical polynomial by the given amount
  32675. * @param scale the amount to scale
  32676. */
  32677. scaleInPlace(scale: number): void;
  32678. /**
  32679. * Gets the spherical polynomial from harmonics
  32680. * @param harmonics the spherical harmonics
  32681. * @returns the spherical polynomial
  32682. */
  32683. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32684. /**
  32685. * Constructs a spherical polynomial from an array.
  32686. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32687. * @returns the spherical polynomial
  32688. */
  32689. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32690. }
  32691. }
  32692. declare module BABYLON {
  32693. /**
  32694. * Defines the source of the internal texture
  32695. */
  32696. export enum InternalTextureSource {
  32697. /**
  32698. * The source of the texture data is unknown
  32699. */
  32700. Unknown = 0,
  32701. /**
  32702. * Texture data comes from an URL
  32703. */
  32704. Url = 1,
  32705. /**
  32706. * Texture data is only used for temporary storage
  32707. */
  32708. Temp = 2,
  32709. /**
  32710. * Texture data comes from raw data (ArrayBuffer)
  32711. */
  32712. Raw = 3,
  32713. /**
  32714. * Texture content is dynamic (video or dynamic texture)
  32715. */
  32716. Dynamic = 4,
  32717. /**
  32718. * Texture content is generated by rendering to it
  32719. */
  32720. RenderTarget = 5,
  32721. /**
  32722. * Texture content is part of a multi render target process
  32723. */
  32724. MultiRenderTarget = 6,
  32725. /**
  32726. * Texture data comes from a cube data file
  32727. */
  32728. Cube = 7,
  32729. /**
  32730. * Texture data comes from a raw cube data
  32731. */
  32732. CubeRaw = 8,
  32733. /**
  32734. * Texture data come from a prefiltered cube data file
  32735. */
  32736. CubePrefiltered = 9,
  32737. /**
  32738. * Texture content is raw 3D data
  32739. */
  32740. Raw3D = 10,
  32741. /**
  32742. * Texture content is raw 2D array data
  32743. */
  32744. Raw2DArray = 11,
  32745. /**
  32746. * Texture content is a depth texture
  32747. */
  32748. Depth = 12,
  32749. /**
  32750. * Texture data comes from a raw cube data encoded with RGBD
  32751. */
  32752. CubeRawRGBD = 13
  32753. }
  32754. /**
  32755. * Class used to store data associated with WebGL texture data for the engine
  32756. * This class should not be used directly
  32757. */
  32758. export class InternalTexture {
  32759. /** @hidden */
  32760. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32761. /**
  32762. * Defines if the texture is ready
  32763. */
  32764. isReady: boolean;
  32765. /**
  32766. * Defines if the texture is a cube texture
  32767. */
  32768. isCube: boolean;
  32769. /**
  32770. * Defines if the texture contains 3D data
  32771. */
  32772. is3D: boolean;
  32773. /**
  32774. * Defines if the texture contains 2D array data
  32775. */
  32776. is2DArray: boolean;
  32777. /**
  32778. * Defines if the texture contains multiview data
  32779. */
  32780. isMultiview: boolean;
  32781. /**
  32782. * Gets the URL used to load this texture
  32783. */
  32784. url: string;
  32785. /**
  32786. * Gets the sampling mode of the texture
  32787. */
  32788. samplingMode: number;
  32789. /**
  32790. * Gets a boolean indicating if the texture needs mipmaps generation
  32791. */
  32792. generateMipMaps: boolean;
  32793. /**
  32794. * Gets the number of samples used by the texture (WebGL2+ only)
  32795. */
  32796. samples: number;
  32797. /**
  32798. * Gets the type of the texture (int, float...)
  32799. */
  32800. type: number;
  32801. /**
  32802. * Gets the format of the texture (RGB, RGBA...)
  32803. */
  32804. format: number;
  32805. /**
  32806. * Observable called when the texture is loaded
  32807. */
  32808. onLoadedObservable: Observable<InternalTexture>;
  32809. /**
  32810. * Gets the width of the texture
  32811. */
  32812. width: number;
  32813. /**
  32814. * Gets the height of the texture
  32815. */
  32816. height: number;
  32817. /**
  32818. * Gets the depth of the texture
  32819. */
  32820. depth: number;
  32821. /**
  32822. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32823. */
  32824. baseWidth: number;
  32825. /**
  32826. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32827. */
  32828. baseHeight: number;
  32829. /**
  32830. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32831. */
  32832. baseDepth: number;
  32833. /**
  32834. * Gets a boolean indicating if the texture is inverted on Y axis
  32835. */
  32836. invertY: boolean;
  32837. /** @hidden */
  32838. _invertVScale: boolean;
  32839. /** @hidden */
  32840. _associatedChannel: number;
  32841. /** @hidden */
  32842. _source: InternalTextureSource;
  32843. /** @hidden */
  32844. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32845. /** @hidden */
  32846. _bufferView: Nullable<ArrayBufferView>;
  32847. /** @hidden */
  32848. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32849. /** @hidden */
  32850. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32851. /** @hidden */
  32852. _size: number;
  32853. /** @hidden */
  32854. _extension: string;
  32855. /** @hidden */
  32856. _files: Nullable<string[]>;
  32857. /** @hidden */
  32858. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32859. /** @hidden */
  32860. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32861. /** @hidden */
  32862. _framebuffer: Nullable<WebGLFramebuffer>;
  32863. /** @hidden */
  32864. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32865. /** @hidden */
  32866. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32867. /** @hidden */
  32868. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32869. /** @hidden */
  32870. _attachments: Nullable<number[]>;
  32871. /** @hidden */
  32872. _cachedCoordinatesMode: Nullable<number>;
  32873. /** @hidden */
  32874. _cachedWrapU: Nullable<number>;
  32875. /** @hidden */
  32876. _cachedWrapV: Nullable<number>;
  32877. /** @hidden */
  32878. _cachedWrapR: Nullable<number>;
  32879. /** @hidden */
  32880. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32881. /** @hidden */
  32882. _isDisabled: boolean;
  32883. /** @hidden */
  32884. _compression: Nullable<string>;
  32885. /** @hidden */
  32886. _generateStencilBuffer: boolean;
  32887. /** @hidden */
  32888. _generateDepthBuffer: boolean;
  32889. /** @hidden */
  32890. _comparisonFunction: number;
  32891. /** @hidden */
  32892. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32893. /** @hidden */
  32894. _lodGenerationScale: number;
  32895. /** @hidden */
  32896. _lodGenerationOffset: number;
  32897. /** @hidden */
  32898. _depthStencilTexture: Nullable<InternalTexture>;
  32899. /** @hidden */
  32900. _colorTextureArray: Nullable<WebGLTexture>;
  32901. /** @hidden */
  32902. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32903. /** @hidden */
  32904. _lodTextureHigh: Nullable<BaseTexture>;
  32905. /** @hidden */
  32906. _lodTextureMid: Nullable<BaseTexture>;
  32907. /** @hidden */
  32908. _lodTextureLow: Nullable<BaseTexture>;
  32909. /** @hidden */
  32910. _isRGBD: boolean;
  32911. /** @hidden */
  32912. _linearSpecularLOD: boolean;
  32913. /** @hidden */
  32914. _irradianceTexture: Nullable<BaseTexture>;
  32915. /** @hidden */
  32916. _webGLTexture: Nullable<WebGLTexture>;
  32917. /** @hidden */
  32918. _references: number;
  32919. private _engine;
  32920. /**
  32921. * Gets the Engine the texture belongs to.
  32922. * @returns The babylon engine
  32923. */
  32924. getEngine(): ThinEngine;
  32925. /**
  32926. * Gets the data source type of the texture
  32927. */
  32928. get source(): InternalTextureSource;
  32929. /**
  32930. * Creates a new InternalTexture
  32931. * @param engine defines the engine to use
  32932. * @param source defines the type of data that will be used
  32933. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32934. */
  32935. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32936. /**
  32937. * Increments the number of references (ie. the number of Texture that point to it)
  32938. */
  32939. incrementReferences(): void;
  32940. /**
  32941. * Change the size of the texture (not the size of the content)
  32942. * @param width defines the new width
  32943. * @param height defines the new height
  32944. * @param depth defines the new depth (1 by default)
  32945. */
  32946. updateSize(width: int, height: int, depth?: int): void;
  32947. /** @hidden */
  32948. _rebuild(): void;
  32949. /** @hidden */
  32950. _swapAndDie(target: InternalTexture): void;
  32951. /**
  32952. * Dispose the current allocated resources
  32953. */
  32954. dispose(): void;
  32955. }
  32956. }
  32957. declare module BABYLON {
  32958. /**
  32959. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32961. */
  32962. export class Analyser {
  32963. /**
  32964. * Gets or sets the smoothing
  32965. * @ignorenaming
  32966. */
  32967. SMOOTHING: number;
  32968. /**
  32969. * Gets or sets the FFT table size
  32970. * @ignorenaming
  32971. */
  32972. FFT_SIZE: number;
  32973. /**
  32974. * Gets or sets the bar graph amplitude
  32975. * @ignorenaming
  32976. */
  32977. BARGRAPHAMPLITUDE: number;
  32978. /**
  32979. * Gets or sets the position of the debug canvas
  32980. * @ignorenaming
  32981. */
  32982. DEBUGCANVASPOS: {
  32983. x: number;
  32984. y: number;
  32985. };
  32986. /**
  32987. * Gets or sets the debug canvas size
  32988. * @ignorenaming
  32989. */
  32990. DEBUGCANVASSIZE: {
  32991. width: number;
  32992. height: number;
  32993. };
  32994. private _byteFreqs;
  32995. private _byteTime;
  32996. private _floatFreqs;
  32997. private _webAudioAnalyser;
  32998. private _debugCanvas;
  32999. private _debugCanvasContext;
  33000. private _scene;
  33001. private _registerFunc;
  33002. private _audioEngine;
  33003. /**
  33004. * Creates a new analyser
  33005. * @param scene defines hosting scene
  33006. */
  33007. constructor(scene: Scene);
  33008. /**
  33009. * Get the number of data values you will have to play with for the visualization
  33010. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33011. * @returns a number
  33012. */
  33013. getFrequencyBinCount(): number;
  33014. /**
  33015. * Gets the current frequency data as a byte array
  33016. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33017. * @returns a Uint8Array
  33018. */
  33019. getByteFrequencyData(): Uint8Array;
  33020. /**
  33021. * Gets the current waveform as a byte array
  33022. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33023. * @returns a Uint8Array
  33024. */
  33025. getByteTimeDomainData(): Uint8Array;
  33026. /**
  33027. * Gets the current frequency data as a float array
  33028. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33029. * @returns a Float32Array
  33030. */
  33031. getFloatFrequencyData(): Float32Array;
  33032. /**
  33033. * Renders the debug canvas
  33034. */
  33035. drawDebugCanvas(): void;
  33036. /**
  33037. * Stops rendering the debug canvas and removes it
  33038. */
  33039. stopDebugCanvas(): void;
  33040. /**
  33041. * Connects two audio nodes
  33042. * @param inputAudioNode defines first node to connect
  33043. * @param outputAudioNode defines second node to connect
  33044. */
  33045. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33046. /**
  33047. * Releases all associated resources
  33048. */
  33049. dispose(): void;
  33050. }
  33051. }
  33052. declare module BABYLON {
  33053. /**
  33054. * This represents an audio engine and it is responsible
  33055. * to play, synchronize and analyse sounds throughout the application.
  33056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33057. */
  33058. export interface IAudioEngine extends IDisposable {
  33059. /**
  33060. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33061. */
  33062. readonly canUseWebAudio: boolean;
  33063. /**
  33064. * Gets the current AudioContext if available.
  33065. */
  33066. readonly audioContext: Nullable<AudioContext>;
  33067. /**
  33068. * The master gain node defines the global audio volume of your audio engine.
  33069. */
  33070. readonly masterGain: GainNode;
  33071. /**
  33072. * Gets whether or not mp3 are supported by your browser.
  33073. */
  33074. readonly isMP3supported: boolean;
  33075. /**
  33076. * Gets whether or not ogg are supported by your browser.
  33077. */
  33078. readonly isOGGsupported: boolean;
  33079. /**
  33080. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33081. * @ignoreNaming
  33082. */
  33083. WarnedWebAudioUnsupported: boolean;
  33084. /**
  33085. * Defines if the audio engine relies on a custom unlocked button.
  33086. * In this case, the embedded button will not be displayed.
  33087. */
  33088. useCustomUnlockedButton: boolean;
  33089. /**
  33090. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33091. */
  33092. readonly unlocked: boolean;
  33093. /**
  33094. * Event raised when audio has been unlocked on the browser.
  33095. */
  33096. onAudioUnlockedObservable: Observable<AudioEngine>;
  33097. /**
  33098. * Event raised when audio has been locked on the browser.
  33099. */
  33100. onAudioLockedObservable: Observable<AudioEngine>;
  33101. /**
  33102. * Flags the audio engine in Locked state.
  33103. * This happens due to new browser policies preventing audio to autoplay.
  33104. */
  33105. lock(): void;
  33106. /**
  33107. * Unlocks the audio engine once a user action has been done on the dom.
  33108. * This is helpful to resume play once browser policies have been satisfied.
  33109. */
  33110. unlock(): void;
  33111. /**
  33112. * Gets the global volume sets on the master gain.
  33113. * @returns the global volume if set or -1 otherwise
  33114. */
  33115. getGlobalVolume(): number;
  33116. /**
  33117. * Sets the global volume of your experience (sets on the master gain).
  33118. * @param newVolume Defines the new global volume of the application
  33119. */
  33120. setGlobalVolume(newVolume: number): void;
  33121. /**
  33122. * Connect the audio engine to an audio analyser allowing some amazing
  33123. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33125. * @param analyser The analyser to connect to the engine
  33126. */
  33127. connectToAnalyser(analyser: Analyser): void;
  33128. }
  33129. /**
  33130. * This represents the default audio engine used in babylon.
  33131. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33133. */
  33134. export class AudioEngine implements IAudioEngine {
  33135. private _audioContext;
  33136. private _audioContextInitialized;
  33137. private _muteButton;
  33138. private _hostElement;
  33139. /**
  33140. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33141. */
  33142. canUseWebAudio: boolean;
  33143. /**
  33144. * The master gain node defines the global audio volume of your audio engine.
  33145. */
  33146. masterGain: GainNode;
  33147. /**
  33148. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33149. * @ignoreNaming
  33150. */
  33151. WarnedWebAudioUnsupported: boolean;
  33152. /**
  33153. * Gets whether or not mp3 are supported by your browser.
  33154. */
  33155. isMP3supported: boolean;
  33156. /**
  33157. * Gets whether or not ogg are supported by your browser.
  33158. */
  33159. isOGGsupported: boolean;
  33160. /**
  33161. * Gets whether audio has been unlocked on the device.
  33162. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33163. * a user interaction has happened.
  33164. */
  33165. unlocked: boolean;
  33166. /**
  33167. * Defines if the audio engine relies on a custom unlocked button.
  33168. * In this case, the embedded button will not be displayed.
  33169. */
  33170. useCustomUnlockedButton: boolean;
  33171. /**
  33172. * Event raised when audio has been unlocked on the browser.
  33173. */
  33174. onAudioUnlockedObservable: Observable<AudioEngine>;
  33175. /**
  33176. * Event raised when audio has been locked on the browser.
  33177. */
  33178. onAudioLockedObservable: Observable<AudioEngine>;
  33179. /**
  33180. * Gets the current AudioContext if available.
  33181. */
  33182. get audioContext(): Nullable<AudioContext>;
  33183. private _connectedAnalyser;
  33184. /**
  33185. * Instantiates a new audio engine.
  33186. *
  33187. * There should be only one per page as some browsers restrict the number
  33188. * of audio contexts you can create.
  33189. * @param hostElement defines the host element where to display the mute icon if necessary
  33190. */
  33191. constructor(hostElement?: Nullable<HTMLElement>);
  33192. /**
  33193. * Flags the audio engine in Locked state.
  33194. * This happens due to new browser policies preventing audio to autoplay.
  33195. */
  33196. lock(): void;
  33197. /**
  33198. * Unlocks the audio engine once a user action has been done on the dom.
  33199. * This is helpful to resume play once browser policies have been satisfied.
  33200. */
  33201. unlock(): void;
  33202. private _resumeAudioContext;
  33203. private _initializeAudioContext;
  33204. private _tryToRun;
  33205. private _triggerRunningState;
  33206. private _triggerSuspendedState;
  33207. private _displayMuteButton;
  33208. private _moveButtonToTopLeft;
  33209. private _onResize;
  33210. private _hideMuteButton;
  33211. /**
  33212. * Destroy and release the resources associated with the audio ccontext.
  33213. */
  33214. dispose(): void;
  33215. /**
  33216. * Gets the global volume sets on the master gain.
  33217. * @returns the global volume if set or -1 otherwise
  33218. */
  33219. getGlobalVolume(): number;
  33220. /**
  33221. * Sets the global volume of your experience (sets on the master gain).
  33222. * @param newVolume Defines the new global volume of the application
  33223. */
  33224. setGlobalVolume(newVolume: number): void;
  33225. /**
  33226. * Connect the audio engine to an audio analyser allowing some amazing
  33227. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33229. * @param analyser The analyser to connect to the engine
  33230. */
  33231. connectToAnalyser(analyser: Analyser): void;
  33232. }
  33233. }
  33234. declare module BABYLON {
  33235. /**
  33236. * Interface used to present a loading screen while loading a scene
  33237. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33238. */
  33239. export interface ILoadingScreen {
  33240. /**
  33241. * Function called to display the loading screen
  33242. */
  33243. displayLoadingUI: () => void;
  33244. /**
  33245. * Function called to hide the loading screen
  33246. */
  33247. hideLoadingUI: () => void;
  33248. /**
  33249. * Gets or sets the color to use for the background
  33250. */
  33251. loadingUIBackgroundColor: string;
  33252. /**
  33253. * Gets or sets the text to display while loading
  33254. */
  33255. loadingUIText: string;
  33256. }
  33257. /**
  33258. * Class used for the default loading screen
  33259. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33260. */
  33261. export class DefaultLoadingScreen implements ILoadingScreen {
  33262. private _renderingCanvas;
  33263. private _loadingText;
  33264. private _loadingDivBackgroundColor;
  33265. private _loadingDiv;
  33266. private _loadingTextDiv;
  33267. /** Gets or sets the logo url to use for the default loading screen */
  33268. static DefaultLogoUrl: string;
  33269. /** Gets or sets the spinner url to use for the default loading screen */
  33270. static DefaultSpinnerUrl: string;
  33271. /**
  33272. * Creates a new default loading screen
  33273. * @param _renderingCanvas defines the canvas used to render the scene
  33274. * @param _loadingText defines the default text to display
  33275. * @param _loadingDivBackgroundColor defines the default background color
  33276. */
  33277. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33278. /**
  33279. * Function called to display the loading screen
  33280. */
  33281. displayLoadingUI(): void;
  33282. /**
  33283. * Function called to hide the loading screen
  33284. */
  33285. hideLoadingUI(): void;
  33286. /**
  33287. * Gets or sets the text to display while loading
  33288. */
  33289. set loadingUIText(text: string);
  33290. get loadingUIText(): string;
  33291. /**
  33292. * Gets or sets the color to use for the background
  33293. */
  33294. get loadingUIBackgroundColor(): string;
  33295. set loadingUIBackgroundColor(color: string);
  33296. private _resizeLoadingUI;
  33297. }
  33298. }
  33299. declare module BABYLON {
  33300. /**
  33301. * Interface for any object that can request an animation frame
  33302. */
  33303. export interface ICustomAnimationFrameRequester {
  33304. /**
  33305. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33306. */
  33307. renderFunction?: Function;
  33308. /**
  33309. * Called to request the next frame to render to
  33310. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33311. */
  33312. requestAnimationFrame: Function;
  33313. /**
  33314. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33315. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33316. */
  33317. requestID?: number;
  33318. }
  33319. }
  33320. declare module BABYLON {
  33321. /**
  33322. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33323. */
  33324. export class PerformanceMonitor {
  33325. private _enabled;
  33326. private _rollingFrameTime;
  33327. private _lastFrameTimeMs;
  33328. /**
  33329. * constructor
  33330. * @param frameSampleSize The number of samples required to saturate the sliding window
  33331. */
  33332. constructor(frameSampleSize?: number);
  33333. /**
  33334. * Samples current frame
  33335. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33336. */
  33337. sampleFrame(timeMs?: number): void;
  33338. /**
  33339. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33340. */
  33341. get averageFrameTime(): number;
  33342. /**
  33343. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33344. */
  33345. get averageFrameTimeVariance(): number;
  33346. /**
  33347. * Returns the frame time of the most recent frame
  33348. */
  33349. get instantaneousFrameTime(): number;
  33350. /**
  33351. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33352. */
  33353. get averageFPS(): number;
  33354. /**
  33355. * Returns the average framerate in frames per second using the most recent frame time
  33356. */
  33357. get instantaneousFPS(): number;
  33358. /**
  33359. * Returns true if enough samples have been taken to completely fill the sliding window
  33360. */
  33361. get isSaturated(): boolean;
  33362. /**
  33363. * Enables contributions to the sliding window sample set
  33364. */
  33365. enable(): void;
  33366. /**
  33367. * Disables contributions to the sliding window sample set
  33368. * Samples will not be interpolated over the disabled period
  33369. */
  33370. disable(): void;
  33371. /**
  33372. * Returns true if sampling is enabled
  33373. */
  33374. get isEnabled(): boolean;
  33375. /**
  33376. * Resets performance monitor
  33377. */
  33378. reset(): void;
  33379. }
  33380. /**
  33381. * RollingAverage
  33382. *
  33383. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33384. */
  33385. export class RollingAverage {
  33386. /**
  33387. * Current average
  33388. */
  33389. average: number;
  33390. /**
  33391. * Current variance
  33392. */
  33393. variance: number;
  33394. protected _samples: Array<number>;
  33395. protected _sampleCount: number;
  33396. protected _pos: number;
  33397. protected _m2: number;
  33398. /**
  33399. * constructor
  33400. * @param length The number of samples required to saturate the sliding window
  33401. */
  33402. constructor(length: number);
  33403. /**
  33404. * Adds a sample to the sample set
  33405. * @param v The sample value
  33406. */
  33407. add(v: number): void;
  33408. /**
  33409. * Returns previously added values or null if outside of history or outside the sliding window domain
  33410. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33411. * @return Value previously recorded with add() or null if outside of range
  33412. */
  33413. history(i: number): number;
  33414. /**
  33415. * Returns true if enough samples have been taken to completely fill the sliding window
  33416. * @return true if sample-set saturated
  33417. */
  33418. isSaturated(): boolean;
  33419. /**
  33420. * Resets the rolling average (equivalent to 0 samples taken so far)
  33421. */
  33422. reset(): void;
  33423. /**
  33424. * Wraps a value around the sample range boundaries
  33425. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33426. * @return Wrapped position in sample range
  33427. */
  33428. protected _wrapPosition(i: number): number;
  33429. }
  33430. }
  33431. declare module BABYLON {
  33432. /**
  33433. * This class is used to track a performance counter which is number based.
  33434. * The user has access to many properties which give statistics of different nature.
  33435. *
  33436. * The implementer can track two kinds of Performance Counter: time and count.
  33437. * 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.
  33438. * 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.
  33439. */
  33440. export class PerfCounter {
  33441. /**
  33442. * Gets or sets a global boolean to turn on and off all the counters
  33443. */
  33444. static Enabled: boolean;
  33445. /**
  33446. * Returns the smallest value ever
  33447. */
  33448. get min(): number;
  33449. /**
  33450. * Returns the biggest value ever
  33451. */
  33452. get max(): number;
  33453. /**
  33454. * Returns the average value since the performance counter is running
  33455. */
  33456. get average(): number;
  33457. /**
  33458. * Returns the average value of the last second the counter was monitored
  33459. */
  33460. get lastSecAverage(): number;
  33461. /**
  33462. * Returns the current value
  33463. */
  33464. get current(): number;
  33465. /**
  33466. * Gets the accumulated total
  33467. */
  33468. get total(): number;
  33469. /**
  33470. * Gets the total value count
  33471. */
  33472. get count(): number;
  33473. /**
  33474. * Creates a new counter
  33475. */
  33476. constructor();
  33477. /**
  33478. * Call this method to start monitoring a new frame.
  33479. * 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.
  33480. */
  33481. fetchNewFrame(): void;
  33482. /**
  33483. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33484. * @param newCount the count value to add to the monitored count
  33485. * @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.
  33486. */
  33487. addCount(newCount: number, fetchResult: boolean): void;
  33488. /**
  33489. * Start monitoring this performance counter
  33490. */
  33491. beginMonitoring(): void;
  33492. /**
  33493. * Compute the time lapsed since the previous beginMonitoring() call.
  33494. * @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
  33495. */
  33496. endMonitoring(newFrame?: boolean): void;
  33497. private _fetchResult;
  33498. private _startMonitoringTime;
  33499. private _min;
  33500. private _max;
  33501. private _average;
  33502. private _current;
  33503. private _totalValueCount;
  33504. private _totalAccumulated;
  33505. private _lastSecAverage;
  33506. private _lastSecAccumulated;
  33507. private _lastSecTime;
  33508. private _lastSecValueCount;
  33509. }
  33510. }
  33511. declare module BABYLON {
  33512. interface ThinEngine {
  33513. /**
  33514. * Sets alpha constants used by some alpha blending modes
  33515. * @param r defines the red component
  33516. * @param g defines the green component
  33517. * @param b defines the blue component
  33518. * @param a defines the alpha component
  33519. */
  33520. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33521. /**
  33522. * Sets the current alpha mode
  33523. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33524. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33525. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33526. */
  33527. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33528. /**
  33529. * Gets the current alpha mode
  33530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33531. * @returns the current alpha mode
  33532. */
  33533. getAlphaMode(): number;
  33534. /**
  33535. * Sets the current alpha equation
  33536. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33537. */
  33538. setAlphaEquation(equation: number): void;
  33539. /**
  33540. * Gets the current alpha equation.
  33541. * @returns the current alpha equation
  33542. */
  33543. getAlphaEquation(): number;
  33544. }
  33545. }
  33546. declare module BABYLON {
  33547. /**
  33548. * Defines the interface used by display changed events
  33549. */
  33550. export interface IDisplayChangedEventArgs {
  33551. /** Gets the vrDisplay object (if any) */
  33552. vrDisplay: Nullable<any>;
  33553. /** Gets a boolean indicating if webVR is supported */
  33554. vrSupported: boolean;
  33555. }
  33556. /**
  33557. * Defines the interface used by objects containing a viewport (like a camera)
  33558. */
  33559. interface IViewportOwnerLike {
  33560. /**
  33561. * Gets or sets the viewport
  33562. */
  33563. viewport: IViewportLike;
  33564. }
  33565. /**
  33566. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33567. */
  33568. export class Engine extends ThinEngine {
  33569. /** Defines that alpha blending is disabled */
  33570. static readonly ALPHA_DISABLE: number;
  33571. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33572. static readonly ALPHA_ADD: number;
  33573. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33574. static readonly ALPHA_COMBINE: number;
  33575. /** Defines that alpha blending to DEST - SRC * DEST */
  33576. static readonly ALPHA_SUBTRACT: number;
  33577. /** Defines that alpha blending to SRC * DEST */
  33578. static readonly ALPHA_MULTIPLY: number;
  33579. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33580. static readonly ALPHA_MAXIMIZED: number;
  33581. /** Defines that alpha blending to SRC + DEST */
  33582. static readonly ALPHA_ONEONE: number;
  33583. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33584. static readonly ALPHA_PREMULTIPLIED: number;
  33585. /**
  33586. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33587. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33588. */
  33589. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33590. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33591. static readonly ALPHA_INTERPOLATE: number;
  33592. /**
  33593. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33594. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33595. */
  33596. static readonly ALPHA_SCREENMODE: number;
  33597. /** Defines that the ressource is not delayed*/
  33598. static readonly DELAYLOADSTATE_NONE: number;
  33599. /** Defines that the ressource was successfully delay loaded */
  33600. static readonly DELAYLOADSTATE_LOADED: number;
  33601. /** Defines that the ressource is currently delay loading */
  33602. static readonly DELAYLOADSTATE_LOADING: number;
  33603. /** Defines that the ressource is delayed and has not started loading */
  33604. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33605. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33606. static readonly NEVER: number;
  33607. /** 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 */
  33608. static readonly ALWAYS: number;
  33609. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33610. static readonly LESS: number;
  33611. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33612. static readonly EQUAL: number;
  33613. /** 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 */
  33614. static readonly LEQUAL: number;
  33615. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33616. static readonly GREATER: number;
  33617. /** 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 */
  33618. static readonly GEQUAL: number;
  33619. /** 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 */
  33620. static readonly NOTEQUAL: number;
  33621. /** Passed to stencilOperation to specify that stencil value must be kept */
  33622. static readonly KEEP: number;
  33623. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33624. static readonly REPLACE: number;
  33625. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33626. static readonly INCR: number;
  33627. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33628. static readonly DECR: number;
  33629. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33630. static readonly INVERT: number;
  33631. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33632. static readonly INCR_WRAP: number;
  33633. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33634. static readonly DECR_WRAP: number;
  33635. /** Texture is not repeating outside of 0..1 UVs */
  33636. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33637. /** Texture is repeating outside of 0..1 UVs */
  33638. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33639. /** Texture is repeating and mirrored */
  33640. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33641. /** ALPHA */
  33642. static readonly TEXTUREFORMAT_ALPHA: number;
  33643. /** LUMINANCE */
  33644. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33645. /** LUMINANCE_ALPHA */
  33646. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33647. /** RGB */
  33648. static readonly TEXTUREFORMAT_RGB: number;
  33649. /** RGBA */
  33650. static readonly TEXTUREFORMAT_RGBA: number;
  33651. /** RED */
  33652. static readonly TEXTUREFORMAT_RED: number;
  33653. /** RED (2nd reference) */
  33654. static readonly TEXTUREFORMAT_R: number;
  33655. /** RG */
  33656. static readonly TEXTUREFORMAT_RG: number;
  33657. /** RED_INTEGER */
  33658. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33659. /** RED_INTEGER (2nd reference) */
  33660. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33661. /** RG_INTEGER */
  33662. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33663. /** RGB_INTEGER */
  33664. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33665. /** RGBA_INTEGER */
  33666. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33667. /** UNSIGNED_BYTE */
  33668. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33669. /** UNSIGNED_BYTE (2nd reference) */
  33670. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33671. /** FLOAT */
  33672. static readonly TEXTURETYPE_FLOAT: number;
  33673. /** HALF_FLOAT */
  33674. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33675. /** BYTE */
  33676. static readonly TEXTURETYPE_BYTE: number;
  33677. /** SHORT */
  33678. static readonly TEXTURETYPE_SHORT: number;
  33679. /** UNSIGNED_SHORT */
  33680. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33681. /** INT */
  33682. static readonly TEXTURETYPE_INT: number;
  33683. /** UNSIGNED_INT */
  33684. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33685. /** UNSIGNED_SHORT_4_4_4_4 */
  33686. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33687. /** UNSIGNED_SHORT_5_5_5_1 */
  33688. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33689. /** UNSIGNED_SHORT_5_6_5 */
  33690. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33691. /** UNSIGNED_INT_2_10_10_10_REV */
  33692. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33693. /** UNSIGNED_INT_24_8 */
  33694. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33695. /** UNSIGNED_INT_10F_11F_11F_REV */
  33696. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33697. /** UNSIGNED_INT_5_9_9_9_REV */
  33698. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33699. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33700. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33701. /** nearest is mag = nearest and min = nearest and mip = linear */
  33702. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33703. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33704. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33705. /** Trilinear is mag = linear and min = linear and mip = linear */
  33706. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33707. /** nearest is mag = nearest and min = nearest and mip = linear */
  33708. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33709. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33710. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33711. /** Trilinear is mag = linear and min = linear and mip = linear */
  33712. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33713. /** mag = nearest and min = nearest and mip = nearest */
  33714. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33715. /** mag = nearest and min = linear and mip = nearest */
  33716. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33717. /** mag = nearest and min = linear and mip = linear */
  33718. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33719. /** mag = nearest and min = linear and mip = none */
  33720. static readonly TEXTURE_NEAREST_LINEAR: number;
  33721. /** mag = nearest and min = nearest and mip = none */
  33722. static readonly TEXTURE_NEAREST_NEAREST: number;
  33723. /** mag = linear and min = nearest and mip = nearest */
  33724. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33725. /** mag = linear and min = nearest and mip = linear */
  33726. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33727. /** mag = linear and min = linear and mip = none */
  33728. static readonly TEXTURE_LINEAR_LINEAR: number;
  33729. /** mag = linear and min = nearest and mip = none */
  33730. static readonly TEXTURE_LINEAR_NEAREST: number;
  33731. /** Explicit coordinates mode */
  33732. static readonly TEXTURE_EXPLICIT_MODE: number;
  33733. /** Spherical coordinates mode */
  33734. static readonly TEXTURE_SPHERICAL_MODE: number;
  33735. /** Planar coordinates mode */
  33736. static readonly TEXTURE_PLANAR_MODE: number;
  33737. /** Cubic coordinates mode */
  33738. static readonly TEXTURE_CUBIC_MODE: number;
  33739. /** Projection coordinates mode */
  33740. static readonly TEXTURE_PROJECTION_MODE: number;
  33741. /** Skybox coordinates mode */
  33742. static readonly TEXTURE_SKYBOX_MODE: number;
  33743. /** Inverse Cubic coordinates mode */
  33744. static readonly TEXTURE_INVCUBIC_MODE: number;
  33745. /** Equirectangular coordinates mode */
  33746. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33747. /** Equirectangular Fixed coordinates mode */
  33748. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33749. /** Equirectangular Fixed Mirrored coordinates mode */
  33750. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33751. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33752. static readonly SCALEMODE_FLOOR: number;
  33753. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33754. static readonly SCALEMODE_NEAREST: number;
  33755. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33756. static readonly SCALEMODE_CEILING: number;
  33757. /**
  33758. * Returns the current npm package of the sdk
  33759. */
  33760. static get NpmPackage(): string;
  33761. /**
  33762. * Returns the current version of the framework
  33763. */
  33764. static get Version(): string;
  33765. /** Gets the list of created engines */
  33766. static get Instances(): Engine[];
  33767. /**
  33768. * Gets the latest created engine
  33769. */
  33770. static get LastCreatedEngine(): Nullable<Engine>;
  33771. /**
  33772. * Gets the latest created scene
  33773. */
  33774. static get LastCreatedScene(): Nullable<Scene>;
  33775. /**
  33776. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33777. * @param flag defines which part of the materials must be marked as dirty
  33778. * @param predicate defines a predicate used to filter which materials should be affected
  33779. */
  33780. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33781. /**
  33782. * Method called to create the default loading screen.
  33783. * This can be overriden in your own app.
  33784. * @param canvas The rendering canvas element
  33785. * @returns The loading screen
  33786. */
  33787. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33788. /**
  33789. * Method called to create the default rescale post process on each engine.
  33790. */
  33791. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33792. /**
  33793. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33794. **/
  33795. enableOfflineSupport: boolean;
  33796. /**
  33797. * 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)
  33798. **/
  33799. disableManifestCheck: boolean;
  33800. /**
  33801. * Gets the list of created scenes
  33802. */
  33803. scenes: Scene[];
  33804. /**
  33805. * Event raised when a new scene is created
  33806. */
  33807. onNewSceneAddedObservable: Observable<Scene>;
  33808. /**
  33809. * Gets the list of created postprocesses
  33810. */
  33811. postProcesses: PostProcess[];
  33812. /**
  33813. * Gets a boolean indicating if the pointer is currently locked
  33814. */
  33815. isPointerLock: boolean;
  33816. /**
  33817. * Observable event triggered each time the rendering canvas is resized
  33818. */
  33819. onResizeObservable: Observable<Engine>;
  33820. /**
  33821. * Observable event triggered each time the canvas loses focus
  33822. */
  33823. onCanvasBlurObservable: Observable<Engine>;
  33824. /**
  33825. * Observable event triggered each time the canvas gains focus
  33826. */
  33827. onCanvasFocusObservable: Observable<Engine>;
  33828. /**
  33829. * Observable event triggered each time the canvas receives pointerout event
  33830. */
  33831. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33832. /**
  33833. * Observable raised when the engine begins a new frame
  33834. */
  33835. onBeginFrameObservable: Observable<Engine>;
  33836. /**
  33837. * If set, will be used to request the next animation frame for the render loop
  33838. */
  33839. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33840. /**
  33841. * Observable raised when the engine ends the current frame
  33842. */
  33843. onEndFrameObservable: Observable<Engine>;
  33844. /**
  33845. * Observable raised when the engine is about to compile a shader
  33846. */
  33847. onBeforeShaderCompilationObservable: Observable<Engine>;
  33848. /**
  33849. * Observable raised when the engine has jsut compiled a shader
  33850. */
  33851. onAfterShaderCompilationObservable: Observable<Engine>;
  33852. /**
  33853. * Gets the audio engine
  33854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33855. * @ignorenaming
  33856. */
  33857. static audioEngine: IAudioEngine;
  33858. /**
  33859. * Default AudioEngine factory responsible of creating the Audio Engine.
  33860. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33861. */
  33862. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33863. /**
  33864. * Default offline support factory responsible of creating a tool used to store data locally.
  33865. * By default, this will create a Database object if the workload has been embedded.
  33866. */
  33867. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33868. private _loadingScreen;
  33869. private _pointerLockRequested;
  33870. private _dummyFramebuffer;
  33871. private _rescalePostProcess;
  33872. private _deterministicLockstep;
  33873. private _lockstepMaxSteps;
  33874. private _timeStep;
  33875. protected get _supportsHardwareTextureRescaling(): boolean;
  33876. private _fps;
  33877. private _deltaTime;
  33878. /** @hidden */
  33879. _drawCalls: PerfCounter;
  33880. /** 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 */
  33881. canvasTabIndex: number;
  33882. /**
  33883. * Turn this value on if you want to pause FPS computation when in background
  33884. */
  33885. disablePerformanceMonitorInBackground: boolean;
  33886. private _performanceMonitor;
  33887. /**
  33888. * Gets the performance monitor attached to this engine
  33889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33890. */
  33891. get performanceMonitor(): PerformanceMonitor;
  33892. private _onFocus;
  33893. private _onBlur;
  33894. private _onCanvasPointerOut;
  33895. private _onCanvasBlur;
  33896. private _onCanvasFocus;
  33897. private _onFullscreenChange;
  33898. private _onPointerLockChange;
  33899. /**
  33900. * Gets the HTML element used to attach event listeners
  33901. * @returns a HTML element
  33902. */
  33903. getInputElement(): Nullable<HTMLElement>;
  33904. /**
  33905. * Creates a new engine
  33906. * @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
  33907. * @param antialias defines enable antialiasing (default: false)
  33908. * @param options defines further options to be sent to the getContext() function
  33909. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33910. */
  33911. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33912. /**
  33913. * Gets current aspect ratio
  33914. * @param viewportOwner defines the camera to use to get the aspect ratio
  33915. * @param useScreen defines if screen size must be used (or the current render target if any)
  33916. * @returns a number defining the aspect ratio
  33917. */
  33918. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33919. /**
  33920. * Gets current screen aspect ratio
  33921. * @returns a number defining the aspect ratio
  33922. */
  33923. getScreenAspectRatio(): number;
  33924. /**
  33925. * Gets the client rect of the HTML canvas attached with the current webGL context
  33926. * @returns a client rectanglee
  33927. */
  33928. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33929. /**
  33930. * Gets the client rect of the HTML element used for events
  33931. * @returns a client rectanglee
  33932. */
  33933. getInputElementClientRect(): Nullable<ClientRect>;
  33934. /**
  33935. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33936. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33937. * @returns true if engine is in deterministic lock step mode
  33938. */
  33939. isDeterministicLockStep(): boolean;
  33940. /**
  33941. * Gets the max steps when engine is running in deterministic lock step
  33942. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33943. * @returns the max steps
  33944. */
  33945. getLockstepMaxSteps(): number;
  33946. /**
  33947. * Returns the time in ms between steps when using deterministic lock step.
  33948. * @returns time step in (ms)
  33949. */
  33950. getTimeStep(): number;
  33951. /**
  33952. * Force the mipmap generation for the given render target texture
  33953. * @param texture defines the render target texture to use
  33954. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33955. */
  33956. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33957. /** States */
  33958. /**
  33959. * Set various states to the webGL context
  33960. * @param culling defines backface culling state
  33961. * @param zOffset defines the value to apply to zOffset (0 by default)
  33962. * @param force defines if states must be applied even if cache is up to date
  33963. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33964. */
  33965. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33966. /**
  33967. * Set the z offset to apply to current rendering
  33968. * @param value defines the offset to apply
  33969. */
  33970. setZOffset(value: number): void;
  33971. /**
  33972. * Gets the current value of the zOffset
  33973. * @returns the current zOffset state
  33974. */
  33975. getZOffset(): number;
  33976. /**
  33977. * Enable or disable depth buffering
  33978. * @param enable defines the state to set
  33979. */
  33980. setDepthBuffer(enable: boolean): void;
  33981. /**
  33982. * Gets a boolean indicating if depth writing is enabled
  33983. * @returns the current depth writing state
  33984. */
  33985. getDepthWrite(): boolean;
  33986. /**
  33987. * Enable or disable depth writing
  33988. * @param enable defines the state to set
  33989. */
  33990. setDepthWrite(enable: boolean): void;
  33991. /**
  33992. * Gets a boolean indicating if stencil buffer is enabled
  33993. * @returns the current stencil buffer state
  33994. */
  33995. getStencilBuffer(): boolean;
  33996. /**
  33997. * Enable or disable the stencil buffer
  33998. * @param enable defines if the stencil buffer must be enabled or disabled
  33999. */
  34000. setStencilBuffer(enable: boolean): void;
  34001. /**
  34002. * Gets the current stencil mask
  34003. * @returns a number defining the new stencil mask to use
  34004. */
  34005. getStencilMask(): number;
  34006. /**
  34007. * Sets the current stencil mask
  34008. * @param mask defines the new stencil mask to use
  34009. */
  34010. setStencilMask(mask: number): void;
  34011. /**
  34012. * Gets the current stencil function
  34013. * @returns a number defining the stencil function to use
  34014. */
  34015. getStencilFunction(): number;
  34016. /**
  34017. * Gets the current stencil reference value
  34018. * @returns a number defining the stencil reference value to use
  34019. */
  34020. getStencilFunctionReference(): number;
  34021. /**
  34022. * Gets the current stencil mask
  34023. * @returns a number defining the stencil mask to use
  34024. */
  34025. getStencilFunctionMask(): number;
  34026. /**
  34027. * Sets the current stencil function
  34028. * @param stencilFunc defines the new stencil function to use
  34029. */
  34030. setStencilFunction(stencilFunc: number): void;
  34031. /**
  34032. * Sets the current stencil reference
  34033. * @param reference defines the new stencil reference to use
  34034. */
  34035. setStencilFunctionReference(reference: number): void;
  34036. /**
  34037. * Sets the current stencil mask
  34038. * @param mask defines the new stencil mask to use
  34039. */
  34040. setStencilFunctionMask(mask: number): void;
  34041. /**
  34042. * Gets the current stencil operation when stencil fails
  34043. * @returns a number defining stencil operation to use when stencil fails
  34044. */
  34045. getStencilOperationFail(): number;
  34046. /**
  34047. * Gets the current stencil operation when depth fails
  34048. * @returns a number defining stencil operation to use when depth fails
  34049. */
  34050. getStencilOperationDepthFail(): number;
  34051. /**
  34052. * Gets the current stencil operation when stencil passes
  34053. * @returns a number defining stencil operation to use when stencil passes
  34054. */
  34055. getStencilOperationPass(): number;
  34056. /**
  34057. * Sets the stencil operation to use when stencil fails
  34058. * @param operation defines the stencil operation to use when stencil fails
  34059. */
  34060. setStencilOperationFail(operation: number): void;
  34061. /**
  34062. * Sets the stencil operation to use when depth fails
  34063. * @param operation defines the stencil operation to use when depth fails
  34064. */
  34065. setStencilOperationDepthFail(operation: number): void;
  34066. /**
  34067. * Sets the stencil operation to use when stencil passes
  34068. * @param operation defines the stencil operation to use when stencil passes
  34069. */
  34070. setStencilOperationPass(operation: number): void;
  34071. /**
  34072. * Sets a boolean indicating if the dithering state is enabled or disabled
  34073. * @param value defines the dithering state
  34074. */
  34075. setDitheringState(value: boolean): void;
  34076. /**
  34077. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34078. * @param value defines the rasterizer state
  34079. */
  34080. setRasterizerState(value: boolean): void;
  34081. /**
  34082. * Gets the current depth function
  34083. * @returns a number defining the depth function
  34084. */
  34085. getDepthFunction(): Nullable<number>;
  34086. /**
  34087. * Sets the current depth function
  34088. * @param depthFunc defines the function to use
  34089. */
  34090. setDepthFunction(depthFunc: number): void;
  34091. /**
  34092. * Sets the current depth function to GREATER
  34093. */
  34094. setDepthFunctionToGreater(): void;
  34095. /**
  34096. * Sets the current depth function to GEQUAL
  34097. */
  34098. setDepthFunctionToGreaterOrEqual(): void;
  34099. /**
  34100. * Sets the current depth function to LESS
  34101. */
  34102. setDepthFunctionToLess(): void;
  34103. /**
  34104. * Sets the current depth function to LEQUAL
  34105. */
  34106. setDepthFunctionToLessOrEqual(): void;
  34107. private _cachedStencilBuffer;
  34108. private _cachedStencilFunction;
  34109. private _cachedStencilMask;
  34110. private _cachedStencilOperationPass;
  34111. private _cachedStencilOperationFail;
  34112. private _cachedStencilOperationDepthFail;
  34113. private _cachedStencilReference;
  34114. /**
  34115. * Caches the the state of the stencil buffer
  34116. */
  34117. cacheStencilState(): void;
  34118. /**
  34119. * Restores the state of the stencil buffer
  34120. */
  34121. restoreStencilState(): void;
  34122. /**
  34123. * Directly set the WebGL Viewport
  34124. * @param x defines the x coordinate of the viewport (in screen space)
  34125. * @param y defines the y coordinate of the viewport (in screen space)
  34126. * @param width defines the width of the viewport (in screen space)
  34127. * @param height defines the height of the viewport (in screen space)
  34128. * @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
  34129. */
  34130. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34131. /**
  34132. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34133. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34134. * @param y defines the y-coordinate of the corner of the clear rectangle
  34135. * @param width defines the width of the clear rectangle
  34136. * @param height defines the height of the clear rectangle
  34137. * @param clearColor defines the clear color
  34138. */
  34139. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34140. /**
  34141. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34142. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34143. * @param y defines the y-coordinate of the corner of the clear rectangle
  34144. * @param width defines the width of the clear rectangle
  34145. * @param height defines the height of the clear rectangle
  34146. */
  34147. enableScissor(x: number, y: number, width: number, height: number): void;
  34148. /**
  34149. * Disable previously set scissor test rectangle
  34150. */
  34151. disableScissor(): void;
  34152. protected _reportDrawCall(): void;
  34153. /**
  34154. * Initializes a webVR display and starts listening to display change events
  34155. * The onVRDisplayChangedObservable will be notified upon these changes
  34156. * @returns The onVRDisplayChangedObservable
  34157. */
  34158. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34159. /** @hidden */
  34160. _prepareVRComponent(): void;
  34161. /** @hidden */
  34162. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34163. /** @hidden */
  34164. _submitVRFrame(): void;
  34165. /**
  34166. * Call this function to leave webVR mode
  34167. * Will do nothing if webVR is not supported or if there is no webVR device
  34168. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34169. */
  34170. disableVR(): void;
  34171. /**
  34172. * Gets a boolean indicating that the system is in VR mode and is presenting
  34173. * @returns true if VR mode is engaged
  34174. */
  34175. isVRPresenting(): boolean;
  34176. /** @hidden */
  34177. _requestVRFrame(): void;
  34178. /** @hidden */
  34179. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34180. /**
  34181. * Gets the source code of the vertex shader associated with a specific webGL program
  34182. * @param program defines the program to use
  34183. * @returns a string containing the source code of the vertex shader associated with the program
  34184. */
  34185. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34186. /**
  34187. * Gets the source code of the fragment shader associated with a specific webGL program
  34188. * @param program defines the program to use
  34189. * @returns a string containing the source code of the fragment shader associated with the program
  34190. */
  34191. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34192. /**
  34193. * Sets a depth stencil texture from a render target to the according uniform.
  34194. * @param channel The texture channel
  34195. * @param uniform The uniform to set
  34196. * @param texture The render target texture containing the depth stencil texture to apply
  34197. */
  34198. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34199. /**
  34200. * Sets a texture to the webGL context from a postprocess
  34201. * @param channel defines the channel to use
  34202. * @param postProcess defines the source postprocess
  34203. */
  34204. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34205. /**
  34206. * Binds the output of the passed in post process to the texture channel specified
  34207. * @param channel The channel the texture should be bound to
  34208. * @param postProcess The post process which's output should be bound
  34209. */
  34210. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34211. protected _rebuildBuffers(): void;
  34212. /** @hidden */
  34213. _renderFrame(): void;
  34214. _renderLoop(): void;
  34215. /** @hidden */
  34216. _renderViews(): boolean;
  34217. /**
  34218. * Toggle full screen mode
  34219. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34220. */
  34221. switchFullscreen(requestPointerLock: boolean): void;
  34222. /**
  34223. * Enters full screen mode
  34224. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34225. */
  34226. enterFullscreen(requestPointerLock: boolean): void;
  34227. /**
  34228. * Exits full screen mode
  34229. */
  34230. exitFullscreen(): void;
  34231. /**
  34232. * Enters Pointerlock mode
  34233. */
  34234. enterPointerlock(): void;
  34235. /**
  34236. * Exits Pointerlock mode
  34237. */
  34238. exitPointerlock(): void;
  34239. /**
  34240. * Begin a new frame
  34241. */
  34242. beginFrame(): void;
  34243. /**
  34244. * Enf the current frame
  34245. */
  34246. endFrame(): void;
  34247. resize(): void;
  34248. /**
  34249. * Force a specific size of the canvas
  34250. * @param width defines the new canvas' width
  34251. * @param height defines the new canvas' height
  34252. */
  34253. setSize(width: number, height: number): void;
  34254. /**
  34255. * Updates a dynamic vertex buffer.
  34256. * @param vertexBuffer the vertex buffer to update
  34257. * @param data the data used to update the vertex buffer
  34258. * @param byteOffset the byte offset of the data
  34259. * @param byteLength the byte length of the data
  34260. */
  34261. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34262. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34263. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34264. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34265. _releaseTexture(texture: InternalTexture): void;
  34266. /**
  34267. * @hidden
  34268. * Rescales a texture
  34269. * @param source input texutre
  34270. * @param destination destination texture
  34271. * @param scene scene to use to render the resize
  34272. * @param internalFormat format to use when resizing
  34273. * @param onComplete callback to be called when resize has completed
  34274. */
  34275. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34276. /**
  34277. * Gets the current framerate
  34278. * @returns a number representing the framerate
  34279. */
  34280. getFps(): number;
  34281. /**
  34282. * Gets the time spent between current and previous frame
  34283. * @returns a number representing the delta time in ms
  34284. */
  34285. getDeltaTime(): number;
  34286. private _measureFps;
  34287. /** @hidden */
  34288. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34289. /**
  34290. * Update a dynamic index buffer
  34291. * @param indexBuffer defines the target index buffer
  34292. * @param indices defines the data to update
  34293. * @param offset defines the offset in the target index buffer where update should start
  34294. */
  34295. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34296. /**
  34297. * Updates the sample count of a render target texture
  34298. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34299. * @param texture defines the texture to update
  34300. * @param samples defines the sample count to set
  34301. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34302. */
  34303. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34304. /**
  34305. * Updates a depth texture Comparison Mode and Function.
  34306. * If the comparison Function is equal to 0, the mode will be set to none.
  34307. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34308. * @param texture The texture to set the comparison function for
  34309. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34310. */
  34311. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34312. /**
  34313. * Creates a webGL buffer to use with instanciation
  34314. * @param capacity defines the size of the buffer
  34315. * @returns the webGL buffer
  34316. */
  34317. createInstancesBuffer(capacity: number): DataBuffer;
  34318. /**
  34319. * Delete a webGL buffer used with instanciation
  34320. * @param buffer defines the webGL buffer to delete
  34321. */
  34322. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34323. private _clientWaitAsync;
  34324. /** @hidden */
  34325. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34326. /** @hidden */
  34327. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34328. dispose(): void;
  34329. private _disableTouchAction;
  34330. /**
  34331. * Display the loading screen
  34332. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34333. */
  34334. displayLoadingUI(): void;
  34335. /**
  34336. * Hide the loading screen
  34337. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34338. */
  34339. hideLoadingUI(): void;
  34340. /**
  34341. * Gets the current loading screen object
  34342. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34343. */
  34344. get loadingScreen(): ILoadingScreen;
  34345. /**
  34346. * Sets the current loading screen object
  34347. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34348. */
  34349. set loadingScreen(loadingScreen: ILoadingScreen);
  34350. /**
  34351. * Sets the current loading screen text
  34352. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34353. */
  34354. set loadingUIText(text: string);
  34355. /**
  34356. * Sets the current loading screen background color
  34357. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34358. */
  34359. set loadingUIBackgroundColor(color: string);
  34360. /** Pointerlock and fullscreen */
  34361. /**
  34362. * Ask the browser to promote the current element to pointerlock mode
  34363. * @param element defines the DOM element to promote
  34364. */
  34365. static _RequestPointerlock(element: HTMLElement): void;
  34366. /**
  34367. * Asks the browser to exit pointerlock mode
  34368. */
  34369. static _ExitPointerlock(): void;
  34370. /**
  34371. * Ask the browser to promote the current element to fullscreen rendering mode
  34372. * @param element defines the DOM element to promote
  34373. */
  34374. static _RequestFullscreen(element: HTMLElement): void;
  34375. /**
  34376. * Asks the browser to exit fullscreen mode
  34377. */
  34378. static _ExitFullscreen(): void;
  34379. }
  34380. }
  34381. declare module BABYLON {
  34382. /**
  34383. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34384. * during the life time of the application.
  34385. */
  34386. export class EngineStore {
  34387. /** Gets the list of created engines */
  34388. static Instances: Engine[];
  34389. /** @hidden */
  34390. static _LastCreatedScene: Nullable<Scene>;
  34391. /**
  34392. * Gets the latest created engine
  34393. */
  34394. static get LastCreatedEngine(): Nullable<Engine>;
  34395. /**
  34396. * Gets the latest created scene
  34397. */
  34398. static get LastCreatedScene(): Nullable<Scene>;
  34399. /**
  34400. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34401. * @ignorenaming
  34402. */
  34403. static UseFallbackTexture: boolean;
  34404. /**
  34405. * Texture content used if a texture cannot loaded
  34406. * @ignorenaming
  34407. */
  34408. static FallbackTexture: string;
  34409. }
  34410. }
  34411. declare module BABYLON {
  34412. /**
  34413. * Helper class that provides a small promise polyfill
  34414. */
  34415. export class PromisePolyfill {
  34416. /**
  34417. * Static function used to check if the polyfill is required
  34418. * If this is the case then the function will inject the polyfill to window.Promise
  34419. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34420. */
  34421. static Apply(force?: boolean): void;
  34422. }
  34423. }
  34424. declare module BABYLON {
  34425. /**
  34426. * Interface for screenshot methods with describe argument called `size` as object with options
  34427. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34428. */
  34429. export interface IScreenshotSize {
  34430. /**
  34431. * number in pixels for canvas height
  34432. */
  34433. height?: number;
  34434. /**
  34435. * multiplier allowing render at a higher or lower resolution
  34436. * If value is defined then height and width will be ignored and taken from camera
  34437. */
  34438. precision?: number;
  34439. /**
  34440. * number in pixels for canvas width
  34441. */
  34442. width?: number;
  34443. }
  34444. }
  34445. declare module BABYLON {
  34446. interface IColor4Like {
  34447. r: float;
  34448. g: float;
  34449. b: float;
  34450. a: float;
  34451. }
  34452. /**
  34453. * Class containing a set of static utilities functions
  34454. */
  34455. export class Tools {
  34456. /**
  34457. * Gets or sets the base URL to use to load assets
  34458. */
  34459. static get BaseUrl(): string;
  34460. static set BaseUrl(value: string);
  34461. /**
  34462. * Enable/Disable Custom HTTP Request Headers globally.
  34463. * default = false
  34464. * @see CustomRequestHeaders
  34465. */
  34466. static UseCustomRequestHeaders: boolean;
  34467. /**
  34468. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34469. * i.e. when loading files, where the server/service expects an Authorization header
  34470. */
  34471. static CustomRequestHeaders: {
  34472. [key: string]: string;
  34473. };
  34474. /**
  34475. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34476. */
  34477. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34478. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34479. /**
  34480. * Default behaviour for cors in the application.
  34481. * It can be a string if the expected behavior is identical in the entire app.
  34482. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34483. */
  34484. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34485. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34486. /**
  34487. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34488. * @ignorenaming
  34489. */
  34490. static get UseFallbackTexture(): boolean;
  34491. static set UseFallbackTexture(value: boolean);
  34492. /**
  34493. * Use this object to register external classes like custom textures or material
  34494. * to allow the laoders to instantiate them
  34495. */
  34496. static get RegisteredExternalClasses(): {
  34497. [key: string]: Object;
  34498. };
  34499. static set RegisteredExternalClasses(classes: {
  34500. [key: string]: Object;
  34501. });
  34502. /**
  34503. * Texture content used if a texture cannot loaded
  34504. * @ignorenaming
  34505. */
  34506. static get fallbackTexture(): string;
  34507. static set fallbackTexture(value: string);
  34508. /**
  34509. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34510. * @param u defines the coordinate on X axis
  34511. * @param v defines the coordinate on Y axis
  34512. * @param width defines the width of the source data
  34513. * @param height defines the height of the source data
  34514. * @param pixels defines the source byte array
  34515. * @param color defines the output color
  34516. */
  34517. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34518. /**
  34519. * Interpolates between a and b via alpha
  34520. * @param a The lower value (returned when alpha = 0)
  34521. * @param b The upper value (returned when alpha = 1)
  34522. * @param alpha The interpolation-factor
  34523. * @return The mixed value
  34524. */
  34525. static Mix(a: number, b: number, alpha: number): number;
  34526. /**
  34527. * Tries to instantiate a new object from a given class name
  34528. * @param className defines the class name to instantiate
  34529. * @returns the new object or null if the system was not able to do the instantiation
  34530. */
  34531. static Instantiate(className: string): any;
  34532. /**
  34533. * Provides a slice function that will work even on IE
  34534. * @param data defines the array to slice
  34535. * @param start defines the start of the data (optional)
  34536. * @param end defines the end of the data (optional)
  34537. * @returns the new sliced array
  34538. */
  34539. static Slice<T>(data: T, start?: number, end?: number): T;
  34540. /**
  34541. * Polyfill for setImmediate
  34542. * @param action defines the action to execute after the current execution block
  34543. */
  34544. static SetImmediate(action: () => void): void;
  34545. /**
  34546. * Function indicating if a number is an exponent of 2
  34547. * @param value defines the value to test
  34548. * @returns true if the value is an exponent of 2
  34549. */
  34550. static IsExponentOfTwo(value: number): boolean;
  34551. private static _tmpFloatArray;
  34552. /**
  34553. * Returns the nearest 32-bit single precision float representation of a Number
  34554. * @param value A Number. If the parameter is of a different type, it will get converted
  34555. * to a number or to NaN if it cannot be converted
  34556. * @returns number
  34557. */
  34558. static FloatRound(value: number): number;
  34559. /**
  34560. * Extracts the filename from a path
  34561. * @param path defines the path to use
  34562. * @returns the filename
  34563. */
  34564. static GetFilename(path: string): string;
  34565. /**
  34566. * Extracts the "folder" part of a path (everything before the filename).
  34567. * @param uri The URI to extract the info from
  34568. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34569. * @returns The "folder" part of the path
  34570. */
  34571. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34572. /**
  34573. * Extracts text content from a DOM element hierarchy
  34574. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34575. */
  34576. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34577. /**
  34578. * Convert an angle in radians to degrees
  34579. * @param angle defines the angle to convert
  34580. * @returns the angle in degrees
  34581. */
  34582. static ToDegrees(angle: number): number;
  34583. /**
  34584. * Convert an angle in degrees to radians
  34585. * @param angle defines the angle to convert
  34586. * @returns the angle in radians
  34587. */
  34588. static ToRadians(angle: number): number;
  34589. /**
  34590. * Returns an array if obj is not an array
  34591. * @param obj defines the object to evaluate as an array
  34592. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34593. * @returns either obj directly if obj is an array or a new array containing obj
  34594. */
  34595. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34596. /**
  34597. * Gets the pointer prefix to use
  34598. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34599. */
  34600. static GetPointerPrefix(): string;
  34601. /**
  34602. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34603. * @param url define the url we are trying
  34604. * @param element define the dom element where to configure the cors policy
  34605. */
  34606. static SetCorsBehavior(url: string | string[], element: {
  34607. crossOrigin: string | null;
  34608. }): void;
  34609. /**
  34610. * Removes unwanted characters from an url
  34611. * @param url defines the url to clean
  34612. * @returns the cleaned url
  34613. */
  34614. static CleanUrl(url: string): string;
  34615. /**
  34616. * Gets or sets a function used to pre-process url before using them to load assets
  34617. */
  34618. static get PreprocessUrl(): (url: string) => string;
  34619. static set PreprocessUrl(processor: (url: string) => string);
  34620. /**
  34621. * Loads an image as an HTMLImageElement.
  34622. * @param input url string, ArrayBuffer, or Blob to load
  34623. * @param onLoad callback called when the image successfully loads
  34624. * @param onError callback called when the image fails to load
  34625. * @param offlineProvider offline provider for caching
  34626. * @param mimeType optional mime type
  34627. * @returns the HTMLImageElement of the loaded image
  34628. */
  34629. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34630. /**
  34631. * Loads a file from a url
  34632. * @param url url string, ArrayBuffer, or Blob to load
  34633. * @param onSuccess callback called when the file successfully loads
  34634. * @param onProgress callback called while file is loading (if the server supports this mode)
  34635. * @param offlineProvider defines the offline provider for caching
  34636. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34637. * @param onError callback called when the file fails to load
  34638. * @returns a file request object
  34639. */
  34640. 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;
  34641. /**
  34642. * Loads a file from a url
  34643. * @param url the file url to load
  34644. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34645. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34646. */
  34647. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34648. /**
  34649. * Load a script (identified by an url). When the url returns, the
  34650. * content of this file is added into a new script element, attached to the DOM (body element)
  34651. * @param scriptUrl defines the url of the script to laod
  34652. * @param onSuccess defines the callback called when the script is loaded
  34653. * @param onError defines the callback to call if an error occurs
  34654. * @param scriptId defines the id of the script element
  34655. */
  34656. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34657. /**
  34658. * Load an asynchronous script (identified by an url). When the url returns, the
  34659. * content of this file is added into a new script element, attached to the DOM (body element)
  34660. * @param scriptUrl defines the url of the script to laod
  34661. * @param scriptId defines the id of the script element
  34662. * @returns a promise request object
  34663. */
  34664. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34665. /**
  34666. * Loads a file from a blob
  34667. * @param fileToLoad defines the blob to use
  34668. * @param callback defines the callback to call when data is loaded
  34669. * @param progressCallback defines the callback to call during loading process
  34670. * @returns a file request object
  34671. */
  34672. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34673. /**
  34674. * Reads a file from a File object
  34675. * @param file defines the file to load
  34676. * @param onSuccess defines the callback to call when data is loaded
  34677. * @param onProgress defines the callback to call during loading process
  34678. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34679. * @param onError defines the callback to call when an error occurs
  34680. * @returns a file request object
  34681. */
  34682. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34683. /**
  34684. * Creates a data url from a given string content
  34685. * @param content defines the content to convert
  34686. * @returns the new data url link
  34687. */
  34688. static FileAsURL(content: string): string;
  34689. /**
  34690. * Format the given number to a specific decimal format
  34691. * @param value defines the number to format
  34692. * @param decimals defines the number of decimals to use
  34693. * @returns the formatted string
  34694. */
  34695. static Format(value: number, decimals?: number): string;
  34696. /**
  34697. * Tries to copy an object by duplicating every property
  34698. * @param source defines the source object
  34699. * @param destination defines the target object
  34700. * @param doNotCopyList defines a list of properties to avoid
  34701. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34702. */
  34703. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34704. /**
  34705. * Gets a boolean indicating if the given object has no own property
  34706. * @param obj defines the object to test
  34707. * @returns true if object has no own property
  34708. */
  34709. static IsEmpty(obj: any): boolean;
  34710. /**
  34711. * Function used to register events at window level
  34712. * @param windowElement defines the Window object to use
  34713. * @param events defines the events to register
  34714. */
  34715. static RegisterTopRootEvents(windowElement: Window, events: {
  34716. name: string;
  34717. handler: Nullable<(e: FocusEvent) => any>;
  34718. }[]): void;
  34719. /**
  34720. * Function used to unregister events from window level
  34721. * @param windowElement defines the Window object to use
  34722. * @param events defines the events to unregister
  34723. */
  34724. static UnregisterTopRootEvents(windowElement: Window, events: {
  34725. name: string;
  34726. handler: Nullable<(e: FocusEvent) => any>;
  34727. }[]): void;
  34728. /**
  34729. * @ignore
  34730. */
  34731. static _ScreenshotCanvas: HTMLCanvasElement;
  34732. /**
  34733. * Dumps the current bound framebuffer
  34734. * @param width defines the rendering width
  34735. * @param height defines the rendering height
  34736. * @param engine defines the hosting engine
  34737. * @param successCallback defines the callback triggered once the data are available
  34738. * @param mimeType defines the mime type of the result
  34739. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34740. */
  34741. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34742. /**
  34743. * Converts the canvas data to blob.
  34744. * This acts as a polyfill for browsers not supporting the to blob function.
  34745. * @param canvas Defines the canvas to extract the data from
  34746. * @param successCallback Defines the callback triggered once the data are available
  34747. * @param mimeType Defines the mime type of the result
  34748. */
  34749. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34750. /**
  34751. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34752. * @param successCallback defines the callback triggered once the data are available
  34753. * @param mimeType defines the mime type of the result
  34754. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34755. */
  34756. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34757. /**
  34758. * Downloads a blob in the browser
  34759. * @param blob defines the blob to download
  34760. * @param fileName defines the name of the downloaded file
  34761. */
  34762. static Download(blob: Blob, fileName: string): void;
  34763. /**
  34764. * Captures a screenshot of the current rendering
  34765. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34766. * @param engine defines the rendering engine
  34767. * @param camera defines the source camera
  34768. * @param size This parameter can be set to a single number or to an object with the
  34769. * following (optional) properties: precision, width, height. If a single number is passed,
  34770. * it will be used for both width and height. If an object is passed, the screenshot size
  34771. * will be derived from the parameters. The precision property is a multiplier allowing
  34772. * rendering at a higher or lower resolution
  34773. * @param successCallback defines the callback receives a single parameter which contains the
  34774. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34775. * src parameter of an <img> to display it
  34776. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34777. * Check your browser for supported MIME types
  34778. */
  34779. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34780. /**
  34781. * Captures a screenshot of the current rendering
  34782. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34783. * @param engine defines the rendering engine
  34784. * @param camera defines the source camera
  34785. * @param size This parameter can be set to a single number or to an object with the
  34786. * following (optional) properties: precision, width, height. If a single number is passed,
  34787. * it will be used for both width and height. If an object is passed, the screenshot size
  34788. * will be derived from the parameters. The precision property is a multiplier allowing
  34789. * rendering at a higher or lower resolution
  34790. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34791. * Check your browser for supported MIME types
  34792. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34793. * to the src parameter of an <img> to display it
  34794. */
  34795. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34796. /**
  34797. * Generates an image screenshot from the specified camera.
  34798. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34799. * @param engine The engine to use for rendering
  34800. * @param camera The camera to use for rendering
  34801. * @param size This parameter can be set to a single number or to an object with the
  34802. * following (optional) properties: precision, width, height. If a single number is passed,
  34803. * it will be used for both width and height. If an object is passed, the screenshot size
  34804. * will be derived from the parameters. The precision property is a multiplier allowing
  34805. * rendering at a higher or lower resolution
  34806. * @param successCallback The callback receives a single parameter which contains the
  34807. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34808. * src parameter of an <img> to display it
  34809. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34810. * Check your browser for supported MIME types
  34811. * @param samples Texture samples (default: 1)
  34812. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34813. * @param fileName A name for for the downloaded file.
  34814. */
  34815. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34816. /**
  34817. * Generates an image screenshot from the specified camera.
  34818. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34819. * @param engine The engine to use for rendering
  34820. * @param camera The camera to use for rendering
  34821. * @param size This parameter can be set to a single number or to an object with the
  34822. * following (optional) properties: precision, width, height. If a single number is passed,
  34823. * it will be used for both width and height. If an object is passed, the screenshot size
  34824. * will be derived from the parameters. The precision property is a multiplier allowing
  34825. * rendering at a higher or lower resolution
  34826. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34827. * Check your browser for supported MIME types
  34828. * @param samples Texture samples (default: 1)
  34829. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34830. * @param fileName A name for for the downloaded file.
  34831. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34832. * to the src parameter of an <img> to display it
  34833. */
  34834. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34835. /**
  34836. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34837. * Be aware Math.random() could cause collisions, but:
  34838. * "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"
  34839. * @returns a pseudo random id
  34840. */
  34841. static RandomId(): string;
  34842. /**
  34843. * Test if the given uri is a base64 string
  34844. * @param uri The uri to test
  34845. * @return True if the uri is a base64 string or false otherwise
  34846. */
  34847. static IsBase64(uri: string): boolean;
  34848. /**
  34849. * Decode the given base64 uri.
  34850. * @param uri The uri to decode
  34851. * @return The decoded base64 data.
  34852. */
  34853. static DecodeBase64(uri: string): ArrayBuffer;
  34854. /**
  34855. * Gets the absolute url.
  34856. * @param url the input url
  34857. * @return the absolute url
  34858. */
  34859. static GetAbsoluteUrl(url: string): string;
  34860. /**
  34861. * No log
  34862. */
  34863. static readonly NoneLogLevel: number;
  34864. /**
  34865. * Only message logs
  34866. */
  34867. static readonly MessageLogLevel: number;
  34868. /**
  34869. * Only warning logs
  34870. */
  34871. static readonly WarningLogLevel: number;
  34872. /**
  34873. * Only error logs
  34874. */
  34875. static readonly ErrorLogLevel: number;
  34876. /**
  34877. * All logs
  34878. */
  34879. static readonly AllLogLevel: number;
  34880. /**
  34881. * Gets a value indicating the number of loading errors
  34882. * @ignorenaming
  34883. */
  34884. static get errorsCount(): number;
  34885. /**
  34886. * Callback called when a new log is added
  34887. */
  34888. static OnNewCacheEntry: (entry: string) => void;
  34889. /**
  34890. * Log a message to the console
  34891. * @param message defines the message to log
  34892. */
  34893. static Log(message: string): void;
  34894. /**
  34895. * Write a warning message to the console
  34896. * @param message defines the message to log
  34897. */
  34898. static Warn(message: string): void;
  34899. /**
  34900. * Write an error message to the console
  34901. * @param message defines the message to log
  34902. */
  34903. static Error(message: string): void;
  34904. /**
  34905. * Gets current log cache (list of logs)
  34906. */
  34907. static get LogCache(): string;
  34908. /**
  34909. * Clears the log cache
  34910. */
  34911. static ClearLogCache(): void;
  34912. /**
  34913. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34914. */
  34915. static set LogLevels(level: number);
  34916. /**
  34917. * Checks if the window object exists
  34918. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34919. */
  34920. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34921. /**
  34922. * No performance log
  34923. */
  34924. static readonly PerformanceNoneLogLevel: number;
  34925. /**
  34926. * Use user marks to log performance
  34927. */
  34928. static readonly PerformanceUserMarkLogLevel: number;
  34929. /**
  34930. * Log performance to the console
  34931. */
  34932. static readonly PerformanceConsoleLogLevel: number;
  34933. private static _performance;
  34934. /**
  34935. * Sets the current performance log level
  34936. */
  34937. static set PerformanceLogLevel(level: number);
  34938. private static _StartPerformanceCounterDisabled;
  34939. private static _EndPerformanceCounterDisabled;
  34940. private static _StartUserMark;
  34941. private static _EndUserMark;
  34942. private static _StartPerformanceConsole;
  34943. private static _EndPerformanceConsole;
  34944. /**
  34945. * Starts a performance counter
  34946. */
  34947. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34948. /**
  34949. * Ends a specific performance coutner
  34950. */
  34951. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34952. /**
  34953. * Gets either window.performance.now() if supported or Date.now() else
  34954. */
  34955. static get Now(): number;
  34956. /**
  34957. * This method will return the name of the class used to create the instance of the given object.
  34958. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34959. * @param object the object to get the class name from
  34960. * @param isType defines if the object is actually a type
  34961. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34962. */
  34963. static GetClassName(object: any, isType?: boolean): string;
  34964. /**
  34965. * Gets the first element of an array satisfying a given predicate
  34966. * @param array defines the array to browse
  34967. * @param predicate defines the predicate to use
  34968. * @returns null if not found or the element
  34969. */
  34970. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34971. /**
  34972. * This method will return the name of the full name of the class, including its owning module (if any).
  34973. * 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).
  34974. * @param object the object to get the class name from
  34975. * @param isType defines if the object is actually a type
  34976. * @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.
  34977. * @ignorenaming
  34978. */
  34979. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34980. /**
  34981. * Returns a promise that resolves after the given amount of time.
  34982. * @param delay Number of milliseconds to delay
  34983. * @returns Promise that resolves after the given amount of time
  34984. */
  34985. static DelayAsync(delay: number): Promise<void>;
  34986. /**
  34987. * Utility function to detect if the current user agent is Safari
  34988. * @returns whether or not the current user agent is safari
  34989. */
  34990. static IsSafari(): boolean;
  34991. }
  34992. /**
  34993. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34994. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34995. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34996. * @param name The name of the class, case should be preserved
  34997. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34998. */
  34999. export function className(name: string, module?: string): (target: Object) => void;
  35000. /**
  35001. * An implementation of a loop for asynchronous functions.
  35002. */
  35003. export class AsyncLoop {
  35004. /**
  35005. * Defines the number of iterations for the loop
  35006. */
  35007. iterations: number;
  35008. /**
  35009. * Defines the current index of the loop.
  35010. */
  35011. index: number;
  35012. private _done;
  35013. private _fn;
  35014. private _successCallback;
  35015. /**
  35016. * Constructor.
  35017. * @param iterations the number of iterations.
  35018. * @param func the function to run each iteration
  35019. * @param successCallback the callback that will be called upon succesful execution
  35020. * @param offset starting offset.
  35021. */
  35022. constructor(
  35023. /**
  35024. * Defines the number of iterations for the loop
  35025. */
  35026. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35027. /**
  35028. * Execute the next iteration. Must be called after the last iteration was finished.
  35029. */
  35030. executeNext(): void;
  35031. /**
  35032. * Break the loop and run the success callback.
  35033. */
  35034. breakLoop(): void;
  35035. /**
  35036. * Create and run an async loop.
  35037. * @param iterations the number of iterations.
  35038. * @param fn the function to run each iteration
  35039. * @param successCallback the callback that will be called upon succesful execution
  35040. * @param offset starting offset.
  35041. * @returns the created async loop object
  35042. */
  35043. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35044. /**
  35045. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35046. * @param iterations total number of iterations
  35047. * @param syncedIterations number of synchronous iterations in each async iteration.
  35048. * @param fn the function to call each iteration.
  35049. * @param callback a success call back that will be called when iterating stops.
  35050. * @param breakFunction a break condition (optional)
  35051. * @param timeout timeout settings for the setTimeout function. default - 0.
  35052. * @returns the created async loop object
  35053. */
  35054. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35055. }
  35056. }
  35057. declare module BABYLON {
  35058. /**
  35059. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35060. * The underlying implementation relies on an associative array to ensure the best performances.
  35061. * The value can be anything including 'null' but except 'undefined'
  35062. */
  35063. export class StringDictionary<T> {
  35064. /**
  35065. * This will clear this dictionary and copy the content from the 'source' one.
  35066. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35067. * @param source the dictionary to take the content from and copy to this dictionary
  35068. */
  35069. copyFrom(source: StringDictionary<T>): void;
  35070. /**
  35071. * Get a value based from its key
  35072. * @param key the given key to get the matching value from
  35073. * @return the value if found, otherwise undefined is returned
  35074. */
  35075. get(key: string): T | undefined;
  35076. /**
  35077. * Get a value from its key or add it if it doesn't exist.
  35078. * This method will ensure you that a given key/data will be present in the dictionary.
  35079. * @param key the given key to get the matching value from
  35080. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35081. * The factory will only be invoked if there's no data for the given key.
  35082. * @return the value corresponding to the key.
  35083. */
  35084. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35085. /**
  35086. * Get a value from its key if present in the dictionary otherwise add it
  35087. * @param key the key to get the value from
  35088. * @param val if there's no such key/value pair in the dictionary add it with this value
  35089. * @return the value corresponding to the key
  35090. */
  35091. getOrAdd(key: string, val: T): T;
  35092. /**
  35093. * Check if there's a given key in the dictionary
  35094. * @param key the key to check for
  35095. * @return true if the key is present, false otherwise
  35096. */
  35097. contains(key: string): boolean;
  35098. /**
  35099. * Add a new key and its corresponding value
  35100. * @param key the key to add
  35101. * @param value the value corresponding to the key
  35102. * @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
  35103. */
  35104. add(key: string, value: T): boolean;
  35105. /**
  35106. * Update a specific value associated to a key
  35107. * @param key defines the key to use
  35108. * @param value defines the value to store
  35109. * @returns true if the value was updated (or false if the key was not found)
  35110. */
  35111. set(key: string, value: T): boolean;
  35112. /**
  35113. * Get the element of the given key and remove it from the dictionary
  35114. * @param key defines the key to search
  35115. * @returns the value associated with the key or null if not found
  35116. */
  35117. getAndRemove(key: string): Nullable<T>;
  35118. /**
  35119. * Remove a key/value from the dictionary.
  35120. * @param key the key to remove
  35121. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35122. */
  35123. remove(key: string): boolean;
  35124. /**
  35125. * Clear the whole content of the dictionary
  35126. */
  35127. clear(): void;
  35128. /**
  35129. * Gets the current count
  35130. */
  35131. get count(): number;
  35132. /**
  35133. * Execute a callback on each key/val of the dictionary.
  35134. * Note that you can remove any element in this dictionary in the callback implementation
  35135. * @param callback the callback to execute on a given key/value pair
  35136. */
  35137. forEach(callback: (key: string, val: T) => void): void;
  35138. /**
  35139. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35140. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35141. * Note that you can remove any element in this dictionary in the callback implementation
  35142. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35143. * @returns the first item
  35144. */
  35145. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35146. private _count;
  35147. private _data;
  35148. }
  35149. }
  35150. declare module BABYLON {
  35151. /** @hidden */
  35152. export interface ICollisionCoordinator {
  35153. createCollider(): Collider;
  35154. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35155. init(scene: Scene): void;
  35156. }
  35157. /** @hidden */
  35158. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35159. private _scene;
  35160. private _scaledPosition;
  35161. private _scaledVelocity;
  35162. private _finalPosition;
  35163. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35164. createCollider(): Collider;
  35165. init(scene: Scene): void;
  35166. private _collideWithWorld;
  35167. }
  35168. }
  35169. declare module BABYLON {
  35170. /**
  35171. * Class used to manage all inputs for the scene.
  35172. */
  35173. export class InputManager {
  35174. /** The distance in pixel that you have to move to prevent some events */
  35175. static DragMovementThreshold: number;
  35176. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35177. static LongPressDelay: number;
  35178. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35179. static DoubleClickDelay: number;
  35180. /** If you need to check double click without raising a single click at first click, enable this flag */
  35181. static ExclusiveDoubleClickMode: boolean;
  35182. private _wheelEventName;
  35183. private _onPointerMove;
  35184. private _onPointerDown;
  35185. private _onPointerUp;
  35186. private _initClickEvent;
  35187. private _initActionManager;
  35188. private _delayedSimpleClick;
  35189. private _delayedSimpleClickTimeout;
  35190. private _previousDelayedSimpleClickTimeout;
  35191. private _meshPickProceed;
  35192. private _previousButtonPressed;
  35193. private _currentPickResult;
  35194. private _previousPickResult;
  35195. private _totalPointersPressed;
  35196. private _doubleClickOccured;
  35197. private _pointerOverMesh;
  35198. private _pickedDownMesh;
  35199. private _pickedUpMesh;
  35200. private _pointerX;
  35201. private _pointerY;
  35202. private _unTranslatedPointerX;
  35203. private _unTranslatedPointerY;
  35204. private _startingPointerPosition;
  35205. private _previousStartingPointerPosition;
  35206. private _startingPointerTime;
  35207. private _previousStartingPointerTime;
  35208. private _pointerCaptures;
  35209. private _onKeyDown;
  35210. private _onKeyUp;
  35211. private _onCanvasFocusObserver;
  35212. private _onCanvasBlurObserver;
  35213. private _scene;
  35214. /**
  35215. * Creates a new InputManager
  35216. * @param scene defines the hosting scene
  35217. */
  35218. constructor(scene: Scene);
  35219. /**
  35220. * Gets the mesh that is currently under the pointer
  35221. */
  35222. get meshUnderPointer(): Nullable<AbstractMesh>;
  35223. /**
  35224. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35225. */
  35226. get unTranslatedPointer(): Vector2;
  35227. /**
  35228. * Gets or sets the current on-screen X position of the pointer
  35229. */
  35230. get pointerX(): number;
  35231. set pointerX(value: number);
  35232. /**
  35233. * Gets or sets the current on-screen Y position of the pointer
  35234. */
  35235. get pointerY(): number;
  35236. set pointerY(value: number);
  35237. private _updatePointerPosition;
  35238. private _processPointerMove;
  35239. private _setRayOnPointerInfo;
  35240. private _checkPrePointerObservable;
  35241. /**
  35242. * Use this method to simulate a pointer move on a mesh
  35243. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35244. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35245. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35246. */
  35247. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35248. /**
  35249. * Use this method to simulate a pointer down on a mesh
  35250. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35251. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35252. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35253. */
  35254. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35255. private _processPointerDown;
  35256. /** @hidden */
  35257. _isPointerSwiping(): boolean;
  35258. /**
  35259. * Use this method to simulate a pointer up on a mesh
  35260. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35261. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35262. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35263. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35264. */
  35265. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35266. private _processPointerUp;
  35267. /**
  35268. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35269. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35270. * @returns true if the pointer was captured
  35271. */
  35272. isPointerCaptured(pointerId?: number): boolean;
  35273. /**
  35274. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35275. * @param attachUp defines if you want to attach events to pointerup
  35276. * @param attachDown defines if you want to attach events to pointerdown
  35277. * @param attachMove defines if you want to attach events to pointermove
  35278. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35279. */
  35280. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35281. /**
  35282. * Detaches all event handlers
  35283. */
  35284. detachControl(): void;
  35285. /**
  35286. * Force the value of meshUnderPointer
  35287. * @param mesh defines the mesh to use
  35288. */
  35289. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35290. /**
  35291. * Gets the mesh under the pointer
  35292. * @returns a Mesh or null if no mesh is under the pointer
  35293. */
  35294. getPointerOverMesh(): Nullable<AbstractMesh>;
  35295. }
  35296. }
  35297. declare module BABYLON {
  35298. /**
  35299. * Helper class used to generate session unique ID
  35300. */
  35301. export class UniqueIdGenerator {
  35302. private static _UniqueIdCounter;
  35303. /**
  35304. * Gets an unique (relatively to the current scene) Id
  35305. */
  35306. static get UniqueId(): number;
  35307. }
  35308. }
  35309. declare module BABYLON {
  35310. /**
  35311. * This class defines the direct association between an animation and a target
  35312. */
  35313. export class TargetedAnimation {
  35314. /**
  35315. * Animation to perform
  35316. */
  35317. animation: Animation;
  35318. /**
  35319. * Target to animate
  35320. */
  35321. target: any;
  35322. /**
  35323. * Serialize the object
  35324. * @returns the JSON object representing the current entity
  35325. */
  35326. serialize(): any;
  35327. }
  35328. /**
  35329. * Use this class to create coordinated animations on multiple targets
  35330. */
  35331. export class AnimationGroup implements IDisposable {
  35332. /** The name of the animation group */
  35333. name: string;
  35334. private _scene;
  35335. private _targetedAnimations;
  35336. private _animatables;
  35337. private _from;
  35338. private _to;
  35339. private _isStarted;
  35340. private _isPaused;
  35341. private _speedRatio;
  35342. private _loopAnimation;
  35343. private _isAdditive;
  35344. /**
  35345. * Gets or sets the unique id of the node
  35346. */
  35347. uniqueId: number;
  35348. /**
  35349. * This observable will notify when one animation have ended
  35350. */
  35351. onAnimationEndObservable: Observable<TargetedAnimation>;
  35352. /**
  35353. * Observer raised when one animation loops
  35354. */
  35355. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35356. /**
  35357. * Observer raised when all animations have looped
  35358. */
  35359. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35360. /**
  35361. * This observable will notify when all animations have ended.
  35362. */
  35363. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35364. /**
  35365. * This observable will notify when all animations have paused.
  35366. */
  35367. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35368. /**
  35369. * This observable will notify when all animations are playing.
  35370. */
  35371. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35372. /**
  35373. * Gets the first frame
  35374. */
  35375. get from(): number;
  35376. /**
  35377. * Gets the last frame
  35378. */
  35379. get to(): number;
  35380. /**
  35381. * Define if the animations are started
  35382. */
  35383. get isStarted(): boolean;
  35384. /**
  35385. * Gets a value indicating that the current group is playing
  35386. */
  35387. get isPlaying(): boolean;
  35388. /**
  35389. * Gets or sets the speed ratio to use for all animations
  35390. */
  35391. get speedRatio(): number;
  35392. /**
  35393. * Gets or sets the speed ratio to use for all animations
  35394. */
  35395. set speedRatio(value: number);
  35396. /**
  35397. * Gets or sets if all animations should loop or not
  35398. */
  35399. get loopAnimation(): boolean;
  35400. set loopAnimation(value: boolean);
  35401. /**
  35402. * Gets or sets if all animations should be evaluated additively
  35403. */
  35404. get isAdditive(): boolean;
  35405. set isAdditive(value: boolean);
  35406. /**
  35407. * Gets the targeted animations for this animation group
  35408. */
  35409. get targetedAnimations(): Array<TargetedAnimation>;
  35410. /**
  35411. * returning the list of animatables controlled by this animation group.
  35412. */
  35413. get animatables(): Array<Animatable>;
  35414. /**
  35415. * Instantiates a new Animation Group.
  35416. * This helps managing several animations at once.
  35417. * @see http://doc.babylonjs.com/how_to/group
  35418. * @param name Defines the name of the group
  35419. * @param scene Defines the scene the group belongs to
  35420. */
  35421. constructor(
  35422. /** The name of the animation group */
  35423. name: string, scene?: Nullable<Scene>);
  35424. /**
  35425. * Add an animation (with its target) in the group
  35426. * @param animation defines the animation we want to add
  35427. * @param target defines the target of the animation
  35428. * @returns the TargetedAnimation object
  35429. */
  35430. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35431. /**
  35432. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35433. * It can add constant keys at begin or end
  35434. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35435. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35436. * @returns the animation group
  35437. */
  35438. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35439. private _animationLoopCount;
  35440. private _animationLoopFlags;
  35441. private _processLoop;
  35442. /**
  35443. * Start all animations on given targets
  35444. * @param loop defines if animations must loop
  35445. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35446. * @param from defines the from key (optional)
  35447. * @param to defines the to key (optional)
  35448. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35449. * @returns the current animation group
  35450. */
  35451. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35452. /**
  35453. * Pause all animations
  35454. * @returns the animation group
  35455. */
  35456. pause(): AnimationGroup;
  35457. /**
  35458. * Play all animations to initial state
  35459. * This function will start() the animations if they were not started or will restart() them if they were paused
  35460. * @param loop defines if animations must loop
  35461. * @returns the animation group
  35462. */
  35463. play(loop?: boolean): AnimationGroup;
  35464. /**
  35465. * Reset all animations to initial state
  35466. * @returns the animation group
  35467. */
  35468. reset(): AnimationGroup;
  35469. /**
  35470. * Restart animations from key 0
  35471. * @returns the animation group
  35472. */
  35473. restart(): AnimationGroup;
  35474. /**
  35475. * Stop all animations
  35476. * @returns the animation group
  35477. */
  35478. stop(): AnimationGroup;
  35479. /**
  35480. * Set animation weight for all animatables
  35481. * @param weight defines the weight to use
  35482. * @return the animationGroup
  35483. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35484. */
  35485. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35486. /**
  35487. * Synchronize and normalize all animatables with a source animatable
  35488. * @param root defines the root animatable to synchronize with
  35489. * @return the animationGroup
  35490. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35491. */
  35492. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35493. /**
  35494. * Goes to a specific frame in this animation group
  35495. * @param frame the frame number to go to
  35496. * @return the animationGroup
  35497. */
  35498. goToFrame(frame: number): AnimationGroup;
  35499. /**
  35500. * Dispose all associated resources
  35501. */
  35502. dispose(): void;
  35503. private _checkAnimationGroupEnded;
  35504. /**
  35505. * Clone the current animation group and returns a copy
  35506. * @param newName defines the name of the new group
  35507. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35508. * @returns the new aniamtion group
  35509. */
  35510. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35511. /**
  35512. * Serializes the animationGroup to an object
  35513. * @returns Serialized object
  35514. */
  35515. serialize(): any;
  35516. /**
  35517. * Returns a new AnimationGroup object parsed from the source provided.
  35518. * @param parsedAnimationGroup defines the source
  35519. * @param scene defines the scene that will receive the animationGroup
  35520. * @returns a new AnimationGroup
  35521. */
  35522. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35523. /**
  35524. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35525. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35526. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35527. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35528. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35529. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35530. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35531. */
  35532. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35533. /**
  35534. * Returns the string "AnimationGroup"
  35535. * @returns "AnimationGroup"
  35536. */
  35537. getClassName(): string;
  35538. /**
  35539. * Creates a detailled string about the object
  35540. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35541. * @returns a string representing the object
  35542. */
  35543. toString(fullDetails?: boolean): string;
  35544. }
  35545. }
  35546. declare module BABYLON {
  35547. /**
  35548. * Define an interface for all classes that will hold resources
  35549. */
  35550. export interface IDisposable {
  35551. /**
  35552. * Releases all held resources
  35553. */
  35554. dispose(): void;
  35555. }
  35556. /** Interface defining initialization parameters for Scene class */
  35557. export interface SceneOptions {
  35558. /**
  35559. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35560. * It will improve performance when the number of geometries becomes important.
  35561. */
  35562. useGeometryUniqueIdsMap?: boolean;
  35563. /**
  35564. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35565. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35566. */
  35567. useMaterialMeshMap?: boolean;
  35568. /**
  35569. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35570. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35571. */
  35572. useClonedMeshMap?: boolean;
  35573. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35574. virtual?: boolean;
  35575. }
  35576. /**
  35577. * Represents a scene to be rendered by the engine.
  35578. * @see http://doc.babylonjs.com/features/scene
  35579. */
  35580. export class Scene extends AbstractScene implements IAnimatable {
  35581. /** The fog is deactivated */
  35582. static readonly FOGMODE_NONE: number;
  35583. /** The fog density is following an exponential function */
  35584. static readonly FOGMODE_EXP: number;
  35585. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35586. static readonly FOGMODE_EXP2: number;
  35587. /** The fog density is following a linear function. */
  35588. static readonly FOGMODE_LINEAR: number;
  35589. /**
  35590. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35591. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35592. */
  35593. static MinDeltaTime: number;
  35594. /**
  35595. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35596. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35597. */
  35598. static MaxDeltaTime: number;
  35599. /**
  35600. * Factory used to create the default material.
  35601. * @param name The name of the material to create
  35602. * @param scene The scene to create the material for
  35603. * @returns The default material
  35604. */
  35605. static DefaultMaterialFactory(scene: Scene): Material;
  35606. /**
  35607. * Factory used to create the a collision coordinator.
  35608. * @returns The collision coordinator
  35609. */
  35610. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35611. /** @hidden */
  35612. _inputManager: InputManager;
  35613. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35614. cameraToUseForPointers: Nullable<Camera>;
  35615. /** @hidden */
  35616. readonly _isScene: boolean;
  35617. /** @hidden */
  35618. _blockEntityCollection: boolean;
  35619. /**
  35620. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35621. */
  35622. autoClear: boolean;
  35623. /**
  35624. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35625. */
  35626. autoClearDepthAndStencil: boolean;
  35627. /**
  35628. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35629. */
  35630. clearColor: Color4;
  35631. /**
  35632. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35633. */
  35634. ambientColor: Color3;
  35635. /**
  35636. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35637. * It should only be one of the following (if not the default embedded one):
  35638. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35639. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35640. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35641. * The material properties need to be setup according to the type of texture in use.
  35642. */
  35643. environmentBRDFTexture: BaseTexture;
  35644. /** @hidden */
  35645. protected _environmentTexture: Nullable<BaseTexture>;
  35646. /**
  35647. * Texture used in all pbr material as the reflection texture.
  35648. * As in the majority of the scene they are the same (exception for multi room and so on),
  35649. * this is easier to reference from here than from all the materials.
  35650. */
  35651. get environmentTexture(): Nullable<BaseTexture>;
  35652. /**
  35653. * Texture used in all pbr material as the reflection texture.
  35654. * As in the majority of the scene they are the same (exception for multi room and so on),
  35655. * this is easier to set here than in all the materials.
  35656. */
  35657. set environmentTexture(value: Nullable<BaseTexture>);
  35658. /** @hidden */
  35659. protected _environmentIntensity: number;
  35660. /**
  35661. * Intensity of the environment in all pbr material.
  35662. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35663. * As in the majority of the scene they are the same (exception for multi room and so on),
  35664. * this is easier to reference from here than from all the materials.
  35665. */
  35666. get environmentIntensity(): number;
  35667. /**
  35668. * Intensity of the environment in all pbr material.
  35669. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35670. * As in the majority of the scene they are the same (exception for multi room and so on),
  35671. * this is easier to set here than in all the materials.
  35672. */
  35673. set environmentIntensity(value: number);
  35674. /** @hidden */
  35675. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35676. /**
  35677. * Default image processing configuration used either in the rendering
  35678. * Forward main pass or through the imageProcessingPostProcess if present.
  35679. * As in the majority of the scene they are the same (exception for multi camera),
  35680. * this is easier to reference from here than from all the materials and post process.
  35681. *
  35682. * No setter as we it is a shared configuration, you can set the values instead.
  35683. */
  35684. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35685. private _forceWireframe;
  35686. /**
  35687. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35688. */
  35689. set forceWireframe(value: boolean);
  35690. get forceWireframe(): boolean;
  35691. private _skipFrustumClipping;
  35692. /**
  35693. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35694. */
  35695. set skipFrustumClipping(value: boolean);
  35696. get skipFrustumClipping(): boolean;
  35697. private _forcePointsCloud;
  35698. /**
  35699. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35700. */
  35701. set forcePointsCloud(value: boolean);
  35702. get forcePointsCloud(): boolean;
  35703. /**
  35704. * Gets or sets the active clipplane 1
  35705. */
  35706. clipPlane: Nullable<Plane>;
  35707. /**
  35708. * Gets or sets the active clipplane 2
  35709. */
  35710. clipPlane2: Nullable<Plane>;
  35711. /**
  35712. * Gets or sets the active clipplane 3
  35713. */
  35714. clipPlane3: Nullable<Plane>;
  35715. /**
  35716. * Gets or sets the active clipplane 4
  35717. */
  35718. clipPlane4: Nullable<Plane>;
  35719. /**
  35720. * Gets or sets the active clipplane 5
  35721. */
  35722. clipPlane5: Nullable<Plane>;
  35723. /**
  35724. * Gets or sets the active clipplane 6
  35725. */
  35726. clipPlane6: Nullable<Plane>;
  35727. /**
  35728. * Gets or sets a boolean indicating if animations are enabled
  35729. */
  35730. animationsEnabled: boolean;
  35731. private _animationPropertiesOverride;
  35732. /**
  35733. * Gets or sets the animation properties override
  35734. */
  35735. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35736. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35737. /**
  35738. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35739. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35740. */
  35741. useConstantAnimationDeltaTime: boolean;
  35742. /**
  35743. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35744. * Please note that it requires to run a ray cast through the scene on every frame
  35745. */
  35746. constantlyUpdateMeshUnderPointer: boolean;
  35747. /**
  35748. * Defines the HTML cursor to use when hovering over interactive elements
  35749. */
  35750. hoverCursor: string;
  35751. /**
  35752. * Defines the HTML default cursor to use (empty by default)
  35753. */
  35754. defaultCursor: string;
  35755. /**
  35756. * Defines whether cursors are handled by the scene.
  35757. */
  35758. doNotHandleCursors: boolean;
  35759. /**
  35760. * This is used to call preventDefault() on pointer down
  35761. * in order to block unwanted artifacts like system double clicks
  35762. */
  35763. preventDefaultOnPointerDown: boolean;
  35764. /**
  35765. * This is used to call preventDefault() on pointer up
  35766. * in order to block unwanted artifacts like system double clicks
  35767. */
  35768. preventDefaultOnPointerUp: boolean;
  35769. /**
  35770. * Gets or sets user defined metadata
  35771. */
  35772. metadata: any;
  35773. /**
  35774. * For internal use only. Please do not use.
  35775. */
  35776. reservedDataStore: any;
  35777. /**
  35778. * Gets the name of the plugin used to load this scene (null by default)
  35779. */
  35780. loadingPluginName: string;
  35781. /**
  35782. * Use this array to add regular expressions used to disable offline support for specific urls
  35783. */
  35784. disableOfflineSupportExceptionRules: RegExp[];
  35785. /**
  35786. * An event triggered when the scene is disposed.
  35787. */
  35788. onDisposeObservable: Observable<Scene>;
  35789. private _onDisposeObserver;
  35790. /** Sets a function to be executed when this scene is disposed. */
  35791. set onDispose(callback: () => void);
  35792. /**
  35793. * An event triggered before rendering the scene (right after animations and physics)
  35794. */
  35795. onBeforeRenderObservable: Observable<Scene>;
  35796. private _onBeforeRenderObserver;
  35797. /** Sets a function to be executed before rendering this scene */
  35798. set beforeRender(callback: Nullable<() => void>);
  35799. /**
  35800. * An event triggered after rendering the scene
  35801. */
  35802. onAfterRenderObservable: Observable<Scene>;
  35803. /**
  35804. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35805. */
  35806. onAfterRenderCameraObservable: Observable<Camera>;
  35807. private _onAfterRenderObserver;
  35808. /** Sets a function to be executed after rendering this scene */
  35809. set afterRender(callback: Nullable<() => void>);
  35810. /**
  35811. * An event triggered before animating the scene
  35812. */
  35813. onBeforeAnimationsObservable: Observable<Scene>;
  35814. /**
  35815. * An event triggered after animations processing
  35816. */
  35817. onAfterAnimationsObservable: Observable<Scene>;
  35818. /**
  35819. * An event triggered before draw calls are ready to be sent
  35820. */
  35821. onBeforeDrawPhaseObservable: Observable<Scene>;
  35822. /**
  35823. * An event triggered after draw calls have been sent
  35824. */
  35825. onAfterDrawPhaseObservable: Observable<Scene>;
  35826. /**
  35827. * An event triggered when the scene is ready
  35828. */
  35829. onReadyObservable: Observable<Scene>;
  35830. /**
  35831. * An event triggered before rendering a camera
  35832. */
  35833. onBeforeCameraRenderObservable: Observable<Camera>;
  35834. private _onBeforeCameraRenderObserver;
  35835. /** Sets a function to be executed before rendering a camera*/
  35836. set beforeCameraRender(callback: () => void);
  35837. /**
  35838. * An event triggered after rendering a camera
  35839. */
  35840. onAfterCameraRenderObservable: Observable<Camera>;
  35841. private _onAfterCameraRenderObserver;
  35842. /** Sets a function to be executed after rendering a camera*/
  35843. set afterCameraRender(callback: () => void);
  35844. /**
  35845. * An event triggered when active meshes evaluation is about to start
  35846. */
  35847. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35848. /**
  35849. * An event triggered when active meshes evaluation is done
  35850. */
  35851. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35852. /**
  35853. * An event triggered when particles rendering is about to start
  35854. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35855. */
  35856. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35857. /**
  35858. * An event triggered when particles rendering is done
  35859. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35860. */
  35861. onAfterParticlesRenderingObservable: Observable<Scene>;
  35862. /**
  35863. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35864. */
  35865. onDataLoadedObservable: Observable<Scene>;
  35866. /**
  35867. * An event triggered when a camera is created
  35868. */
  35869. onNewCameraAddedObservable: Observable<Camera>;
  35870. /**
  35871. * An event triggered when a camera is removed
  35872. */
  35873. onCameraRemovedObservable: Observable<Camera>;
  35874. /**
  35875. * An event triggered when a light is created
  35876. */
  35877. onNewLightAddedObservable: Observable<Light>;
  35878. /**
  35879. * An event triggered when a light is removed
  35880. */
  35881. onLightRemovedObservable: Observable<Light>;
  35882. /**
  35883. * An event triggered when a geometry is created
  35884. */
  35885. onNewGeometryAddedObservable: Observable<Geometry>;
  35886. /**
  35887. * An event triggered when a geometry is removed
  35888. */
  35889. onGeometryRemovedObservable: Observable<Geometry>;
  35890. /**
  35891. * An event triggered when a transform node is created
  35892. */
  35893. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35894. /**
  35895. * An event triggered when a transform node is removed
  35896. */
  35897. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35898. /**
  35899. * An event triggered when a mesh is created
  35900. */
  35901. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35902. /**
  35903. * An event triggered when a mesh is removed
  35904. */
  35905. onMeshRemovedObservable: Observable<AbstractMesh>;
  35906. /**
  35907. * An event triggered when a skeleton is created
  35908. */
  35909. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35910. /**
  35911. * An event triggered when a skeleton is removed
  35912. */
  35913. onSkeletonRemovedObservable: Observable<Skeleton>;
  35914. /**
  35915. * An event triggered when a material is created
  35916. */
  35917. onNewMaterialAddedObservable: Observable<Material>;
  35918. /**
  35919. * An event triggered when a material is removed
  35920. */
  35921. onMaterialRemovedObservable: Observable<Material>;
  35922. /**
  35923. * An event triggered when a texture is created
  35924. */
  35925. onNewTextureAddedObservable: Observable<BaseTexture>;
  35926. /**
  35927. * An event triggered when a texture is removed
  35928. */
  35929. onTextureRemovedObservable: Observable<BaseTexture>;
  35930. /**
  35931. * An event triggered when render targets are about to be rendered
  35932. * Can happen multiple times per frame.
  35933. */
  35934. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35935. /**
  35936. * An event triggered when render targets were rendered.
  35937. * Can happen multiple times per frame.
  35938. */
  35939. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35940. /**
  35941. * An event triggered before calculating deterministic simulation step
  35942. */
  35943. onBeforeStepObservable: Observable<Scene>;
  35944. /**
  35945. * An event triggered after calculating deterministic simulation step
  35946. */
  35947. onAfterStepObservable: Observable<Scene>;
  35948. /**
  35949. * An event triggered when the activeCamera property is updated
  35950. */
  35951. onActiveCameraChanged: Observable<Scene>;
  35952. /**
  35953. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35954. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35955. * 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)
  35956. */
  35957. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35958. /**
  35959. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35960. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35961. * 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)
  35962. */
  35963. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35964. /**
  35965. * This Observable will when a mesh has been imported into the scene.
  35966. */
  35967. onMeshImportedObservable: Observable<AbstractMesh>;
  35968. /**
  35969. * This Observable will when an animation file has been imported into the scene.
  35970. */
  35971. onAnimationFileImportedObservable: Observable<Scene>;
  35972. /**
  35973. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35974. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35975. */
  35976. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35977. /** @hidden */
  35978. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35979. /**
  35980. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35981. */
  35982. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35983. /**
  35984. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35985. */
  35986. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35987. /**
  35988. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35989. */
  35990. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35991. /** Callback called when a pointer move is detected */
  35992. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35993. /** Callback called when a pointer down is detected */
  35994. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35995. /** Callback called when a pointer up is detected */
  35996. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35997. /** Callback called when a pointer pick is detected */
  35998. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35999. /**
  36000. * 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).
  36001. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36002. */
  36003. onPrePointerObservable: Observable<PointerInfoPre>;
  36004. /**
  36005. * Observable event triggered each time an input event is received from the rendering canvas
  36006. */
  36007. onPointerObservable: Observable<PointerInfo>;
  36008. /**
  36009. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36010. */
  36011. get unTranslatedPointer(): Vector2;
  36012. /**
  36013. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36014. */
  36015. static get DragMovementThreshold(): number;
  36016. static set DragMovementThreshold(value: number);
  36017. /**
  36018. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36019. */
  36020. static get LongPressDelay(): number;
  36021. static set LongPressDelay(value: number);
  36022. /**
  36023. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36024. */
  36025. static get DoubleClickDelay(): number;
  36026. static set DoubleClickDelay(value: number);
  36027. /** If you need to check double click without raising a single click at first click, enable this flag */
  36028. static get ExclusiveDoubleClickMode(): boolean;
  36029. static set ExclusiveDoubleClickMode(value: boolean);
  36030. /** @hidden */
  36031. _mirroredCameraPosition: Nullable<Vector3>;
  36032. /**
  36033. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36034. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36035. */
  36036. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36037. /**
  36038. * Observable event triggered each time an keyboard event is received from the hosting window
  36039. */
  36040. onKeyboardObservable: Observable<KeyboardInfo>;
  36041. private _useRightHandedSystem;
  36042. /**
  36043. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36044. */
  36045. set useRightHandedSystem(value: boolean);
  36046. get useRightHandedSystem(): boolean;
  36047. private _timeAccumulator;
  36048. private _currentStepId;
  36049. private _currentInternalStep;
  36050. /**
  36051. * Sets the step Id used by deterministic lock step
  36052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36053. * @param newStepId defines the step Id
  36054. */
  36055. setStepId(newStepId: number): void;
  36056. /**
  36057. * Gets the step Id used by deterministic lock step
  36058. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36059. * @returns the step Id
  36060. */
  36061. getStepId(): number;
  36062. /**
  36063. * Gets the internal step used by deterministic lock step
  36064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36065. * @returns the internal step
  36066. */
  36067. getInternalStep(): number;
  36068. private _fogEnabled;
  36069. /**
  36070. * Gets or sets a boolean indicating if fog is enabled on this scene
  36071. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36072. * (Default is true)
  36073. */
  36074. set fogEnabled(value: boolean);
  36075. get fogEnabled(): boolean;
  36076. private _fogMode;
  36077. /**
  36078. * Gets or sets the fog mode to use
  36079. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36080. * | mode | value |
  36081. * | --- | --- |
  36082. * | FOGMODE_NONE | 0 |
  36083. * | FOGMODE_EXP | 1 |
  36084. * | FOGMODE_EXP2 | 2 |
  36085. * | FOGMODE_LINEAR | 3 |
  36086. */
  36087. set fogMode(value: number);
  36088. get fogMode(): number;
  36089. /**
  36090. * Gets or sets the fog color to use
  36091. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36092. * (Default is Color3(0.2, 0.2, 0.3))
  36093. */
  36094. fogColor: Color3;
  36095. /**
  36096. * Gets or sets the fog density to use
  36097. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36098. * (Default is 0.1)
  36099. */
  36100. fogDensity: number;
  36101. /**
  36102. * Gets or sets the fog start distance to use
  36103. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36104. * (Default is 0)
  36105. */
  36106. fogStart: number;
  36107. /**
  36108. * Gets or sets the fog end distance to use
  36109. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36110. * (Default is 1000)
  36111. */
  36112. fogEnd: number;
  36113. private _shadowsEnabled;
  36114. /**
  36115. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36116. */
  36117. set shadowsEnabled(value: boolean);
  36118. get shadowsEnabled(): boolean;
  36119. private _lightsEnabled;
  36120. /**
  36121. * Gets or sets a boolean indicating if lights are enabled on this scene
  36122. */
  36123. set lightsEnabled(value: boolean);
  36124. get lightsEnabled(): boolean;
  36125. /** All of the active cameras added to this scene. */
  36126. activeCameras: Camera[];
  36127. /** @hidden */
  36128. _activeCamera: Nullable<Camera>;
  36129. /** Gets or sets the current active camera */
  36130. get activeCamera(): Nullable<Camera>;
  36131. set activeCamera(value: Nullable<Camera>);
  36132. private _defaultMaterial;
  36133. /** The default material used on meshes when no material is affected */
  36134. get defaultMaterial(): Material;
  36135. /** The default material used on meshes when no material is affected */
  36136. set defaultMaterial(value: Material);
  36137. private _texturesEnabled;
  36138. /**
  36139. * Gets or sets a boolean indicating if textures are enabled on this scene
  36140. */
  36141. set texturesEnabled(value: boolean);
  36142. get texturesEnabled(): boolean;
  36143. /**
  36144. * Gets or sets a boolean indicating if particles are enabled on this scene
  36145. */
  36146. particlesEnabled: boolean;
  36147. /**
  36148. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36149. */
  36150. spritesEnabled: boolean;
  36151. private _skeletonsEnabled;
  36152. /**
  36153. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36154. */
  36155. set skeletonsEnabled(value: boolean);
  36156. get skeletonsEnabled(): boolean;
  36157. /**
  36158. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36159. */
  36160. lensFlaresEnabled: boolean;
  36161. /**
  36162. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36164. */
  36165. collisionsEnabled: boolean;
  36166. private _collisionCoordinator;
  36167. /** @hidden */
  36168. get collisionCoordinator(): ICollisionCoordinator;
  36169. /**
  36170. * Defines the gravity applied to this scene (used only for collisions)
  36171. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36172. */
  36173. gravity: Vector3;
  36174. /**
  36175. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36176. */
  36177. postProcessesEnabled: boolean;
  36178. /**
  36179. * The list of postprocesses added to the scene
  36180. */
  36181. postProcesses: PostProcess[];
  36182. /**
  36183. * Gets the current postprocess manager
  36184. */
  36185. postProcessManager: PostProcessManager;
  36186. /**
  36187. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36188. */
  36189. renderTargetsEnabled: boolean;
  36190. /**
  36191. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36192. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36193. */
  36194. dumpNextRenderTargets: boolean;
  36195. /**
  36196. * The list of user defined render targets added to the scene
  36197. */
  36198. customRenderTargets: RenderTargetTexture[];
  36199. /**
  36200. * Defines if texture loading must be delayed
  36201. * If true, textures will only be loaded when they need to be rendered
  36202. */
  36203. useDelayedTextureLoading: boolean;
  36204. /**
  36205. * Gets the list of meshes imported to the scene through SceneLoader
  36206. */
  36207. importedMeshesFiles: String[];
  36208. /**
  36209. * Gets or sets a boolean indicating if probes are enabled on this scene
  36210. */
  36211. probesEnabled: boolean;
  36212. /**
  36213. * Gets or sets the current offline provider to use to store scene data
  36214. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36215. */
  36216. offlineProvider: IOfflineProvider;
  36217. /**
  36218. * Gets or sets the action manager associated with the scene
  36219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36220. */
  36221. actionManager: AbstractActionManager;
  36222. private _meshesForIntersections;
  36223. /**
  36224. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36225. */
  36226. proceduralTexturesEnabled: boolean;
  36227. private _engine;
  36228. private _totalVertices;
  36229. /** @hidden */
  36230. _activeIndices: PerfCounter;
  36231. /** @hidden */
  36232. _activeParticles: PerfCounter;
  36233. /** @hidden */
  36234. _activeBones: PerfCounter;
  36235. private _animationRatio;
  36236. /** @hidden */
  36237. _animationTimeLast: number;
  36238. /** @hidden */
  36239. _animationTime: number;
  36240. /**
  36241. * Gets or sets a general scale for animation speed
  36242. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36243. */
  36244. animationTimeScale: number;
  36245. /** @hidden */
  36246. _cachedMaterial: Nullable<Material>;
  36247. /** @hidden */
  36248. _cachedEffect: Nullable<Effect>;
  36249. /** @hidden */
  36250. _cachedVisibility: Nullable<number>;
  36251. private _renderId;
  36252. private _frameId;
  36253. private _executeWhenReadyTimeoutId;
  36254. private _intermediateRendering;
  36255. private _viewUpdateFlag;
  36256. private _projectionUpdateFlag;
  36257. /** @hidden */
  36258. _toBeDisposed: Nullable<IDisposable>[];
  36259. private _activeRequests;
  36260. /** @hidden */
  36261. _pendingData: any[];
  36262. private _isDisposed;
  36263. /**
  36264. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36265. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36266. */
  36267. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36268. private _activeMeshes;
  36269. private _processedMaterials;
  36270. private _renderTargets;
  36271. /** @hidden */
  36272. _activeParticleSystems: SmartArray<IParticleSystem>;
  36273. private _activeSkeletons;
  36274. private _softwareSkinnedMeshes;
  36275. private _renderingManager;
  36276. /** @hidden */
  36277. _activeAnimatables: Animatable[];
  36278. private _transformMatrix;
  36279. private _sceneUbo;
  36280. /** @hidden */
  36281. _viewMatrix: Matrix;
  36282. private _projectionMatrix;
  36283. /** @hidden */
  36284. _forcedViewPosition: Nullable<Vector3>;
  36285. /** @hidden */
  36286. _frustumPlanes: Plane[];
  36287. /**
  36288. * Gets the list of frustum planes (built from the active camera)
  36289. */
  36290. get frustumPlanes(): Plane[];
  36291. /**
  36292. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36293. * This is useful if there are more lights that the maximum simulteanous authorized
  36294. */
  36295. requireLightSorting: boolean;
  36296. /** @hidden */
  36297. readonly useMaterialMeshMap: boolean;
  36298. /** @hidden */
  36299. readonly useClonedMeshMap: boolean;
  36300. private _externalData;
  36301. private _uid;
  36302. /**
  36303. * @hidden
  36304. * Backing store of defined scene components.
  36305. */
  36306. _components: ISceneComponent[];
  36307. /**
  36308. * @hidden
  36309. * Backing store of defined scene components.
  36310. */
  36311. _serializableComponents: ISceneSerializableComponent[];
  36312. /**
  36313. * List of components to register on the next registration step.
  36314. */
  36315. private _transientComponents;
  36316. /**
  36317. * Registers the transient components if needed.
  36318. */
  36319. private _registerTransientComponents;
  36320. /**
  36321. * @hidden
  36322. * Add a component to the scene.
  36323. * Note that the ccomponent could be registered on th next frame if this is called after
  36324. * the register component stage.
  36325. * @param component Defines the component to add to the scene
  36326. */
  36327. _addComponent(component: ISceneComponent): void;
  36328. /**
  36329. * @hidden
  36330. * Gets a component from the scene.
  36331. * @param name defines the name of the component to retrieve
  36332. * @returns the component or null if not present
  36333. */
  36334. _getComponent(name: string): Nullable<ISceneComponent>;
  36335. /**
  36336. * @hidden
  36337. * Defines the actions happening before camera updates.
  36338. */
  36339. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36340. /**
  36341. * @hidden
  36342. * Defines the actions happening before clear the canvas.
  36343. */
  36344. _beforeClearStage: Stage<SimpleStageAction>;
  36345. /**
  36346. * @hidden
  36347. * Defines the actions when collecting render targets for the frame.
  36348. */
  36349. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36350. /**
  36351. * @hidden
  36352. * Defines the actions happening for one camera in the frame.
  36353. */
  36354. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36355. /**
  36356. * @hidden
  36357. * Defines the actions happening during the per mesh ready checks.
  36358. */
  36359. _isReadyForMeshStage: Stage<MeshStageAction>;
  36360. /**
  36361. * @hidden
  36362. * Defines the actions happening before evaluate active mesh checks.
  36363. */
  36364. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36365. /**
  36366. * @hidden
  36367. * Defines the actions happening during the evaluate sub mesh checks.
  36368. */
  36369. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36370. /**
  36371. * @hidden
  36372. * Defines the actions happening during the active mesh stage.
  36373. */
  36374. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36375. /**
  36376. * @hidden
  36377. * Defines the actions happening during the per camera render target step.
  36378. */
  36379. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36380. /**
  36381. * @hidden
  36382. * Defines the actions happening just before the active camera is drawing.
  36383. */
  36384. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36385. /**
  36386. * @hidden
  36387. * Defines the actions happening just before a render target is drawing.
  36388. */
  36389. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36390. /**
  36391. * @hidden
  36392. * Defines the actions happening just before a rendering group is drawing.
  36393. */
  36394. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36395. /**
  36396. * @hidden
  36397. * Defines the actions happening just before a mesh is drawing.
  36398. */
  36399. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36400. /**
  36401. * @hidden
  36402. * Defines the actions happening just after a mesh has been drawn.
  36403. */
  36404. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36405. /**
  36406. * @hidden
  36407. * Defines the actions happening just after a rendering group has been drawn.
  36408. */
  36409. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36410. /**
  36411. * @hidden
  36412. * Defines the actions happening just after the active camera has been drawn.
  36413. */
  36414. _afterCameraDrawStage: Stage<CameraStageAction>;
  36415. /**
  36416. * @hidden
  36417. * Defines the actions happening just after a render target has been drawn.
  36418. */
  36419. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36420. /**
  36421. * @hidden
  36422. * Defines the actions happening just after rendering all cameras and computing intersections.
  36423. */
  36424. _afterRenderStage: Stage<SimpleStageAction>;
  36425. /**
  36426. * @hidden
  36427. * Defines the actions happening when a pointer move event happens.
  36428. */
  36429. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36430. /**
  36431. * @hidden
  36432. * Defines the actions happening when a pointer down event happens.
  36433. */
  36434. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36435. /**
  36436. * @hidden
  36437. * Defines the actions happening when a pointer up event happens.
  36438. */
  36439. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36440. /**
  36441. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36442. */
  36443. private geometriesByUniqueId;
  36444. /**
  36445. * Creates a new Scene
  36446. * @param engine defines the engine to use to render this scene
  36447. * @param options defines the scene options
  36448. */
  36449. constructor(engine: Engine, options?: SceneOptions);
  36450. /**
  36451. * Gets a string idenfifying the name of the class
  36452. * @returns "Scene" string
  36453. */
  36454. getClassName(): string;
  36455. private _defaultMeshCandidates;
  36456. /**
  36457. * @hidden
  36458. */
  36459. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36460. private _defaultSubMeshCandidates;
  36461. /**
  36462. * @hidden
  36463. */
  36464. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36465. /**
  36466. * Sets the default candidate providers for the scene.
  36467. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36468. * and getCollidingSubMeshCandidates to their default function
  36469. */
  36470. setDefaultCandidateProviders(): void;
  36471. /**
  36472. * Gets the mesh that is currently under the pointer
  36473. */
  36474. get meshUnderPointer(): Nullable<AbstractMesh>;
  36475. /**
  36476. * Gets or sets the current on-screen X position of the pointer
  36477. */
  36478. get pointerX(): number;
  36479. set pointerX(value: number);
  36480. /**
  36481. * Gets or sets the current on-screen Y position of the pointer
  36482. */
  36483. get pointerY(): number;
  36484. set pointerY(value: number);
  36485. /**
  36486. * Gets the cached material (ie. the latest rendered one)
  36487. * @returns the cached material
  36488. */
  36489. getCachedMaterial(): Nullable<Material>;
  36490. /**
  36491. * Gets the cached effect (ie. the latest rendered one)
  36492. * @returns the cached effect
  36493. */
  36494. getCachedEffect(): Nullable<Effect>;
  36495. /**
  36496. * Gets the cached visibility state (ie. the latest rendered one)
  36497. * @returns the cached visibility state
  36498. */
  36499. getCachedVisibility(): Nullable<number>;
  36500. /**
  36501. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36502. * @param material defines the current material
  36503. * @param effect defines the current effect
  36504. * @param visibility defines the current visibility state
  36505. * @returns true if one parameter is not cached
  36506. */
  36507. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36508. /**
  36509. * Gets the engine associated with the scene
  36510. * @returns an Engine
  36511. */
  36512. getEngine(): Engine;
  36513. /**
  36514. * Gets the total number of vertices rendered per frame
  36515. * @returns the total number of vertices rendered per frame
  36516. */
  36517. getTotalVertices(): number;
  36518. /**
  36519. * Gets the performance counter for total vertices
  36520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36521. */
  36522. get totalVerticesPerfCounter(): PerfCounter;
  36523. /**
  36524. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36525. * @returns the total number of active indices rendered per frame
  36526. */
  36527. getActiveIndices(): number;
  36528. /**
  36529. * Gets the performance counter for active indices
  36530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36531. */
  36532. get totalActiveIndicesPerfCounter(): PerfCounter;
  36533. /**
  36534. * Gets the total number of active particles rendered per frame
  36535. * @returns the total number of active particles rendered per frame
  36536. */
  36537. getActiveParticles(): number;
  36538. /**
  36539. * Gets the performance counter for active particles
  36540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36541. */
  36542. get activeParticlesPerfCounter(): PerfCounter;
  36543. /**
  36544. * Gets the total number of active bones rendered per frame
  36545. * @returns the total number of active bones rendered per frame
  36546. */
  36547. getActiveBones(): number;
  36548. /**
  36549. * Gets the performance counter for active bones
  36550. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36551. */
  36552. get activeBonesPerfCounter(): PerfCounter;
  36553. /**
  36554. * Gets the array of active meshes
  36555. * @returns an array of AbstractMesh
  36556. */
  36557. getActiveMeshes(): SmartArray<AbstractMesh>;
  36558. /**
  36559. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36560. * @returns a number
  36561. */
  36562. getAnimationRatio(): number;
  36563. /**
  36564. * Gets an unique Id for the current render phase
  36565. * @returns a number
  36566. */
  36567. getRenderId(): number;
  36568. /**
  36569. * Gets an unique Id for the current frame
  36570. * @returns a number
  36571. */
  36572. getFrameId(): number;
  36573. /** Call this function if you want to manually increment the render Id*/
  36574. incrementRenderId(): void;
  36575. private _createUbo;
  36576. /**
  36577. * Use this method to simulate a pointer move on a mesh
  36578. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36579. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36580. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36581. * @returns the current scene
  36582. */
  36583. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36584. /**
  36585. * Use this method to simulate a pointer down on a mesh
  36586. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36587. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36588. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36589. * @returns the current scene
  36590. */
  36591. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36592. /**
  36593. * Use this method to simulate a pointer up on a mesh
  36594. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36595. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36596. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36597. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36598. * @returns the current scene
  36599. */
  36600. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36601. /**
  36602. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36603. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36604. * @returns true if the pointer was captured
  36605. */
  36606. isPointerCaptured(pointerId?: number): boolean;
  36607. /**
  36608. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36609. * @param attachUp defines if you want to attach events to pointerup
  36610. * @param attachDown defines if you want to attach events to pointerdown
  36611. * @param attachMove defines if you want to attach events to pointermove
  36612. */
  36613. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36614. /** Detaches all event handlers*/
  36615. detachControl(): void;
  36616. /**
  36617. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36618. * Delay loaded resources are not taking in account
  36619. * @return true if all required resources are ready
  36620. */
  36621. isReady(): boolean;
  36622. /** Resets all cached information relative to material (including effect and visibility) */
  36623. resetCachedMaterial(): void;
  36624. /**
  36625. * Registers a function to be called before every frame render
  36626. * @param func defines the function to register
  36627. */
  36628. registerBeforeRender(func: () => void): void;
  36629. /**
  36630. * Unregisters a function called before every frame render
  36631. * @param func defines the function to unregister
  36632. */
  36633. unregisterBeforeRender(func: () => void): void;
  36634. /**
  36635. * Registers a function to be called after every frame render
  36636. * @param func defines the function to register
  36637. */
  36638. registerAfterRender(func: () => void): void;
  36639. /**
  36640. * Unregisters a function called after every frame render
  36641. * @param func defines the function to unregister
  36642. */
  36643. unregisterAfterRender(func: () => void): void;
  36644. private _executeOnceBeforeRender;
  36645. /**
  36646. * The provided function will run before render once and will be disposed afterwards.
  36647. * A timeout delay can be provided so that the function will be executed in N ms.
  36648. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36649. * @param func The function to be executed.
  36650. * @param timeout optional delay in ms
  36651. */
  36652. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36653. /** @hidden */
  36654. _addPendingData(data: any): void;
  36655. /** @hidden */
  36656. _removePendingData(data: any): void;
  36657. /**
  36658. * Returns the number of items waiting to be loaded
  36659. * @returns the number of items waiting to be loaded
  36660. */
  36661. getWaitingItemsCount(): number;
  36662. /**
  36663. * Returns a boolean indicating if the scene is still loading data
  36664. */
  36665. get isLoading(): boolean;
  36666. /**
  36667. * Registers a function to be executed when the scene is ready
  36668. * @param {Function} func - the function to be executed
  36669. */
  36670. executeWhenReady(func: () => void): void;
  36671. /**
  36672. * Returns a promise that resolves when the scene is ready
  36673. * @returns A promise that resolves when the scene is ready
  36674. */
  36675. whenReadyAsync(): Promise<void>;
  36676. /** @hidden */
  36677. _checkIsReady(): void;
  36678. /**
  36679. * Gets all animatable attached to the scene
  36680. */
  36681. get animatables(): Animatable[];
  36682. /**
  36683. * Resets the last animation time frame.
  36684. * Useful to override when animations start running when loading a scene for the first time.
  36685. */
  36686. resetLastAnimationTimeFrame(): void;
  36687. /**
  36688. * Gets the current view matrix
  36689. * @returns a Matrix
  36690. */
  36691. getViewMatrix(): Matrix;
  36692. /**
  36693. * Gets the current projection matrix
  36694. * @returns a Matrix
  36695. */
  36696. getProjectionMatrix(): Matrix;
  36697. /**
  36698. * Gets the current transform matrix
  36699. * @returns a Matrix made of View * Projection
  36700. */
  36701. getTransformMatrix(): Matrix;
  36702. /**
  36703. * Sets the current transform matrix
  36704. * @param viewL defines the View matrix to use
  36705. * @param projectionL defines the Projection matrix to use
  36706. * @param viewR defines the right View matrix to use (if provided)
  36707. * @param projectionR defines the right Projection matrix to use (if provided)
  36708. */
  36709. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36710. /**
  36711. * Gets the uniform buffer used to store scene data
  36712. * @returns a UniformBuffer
  36713. */
  36714. getSceneUniformBuffer(): UniformBuffer;
  36715. /**
  36716. * Gets an unique (relatively to the current scene) Id
  36717. * @returns an unique number for the scene
  36718. */
  36719. getUniqueId(): number;
  36720. /**
  36721. * Add a mesh to the list of scene's meshes
  36722. * @param newMesh defines the mesh to add
  36723. * @param recursive if all child meshes should also be added to the scene
  36724. */
  36725. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36726. /**
  36727. * Remove a mesh for the list of scene's meshes
  36728. * @param toRemove defines the mesh to remove
  36729. * @param recursive if all child meshes should also be removed from the scene
  36730. * @returns the index where the mesh was in the mesh list
  36731. */
  36732. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36733. /**
  36734. * Add a transform node to the list of scene's transform nodes
  36735. * @param newTransformNode defines the transform node to add
  36736. */
  36737. addTransformNode(newTransformNode: TransformNode): void;
  36738. /**
  36739. * Remove a transform node for the list of scene's transform nodes
  36740. * @param toRemove defines the transform node to remove
  36741. * @returns the index where the transform node was in the transform node list
  36742. */
  36743. removeTransformNode(toRemove: TransformNode): number;
  36744. /**
  36745. * Remove a skeleton for the list of scene's skeletons
  36746. * @param toRemove defines the skeleton to remove
  36747. * @returns the index where the skeleton was in the skeleton list
  36748. */
  36749. removeSkeleton(toRemove: Skeleton): number;
  36750. /**
  36751. * Remove a morph target for the list of scene's morph targets
  36752. * @param toRemove defines the morph target to remove
  36753. * @returns the index where the morph target was in the morph target list
  36754. */
  36755. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36756. /**
  36757. * Remove a light for the list of scene's lights
  36758. * @param toRemove defines the light to remove
  36759. * @returns the index where the light was in the light list
  36760. */
  36761. removeLight(toRemove: Light): number;
  36762. /**
  36763. * Remove a camera for the list of scene's cameras
  36764. * @param toRemove defines the camera to remove
  36765. * @returns the index where the camera was in the camera list
  36766. */
  36767. removeCamera(toRemove: Camera): number;
  36768. /**
  36769. * Remove a particle system for the list of scene's particle systems
  36770. * @param toRemove defines the particle system to remove
  36771. * @returns the index where the particle system was in the particle system list
  36772. */
  36773. removeParticleSystem(toRemove: IParticleSystem): number;
  36774. /**
  36775. * Remove a animation for the list of scene's animations
  36776. * @param toRemove defines the animation to remove
  36777. * @returns the index where the animation was in the animation list
  36778. */
  36779. removeAnimation(toRemove: Animation): number;
  36780. /**
  36781. * Will stop the animation of the given target
  36782. * @param target - the target
  36783. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36784. * @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)
  36785. */
  36786. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36787. /**
  36788. * Removes the given animation group from this scene.
  36789. * @param toRemove The animation group to remove
  36790. * @returns The index of the removed animation group
  36791. */
  36792. removeAnimationGroup(toRemove: AnimationGroup): number;
  36793. /**
  36794. * Removes the given multi-material from this scene.
  36795. * @param toRemove The multi-material to remove
  36796. * @returns The index of the removed multi-material
  36797. */
  36798. removeMultiMaterial(toRemove: MultiMaterial): number;
  36799. /**
  36800. * Removes the given material from this scene.
  36801. * @param toRemove The material to remove
  36802. * @returns The index of the removed material
  36803. */
  36804. removeMaterial(toRemove: Material): number;
  36805. /**
  36806. * Removes the given action manager from this scene.
  36807. * @param toRemove The action manager to remove
  36808. * @returns The index of the removed action manager
  36809. */
  36810. removeActionManager(toRemove: AbstractActionManager): number;
  36811. /**
  36812. * Removes the given texture from this scene.
  36813. * @param toRemove The texture to remove
  36814. * @returns The index of the removed texture
  36815. */
  36816. removeTexture(toRemove: BaseTexture): number;
  36817. /**
  36818. * Adds the given light to this scene
  36819. * @param newLight The light to add
  36820. */
  36821. addLight(newLight: Light): void;
  36822. /**
  36823. * Sorts the list list based on light priorities
  36824. */
  36825. sortLightsByPriority(): void;
  36826. /**
  36827. * Adds the given camera to this scene
  36828. * @param newCamera The camera to add
  36829. */
  36830. addCamera(newCamera: Camera): void;
  36831. /**
  36832. * Adds the given skeleton to this scene
  36833. * @param newSkeleton The skeleton to add
  36834. */
  36835. addSkeleton(newSkeleton: Skeleton): void;
  36836. /**
  36837. * Adds the given particle system to this scene
  36838. * @param newParticleSystem The particle system to add
  36839. */
  36840. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36841. /**
  36842. * Adds the given animation to this scene
  36843. * @param newAnimation The animation to add
  36844. */
  36845. addAnimation(newAnimation: Animation): void;
  36846. /**
  36847. * Adds the given animation group to this scene.
  36848. * @param newAnimationGroup The animation group to add
  36849. */
  36850. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36851. /**
  36852. * Adds the given multi-material to this scene
  36853. * @param newMultiMaterial The multi-material to add
  36854. */
  36855. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36856. /**
  36857. * Adds the given material to this scene
  36858. * @param newMaterial The material to add
  36859. */
  36860. addMaterial(newMaterial: Material): void;
  36861. /**
  36862. * Adds the given morph target to this scene
  36863. * @param newMorphTargetManager The morph target to add
  36864. */
  36865. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36866. /**
  36867. * Adds the given geometry to this scene
  36868. * @param newGeometry The geometry to add
  36869. */
  36870. addGeometry(newGeometry: Geometry): void;
  36871. /**
  36872. * Adds the given action manager to this scene
  36873. * @param newActionManager The action manager to add
  36874. */
  36875. addActionManager(newActionManager: AbstractActionManager): void;
  36876. /**
  36877. * Adds the given texture to this scene.
  36878. * @param newTexture The texture to add
  36879. */
  36880. addTexture(newTexture: BaseTexture): void;
  36881. /**
  36882. * Switch active camera
  36883. * @param newCamera defines the new active camera
  36884. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36885. */
  36886. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36887. /**
  36888. * sets the active camera of the scene using its ID
  36889. * @param id defines the camera's ID
  36890. * @return the new active camera or null if none found.
  36891. */
  36892. setActiveCameraByID(id: string): Nullable<Camera>;
  36893. /**
  36894. * sets the active camera of the scene using its name
  36895. * @param name defines the camera's name
  36896. * @returns the new active camera or null if none found.
  36897. */
  36898. setActiveCameraByName(name: string): Nullable<Camera>;
  36899. /**
  36900. * get an animation group using its name
  36901. * @param name defines the material's name
  36902. * @return the animation group or null if none found.
  36903. */
  36904. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36905. /**
  36906. * Get a material using its unique id
  36907. * @param uniqueId defines the material's unique id
  36908. * @return the material or null if none found.
  36909. */
  36910. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36911. /**
  36912. * get a material using its id
  36913. * @param id defines the material's ID
  36914. * @return the material or null if none found.
  36915. */
  36916. getMaterialByID(id: string): Nullable<Material>;
  36917. /**
  36918. * Gets a the last added material using a given id
  36919. * @param id defines the material's ID
  36920. * @return the last material with the given id or null if none found.
  36921. */
  36922. getLastMaterialByID(id: string): Nullable<Material>;
  36923. /**
  36924. * Gets a material using its name
  36925. * @param name defines the material's name
  36926. * @return the material or null if none found.
  36927. */
  36928. getMaterialByName(name: string): Nullable<Material>;
  36929. /**
  36930. * Get a texture using its unique id
  36931. * @param uniqueId defines the texture's unique id
  36932. * @return the texture or null if none found.
  36933. */
  36934. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36935. /**
  36936. * Gets a camera using its id
  36937. * @param id defines the id to look for
  36938. * @returns the camera or null if not found
  36939. */
  36940. getCameraByID(id: string): Nullable<Camera>;
  36941. /**
  36942. * Gets a camera using its unique id
  36943. * @param uniqueId defines the unique id to look for
  36944. * @returns the camera or null if not found
  36945. */
  36946. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36947. /**
  36948. * Gets a camera using its name
  36949. * @param name defines the camera's name
  36950. * @return the camera or null if none found.
  36951. */
  36952. getCameraByName(name: string): Nullable<Camera>;
  36953. /**
  36954. * Gets a bone using its id
  36955. * @param id defines the bone's id
  36956. * @return the bone or null if not found
  36957. */
  36958. getBoneByID(id: string): Nullable<Bone>;
  36959. /**
  36960. * Gets a bone using its id
  36961. * @param name defines the bone's name
  36962. * @return the bone or null if not found
  36963. */
  36964. getBoneByName(name: string): Nullable<Bone>;
  36965. /**
  36966. * Gets a light node using its name
  36967. * @param name defines the the light's name
  36968. * @return the light or null if none found.
  36969. */
  36970. getLightByName(name: string): Nullable<Light>;
  36971. /**
  36972. * Gets a light node using its id
  36973. * @param id defines the light's id
  36974. * @return the light or null if none found.
  36975. */
  36976. getLightByID(id: string): Nullable<Light>;
  36977. /**
  36978. * Gets a light node using its scene-generated unique ID
  36979. * @param uniqueId defines the light's unique id
  36980. * @return the light or null if none found.
  36981. */
  36982. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36983. /**
  36984. * Gets a particle system by id
  36985. * @param id defines the particle system id
  36986. * @return the corresponding system or null if none found
  36987. */
  36988. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36989. /**
  36990. * Gets a geometry using its ID
  36991. * @param id defines the geometry's id
  36992. * @return the geometry or null if none found.
  36993. */
  36994. getGeometryByID(id: string): Nullable<Geometry>;
  36995. private _getGeometryByUniqueID;
  36996. /**
  36997. * Add a new geometry to this scene
  36998. * @param geometry defines the geometry to be added to the scene.
  36999. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37000. * @return a boolean defining if the geometry was added or not
  37001. */
  37002. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37003. /**
  37004. * Removes an existing geometry
  37005. * @param geometry defines the geometry to be removed from the scene
  37006. * @return a boolean defining if the geometry was removed or not
  37007. */
  37008. removeGeometry(geometry: Geometry): boolean;
  37009. /**
  37010. * Gets the list of geometries attached to the scene
  37011. * @returns an array of Geometry
  37012. */
  37013. getGeometries(): Geometry[];
  37014. /**
  37015. * Gets the first added mesh found of a given ID
  37016. * @param id defines the id to search for
  37017. * @return the mesh found or null if not found at all
  37018. */
  37019. getMeshByID(id: string): Nullable<AbstractMesh>;
  37020. /**
  37021. * Gets a list of meshes using their id
  37022. * @param id defines the id to search for
  37023. * @returns a list of meshes
  37024. */
  37025. getMeshesByID(id: string): Array<AbstractMesh>;
  37026. /**
  37027. * Gets the first added transform node found of a given ID
  37028. * @param id defines the id to search for
  37029. * @return the found transform node or null if not found at all.
  37030. */
  37031. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37032. /**
  37033. * Gets a transform node with its auto-generated unique id
  37034. * @param uniqueId efines the unique id to search for
  37035. * @return the found transform node or null if not found at all.
  37036. */
  37037. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37038. /**
  37039. * Gets a list of transform nodes using their id
  37040. * @param id defines the id to search for
  37041. * @returns a list of transform nodes
  37042. */
  37043. getTransformNodesByID(id: string): Array<TransformNode>;
  37044. /**
  37045. * Gets a mesh with its auto-generated unique id
  37046. * @param uniqueId defines the unique id to search for
  37047. * @return the found mesh or null if not found at all.
  37048. */
  37049. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37050. /**
  37051. * Gets a the last added mesh using a given id
  37052. * @param id defines the id to search for
  37053. * @return the found mesh or null if not found at all.
  37054. */
  37055. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37056. /**
  37057. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37058. * @param id defines the id to search for
  37059. * @return the found node or null if not found at all
  37060. */
  37061. getLastEntryByID(id: string): Nullable<Node>;
  37062. /**
  37063. * Gets a node (Mesh, Camera, Light) using a given id
  37064. * @param id defines the id to search for
  37065. * @return the found node or null if not found at all
  37066. */
  37067. getNodeByID(id: string): Nullable<Node>;
  37068. /**
  37069. * Gets a node (Mesh, Camera, Light) using a given name
  37070. * @param name defines the name to search for
  37071. * @return the found node or null if not found at all.
  37072. */
  37073. getNodeByName(name: string): Nullable<Node>;
  37074. /**
  37075. * Gets a mesh using a given name
  37076. * @param name defines the name to search for
  37077. * @return the found mesh or null if not found at all.
  37078. */
  37079. getMeshByName(name: string): Nullable<AbstractMesh>;
  37080. /**
  37081. * Gets a transform node using a given name
  37082. * @param name defines the name to search for
  37083. * @return the found transform node or null if not found at all.
  37084. */
  37085. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37086. /**
  37087. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37088. * @param id defines the id to search for
  37089. * @return the found skeleton or null if not found at all.
  37090. */
  37091. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37092. /**
  37093. * Gets a skeleton using a given auto generated unique id
  37094. * @param uniqueId defines the unique id to search for
  37095. * @return the found skeleton or null if not found at all.
  37096. */
  37097. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37098. /**
  37099. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37100. * @param id defines the id to search for
  37101. * @return the found skeleton or null if not found at all.
  37102. */
  37103. getSkeletonById(id: string): Nullable<Skeleton>;
  37104. /**
  37105. * Gets a skeleton using a given name
  37106. * @param name defines the name to search for
  37107. * @return the found skeleton or null if not found at all.
  37108. */
  37109. getSkeletonByName(name: string): Nullable<Skeleton>;
  37110. /**
  37111. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37112. * @param id defines the id to search for
  37113. * @return the found morph target manager or null if not found at all.
  37114. */
  37115. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37116. /**
  37117. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37118. * @param id defines the id to search for
  37119. * @return the found morph target or null if not found at all.
  37120. */
  37121. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37122. /**
  37123. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37124. * @param name defines the name to search for
  37125. * @return the found morph target or null if not found at all.
  37126. */
  37127. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37128. /**
  37129. * Gets a boolean indicating if the given mesh is active
  37130. * @param mesh defines the mesh to look for
  37131. * @returns true if the mesh is in the active list
  37132. */
  37133. isActiveMesh(mesh: AbstractMesh): boolean;
  37134. /**
  37135. * Return a unique id as a string which can serve as an identifier for the scene
  37136. */
  37137. get uid(): string;
  37138. /**
  37139. * Add an externaly attached data from its key.
  37140. * This method call will fail and return false, if such key already exists.
  37141. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37142. * @param key the unique key that identifies the data
  37143. * @param data the data object to associate to the key for this Engine instance
  37144. * @return true if no such key were already present and the data was added successfully, false otherwise
  37145. */
  37146. addExternalData<T>(key: string, data: T): boolean;
  37147. /**
  37148. * Get an externaly attached data from its key
  37149. * @param key the unique key that identifies the data
  37150. * @return the associated data, if present (can be null), or undefined if not present
  37151. */
  37152. getExternalData<T>(key: string): Nullable<T>;
  37153. /**
  37154. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37155. * @param key the unique key that identifies the data
  37156. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37157. * @return the associated data, can be null if the factory returned null.
  37158. */
  37159. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37160. /**
  37161. * Remove an externaly attached data from the Engine instance
  37162. * @param key the unique key that identifies the data
  37163. * @return true if the data was successfully removed, false if it doesn't exist
  37164. */
  37165. removeExternalData(key: string): boolean;
  37166. private _evaluateSubMesh;
  37167. /**
  37168. * Clear the processed materials smart array preventing retention point in material dispose.
  37169. */
  37170. freeProcessedMaterials(): void;
  37171. private _preventFreeActiveMeshesAndRenderingGroups;
  37172. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37173. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37174. * when disposing several meshes in a row or a hierarchy of meshes.
  37175. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37176. */
  37177. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37178. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37179. /**
  37180. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37181. */
  37182. freeActiveMeshes(): void;
  37183. /**
  37184. * Clear the info related to rendering groups preventing retention points during dispose.
  37185. */
  37186. freeRenderingGroups(): void;
  37187. /** @hidden */
  37188. _isInIntermediateRendering(): boolean;
  37189. /**
  37190. * Lambda returning the list of potentially active meshes.
  37191. */
  37192. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37193. /**
  37194. * Lambda returning the list of potentially active sub meshes.
  37195. */
  37196. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37197. /**
  37198. * Lambda returning the list of potentially intersecting sub meshes.
  37199. */
  37200. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37201. /**
  37202. * Lambda returning the list of potentially colliding sub meshes.
  37203. */
  37204. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37205. private _activeMeshesFrozen;
  37206. private _skipEvaluateActiveMeshesCompletely;
  37207. /**
  37208. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37209. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37210. * @returns the current scene
  37211. */
  37212. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37213. /**
  37214. * Use this function to restart evaluating active meshes on every frame
  37215. * @returns the current scene
  37216. */
  37217. unfreezeActiveMeshes(): Scene;
  37218. private _evaluateActiveMeshes;
  37219. private _activeMesh;
  37220. /**
  37221. * Update the transform matrix to update from the current active camera
  37222. * @param force defines a boolean used to force the update even if cache is up to date
  37223. */
  37224. updateTransformMatrix(force?: boolean): void;
  37225. private _bindFrameBuffer;
  37226. /** @hidden */
  37227. _allowPostProcessClearColor: boolean;
  37228. /** @hidden */
  37229. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37230. private _processSubCameras;
  37231. private _checkIntersections;
  37232. /** @hidden */
  37233. _advancePhysicsEngineStep(step: number): void;
  37234. /**
  37235. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37236. */
  37237. getDeterministicFrameTime: () => number;
  37238. /** @hidden */
  37239. _animate(): void;
  37240. /** Execute all animations (for a frame) */
  37241. animate(): void;
  37242. /**
  37243. * Render the scene
  37244. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37245. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37246. */
  37247. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37248. /**
  37249. * Freeze all materials
  37250. * A frozen material will not be updatable but should be faster to render
  37251. */
  37252. freezeMaterials(): void;
  37253. /**
  37254. * Unfreeze all materials
  37255. * A frozen material will not be updatable but should be faster to render
  37256. */
  37257. unfreezeMaterials(): void;
  37258. /**
  37259. * Releases all held ressources
  37260. */
  37261. dispose(): void;
  37262. /**
  37263. * Gets if the scene is already disposed
  37264. */
  37265. get isDisposed(): boolean;
  37266. /**
  37267. * Call this function to reduce memory footprint of the scene.
  37268. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37269. */
  37270. clearCachedVertexData(): void;
  37271. /**
  37272. * This function will remove the local cached buffer data from texture.
  37273. * It will save memory but will prevent the texture from being rebuilt
  37274. */
  37275. cleanCachedTextureBuffer(): void;
  37276. /**
  37277. * Get the world extend vectors with an optional filter
  37278. *
  37279. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37280. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37281. */
  37282. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37283. min: Vector3;
  37284. max: Vector3;
  37285. };
  37286. /**
  37287. * Creates a ray that can be used to pick in the scene
  37288. * @param x defines the x coordinate of the origin (on-screen)
  37289. * @param y defines the y coordinate of the origin (on-screen)
  37290. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37291. * @param camera defines the camera to use for the picking
  37292. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37293. * @returns a Ray
  37294. */
  37295. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37296. /**
  37297. * Creates a ray that can be used to pick in the scene
  37298. * @param x defines the x coordinate of the origin (on-screen)
  37299. * @param y defines the y coordinate of the origin (on-screen)
  37300. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37301. * @param result defines the ray where to store the picking ray
  37302. * @param camera defines the camera to use for the picking
  37303. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37304. * @returns the current scene
  37305. */
  37306. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37307. /**
  37308. * Creates a ray that can be used to pick in the scene
  37309. * @param x defines the x coordinate of the origin (on-screen)
  37310. * @param y defines the y coordinate of the origin (on-screen)
  37311. * @param camera defines the camera to use for the picking
  37312. * @returns a Ray
  37313. */
  37314. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37315. /**
  37316. * Creates a ray that can be used to pick in the scene
  37317. * @param x defines the x coordinate of the origin (on-screen)
  37318. * @param y defines the y coordinate of the origin (on-screen)
  37319. * @param result defines the ray where to store the picking ray
  37320. * @param camera defines the camera to use for the picking
  37321. * @returns the current scene
  37322. */
  37323. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37324. /** Launch a ray to try to pick a mesh in the scene
  37325. * @param x position on screen
  37326. * @param y position on screen
  37327. * @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
  37328. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37329. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37330. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37331. * @returns a PickingInfo
  37332. */
  37333. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37334. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37335. * @param x position on screen
  37336. * @param y position on screen
  37337. * @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
  37338. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37339. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37340. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  37341. */
  37342. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37343. /** Use the given ray to pick a mesh in the scene
  37344. * @param ray The ray to use to pick meshes
  37345. * @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
  37346. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37347. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37348. * @returns a PickingInfo
  37349. */
  37350. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37351. /**
  37352. * Launch a ray to try to pick a mesh in the scene
  37353. * @param x X position on screen
  37354. * @param y Y position on screen
  37355. * @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
  37356. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37358. * @returns an array of PickingInfo
  37359. */
  37360. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37361. /**
  37362. * Launch a ray to try to pick a mesh in the scene
  37363. * @param ray Ray to use
  37364. * @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
  37365. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37366. * @returns an array of PickingInfo
  37367. */
  37368. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37369. /**
  37370. * Force the value of meshUnderPointer
  37371. * @param mesh defines the mesh to use
  37372. */
  37373. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37374. /**
  37375. * Gets the mesh under the pointer
  37376. * @returns a Mesh or null if no mesh is under the pointer
  37377. */
  37378. getPointerOverMesh(): Nullable<AbstractMesh>;
  37379. /** @hidden */
  37380. _rebuildGeometries(): void;
  37381. /** @hidden */
  37382. _rebuildTextures(): void;
  37383. private _getByTags;
  37384. /**
  37385. * Get a list of meshes by tags
  37386. * @param tagsQuery defines the tags query to use
  37387. * @param forEach defines a predicate used to filter results
  37388. * @returns an array of Mesh
  37389. */
  37390. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37391. /**
  37392. * Get a list of cameras by tags
  37393. * @param tagsQuery defines the tags query to use
  37394. * @param forEach defines a predicate used to filter results
  37395. * @returns an array of Camera
  37396. */
  37397. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37398. /**
  37399. * Get a list of lights by tags
  37400. * @param tagsQuery defines the tags query to use
  37401. * @param forEach defines a predicate used to filter results
  37402. * @returns an array of Light
  37403. */
  37404. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37405. /**
  37406. * Get a list of materials by tags
  37407. * @param tagsQuery defines the tags query to use
  37408. * @param forEach defines a predicate used to filter results
  37409. * @returns an array of Material
  37410. */
  37411. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37412. /**
  37413. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37414. * This allowed control for front to back rendering or reversly depending of the special needs.
  37415. *
  37416. * @param renderingGroupId The rendering group id corresponding to its index
  37417. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37418. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37419. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37420. */
  37421. 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;
  37422. /**
  37423. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37424. *
  37425. * @param renderingGroupId The rendering group id corresponding to its index
  37426. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37427. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37428. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37429. */
  37430. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37431. /**
  37432. * Gets the current auto clear configuration for one rendering group of the rendering
  37433. * manager.
  37434. * @param index the rendering group index to get the information for
  37435. * @returns The auto clear setup for the requested rendering group
  37436. */
  37437. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37438. private _blockMaterialDirtyMechanism;
  37439. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37440. get blockMaterialDirtyMechanism(): boolean;
  37441. set blockMaterialDirtyMechanism(value: boolean);
  37442. /**
  37443. * Will flag all materials as dirty to trigger new shader compilation
  37444. * @param flag defines the flag used to specify which material part must be marked as dirty
  37445. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37446. */
  37447. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37448. /** @hidden */
  37449. _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;
  37450. /** @hidden */
  37451. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37452. /** @hidden */
  37453. _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;
  37454. /** @hidden */
  37455. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37456. /** @hidden */
  37457. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37458. /** @hidden */
  37459. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37460. }
  37461. }
  37462. declare module BABYLON {
  37463. /**
  37464. * Set of assets to keep when moving a scene into an asset container.
  37465. */
  37466. export class KeepAssets extends AbstractScene {
  37467. }
  37468. /**
  37469. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37470. */
  37471. export class InstantiatedEntries {
  37472. /**
  37473. * List of new root nodes (eg. nodes with no parent)
  37474. */
  37475. rootNodes: TransformNode[];
  37476. /**
  37477. * List of new skeletons
  37478. */
  37479. skeletons: Skeleton[];
  37480. /**
  37481. * List of new animation groups
  37482. */
  37483. animationGroups: AnimationGroup[];
  37484. }
  37485. /**
  37486. * Container with a set of assets that can be added or removed from a scene.
  37487. */
  37488. export class AssetContainer extends AbstractScene {
  37489. private _wasAddedToScene;
  37490. /**
  37491. * The scene the AssetContainer belongs to.
  37492. */
  37493. scene: Scene;
  37494. /**
  37495. * Instantiates an AssetContainer.
  37496. * @param scene The scene the AssetContainer belongs to.
  37497. */
  37498. constructor(scene: Scene);
  37499. /**
  37500. * Instantiate or clone all meshes and add the new ones to the scene.
  37501. * Skeletons and animation groups will all be cloned
  37502. * @param nameFunction defines an optional function used to get new names for clones
  37503. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37504. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37505. */
  37506. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37507. /**
  37508. * Adds all the assets from the container to the scene.
  37509. */
  37510. addAllToScene(): void;
  37511. /**
  37512. * Removes all the assets in the container from the scene
  37513. */
  37514. removeAllFromScene(): void;
  37515. /**
  37516. * Disposes all the assets in the container
  37517. */
  37518. dispose(): void;
  37519. private _moveAssets;
  37520. /**
  37521. * Removes all the assets contained in the scene and adds them to the container.
  37522. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37523. */
  37524. moveAllFromScene(keepAssets?: KeepAssets): void;
  37525. /**
  37526. * 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.
  37527. * @returns the root mesh
  37528. */
  37529. createRootMesh(): Mesh;
  37530. /**
  37531. * Merge animations (direct and animation groups) from this asset container into a scene
  37532. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37533. * @param animatables set of animatables to retarget to a node from the scene
  37534. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37535. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37536. */
  37537. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37538. }
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * Defines how the parser contract is defined.
  37543. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37544. */
  37545. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37546. /**
  37547. * Defines how the individual parser contract is defined.
  37548. * These parser can parse an individual asset
  37549. */
  37550. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37551. /**
  37552. * Base class of the scene acting as a container for the different elements composing a scene.
  37553. * This class is dynamically extended by the different components of the scene increasing
  37554. * flexibility and reducing coupling
  37555. */
  37556. export abstract class AbstractScene {
  37557. /**
  37558. * Stores the list of available parsers in the application.
  37559. */
  37560. private static _BabylonFileParsers;
  37561. /**
  37562. * Stores the list of available individual parsers in the application.
  37563. */
  37564. private static _IndividualBabylonFileParsers;
  37565. /**
  37566. * Adds a parser in the list of available ones
  37567. * @param name Defines the name of the parser
  37568. * @param parser Defines the parser to add
  37569. */
  37570. static AddParser(name: string, parser: BabylonFileParser): void;
  37571. /**
  37572. * Gets a general parser from the list of avaialble ones
  37573. * @param name Defines the name of the parser
  37574. * @returns the requested parser or null
  37575. */
  37576. static GetParser(name: string): Nullable<BabylonFileParser>;
  37577. /**
  37578. * Adds n individual parser in the list of available ones
  37579. * @param name Defines the name of the parser
  37580. * @param parser Defines the parser to add
  37581. */
  37582. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37583. /**
  37584. * Gets an individual parser from the list of avaialble ones
  37585. * @param name Defines the name of the parser
  37586. * @returns the requested parser or null
  37587. */
  37588. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37589. /**
  37590. * Parser json data and populate both a scene and its associated container object
  37591. * @param jsonData Defines the data to parse
  37592. * @param scene Defines the scene to parse the data for
  37593. * @param container Defines the container attached to the parsing sequence
  37594. * @param rootUrl Defines the root url of the data
  37595. */
  37596. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37597. /**
  37598. * Gets the list of root nodes (ie. nodes with no parent)
  37599. */
  37600. rootNodes: Node[];
  37601. /** All of the cameras added to this scene
  37602. * @see http://doc.babylonjs.com/babylon101/cameras
  37603. */
  37604. cameras: Camera[];
  37605. /**
  37606. * All of the lights added to this scene
  37607. * @see http://doc.babylonjs.com/babylon101/lights
  37608. */
  37609. lights: Light[];
  37610. /**
  37611. * All of the (abstract) meshes added to this scene
  37612. */
  37613. meshes: AbstractMesh[];
  37614. /**
  37615. * The list of skeletons added to the scene
  37616. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37617. */
  37618. skeletons: Skeleton[];
  37619. /**
  37620. * All of the particle systems added to this scene
  37621. * @see http://doc.babylonjs.com/babylon101/particles
  37622. */
  37623. particleSystems: IParticleSystem[];
  37624. /**
  37625. * Gets a list of Animations associated with the scene
  37626. */
  37627. animations: Animation[];
  37628. /**
  37629. * All of the animation groups added to this scene
  37630. * @see http://doc.babylonjs.com/how_to/group
  37631. */
  37632. animationGroups: AnimationGroup[];
  37633. /**
  37634. * All of the multi-materials added to this scene
  37635. * @see http://doc.babylonjs.com/how_to/multi_materials
  37636. */
  37637. multiMaterials: MultiMaterial[];
  37638. /**
  37639. * All of the materials added to this scene
  37640. * In the context of a Scene, it is not supposed to be modified manually.
  37641. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37642. * Note also that the order of the Material within the array is not significant and might change.
  37643. * @see http://doc.babylonjs.com/babylon101/materials
  37644. */
  37645. materials: Material[];
  37646. /**
  37647. * The list of morph target managers added to the scene
  37648. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37649. */
  37650. morphTargetManagers: MorphTargetManager[];
  37651. /**
  37652. * The list of geometries used in the scene.
  37653. */
  37654. geometries: Geometry[];
  37655. /**
  37656. * All of the tranform nodes added to this scene
  37657. * In the context of a Scene, it is not supposed to be modified manually.
  37658. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37659. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37660. * @see http://doc.babylonjs.com/how_to/transformnode
  37661. */
  37662. transformNodes: TransformNode[];
  37663. /**
  37664. * ActionManagers available on the scene.
  37665. */
  37666. actionManagers: AbstractActionManager[];
  37667. /**
  37668. * Textures to keep.
  37669. */
  37670. textures: BaseTexture[];
  37671. /**
  37672. * Environment texture for the scene
  37673. */
  37674. environmentTexture: Nullable<BaseTexture>;
  37675. /**
  37676. * @returns all meshes, lights, cameras, transformNodes and bones
  37677. */
  37678. getNodes(): Array<Node>;
  37679. }
  37680. }
  37681. declare module BABYLON {
  37682. /**
  37683. * Interface used to define options for Sound class
  37684. */
  37685. export interface ISoundOptions {
  37686. /**
  37687. * Does the sound autoplay once loaded.
  37688. */
  37689. autoplay?: boolean;
  37690. /**
  37691. * Does the sound loop after it finishes playing once.
  37692. */
  37693. loop?: boolean;
  37694. /**
  37695. * Sound's volume
  37696. */
  37697. volume?: number;
  37698. /**
  37699. * Is it a spatial sound?
  37700. */
  37701. spatialSound?: boolean;
  37702. /**
  37703. * Maximum distance to hear that sound
  37704. */
  37705. maxDistance?: number;
  37706. /**
  37707. * Uses user defined attenuation function
  37708. */
  37709. useCustomAttenuation?: boolean;
  37710. /**
  37711. * Define the roll off factor of spatial sounds.
  37712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37713. */
  37714. rolloffFactor?: number;
  37715. /**
  37716. * Define the reference distance the sound should be heard perfectly.
  37717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37718. */
  37719. refDistance?: number;
  37720. /**
  37721. * Define the distance attenuation model the sound will follow.
  37722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37723. */
  37724. distanceModel?: string;
  37725. /**
  37726. * Defines the playback speed (1 by default)
  37727. */
  37728. playbackRate?: number;
  37729. /**
  37730. * Defines if the sound is from a streaming source
  37731. */
  37732. streaming?: boolean;
  37733. /**
  37734. * Defines an optional length (in seconds) inside the sound file
  37735. */
  37736. length?: number;
  37737. /**
  37738. * Defines an optional offset (in seconds) inside the sound file
  37739. */
  37740. offset?: number;
  37741. /**
  37742. * If true, URLs will not be required to state the audio file codec to use.
  37743. */
  37744. skipCodecCheck?: boolean;
  37745. }
  37746. /**
  37747. * Defines a sound that can be played in the application.
  37748. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37750. */
  37751. export class Sound {
  37752. /**
  37753. * The name of the sound in the scene.
  37754. */
  37755. name: string;
  37756. /**
  37757. * Does the sound autoplay once loaded.
  37758. */
  37759. autoplay: boolean;
  37760. /**
  37761. * Does the sound loop after it finishes playing once.
  37762. */
  37763. loop: boolean;
  37764. /**
  37765. * Does the sound use a custom attenuation curve to simulate the falloff
  37766. * happening when the source gets further away from the camera.
  37767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37768. */
  37769. useCustomAttenuation: boolean;
  37770. /**
  37771. * The sound track id this sound belongs to.
  37772. */
  37773. soundTrackId: number;
  37774. /**
  37775. * Is this sound currently played.
  37776. */
  37777. isPlaying: boolean;
  37778. /**
  37779. * Is this sound currently paused.
  37780. */
  37781. isPaused: boolean;
  37782. /**
  37783. * Does this sound enables spatial sound.
  37784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37785. */
  37786. spatialSound: boolean;
  37787. /**
  37788. * Define the reference distance the sound should be heard perfectly.
  37789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37790. */
  37791. refDistance: number;
  37792. /**
  37793. * Define the roll off factor of spatial sounds.
  37794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37795. */
  37796. rolloffFactor: number;
  37797. /**
  37798. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37800. */
  37801. maxDistance: number;
  37802. /**
  37803. * Define the distance attenuation model the sound will follow.
  37804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37805. */
  37806. distanceModel: string;
  37807. /**
  37808. * @hidden
  37809. * Back Compat
  37810. **/
  37811. onended: () => any;
  37812. /**
  37813. * Observable event when the current playing sound finishes.
  37814. */
  37815. onEndedObservable: Observable<Sound>;
  37816. private _panningModel;
  37817. private _playbackRate;
  37818. private _streaming;
  37819. private _startTime;
  37820. private _startOffset;
  37821. private _position;
  37822. /** @hidden */
  37823. _positionInEmitterSpace: boolean;
  37824. private _localDirection;
  37825. private _volume;
  37826. private _isReadyToPlay;
  37827. private _isDirectional;
  37828. private _readyToPlayCallback;
  37829. private _audioBuffer;
  37830. private _soundSource;
  37831. private _streamingSource;
  37832. private _soundPanner;
  37833. private _soundGain;
  37834. private _inputAudioNode;
  37835. private _outputAudioNode;
  37836. private _coneInnerAngle;
  37837. private _coneOuterAngle;
  37838. private _coneOuterGain;
  37839. private _scene;
  37840. private _connectedTransformNode;
  37841. private _customAttenuationFunction;
  37842. private _registerFunc;
  37843. private _isOutputConnected;
  37844. private _htmlAudioElement;
  37845. private _urlType;
  37846. private _length?;
  37847. private _offset?;
  37848. /** @hidden */
  37849. static _SceneComponentInitialization: (scene: Scene) => void;
  37850. /**
  37851. * Create a sound and attach it to a scene
  37852. * @param name Name of your sound
  37853. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37854. * @param scene defines the scene the sound belongs to
  37855. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37856. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37857. */
  37858. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37859. /**
  37860. * Release the sound and its associated resources
  37861. */
  37862. dispose(): void;
  37863. /**
  37864. * Gets if the sounds is ready to be played or not.
  37865. * @returns true if ready, otherwise false
  37866. */
  37867. isReady(): boolean;
  37868. private _soundLoaded;
  37869. /**
  37870. * Sets the data of the sound from an audiobuffer
  37871. * @param audioBuffer The audioBuffer containing the data
  37872. */
  37873. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37874. /**
  37875. * Updates the current sounds options such as maxdistance, loop...
  37876. * @param options A JSON object containing values named as the object properties
  37877. */
  37878. updateOptions(options: ISoundOptions): void;
  37879. private _createSpatialParameters;
  37880. private _updateSpatialParameters;
  37881. /**
  37882. * Switch the panning model to HRTF:
  37883. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37885. */
  37886. switchPanningModelToHRTF(): void;
  37887. /**
  37888. * Switch the panning model to Equal Power:
  37889. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37891. */
  37892. switchPanningModelToEqualPower(): void;
  37893. private _switchPanningModel;
  37894. /**
  37895. * Connect this sound to a sound track audio node like gain...
  37896. * @param soundTrackAudioNode the sound track audio node to connect to
  37897. */
  37898. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37899. /**
  37900. * Transform this sound into a directional source
  37901. * @param coneInnerAngle Size of the inner cone in degree
  37902. * @param coneOuterAngle Size of the outer cone in degree
  37903. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37904. */
  37905. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37906. /**
  37907. * Gets or sets the inner angle for the directional cone.
  37908. */
  37909. get directionalConeInnerAngle(): number;
  37910. /**
  37911. * Gets or sets the inner angle for the directional cone.
  37912. */
  37913. set directionalConeInnerAngle(value: number);
  37914. /**
  37915. * Gets or sets the outer angle for the directional cone.
  37916. */
  37917. get directionalConeOuterAngle(): number;
  37918. /**
  37919. * Gets or sets the outer angle for the directional cone.
  37920. */
  37921. set directionalConeOuterAngle(value: number);
  37922. /**
  37923. * Sets the position of the emitter if spatial sound is enabled
  37924. * @param newPosition Defines the new posisiton
  37925. */
  37926. setPosition(newPosition: Vector3): void;
  37927. /**
  37928. * Sets the local direction of the emitter if spatial sound is enabled
  37929. * @param newLocalDirection Defines the new local direction
  37930. */
  37931. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37932. private _updateDirection;
  37933. /** @hidden */
  37934. updateDistanceFromListener(): void;
  37935. /**
  37936. * Sets a new custom attenuation function for the sound.
  37937. * @param callback Defines the function used for the attenuation
  37938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37939. */
  37940. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37941. /**
  37942. * Play the sound
  37943. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37944. * @param offset (optional) Start the sound at a specific time in seconds
  37945. * @param length (optional) Sound duration (in seconds)
  37946. */
  37947. play(time?: number, offset?: number, length?: number): void;
  37948. private _onended;
  37949. /**
  37950. * Stop the sound
  37951. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37952. */
  37953. stop(time?: number): void;
  37954. /**
  37955. * Put the sound in pause
  37956. */
  37957. pause(): void;
  37958. /**
  37959. * Sets a dedicated volume for this sounds
  37960. * @param newVolume Define the new volume of the sound
  37961. * @param time Define time for gradual change to new volume
  37962. */
  37963. setVolume(newVolume: number, time?: number): void;
  37964. /**
  37965. * Set the sound play back rate
  37966. * @param newPlaybackRate Define the playback rate the sound should be played at
  37967. */
  37968. setPlaybackRate(newPlaybackRate: number): void;
  37969. /**
  37970. * Gets the volume of the sound.
  37971. * @returns the volume of the sound
  37972. */
  37973. getVolume(): number;
  37974. /**
  37975. * Attach the sound to a dedicated mesh
  37976. * @param transformNode The transform node to connect the sound with
  37977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37978. */
  37979. attachToMesh(transformNode: TransformNode): void;
  37980. /**
  37981. * Detach the sound from the previously attached mesh
  37982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37983. */
  37984. detachFromMesh(): void;
  37985. private _onRegisterAfterWorldMatrixUpdate;
  37986. /**
  37987. * Clone the current sound in the scene.
  37988. * @returns the new sound clone
  37989. */
  37990. clone(): Nullable<Sound>;
  37991. /**
  37992. * Gets the current underlying audio buffer containing the data
  37993. * @returns the audio buffer
  37994. */
  37995. getAudioBuffer(): Nullable<AudioBuffer>;
  37996. /**
  37997. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37998. * @returns the source node
  37999. */
  38000. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38001. /**
  38002. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38003. * @returns the gain node
  38004. */
  38005. getSoundGain(): Nullable<GainNode>;
  38006. /**
  38007. * Serializes the Sound in a JSON representation
  38008. * @returns the JSON representation of the sound
  38009. */
  38010. serialize(): any;
  38011. /**
  38012. * Parse a JSON representation of a sound to innstantiate in a given scene
  38013. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38014. * @param scene Define the scene the new parsed sound should be created in
  38015. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38016. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38017. * @returns the newly parsed sound
  38018. */
  38019. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38020. }
  38021. }
  38022. declare module BABYLON {
  38023. /**
  38024. * This defines an action helpful to play a defined sound on a triggered action.
  38025. */
  38026. export class PlaySoundAction extends Action {
  38027. private _sound;
  38028. /**
  38029. * Instantiate the action
  38030. * @param triggerOptions defines the trigger options
  38031. * @param sound defines the sound to play
  38032. * @param condition defines the trigger related conditions
  38033. */
  38034. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38035. /** @hidden */
  38036. _prepare(): void;
  38037. /**
  38038. * Execute the action and play the sound.
  38039. */
  38040. execute(): void;
  38041. /**
  38042. * Serializes the actions and its related information.
  38043. * @param parent defines the object to serialize in
  38044. * @returns the serialized object
  38045. */
  38046. serialize(parent: any): any;
  38047. }
  38048. /**
  38049. * This defines an action helpful to stop a defined sound on a triggered action.
  38050. */
  38051. export class StopSoundAction extends Action {
  38052. private _sound;
  38053. /**
  38054. * Instantiate the action
  38055. * @param triggerOptions defines the trigger options
  38056. * @param sound defines the sound to stop
  38057. * @param condition defines the trigger related conditions
  38058. */
  38059. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38060. /** @hidden */
  38061. _prepare(): void;
  38062. /**
  38063. * Execute the action and stop the sound.
  38064. */
  38065. execute(): void;
  38066. /**
  38067. * Serializes the actions and its related information.
  38068. * @param parent defines the object to serialize in
  38069. * @returns the serialized object
  38070. */
  38071. serialize(parent: any): any;
  38072. }
  38073. }
  38074. declare module BABYLON {
  38075. /**
  38076. * This defines an action responsible to change the value of a property
  38077. * by interpolating between its current value and the newly set one once triggered.
  38078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38079. */
  38080. export class InterpolateValueAction extends Action {
  38081. /**
  38082. * Defines the path of the property where the value should be interpolated
  38083. */
  38084. propertyPath: string;
  38085. /**
  38086. * Defines the target value at the end of the interpolation.
  38087. */
  38088. value: any;
  38089. /**
  38090. * Defines the time it will take for the property to interpolate to the value.
  38091. */
  38092. duration: number;
  38093. /**
  38094. * Defines if the other scene animations should be stopped when the action has been triggered
  38095. */
  38096. stopOtherAnimations?: boolean;
  38097. /**
  38098. * Defines a callback raised once the interpolation animation has been done.
  38099. */
  38100. onInterpolationDone?: () => void;
  38101. /**
  38102. * Observable triggered once the interpolation animation has been done.
  38103. */
  38104. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38105. private _target;
  38106. private _effectiveTarget;
  38107. private _property;
  38108. /**
  38109. * Instantiate the action
  38110. * @param triggerOptions defines the trigger options
  38111. * @param target defines the object containing the value to interpolate
  38112. * @param propertyPath defines the path to the property in the target object
  38113. * @param value defines the target value at the end of the interpolation
  38114. * @param duration deines the time it will take for the property to interpolate to the value.
  38115. * @param condition defines the trigger related conditions
  38116. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38117. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38118. */
  38119. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38120. /** @hidden */
  38121. _prepare(): void;
  38122. /**
  38123. * Execute the action starts the value interpolation.
  38124. */
  38125. execute(): void;
  38126. /**
  38127. * Serializes the actions and its related information.
  38128. * @param parent defines the object to serialize in
  38129. * @returns the serialized object
  38130. */
  38131. serialize(parent: any): any;
  38132. }
  38133. }
  38134. declare module BABYLON {
  38135. /**
  38136. * Options allowed during the creation of a sound track.
  38137. */
  38138. export interface ISoundTrackOptions {
  38139. /**
  38140. * The volume the sound track should take during creation
  38141. */
  38142. volume?: number;
  38143. /**
  38144. * Define if the sound track is the main sound track of the scene
  38145. */
  38146. mainTrack?: boolean;
  38147. }
  38148. /**
  38149. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38150. * It will be also used in a future release to apply effects on a specific track.
  38151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38152. */
  38153. export class SoundTrack {
  38154. /**
  38155. * The unique identifier of the sound track in the scene.
  38156. */
  38157. id: number;
  38158. /**
  38159. * The list of sounds included in the sound track.
  38160. */
  38161. soundCollection: Array<Sound>;
  38162. private _outputAudioNode;
  38163. private _scene;
  38164. private _connectedAnalyser;
  38165. private _options;
  38166. private _isInitialized;
  38167. /**
  38168. * Creates a new sound track.
  38169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38170. * @param scene Define the scene the sound track belongs to
  38171. * @param options
  38172. */
  38173. constructor(scene: Scene, options?: ISoundTrackOptions);
  38174. private _initializeSoundTrackAudioGraph;
  38175. /**
  38176. * Release the sound track and its associated resources
  38177. */
  38178. dispose(): void;
  38179. /**
  38180. * Adds a sound to this sound track
  38181. * @param sound define the cound to add
  38182. * @ignoreNaming
  38183. */
  38184. AddSound(sound: Sound): void;
  38185. /**
  38186. * Removes a sound to this sound track
  38187. * @param sound define the cound to remove
  38188. * @ignoreNaming
  38189. */
  38190. RemoveSound(sound: Sound): void;
  38191. /**
  38192. * Set a global volume for the full sound track.
  38193. * @param newVolume Define the new volume of the sound track
  38194. */
  38195. setVolume(newVolume: number): void;
  38196. /**
  38197. * Switch the panning model to HRTF:
  38198. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38200. */
  38201. switchPanningModelToHRTF(): void;
  38202. /**
  38203. * Switch the panning model to Equal Power:
  38204. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38206. */
  38207. switchPanningModelToEqualPower(): void;
  38208. /**
  38209. * Connect the sound track to an audio analyser allowing some amazing
  38210. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38212. * @param analyser The analyser to connect to the engine
  38213. */
  38214. connectToAnalyser(analyser: Analyser): void;
  38215. }
  38216. }
  38217. declare module BABYLON {
  38218. interface AbstractScene {
  38219. /**
  38220. * The list of sounds used in the scene.
  38221. */
  38222. sounds: Nullable<Array<Sound>>;
  38223. }
  38224. interface Scene {
  38225. /**
  38226. * @hidden
  38227. * Backing field
  38228. */
  38229. _mainSoundTrack: SoundTrack;
  38230. /**
  38231. * The main sound track played by the scene.
  38232. * It cotains your primary collection of sounds.
  38233. */
  38234. mainSoundTrack: SoundTrack;
  38235. /**
  38236. * The list of sound tracks added to the scene
  38237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38238. */
  38239. soundTracks: Nullable<Array<SoundTrack>>;
  38240. /**
  38241. * Gets a sound using a given name
  38242. * @param name defines the name to search for
  38243. * @return the found sound or null if not found at all.
  38244. */
  38245. getSoundByName(name: string): Nullable<Sound>;
  38246. /**
  38247. * Gets or sets if audio support is enabled
  38248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38249. */
  38250. audioEnabled: boolean;
  38251. /**
  38252. * Gets or sets if audio will be output to headphones
  38253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38254. */
  38255. headphone: boolean;
  38256. /**
  38257. * Gets or sets custom audio listener position provider
  38258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38259. */
  38260. audioListenerPositionProvider: Nullable<() => Vector3>;
  38261. /**
  38262. * Gets or sets a refresh rate when using 3D audio positioning
  38263. */
  38264. audioPositioningRefreshRate: number;
  38265. }
  38266. /**
  38267. * Defines the sound scene component responsible to manage any sounds
  38268. * in a given scene.
  38269. */
  38270. export class AudioSceneComponent implements ISceneSerializableComponent {
  38271. /**
  38272. * The component name helpfull to identify the component in the list of scene components.
  38273. */
  38274. readonly name: string;
  38275. /**
  38276. * The scene the component belongs to.
  38277. */
  38278. scene: Scene;
  38279. private _audioEnabled;
  38280. /**
  38281. * Gets whether audio is enabled or not.
  38282. * Please use related enable/disable method to switch state.
  38283. */
  38284. get audioEnabled(): boolean;
  38285. private _headphone;
  38286. /**
  38287. * Gets whether audio is outputing to headphone or not.
  38288. * Please use the according Switch methods to change output.
  38289. */
  38290. get headphone(): boolean;
  38291. /**
  38292. * Gets or sets a refresh rate when using 3D audio positioning
  38293. */
  38294. audioPositioningRefreshRate: number;
  38295. private _audioListenerPositionProvider;
  38296. /**
  38297. * Gets the current audio listener position provider
  38298. */
  38299. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38300. /**
  38301. * Sets a custom listener position for all sounds in the scene
  38302. * By default, this is the position of the first active camera
  38303. */
  38304. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38305. /**
  38306. * Creates a new instance of the component for the given scene
  38307. * @param scene Defines the scene to register the component in
  38308. */
  38309. constructor(scene: Scene);
  38310. /**
  38311. * Registers the component in a given scene
  38312. */
  38313. register(): void;
  38314. /**
  38315. * Rebuilds the elements related to this component in case of
  38316. * context lost for instance.
  38317. */
  38318. rebuild(): void;
  38319. /**
  38320. * Serializes the component data to the specified json object
  38321. * @param serializationObject The object to serialize to
  38322. */
  38323. serialize(serializationObject: any): void;
  38324. /**
  38325. * Adds all the elements from the container to the scene
  38326. * @param container the container holding the elements
  38327. */
  38328. addFromContainer(container: AbstractScene): void;
  38329. /**
  38330. * Removes all the elements in the container from the scene
  38331. * @param container contains the elements to remove
  38332. * @param dispose if the removed element should be disposed (default: false)
  38333. */
  38334. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38335. /**
  38336. * Disposes the component and the associated ressources.
  38337. */
  38338. dispose(): void;
  38339. /**
  38340. * Disables audio in the associated scene.
  38341. */
  38342. disableAudio(): void;
  38343. /**
  38344. * Enables audio in the associated scene.
  38345. */
  38346. enableAudio(): void;
  38347. /**
  38348. * Switch audio to headphone output.
  38349. */
  38350. switchAudioModeForHeadphones(): void;
  38351. /**
  38352. * Switch audio to normal speakers.
  38353. */
  38354. switchAudioModeForNormalSpeakers(): void;
  38355. private _cachedCameraDirection;
  38356. private _cachedCameraPosition;
  38357. private _lastCheck;
  38358. private _afterRender;
  38359. }
  38360. }
  38361. declare module BABYLON {
  38362. /**
  38363. * Wraps one or more Sound objects and selects one with random weight for playback.
  38364. */
  38365. export class WeightedSound {
  38366. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38367. loop: boolean;
  38368. private _coneInnerAngle;
  38369. private _coneOuterAngle;
  38370. private _volume;
  38371. /** A Sound is currently playing. */
  38372. isPlaying: boolean;
  38373. /** A Sound is currently paused. */
  38374. isPaused: boolean;
  38375. private _sounds;
  38376. private _weights;
  38377. private _currentIndex?;
  38378. /**
  38379. * Creates a new WeightedSound from the list of sounds given.
  38380. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38381. * @param sounds Array of Sounds that will be selected from.
  38382. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38383. */
  38384. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38385. /**
  38386. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38387. */
  38388. get directionalConeInnerAngle(): number;
  38389. /**
  38390. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38391. */
  38392. set directionalConeInnerAngle(value: number);
  38393. /**
  38394. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38395. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38396. */
  38397. get directionalConeOuterAngle(): number;
  38398. /**
  38399. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38400. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38401. */
  38402. set directionalConeOuterAngle(value: number);
  38403. /**
  38404. * Playback volume.
  38405. */
  38406. get volume(): number;
  38407. /**
  38408. * Playback volume.
  38409. */
  38410. set volume(value: number);
  38411. private _onended;
  38412. /**
  38413. * Suspend playback
  38414. */
  38415. pause(): void;
  38416. /**
  38417. * Stop playback
  38418. */
  38419. stop(): void;
  38420. /**
  38421. * Start playback.
  38422. * @param startOffset Position the clip head at a specific time in seconds.
  38423. */
  38424. play(startOffset?: number): void;
  38425. }
  38426. }
  38427. declare module BABYLON {
  38428. /**
  38429. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38430. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38431. */
  38432. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38433. /**
  38434. * Gets the name of the behavior.
  38435. */
  38436. get name(): string;
  38437. /**
  38438. * The easing function used by animations
  38439. */
  38440. static EasingFunction: BackEase;
  38441. /**
  38442. * The easing mode used by animations
  38443. */
  38444. static EasingMode: number;
  38445. /**
  38446. * The duration of the animation, in milliseconds
  38447. */
  38448. transitionDuration: number;
  38449. /**
  38450. * Length of the distance animated by the transition when lower radius is reached
  38451. */
  38452. lowerRadiusTransitionRange: number;
  38453. /**
  38454. * Length of the distance animated by the transition when upper radius is reached
  38455. */
  38456. upperRadiusTransitionRange: number;
  38457. private _autoTransitionRange;
  38458. /**
  38459. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38460. */
  38461. get autoTransitionRange(): boolean;
  38462. /**
  38463. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38464. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38465. */
  38466. set autoTransitionRange(value: boolean);
  38467. private _attachedCamera;
  38468. private _onAfterCheckInputsObserver;
  38469. private _onMeshTargetChangedObserver;
  38470. /**
  38471. * Initializes the behavior.
  38472. */
  38473. init(): void;
  38474. /**
  38475. * Attaches the behavior to its arc rotate camera.
  38476. * @param camera Defines the camera to attach the behavior to
  38477. */
  38478. attach(camera: ArcRotateCamera): void;
  38479. /**
  38480. * Detaches the behavior from its current arc rotate camera.
  38481. */
  38482. detach(): void;
  38483. private _radiusIsAnimating;
  38484. private _radiusBounceTransition;
  38485. private _animatables;
  38486. private _cachedWheelPrecision;
  38487. /**
  38488. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38489. * @param radiusLimit The limit to check against.
  38490. * @return Bool to indicate if at limit.
  38491. */
  38492. private _isRadiusAtLimit;
  38493. /**
  38494. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38495. * @param radiusDelta The delta by which to animate to. Can be negative.
  38496. */
  38497. private _applyBoundRadiusAnimation;
  38498. /**
  38499. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38500. */
  38501. protected _clearAnimationLocks(): void;
  38502. /**
  38503. * Stops and removes all animations that have been applied to the camera
  38504. */
  38505. stopAllAnimations(): void;
  38506. }
  38507. }
  38508. declare module BABYLON {
  38509. /**
  38510. * 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.
  38511. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38512. */
  38513. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38514. /**
  38515. * Gets the name of the behavior.
  38516. */
  38517. get name(): string;
  38518. private _mode;
  38519. private _radiusScale;
  38520. private _positionScale;
  38521. private _defaultElevation;
  38522. private _elevationReturnTime;
  38523. private _elevationReturnWaitTime;
  38524. private _zoomStopsAnimation;
  38525. private _framingTime;
  38526. /**
  38527. * The easing function used by animations
  38528. */
  38529. static EasingFunction: ExponentialEase;
  38530. /**
  38531. * The easing mode used by animations
  38532. */
  38533. static EasingMode: number;
  38534. /**
  38535. * Sets the current mode used by the behavior
  38536. */
  38537. set mode(mode: number);
  38538. /**
  38539. * Gets current mode used by the behavior.
  38540. */
  38541. get mode(): number;
  38542. /**
  38543. * Sets the scale applied to the radius (1 by default)
  38544. */
  38545. set radiusScale(radius: number);
  38546. /**
  38547. * Gets the scale applied to the radius
  38548. */
  38549. get radiusScale(): number;
  38550. /**
  38551. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38552. */
  38553. set positionScale(scale: number);
  38554. /**
  38555. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38556. */
  38557. get positionScale(): number;
  38558. /**
  38559. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38560. * behaviour is triggered, in radians.
  38561. */
  38562. set defaultElevation(elevation: number);
  38563. /**
  38564. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38565. * behaviour is triggered, in radians.
  38566. */
  38567. get defaultElevation(): number;
  38568. /**
  38569. * Sets the time (in milliseconds) taken to return to the default beta position.
  38570. * Negative value indicates camera should not return to default.
  38571. */
  38572. set elevationReturnTime(speed: number);
  38573. /**
  38574. * Gets the time (in milliseconds) taken to return to the default beta position.
  38575. * Negative value indicates camera should not return to default.
  38576. */
  38577. get elevationReturnTime(): number;
  38578. /**
  38579. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38580. */
  38581. set elevationReturnWaitTime(time: number);
  38582. /**
  38583. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38584. */
  38585. get elevationReturnWaitTime(): number;
  38586. /**
  38587. * Sets the flag that indicates if user zooming should stop animation.
  38588. */
  38589. set zoomStopsAnimation(flag: boolean);
  38590. /**
  38591. * Gets the flag that indicates if user zooming should stop animation.
  38592. */
  38593. get zoomStopsAnimation(): boolean;
  38594. /**
  38595. * Sets the transition time when framing the mesh, in milliseconds
  38596. */
  38597. set framingTime(time: number);
  38598. /**
  38599. * Gets the transition time when framing the mesh, in milliseconds
  38600. */
  38601. get framingTime(): number;
  38602. /**
  38603. * Define if the behavior should automatically change the configured
  38604. * camera limits and sensibilities.
  38605. */
  38606. autoCorrectCameraLimitsAndSensibility: boolean;
  38607. private _onPrePointerObservableObserver;
  38608. private _onAfterCheckInputsObserver;
  38609. private _onMeshTargetChangedObserver;
  38610. private _attachedCamera;
  38611. private _isPointerDown;
  38612. private _lastInteractionTime;
  38613. /**
  38614. * Initializes the behavior.
  38615. */
  38616. init(): void;
  38617. /**
  38618. * Attaches the behavior to its arc rotate camera.
  38619. * @param camera Defines the camera to attach the behavior to
  38620. */
  38621. attach(camera: ArcRotateCamera): void;
  38622. /**
  38623. * Detaches the behavior from its current arc rotate camera.
  38624. */
  38625. detach(): void;
  38626. private _animatables;
  38627. private _betaIsAnimating;
  38628. private _betaTransition;
  38629. private _radiusTransition;
  38630. private _vectorTransition;
  38631. /**
  38632. * Targets the given mesh and updates zoom level accordingly.
  38633. * @param mesh The mesh to target.
  38634. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38635. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38636. */
  38637. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38638. /**
  38639. * Targets the given mesh with its children and updates zoom level accordingly.
  38640. * @param mesh The mesh to target.
  38641. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38642. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38643. */
  38644. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38645. /**
  38646. * Targets the given meshes with their children and updates zoom level accordingly.
  38647. * @param meshes The mesh to target.
  38648. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38649. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38650. */
  38651. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38652. /**
  38653. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38654. * @param minimumWorld Determines the smaller position of the bounding box extend
  38655. * @param maximumWorld Determines the bigger position of the bounding box extend
  38656. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38657. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38658. */
  38659. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38660. /**
  38661. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38662. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38663. * frustum width.
  38664. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38665. * to fully enclose the mesh in the viewing frustum.
  38666. */
  38667. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38668. /**
  38669. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38670. * is automatically returned to its default position (expected to be above ground plane).
  38671. */
  38672. private _maintainCameraAboveGround;
  38673. /**
  38674. * Returns the frustum slope based on the canvas ratio and camera FOV
  38675. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38676. */
  38677. private _getFrustumSlope;
  38678. /**
  38679. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38680. */
  38681. private _clearAnimationLocks;
  38682. /**
  38683. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38684. */
  38685. private _applyUserInteraction;
  38686. /**
  38687. * Stops and removes all animations that have been applied to the camera
  38688. */
  38689. stopAllAnimations(): void;
  38690. /**
  38691. * Gets a value indicating if the user is moving the camera
  38692. */
  38693. get isUserIsMoving(): boolean;
  38694. /**
  38695. * The camera can move all the way towards the mesh.
  38696. */
  38697. static IgnoreBoundsSizeMode: number;
  38698. /**
  38699. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38700. */
  38701. static FitFrustumSidesMode: number;
  38702. }
  38703. }
  38704. declare module BABYLON {
  38705. /**
  38706. * Base class for Camera Pointer Inputs.
  38707. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38708. * for example usage.
  38709. */
  38710. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38711. /**
  38712. * Defines the camera the input is attached to.
  38713. */
  38714. abstract camera: Camera;
  38715. /**
  38716. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38717. */
  38718. protected _altKey: boolean;
  38719. protected _ctrlKey: boolean;
  38720. protected _metaKey: boolean;
  38721. protected _shiftKey: boolean;
  38722. /**
  38723. * Which mouse buttons were pressed at time of last mouse event.
  38724. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38725. */
  38726. protected _buttonsPressed: number;
  38727. /**
  38728. * Defines the buttons associated with the input to handle camera move.
  38729. */
  38730. buttons: number[];
  38731. /**
  38732. * Attach the input controls to a specific dom element to get the input from.
  38733. * @param element Defines the element the controls should be listened from
  38734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38735. */
  38736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38737. /**
  38738. * Detach the current controls from the specified dom element.
  38739. * @param element Defines the element to stop listening the inputs from
  38740. */
  38741. detachControl(element: Nullable<HTMLElement>): void;
  38742. /**
  38743. * Gets the class name of the current input.
  38744. * @returns the class name
  38745. */
  38746. getClassName(): string;
  38747. /**
  38748. * Get the friendly name associated with the input class.
  38749. * @returns the input friendly name
  38750. */
  38751. getSimpleName(): string;
  38752. /**
  38753. * Called on pointer POINTERDOUBLETAP event.
  38754. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38755. */
  38756. protected onDoubleTap(type: string): void;
  38757. /**
  38758. * Called on pointer POINTERMOVE event if only a single touch is active.
  38759. * Override this method to provide functionality.
  38760. */
  38761. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38762. /**
  38763. * Called on pointer POINTERMOVE event if multiple touches are active.
  38764. * Override this method to provide functionality.
  38765. */
  38766. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38767. /**
  38768. * Called on JS contextmenu event.
  38769. * Override this method to provide functionality.
  38770. */
  38771. protected onContextMenu(evt: PointerEvent): void;
  38772. /**
  38773. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38774. * press.
  38775. * Override this method to provide functionality.
  38776. */
  38777. protected onButtonDown(evt: PointerEvent): void;
  38778. /**
  38779. * Called each time a new POINTERUP event occurs. Ie, for each button
  38780. * release.
  38781. * Override this method to provide functionality.
  38782. */
  38783. protected onButtonUp(evt: PointerEvent): void;
  38784. /**
  38785. * Called when window becomes inactive.
  38786. * Override this method to provide functionality.
  38787. */
  38788. protected onLostFocus(): void;
  38789. private _pointerInput;
  38790. private _observer;
  38791. private _onLostFocus;
  38792. private pointA;
  38793. private pointB;
  38794. }
  38795. }
  38796. declare module BABYLON {
  38797. /**
  38798. * Manage the pointers inputs to control an arc rotate camera.
  38799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38800. */
  38801. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38802. /**
  38803. * Defines the camera the input is attached to.
  38804. */
  38805. camera: ArcRotateCamera;
  38806. /**
  38807. * Gets the class name of the current input.
  38808. * @returns the class name
  38809. */
  38810. getClassName(): string;
  38811. /**
  38812. * Defines the buttons associated with the input to handle camera move.
  38813. */
  38814. buttons: number[];
  38815. /**
  38816. * Defines the pointer angular sensibility along the X axis or how fast is
  38817. * the camera rotating.
  38818. */
  38819. angularSensibilityX: number;
  38820. /**
  38821. * Defines the pointer angular sensibility along the Y axis or how fast is
  38822. * the camera rotating.
  38823. */
  38824. angularSensibilityY: number;
  38825. /**
  38826. * Defines the pointer pinch precision or how fast is the camera zooming.
  38827. */
  38828. pinchPrecision: number;
  38829. /**
  38830. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38831. * from 0.
  38832. * It defines the percentage of current camera.radius to use as delta when
  38833. * pinch zoom is used.
  38834. */
  38835. pinchDeltaPercentage: number;
  38836. /**
  38837. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38838. * that any object in the plane at the camera's target point will scale
  38839. * perfectly with finger motion.
  38840. * Overrides pinchDeltaPercentage and pinchPrecision.
  38841. */
  38842. useNaturalPinchZoom: boolean;
  38843. /**
  38844. * Defines the pointer panning sensibility or how fast is the camera moving.
  38845. */
  38846. panningSensibility: number;
  38847. /**
  38848. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38849. */
  38850. multiTouchPanning: boolean;
  38851. /**
  38852. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38853. * zoom (pinch) through multitouch.
  38854. */
  38855. multiTouchPanAndZoom: boolean;
  38856. /**
  38857. * Revers pinch action direction.
  38858. */
  38859. pinchInwards: boolean;
  38860. private _isPanClick;
  38861. private _twoFingerActivityCount;
  38862. private _isPinching;
  38863. /**
  38864. * Called on pointer POINTERMOVE event if only a single touch is active.
  38865. */
  38866. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38867. /**
  38868. * Called on pointer POINTERDOUBLETAP event.
  38869. */
  38870. protected onDoubleTap(type: string): void;
  38871. /**
  38872. * Called on pointer POINTERMOVE event if multiple touches are active.
  38873. */
  38874. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38875. /**
  38876. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38877. * press.
  38878. */
  38879. protected onButtonDown(evt: PointerEvent): void;
  38880. /**
  38881. * Called each time a new POINTERUP event occurs. Ie, for each button
  38882. * release.
  38883. */
  38884. protected onButtonUp(evt: PointerEvent): void;
  38885. /**
  38886. * Called when window becomes inactive.
  38887. */
  38888. protected onLostFocus(): void;
  38889. }
  38890. }
  38891. declare module BABYLON {
  38892. /**
  38893. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38895. */
  38896. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38897. /**
  38898. * Defines the camera the input is attached to.
  38899. */
  38900. camera: ArcRotateCamera;
  38901. /**
  38902. * Defines the list of key codes associated with the up action (increase alpha)
  38903. */
  38904. keysUp: number[];
  38905. /**
  38906. * Defines the list of key codes associated with the down action (decrease alpha)
  38907. */
  38908. keysDown: number[];
  38909. /**
  38910. * Defines the list of key codes associated with the left action (increase beta)
  38911. */
  38912. keysLeft: number[];
  38913. /**
  38914. * Defines the list of key codes associated with the right action (decrease beta)
  38915. */
  38916. keysRight: number[];
  38917. /**
  38918. * Defines the list of key codes associated with the reset action.
  38919. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38920. */
  38921. keysReset: number[];
  38922. /**
  38923. * Defines the panning sensibility of the inputs.
  38924. * (How fast is the camera panning)
  38925. */
  38926. panningSensibility: number;
  38927. /**
  38928. * Defines the zooming sensibility of the inputs.
  38929. * (How fast is the camera zooming)
  38930. */
  38931. zoomingSensibility: number;
  38932. /**
  38933. * Defines whether maintaining the alt key down switch the movement mode from
  38934. * orientation to zoom.
  38935. */
  38936. useAltToZoom: boolean;
  38937. /**
  38938. * Rotation speed of the camera
  38939. */
  38940. angularSpeed: number;
  38941. private _keys;
  38942. private _ctrlPressed;
  38943. private _altPressed;
  38944. private _onCanvasBlurObserver;
  38945. private _onKeyboardObserver;
  38946. private _engine;
  38947. private _scene;
  38948. /**
  38949. * Attach the input controls to a specific dom element to get the input from.
  38950. * @param element Defines the element the controls should be listened from
  38951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38952. */
  38953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38954. /**
  38955. * Detach the current controls from the specified dom element.
  38956. * @param element Defines the element to stop listening the inputs from
  38957. */
  38958. detachControl(element: Nullable<HTMLElement>): void;
  38959. /**
  38960. * Update the current camera state depending on the inputs that have been used this frame.
  38961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38962. */
  38963. checkInputs(): void;
  38964. /**
  38965. * Gets the class name of the current intput.
  38966. * @returns the class name
  38967. */
  38968. getClassName(): string;
  38969. /**
  38970. * Get the friendly name associated with the input class.
  38971. * @returns the input friendly name
  38972. */
  38973. getSimpleName(): string;
  38974. }
  38975. }
  38976. declare module BABYLON {
  38977. /**
  38978. * Manage the mouse wheel inputs to control an arc rotate camera.
  38979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38980. */
  38981. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38982. /**
  38983. * Defines the camera the input is attached to.
  38984. */
  38985. camera: ArcRotateCamera;
  38986. /**
  38987. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38988. */
  38989. wheelPrecision: number;
  38990. /**
  38991. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38992. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38993. */
  38994. wheelDeltaPercentage: number;
  38995. private _wheel;
  38996. private _observer;
  38997. private computeDeltaFromMouseWheelLegacyEvent;
  38998. /**
  38999. * Attach the input controls to a specific dom element to get the input from.
  39000. * @param element Defines the element the controls should be listened from
  39001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39002. */
  39003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39004. /**
  39005. * Detach the current controls from the specified dom element.
  39006. * @param element Defines the element to stop listening the inputs from
  39007. */
  39008. detachControl(element: Nullable<HTMLElement>): void;
  39009. /**
  39010. * Gets the class name of the current intput.
  39011. * @returns the class name
  39012. */
  39013. getClassName(): string;
  39014. /**
  39015. * Get the friendly name associated with the input class.
  39016. * @returns the input friendly name
  39017. */
  39018. getSimpleName(): string;
  39019. }
  39020. }
  39021. declare module BABYLON {
  39022. /**
  39023. * Default Inputs manager for the ArcRotateCamera.
  39024. * It groups all the default supported inputs for ease of use.
  39025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39026. */
  39027. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39028. /**
  39029. * Instantiates a new ArcRotateCameraInputsManager.
  39030. * @param camera Defines the camera the inputs belong to
  39031. */
  39032. constructor(camera: ArcRotateCamera);
  39033. /**
  39034. * Add mouse wheel input support to the input manager.
  39035. * @returns the current input manager
  39036. */
  39037. addMouseWheel(): ArcRotateCameraInputsManager;
  39038. /**
  39039. * Add pointers input support to the input manager.
  39040. * @returns the current input manager
  39041. */
  39042. addPointers(): ArcRotateCameraInputsManager;
  39043. /**
  39044. * Add keyboard input support to the input manager.
  39045. * @returns the current input manager
  39046. */
  39047. addKeyboard(): ArcRotateCameraInputsManager;
  39048. }
  39049. }
  39050. declare module BABYLON {
  39051. /**
  39052. * This represents an orbital type of camera.
  39053. *
  39054. * 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.
  39055. * 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.
  39056. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39057. */
  39058. export class ArcRotateCamera extends TargetCamera {
  39059. /**
  39060. * Defines the rotation angle of the camera along the longitudinal axis.
  39061. */
  39062. alpha: number;
  39063. /**
  39064. * Defines the rotation angle of the camera along the latitudinal axis.
  39065. */
  39066. beta: number;
  39067. /**
  39068. * Defines the radius of the camera from it s target point.
  39069. */
  39070. radius: number;
  39071. protected _target: Vector3;
  39072. protected _targetHost: Nullable<AbstractMesh>;
  39073. /**
  39074. * Defines the target point of the camera.
  39075. * The camera looks towards it form the radius distance.
  39076. */
  39077. get target(): Vector3;
  39078. set target(value: Vector3);
  39079. /**
  39080. * Define the current local position of the camera in the scene
  39081. */
  39082. get position(): Vector3;
  39083. set position(newPosition: Vector3);
  39084. protected _upVector: Vector3;
  39085. protected _upToYMatrix: Matrix;
  39086. protected _YToUpMatrix: Matrix;
  39087. /**
  39088. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39089. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39090. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39091. */
  39092. set upVector(vec: Vector3);
  39093. get upVector(): Vector3;
  39094. /**
  39095. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39096. */
  39097. setMatUp(): void;
  39098. /**
  39099. * Current inertia value on the longitudinal axis.
  39100. * The bigger this number the longer it will take for the camera to stop.
  39101. */
  39102. inertialAlphaOffset: number;
  39103. /**
  39104. * Current inertia value on the latitudinal axis.
  39105. * The bigger this number the longer it will take for the camera to stop.
  39106. */
  39107. inertialBetaOffset: number;
  39108. /**
  39109. * Current inertia value on the radius axis.
  39110. * The bigger this number the longer it will take for the camera to stop.
  39111. */
  39112. inertialRadiusOffset: number;
  39113. /**
  39114. * Minimum allowed angle on the longitudinal axis.
  39115. * This can help limiting how the Camera is able to move in the scene.
  39116. */
  39117. lowerAlphaLimit: Nullable<number>;
  39118. /**
  39119. * Maximum allowed angle on the longitudinal axis.
  39120. * This can help limiting how the Camera is able to move in the scene.
  39121. */
  39122. upperAlphaLimit: Nullable<number>;
  39123. /**
  39124. * Minimum allowed angle on the latitudinal axis.
  39125. * This can help limiting how the Camera is able to move in the scene.
  39126. */
  39127. lowerBetaLimit: number;
  39128. /**
  39129. * Maximum allowed angle on the latitudinal axis.
  39130. * This can help limiting how the Camera is able to move in the scene.
  39131. */
  39132. upperBetaLimit: number;
  39133. /**
  39134. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39135. * This can help limiting how the Camera is able to move in the scene.
  39136. */
  39137. lowerRadiusLimit: Nullable<number>;
  39138. /**
  39139. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39140. * This can help limiting how the Camera is able to move in the scene.
  39141. */
  39142. upperRadiusLimit: Nullable<number>;
  39143. /**
  39144. * Defines the current inertia value used during panning of the camera along the X axis.
  39145. */
  39146. inertialPanningX: number;
  39147. /**
  39148. * Defines the current inertia value used during panning of the camera along the Y axis.
  39149. */
  39150. inertialPanningY: number;
  39151. /**
  39152. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39153. * Basically if your fingers moves away from more than this distance you will be considered
  39154. * in pinch mode.
  39155. */
  39156. pinchToPanMaxDistance: number;
  39157. /**
  39158. * Defines the maximum distance the camera can pan.
  39159. * This could help keeping the cammera always in your scene.
  39160. */
  39161. panningDistanceLimit: Nullable<number>;
  39162. /**
  39163. * Defines the target of the camera before paning.
  39164. */
  39165. panningOriginTarget: Vector3;
  39166. /**
  39167. * Defines the value of the inertia used during panning.
  39168. * 0 would mean stop inertia and one would mean no decelleration at all.
  39169. */
  39170. panningInertia: number;
  39171. /**
  39172. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39173. */
  39174. get angularSensibilityX(): number;
  39175. set angularSensibilityX(value: number);
  39176. /**
  39177. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39178. */
  39179. get angularSensibilityY(): number;
  39180. set angularSensibilityY(value: number);
  39181. /**
  39182. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39183. */
  39184. get pinchPrecision(): number;
  39185. set pinchPrecision(value: number);
  39186. /**
  39187. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39188. * It will be used instead of pinchDeltaPrecision if different from 0.
  39189. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39190. */
  39191. get pinchDeltaPercentage(): number;
  39192. set pinchDeltaPercentage(value: number);
  39193. /**
  39194. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39195. * and pinch delta percentage.
  39196. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39197. * that any object in the plane at the camera's target point will scale
  39198. * perfectly with finger motion.
  39199. */
  39200. get useNaturalPinchZoom(): boolean;
  39201. set useNaturalPinchZoom(value: boolean);
  39202. /**
  39203. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39204. */
  39205. get panningSensibility(): number;
  39206. set panningSensibility(value: number);
  39207. /**
  39208. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39209. */
  39210. get keysUp(): number[];
  39211. set keysUp(value: number[]);
  39212. /**
  39213. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39214. */
  39215. get keysDown(): number[];
  39216. set keysDown(value: number[]);
  39217. /**
  39218. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39219. */
  39220. get keysLeft(): number[];
  39221. set keysLeft(value: number[]);
  39222. /**
  39223. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39224. */
  39225. get keysRight(): number[];
  39226. set keysRight(value: number[]);
  39227. /**
  39228. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39229. */
  39230. get wheelPrecision(): number;
  39231. set wheelPrecision(value: number);
  39232. /**
  39233. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39234. * It will be used instead of pinchDeltaPrecision if different from 0.
  39235. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39236. */
  39237. get wheelDeltaPercentage(): number;
  39238. set wheelDeltaPercentage(value: number);
  39239. /**
  39240. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39241. */
  39242. zoomOnFactor: number;
  39243. /**
  39244. * Defines a screen offset for the camera position.
  39245. */
  39246. targetScreenOffset: Vector2;
  39247. /**
  39248. * Allows the camera to be completely reversed.
  39249. * If false the camera can not arrive upside down.
  39250. */
  39251. allowUpsideDown: boolean;
  39252. /**
  39253. * Define if double tap/click is used to restore the previously saved state of the camera.
  39254. */
  39255. useInputToRestoreState: boolean;
  39256. /** @hidden */
  39257. _viewMatrix: Matrix;
  39258. /** @hidden */
  39259. _useCtrlForPanning: boolean;
  39260. /** @hidden */
  39261. _panningMouseButton: number;
  39262. /**
  39263. * Defines the input associated to the camera.
  39264. */
  39265. inputs: ArcRotateCameraInputsManager;
  39266. /** @hidden */
  39267. _reset: () => void;
  39268. /**
  39269. * Defines the allowed panning axis.
  39270. */
  39271. panningAxis: Vector3;
  39272. protected _localDirection: Vector3;
  39273. protected _transformedDirection: Vector3;
  39274. private _bouncingBehavior;
  39275. /**
  39276. * Gets the bouncing behavior of the camera if it has been enabled.
  39277. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39278. */
  39279. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39280. /**
  39281. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39282. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39283. */
  39284. get useBouncingBehavior(): boolean;
  39285. set useBouncingBehavior(value: boolean);
  39286. private _framingBehavior;
  39287. /**
  39288. * Gets the framing behavior of the camera if it has been enabled.
  39289. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39290. */
  39291. get framingBehavior(): Nullable<FramingBehavior>;
  39292. /**
  39293. * Defines if the framing behavior of the camera is enabled on the camera.
  39294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39295. */
  39296. get useFramingBehavior(): boolean;
  39297. set useFramingBehavior(value: boolean);
  39298. private _autoRotationBehavior;
  39299. /**
  39300. * Gets the auto rotation behavior of the camera if it has been enabled.
  39301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39302. */
  39303. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39304. /**
  39305. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39306. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39307. */
  39308. get useAutoRotationBehavior(): boolean;
  39309. set useAutoRotationBehavior(value: boolean);
  39310. /**
  39311. * Observable triggered when the mesh target has been changed on the camera.
  39312. */
  39313. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39314. /**
  39315. * Event raised when the camera is colliding with a mesh.
  39316. */
  39317. onCollide: (collidedMesh: AbstractMesh) => void;
  39318. /**
  39319. * Defines whether the camera should check collision with the objects oh the scene.
  39320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39321. */
  39322. checkCollisions: boolean;
  39323. /**
  39324. * Defines the collision radius of the camera.
  39325. * This simulates a sphere around the camera.
  39326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39327. */
  39328. collisionRadius: Vector3;
  39329. protected _collider: Collider;
  39330. protected _previousPosition: Vector3;
  39331. protected _collisionVelocity: Vector3;
  39332. protected _newPosition: Vector3;
  39333. protected _previousAlpha: number;
  39334. protected _previousBeta: number;
  39335. protected _previousRadius: number;
  39336. protected _collisionTriggered: boolean;
  39337. protected _targetBoundingCenter: Nullable<Vector3>;
  39338. private _computationVector;
  39339. /**
  39340. * Instantiates a new ArcRotateCamera in a given scene
  39341. * @param name Defines the name of the camera
  39342. * @param alpha Defines the camera rotation along the logitudinal axis
  39343. * @param beta Defines the camera rotation along the latitudinal axis
  39344. * @param radius Defines the camera distance from its target
  39345. * @param target Defines the camera target
  39346. * @param scene Defines the scene the camera belongs to
  39347. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39348. */
  39349. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39350. /** @hidden */
  39351. _initCache(): void;
  39352. /** @hidden */
  39353. _updateCache(ignoreParentClass?: boolean): void;
  39354. protected _getTargetPosition(): Vector3;
  39355. private _storedAlpha;
  39356. private _storedBeta;
  39357. private _storedRadius;
  39358. private _storedTarget;
  39359. private _storedTargetScreenOffset;
  39360. /**
  39361. * Stores the current state of the camera (alpha, beta, radius and target)
  39362. * @returns the camera itself
  39363. */
  39364. storeState(): Camera;
  39365. /**
  39366. * @hidden
  39367. * Restored camera state. You must call storeState() first
  39368. */
  39369. _restoreStateValues(): boolean;
  39370. /** @hidden */
  39371. _isSynchronizedViewMatrix(): boolean;
  39372. /**
  39373. * Attached controls to the current camera.
  39374. * @param element Defines the element the controls should be listened from
  39375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39376. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39377. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39378. */
  39379. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39380. /**
  39381. * Detach the current controls from the camera.
  39382. * The camera will stop reacting to inputs.
  39383. * @param element Defines the element to stop listening the inputs from
  39384. */
  39385. detachControl(element: HTMLElement): void;
  39386. /** @hidden */
  39387. _checkInputs(): void;
  39388. protected _checkLimits(): void;
  39389. /**
  39390. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39391. */
  39392. rebuildAnglesAndRadius(): void;
  39393. /**
  39394. * Use a position to define the current camera related information like alpha, beta and radius
  39395. * @param position Defines the position to set the camera at
  39396. */
  39397. setPosition(position: Vector3): void;
  39398. /**
  39399. * Defines the target the camera should look at.
  39400. * This will automatically adapt alpha beta and radius to fit within the new target.
  39401. * @param target Defines the new target as a Vector or a mesh
  39402. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39403. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39404. */
  39405. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39406. /** @hidden */
  39407. _getViewMatrix(): Matrix;
  39408. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39409. /**
  39410. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39411. * @param meshes Defines the mesh to zoom on
  39412. * @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)
  39413. */
  39414. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39415. /**
  39416. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39417. * The target will be changed but the radius
  39418. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39419. * @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)
  39420. */
  39421. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39422. min: Vector3;
  39423. max: Vector3;
  39424. distance: number;
  39425. }, doNotUpdateMaxZ?: boolean): void;
  39426. /**
  39427. * @override
  39428. * Override Camera.createRigCamera
  39429. */
  39430. createRigCamera(name: string, cameraIndex: number): Camera;
  39431. /**
  39432. * @hidden
  39433. * @override
  39434. * Override Camera._updateRigCameras
  39435. */
  39436. _updateRigCameras(): void;
  39437. /**
  39438. * Destroy the camera and release the current resources hold by it.
  39439. */
  39440. dispose(): void;
  39441. /**
  39442. * Gets the current object class name.
  39443. * @return the class name
  39444. */
  39445. getClassName(): string;
  39446. }
  39447. }
  39448. declare module BABYLON {
  39449. /**
  39450. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39451. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39452. */
  39453. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39454. /**
  39455. * Gets the name of the behavior.
  39456. */
  39457. get name(): string;
  39458. private _zoomStopsAnimation;
  39459. private _idleRotationSpeed;
  39460. private _idleRotationWaitTime;
  39461. private _idleRotationSpinupTime;
  39462. /**
  39463. * Sets the flag that indicates if user zooming should stop animation.
  39464. */
  39465. set zoomStopsAnimation(flag: boolean);
  39466. /**
  39467. * Gets the flag that indicates if user zooming should stop animation.
  39468. */
  39469. get zoomStopsAnimation(): boolean;
  39470. /**
  39471. * Sets the default speed at which the camera rotates around the model.
  39472. */
  39473. set idleRotationSpeed(speed: number);
  39474. /**
  39475. * Gets the default speed at which the camera rotates around the model.
  39476. */
  39477. get idleRotationSpeed(): number;
  39478. /**
  39479. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39480. */
  39481. set idleRotationWaitTime(time: number);
  39482. /**
  39483. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39484. */
  39485. get idleRotationWaitTime(): number;
  39486. /**
  39487. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39488. */
  39489. set idleRotationSpinupTime(time: number);
  39490. /**
  39491. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39492. */
  39493. get idleRotationSpinupTime(): number;
  39494. /**
  39495. * Gets a value indicating if the camera is currently rotating because of this behavior
  39496. */
  39497. get rotationInProgress(): boolean;
  39498. private _onPrePointerObservableObserver;
  39499. private _onAfterCheckInputsObserver;
  39500. private _attachedCamera;
  39501. private _isPointerDown;
  39502. private _lastFrameTime;
  39503. private _lastInteractionTime;
  39504. private _cameraRotationSpeed;
  39505. /**
  39506. * Initializes the behavior.
  39507. */
  39508. init(): void;
  39509. /**
  39510. * Attaches the behavior to its arc rotate camera.
  39511. * @param camera Defines the camera to attach the behavior to
  39512. */
  39513. attach(camera: ArcRotateCamera): void;
  39514. /**
  39515. * Detaches the behavior from its current arc rotate camera.
  39516. */
  39517. detach(): void;
  39518. /**
  39519. * Returns true if user is scrolling.
  39520. * @return true if user is scrolling.
  39521. */
  39522. private _userIsZooming;
  39523. private _lastFrameRadius;
  39524. private _shouldAnimationStopForInteraction;
  39525. /**
  39526. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39527. */
  39528. private _applyUserInteraction;
  39529. private _userIsMoving;
  39530. }
  39531. }
  39532. declare module BABYLON {
  39533. /**
  39534. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39535. */
  39536. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39537. private ui;
  39538. /**
  39539. * The name of the behavior
  39540. */
  39541. name: string;
  39542. /**
  39543. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39544. */
  39545. distanceAwayFromFace: number;
  39546. /**
  39547. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39548. */
  39549. distanceAwayFromBottomOfFace: number;
  39550. private _faceVectors;
  39551. private _target;
  39552. private _scene;
  39553. private _onRenderObserver;
  39554. private _tmpMatrix;
  39555. private _tmpVector;
  39556. /**
  39557. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39558. * @param ui The transform node that should be attched to the mesh
  39559. */
  39560. constructor(ui: TransformNode);
  39561. /**
  39562. * Initializes the behavior
  39563. */
  39564. init(): void;
  39565. private _closestFace;
  39566. private _zeroVector;
  39567. private _lookAtTmpMatrix;
  39568. private _lookAtToRef;
  39569. /**
  39570. * Attaches the AttachToBoxBehavior to the passed in mesh
  39571. * @param target The mesh that the specified node will be attached to
  39572. */
  39573. attach(target: Mesh): void;
  39574. /**
  39575. * Detaches the behavior from the mesh
  39576. */
  39577. detach(): void;
  39578. }
  39579. }
  39580. declare module BABYLON {
  39581. /**
  39582. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39583. */
  39584. export class FadeInOutBehavior implements Behavior<Mesh> {
  39585. /**
  39586. * Time in milliseconds to delay before fading in (Default: 0)
  39587. */
  39588. delay: number;
  39589. /**
  39590. * Time in milliseconds for the mesh to fade in (Default: 300)
  39591. */
  39592. fadeInTime: number;
  39593. private _millisecondsPerFrame;
  39594. private _hovered;
  39595. private _hoverValue;
  39596. private _ownerNode;
  39597. /**
  39598. * Instatiates the FadeInOutBehavior
  39599. */
  39600. constructor();
  39601. /**
  39602. * The name of the behavior
  39603. */
  39604. get name(): string;
  39605. /**
  39606. * Initializes the behavior
  39607. */
  39608. init(): void;
  39609. /**
  39610. * Attaches the fade behavior on the passed in mesh
  39611. * @param ownerNode The mesh that will be faded in/out once attached
  39612. */
  39613. attach(ownerNode: Mesh): void;
  39614. /**
  39615. * Detaches the behavior from the mesh
  39616. */
  39617. detach(): void;
  39618. /**
  39619. * Triggers the mesh to begin fading in or out
  39620. * @param value if the object should fade in or out (true to fade in)
  39621. */
  39622. fadeIn(value: boolean): void;
  39623. private _update;
  39624. private _setAllVisibility;
  39625. }
  39626. }
  39627. declare module BABYLON {
  39628. /**
  39629. * Class containing a set of static utilities functions for managing Pivots
  39630. * @hidden
  39631. */
  39632. export class PivotTools {
  39633. private static _PivotCached;
  39634. private static _OldPivotPoint;
  39635. private static _PivotTranslation;
  39636. private static _PivotTmpVector;
  39637. /** @hidden */
  39638. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39639. /** @hidden */
  39640. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39641. }
  39642. }
  39643. declare module BABYLON {
  39644. /**
  39645. * Class containing static functions to help procedurally build meshes
  39646. */
  39647. export class PlaneBuilder {
  39648. /**
  39649. * Creates a plane mesh
  39650. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39651. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39652. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39654. * * 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
  39655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39656. * @param name defines the name of the mesh
  39657. * @param options defines the options used to create the mesh
  39658. * @param scene defines the hosting scene
  39659. * @returns the plane mesh
  39660. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39661. */
  39662. static CreatePlane(name: string, options: {
  39663. size?: number;
  39664. width?: number;
  39665. height?: number;
  39666. sideOrientation?: number;
  39667. frontUVs?: Vector4;
  39668. backUVs?: Vector4;
  39669. updatable?: boolean;
  39670. sourcePlane?: Plane;
  39671. }, scene?: Nullable<Scene>): Mesh;
  39672. }
  39673. }
  39674. declare module BABYLON {
  39675. /**
  39676. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39677. */
  39678. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39679. private static _AnyMouseID;
  39680. /**
  39681. * Abstract mesh the behavior is set on
  39682. */
  39683. attachedNode: AbstractMesh;
  39684. private _dragPlane;
  39685. private _scene;
  39686. private _pointerObserver;
  39687. private _beforeRenderObserver;
  39688. private static _planeScene;
  39689. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39690. /**
  39691. * 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)
  39692. */
  39693. maxDragAngle: number;
  39694. /**
  39695. * @hidden
  39696. */
  39697. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39698. /**
  39699. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39700. */
  39701. currentDraggingPointerID: number;
  39702. /**
  39703. * The last position where the pointer hit the drag plane in world space
  39704. */
  39705. lastDragPosition: Vector3;
  39706. /**
  39707. * If the behavior is currently in a dragging state
  39708. */
  39709. dragging: boolean;
  39710. /**
  39711. * 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)
  39712. */
  39713. dragDeltaRatio: number;
  39714. /**
  39715. * If the drag plane orientation should be updated during the dragging (Default: true)
  39716. */
  39717. updateDragPlane: boolean;
  39718. private _debugMode;
  39719. private _moving;
  39720. /**
  39721. * Fires each time the attached mesh is dragged with the pointer
  39722. * * delta between last drag position and current drag position in world space
  39723. * * dragDistance along the drag axis
  39724. * * dragPlaneNormal normal of the current drag plane used during the drag
  39725. * * dragPlanePoint in world space where the drag intersects the drag plane
  39726. */
  39727. onDragObservable: Observable<{
  39728. delta: Vector3;
  39729. dragPlanePoint: Vector3;
  39730. dragPlaneNormal: Vector3;
  39731. dragDistance: number;
  39732. pointerId: number;
  39733. }>;
  39734. /**
  39735. * Fires each time a drag begins (eg. mouse down on mesh)
  39736. */
  39737. onDragStartObservable: Observable<{
  39738. dragPlanePoint: Vector3;
  39739. pointerId: number;
  39740. }>;
  39741. /**
  39742. * Fires each time a drag ends (eg. mouse release after drag)
  39743. */
  39744. onDragEndObservable: Observable<{
  39745. dragPlanePoint: Vector3;
  39746. pointerId: number;
  39747. }>;
  39748. /**
  39749. * If the attached mesh should be moved when dragged
  39750. */
  39751. moveAttached: boolean;
  39752. /**
  39753. * If the drag behavior will react to drag events (Default: true)
  39754. */
  39755. enabled: boolean;
  39756. /**
  39757. * If pointer events should start and release the drag (Default: true)
  39758. */
  39759. startAndReleaseDragOnPointerEvents: boolean;
  39760. /**
  39761. * If camera controls should be detached during the drag
  39762. */
  39763. detachCameraControls: boolean;
  39764. /**
  39765. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39766. */
  39767. useObjectOrientationForDragging: boolean;
  39768. private _options;
  39769. /**
  39770. * Gets the options used by the behavior
  39771. */
  39772. get options(): {
  39773. dragAxis?: Vector3;
  39774. dragPlaneNormal?: Vector3;
  39775. };
  39776. /**
  39777. * Sets the options used by the behavior
  39778. */
  39779. set options(options: {
  39780. dragAxis?: Vector3;
  39781. dragPlaneNormal?: Vector3;
  39782. });
  39783. /**
  39784. * Creates a pointer drag behavior that can be attached to a mesh
  39785. * @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)
  39786. */
  39787. constructor(options?: {
  39788. dragAxis?: Vector3;
  39789. dragPlaneNormal?: Vector3;
  39790. });
  39791. /**
  39792. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39793. */
  39794. validateDrag: (targetPosition: Vector3) => boolean;
  39795. /**
  39796. * The name of the behavior
  39797. */
  39798. get name(): string;
  39799. /**
  39800. * Initializes the behavior
  39801. */
  39802. init(): void;
  39803. private _tmpVector;
  39804. private _alternatePickedPoint;
  39805. private _worldDragAxis;
  39806. private _targetPosition;
  39807. private _attachedElement;
  39808. /**
  39809. * Attaches the drag behavior the passed in mesh
  39810. * @param ownerNode The mesh that will be dragged around once attached
  39811. * @param predicate Predicate to use for pick filtering
  39812. */
  39813. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39814. /**
  39815. * Force relase the drag action by code.
  39816. */
  39817. releaseDrag(): void;
  39818. private _startDragRay;
  39819. private _lastPointerRay;
  39820. /**
  39821. * Simulates the start of a pointer drag event on the behavior
  39822. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39823. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39824. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39825. */
  39826. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39827. private _startDrag;
  39828. private _dragDelta;
  39829. private _moveDrag;
  39830. private _pickWithRayOnDragPlane;
  39831. private _pointA;
  39832. private _pointB;
  39833. private _pointC;
  39834. private _lineA;
  39835. private _lineB;
  39836. private _localAxis;
  39837. private _lookAt;
  39838. private _updateDragPlanePosition;
  39839. /**
  39840. * Detaches the behavior from the mesh
  39841. */
  39842. detach(): void;
  39843. }
  39844. }
  39845. declare module BABYLON {
  39846. /**
  39847. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39848. */
  39849. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39850. private _dragBehaviorA;
  39851. private _dragBehaviorB;
  39852. private _startDistance;
  39853. private _initialScale;
  39854. private _targetScale;
  39855. private _ownerNode;
  39856. private _sceneRenderObserver;
  39857. /**
  39858. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39859. */
  39860. constructor();
  39861. /**
  39862. * The name of the behavior
  39863. */
  39864. get name(): string;
  39865. /**
  39866. * Initializes the behavior
  39867. */
  39868. init(): void;
  39869. private _getCurrentDistance;
  39870. /**
  39871. * Attaches the scale behavior the passed in mesh
  39872. * @param ownerNode The mesh that will be scaled around once attached
  39873. */
  39874. attach(ownerNode: Mesh): void;
  39875. /**
  39876. * Detaches the behavior from the mesh
  39877. */
  39878. detach(): void;
  39879. }
  39880. }
  39881. declare module BABYLON {
  39882. /**
  39883. * 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
  39884. */
  39885. export class SixDofDragBehavior implements Behavior<Mesh> {
  39886. private static _virtualScene;
  39887. private _ownerNode;
  39888. private _sceneRenderObserver;
  39889. private _scene;
  39890. private _targetPosition;
  39891. private _virtualOriginMesh;
  39892. private _virtualDragMesh;
  39893. private _pointerObserver;
  39894. private _moving;
  39895. private _startingOrientation;
  39896. private _attachedElement;
  39897. /**
  39898. * 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)
  39899. */
  39900. private zDragFactor;
  39901. /**
  39902. * If the object should rotate to face the drag origin
  39903. */
  39904. rotateDraggedObject: boolean;
  39905. /**
  39906. * If the behavior is currently in a dragging state
  39907. */
  39908. dragging: boolean;
  39909. /**
  39910. * 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)
  39911. */
  39912. dragDeltaRatio: number;
  39913. /**
  39914. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39915. */
  39916. currentDraggingPointerID: number;
  39917. /**
  39918. * If camera controls should be detached during the drag
  39919. */
  39920. detachCameraControls: boolean;
  39921. /**
  39922. * Fires each time a drag starts
  39923. */
  39924. onDragStartObservable: Observable<{}>;
  39925. /**
  39926. * Fires each time a drag ends (eg. mouse release after drag)
  39927. */
  39928. onDragEndObservable: Observable<{}>;
  39929. /**
  39930. * 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
  39931. */
  39932. constructor();
  39933. /**
  39934. * The name of the behavior
  39935. */
  39936. get name(): string;
  39937. /**
  39938. * Initializes the behavior
  39939. */
  39940. init(): void;
  39941. /**
  39942. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39943. */
  39944. private get _pointerCamera();
  39945. /**
  39946. * Attaches the scale behavior the passed in mesh
  39947. * @param ownerNode The mesh that will be scaled around once attached
  39948. */
  39949. attach(ownerNode: Mesh): void;
  39950. /**
  39951. * Detaches the behavior from the mesh
  39952. */
  39953. detach(): void;
  39954. }
  39955. }
  39956. declare module BABYLON {
  39957. /**
  39958. * Class used to apply inverse kinematics to bones
  39959. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39960. */
  39961. export class BoneIKController {
  39962. private static _tmpVecs;
  39963. private static _tmpQuat;
  39964. private static _tmpMats;
  39965. /**
  39966. * Gets or sets the target mesh
  39967. */
  39968. targetMesh: AbstractMesh;
  39969. /** Gets or sets the mesh used as pole */
  39970. poleTargetMesh: AbstractMesh;
  39971. /**
  39972. * Gets or sets the bone used as pole
  39973. */
  39974. poleTargetBone: Nullable<Bone>;
  39975. /**
  39976. * Gets or sets the target position
  39977. */
  39978. targetPosition: Vector3;
  39979. /**
  39980. * Gets or sets the pole target position
  39981. */
  39982. poleTargetPosition: Vector3;
  39983. /**
  39984. * Gets or sets the pole target local offset
  39985. */
  39986. poleTargetLocalOffset: Vector3;
  39987. /**
  39988. * Gets or sets the pole angle
  39989. */
  39990. poleAngle: number;
  39991. /**
  39992. * Gets or sets the mesh associated with the controller
  39993. */
  39994. mesh: AbstractMesh;
  39995. /**
  39996. * 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)
  39997. */
  39998. slerpAmount: number;
  39999. private _bone1Quat;
  40000. private _bone1Mat;
  40001. private _bone2Ang;
  40002. private _bone1;
  40003. private _bone2;
  40004. private _bone1Length;
  40005. private _bone2Length;
  40006. private _maxAngle;
  40007. private _maxReach;
  40008. private _rightHandedSystem;
  40009. private _bendAxis;
  40010. private _slerping;
  40011. private _adjustRoll;
  40012. /**
  40013. * Gets or sets maximum allowed angle
  40014. */
  40015. get maxAngle(): number;
  40016. set maxAngle(value: number);
  40017. /**
  40018. * Creates a new BoneIKController
  40019. * @param mesh defines the mesh to control
  40020. * @param bone defines the bone to control
  40021. * @param options defines options to set up the controller
  40022. */
  40023. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40024. targetMesh?: AbstractMesh;
  40025. poleTargetMesh?: AbstractMesh;
  40026. poleTargetBone?: Bone;
  40027. poleTargetLocalOffset?: Vector3;
  40028. poleAngle?: number;
  40029. bendAxis?: Vector3;
  40030. maxAngle?: number;
  40031. slerpAmount?: number;
  40032. });
  40033. private _setMaxAngle;
  40034. /**
  40035. * Force the controller to update the bones
  40036. */
  40037. update(): void;
  40038. }
  40039. }
  40040. declare module BABYLON {
  40041. /**
  40042. * Class used to make a bone look toward a point in space
  40043. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40044. */
  40045. export class BoneLookController {
  40046. private static _tmpVecs;
  40047. private static _tmpQuat;
  40048. private static _tmpMats;
  40049. /**
  40050. * The target Vector3 that the bone will look at
  40051. */
  40052. target: Vector3;
  40053. /**
  40054. * The mesh that the bone is attached to
  40055. */
  40056. mesh: AbstractMesh;
  40057. /**
  40058. * The bone that will be looking to the target
  40059. */
  40060. bone: Bone;
  40061. /**
  40062. * The up axis of the coordinate system that is used when the bone is rotated
  40063. */
  40064. upAxis: Vector3;
  40065. /**
  40066. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40067. */
  40068. upAxisSpace: Space;
  40069. /**
  40070. * Used to make an adjustment to the yaw of the bone
  40071. */
  40072. adjustYaw: number;
  40073. /**
  40074. * Used to make an adjustment to the pitch of the bone
  40075. */
  40076. adjustPitch: number;
  40077. /**
  40078. * Used to make an adjustment to the roll of the bone
  40079. */
  40080. adjustRoll: number;
  40081. /**
  40082. * 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)
  40083. */
  40084. slerpAmount: number;
  40085. private _minYaw;
  40086. private _maxYaw;
  40087. private _minPitch;
  40088. private _maxPitch;
  40089. private _minYawSin;
  40090. private _minYawCos;
  40091. private _maxYawSin;
  40092. private _maxYawCos;
  40093. private _midYawConstraint;
  40094. private _minPitchTan;
  40095. private _maxPitchTan;
  40096. private _boneQuat;
  40097. private _slerping;
  40098. private _transformYawPitch;
  40099. private _transformYawPitchInv;
  40100. private _firstFrameSkipped;
  40101. private _yawRange;
  40102. private _fowardAxis;
  40103. /**
  40104. * Gets or sets the minimum yaw angle that the bone can look to
  40105. */
  40106. get minYaw(): number;
  40107. set minYaw(value: number);
  40108. /**
  40109. * Gets or sets the maximum yaw angle that the bone can look to
  40110. */
  40111. get maxYaw(): number;
  40112. set maxYaw(value: number);
  40113. /**
  40114. * Gets or sets the minimum pitch angle that the bone can look to
  40115. */
  40116. get minPitch(): number;
  40117. set minPitch(value: number);
  40118. /**
  40119. * Gets or sets the maximum pitch angle that the bone can look to
  40120. */
  40121. get maxPitch(): number;
  40122. set maxPitch(value: number);
  40123. /**
  40124. * Create a BoneLookController
  40125. * @param mesh the mesh that the bone belongs to
  40126. * @param bone the bone that will be looking to the target
  40127. * @param target the target Vector3 to look at
  40128. * @param options optional settings:
  40129. * * maxYaw: the maximum angle the bone will yaw to
  40130. * * minYaw: the minimum angle the bone will yaw to
  40131. * * maxPitch: the maximum angle the bone will pitch to
  40132. * * minPitch: the minimum angle the bone will yaw to
  40133. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40134. * * upAxis: the up axis of the coordinate system
  40135. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40136. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40137. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40138. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40139. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40140. * * adjustRoll: used to make an adjustment to the roll of the bone
  40141. **/
  40142. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40143. maxYaw?: number;
  40144. minYaw?: number;
  40145. maxPitch?: number;
  40146. minPitch?: number;
  40147. slerpAmount?: number;
  40148. upAxis?: Vector3;
  40149. upAxisSpace?: Space;
  40150. yawAxis?: Vector3;
  40151. pitchAxis?: Vector3;
  40152. adjustYaw?: number;
  40153. adjustPitch?: number;
  40154. adjustRoll?: number;
  40155. });
  40156. /**
  40157. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40158. */
  40159. update(): void;
  40160. private _getAngleDiff;
  40161. private _getAngleBetween;
  40162. private _isAngleBetween;
  40163. }
  40164. }
  40165. declare module BABYLON {
  40166. /**
  40167. * Manage the gamepad inputs to control an arc rotate camera.
  40168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40169. */
  40170. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40171. /**
  40172. * Defines the camera the input is attached to.
  40173. */
  40174. camera: ArcRotateCamera;
  40175. /**
  40176. * Defines the gamepad the input is gathering event from.
  40177. */
  40178. gamepad: Nullable<Gamepad>;
  40179. /**
  40180. * Defines the gamepad rotation sensiblity.
  40181. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40182. */
  40183. gamepadRotationSensibility: number;
  40184. /**
  40185. * Defines the gamepad move sensiblity.
  40186. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40187. */
  40188. gamepadMoveSensibility: number;
  40189. private _yAxisScale;
  40190. /**
  40191. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40192. */
  40193. get invertYAxis(): boolean;
  40194. set invertYAxis(value: boolean);
  40195. private _onGamepadConnectedObserver;
  40196. private _onGamepadDisconnectedObserver;
  40197. /**
  40198. * Attach the input controls to a specific dom element to get the input from.
  40199. * @param element Defines the element the controls should be listened from
  40200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40201. */
  40202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40203. /**
  40204. * Detach the current controls from the specified dom element.
  40205. * @param element Defines the element to stop listening the inputs from
  40206. */
  40207. detachControl(element: Nullable<HTMLElement>): void;
  40208. /**
  40209. * Update the current camera state depending on the inputs that have been used this frame.
  40210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40211. */
  40212. checkInputs(): void;
  40213. /**
  40214. * Gets the class name of the current intput.
  40215. * @returns the class name
  40216. */
  40217. getClassName(): string;
  40218. /**
  40219. * Get the friendly name associated with the input class.
  40220. * @returns the input friendly name
  40221. */
  40222. getSimpleName(): string;
  40223. }
  40224. }
  40225. declare module BABYLON {
  40226. interface ArcRotateCameraInputsManager {
  40227. /**
  40228. * Add orientation input support to the input manager.
  40229. * @returns the current input manager
  40230. */
  40231. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40232. }
  40233. /**
  40234. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40236. */
  40237. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40238. /**
  40239. * Defines the camera the input is attached to.
  40240. */
  40241. camera: ArcRotateCamera;
  40242. /**
  40243. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40244. */
  40245. alphaCorrection: number;
  40246. /**
  40247. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40248. */
  40249. gammaCorrection: number;
  40250. private _alpha;
  40251. private _gamma;
  40252. private _dirty;
  40253. private _deviceOrientationHandler;
  40254. /**
  40255. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40256. */
  40257. constructor();
  40258. /**
  40259. * Attach the input controls to a specific dom element to get the input from.
  40260. * @param element Defines the element the controls should be listened from
  40261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40262. */
  40263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40264. /** @hidden */
  40265. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40266. /**
  40267. * Update the current camera state depending on the inputs that have been used this frame.
  40268. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40269. */
  40270. checkInputs(): void;
  40271. /**
  40272. * Detach the current controls from the specified dom element.
  40273. * @param element Defines the element to stop listening the inputs from
  40274. */
  40275. detachControl(element: Nullable<HTMLElement>): void;
  40276. /**
  40277. * Gets the class name of the current intput.
  40278. * @returns the class name
  40279. */
  40280. getClassName(): string;
  40281. /**
  40282. * Get the friendly name associated with the input class.
  40283. * @returns the input friendly name
  40284. */
  40285. getSimpleName(): string;
  40286. }
  40287. }
  40288. declare module BABYLON {
  40289. /**
  40290. * Listen to mouse events to control the camera.
  40291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40292. */
  40293. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40294. /**
  40295. * Defines the camera the input is attached to.
  40296. */
  40297. camera: FlyCamera;
  40298. /**
  40299. * Defines if touch is enabled. (Default is true.)
  40300. */
  40301. touchEnabled: boolean;
  40302. /**
  40303. * Defines the buttons associated with the input to handle camera rotation.
  40304. */
  40305. buttons: number[];
  40306. /**
  40307. * Assign buttons for Yaw control.
  40308. */
  40309. buttonsYaw: number[];
  40310. /**
  40311. * Assign buttons for Pitch control.
  40312. */
  40313. buttonsPitch: number[];
  40314. /**
  40315. * Assign buttons for Roll control.
  40316. */
  40317. buttonsRoll: number[];
  40318. /**
  40319. * Detect if any button is being pressed while mouse is moved.
  40320. * -1 = Mouse locked.
  40321. * 0 = Left button.
  40322. * 1 = Middle Button.
  40323. * 2 = Right Button.
  40324. */
  40325. activeButton: number;
  40326. /**
  40327. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40328. * Higher values reduce its sensitivity.
  40329. */
  40330. angularSensibility: number;
  40331. private _mousemoveCallback;
  40332. private _observer;
  40333. private _rollObserver;
  40334. private previousPosition;
  40335. private noPreventDefault;
  40336. private element;
  40337. /**
  40338. * Listen to mouse events to control the camera.
  40339. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40341. */
  40342. constructor(touchEnabled?: boolean);
  40343. /**
  40344. * Attach the mouse control to the HTML DOM element.
  40345. * @param element Defines the element that listens to the input events.
  40346. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40347. */
  40348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40349. /**
  40350. * Detach the current controls from the specified dom element.
  40351. * @param element Defines the element to stop listening the inputs from
  40352. */
  40353. detachControl(element: Nullable<HTMLElement>): void;
  40354. /**
  40355. * Gets the class name of the current input.
  40356. * @returns the class name.
  40357. */
  40358. getClassName(): string;
  40359. /**
  40360. * Get the friendly name associated with the input class.
  40361. * @returns the input's friendly name.
  40362. */
  40363. getSimpleName(): string;
  40364. private _pointerInput;
  40365. private _onMouseMove;
  40366. /**
  40367. * Rotate camera by mouse offset.
  40368. */
  40369. private rotateCamera;
  40370. }
  40371. }
  40372. declare module BABYLON {
  40373. /**
  40374. * Default Inputs manager for the FlyCamera.
  40375. * It groups all the default supported inputs for ease of use.
  40376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40377. */
  40378. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40379. /**
  40380. * Instantiates a new FlyCameraInputsManager.
  40381. * @param camera Defines the camera the inputs belong to.
  40382. */
  40383. constructor(camera: FlyCamera);
  40384. /**
  40385. * Add keyboard input support to the input manager.
  40386. * @returns the new FlyCameraKeyboardMoveInput().
  40387. */
  40388. addKeyboard(): FlyCameraInputsManager;
  40389. /**
  40390. * Add mouse input support to the input manager.
  40391. * @param touchEnabled Enable touch screen support.
  40392. * @returns the new FlyCameraMouseInput().
  40393. */
  40394. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40395. }
  40396. }
  40397. declare module BABYLON {
  40398. /**
  40399. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40400. * such as in a 3D Space Shooter or a Flight Simulator.
  40401. */
  40402. export class FlyCamera extends TargetCamera {
  40403. /**
  40404. * Define the collision ellipsoid of the camera.
  40405. * This is helpful for simulating a camera body, like a player's body.
  40406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40407. */
  40408. ellipsoid: Vector3;
  40409. /**
  40410. * Define an offset for the position of the ellipsoid around the camera.
  40411. * This can be helpful if the camera is attached away from the player's body center,
  40412. * such as at its head.
  40413. */
  40414. ellipsoidOffset: Vector3;
  40415. /**
  40416. * Enable or disable collisions of the camera with the rest of the scene objects.
  40417. */
  40418. checkCollisions: boolean;
  40419. /**
  40420. * Enable or disable gravity on the camera.
  40421. */
  40422. applyGravity: boolean;
  40423. /**
  40424. * Define the current direction the camera is moving to.
  40425. */
  40426. cameraDirection: Vector3;
  40427. /**
  40428. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40429. * This overrides and empties cameraRotation.
  40430. */
  40431. rotationQuaternion: Quaternion;
  40432. /**
  40433. * Track Roll to maintain the wanted Rolling when looking around.
  40434. */
  40435. _trackRoll: number;
  40436. /**
  40437. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40438. */
  40439. rollCorrect: number;
  40440. /**
  40441. * Mimic a banked turn, Rolling the camera when Yawing.
  40442. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40443. */
  40444. bankedTurn: boolean;
  40445. /**
  40446. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40447. */
  40448. bankedTurnLimit: number;
  40449. /**
  40450. * Value of 0 disables the banked Roll.
  40451. * Value of 1 is equal to the Yaw angle in radians.
  40452. */
  40453. bankedTurnMultiplier: number;
  40454. /**
  40455. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40456. */
  40457. inputs: FlyCameraInputsManager;
  40458. /**
  40459. * Gets the input sensibility for mouse input.
  40460. * Higher values reduce sensitivity.
  40461. */
  40462. get angularSensibility(): number;
  40463. /**
  40464. * Sets the input sensibility for a mouse input.
  40465. * Higher values reduce sensitivity.
  40466. */
  40467. set angularSensibility(value: number);
  40468. /**
  40469. * Get the keys for camera movement forward.
  40470. */
  40471. get keysForward(): number[];
  40472. /**
  40473. * Set the keys for camera movement forward.
  40474. */
  40475. set keysForward(value: number[]);
  40476. /**
  40477. * Get the keys for camera movement backward.
  40478. */
  40479. get keysBackward(): number[];
  40480. set keysBackward(value: number[]);
  40481. /**
  40482. * Get the keys for camera movement up.
  40483. */
  40484. get keysUp(): number[];
  40485. /**
  40486. * Set the keys for camera movement up.
  40487. */
  40488. set keysUp(value: number[]);
  40489. /**
  40490. * Get the keys for camera movement down.
  40491. */
  40492. get keysDown(): number[];
  40493. /**
  40494. * Set the keys for camera movement down.
  40495. */
  40496. set keysDown(value: number[]);
  40497. /**
  40498. * Get the keys for camera movement left.
  40499. */
  40500. get keysLeft(): number[];
  40501. /**
  40502. * Set the keys for camera movement left.
  40503. */
  40504. set keysLeft(value: number[]);
  40505. /**
  40506. * Set the keys for camera movement right.
  40507. */
  40508. get keysRight(): number[];
  40509. /**
  40510. * Set the keys for camera movement right.
  40511. */
  40512. set keysRight(value: number[]);
  40513. /**
  40514. * Event raised when the camera collides with a mesh in the scene.
  40515. */
  40516. onCollide: (collidedMesh: AbstractMesh) => void;
  40517. private _collider;
  40518. private _needMoveForGravity;
  40519. private _oldPosition;
  40520. private _diffPosition;
  40521. private _newPosition;
  40522. /** @hidden */
  40523. _localDirection: Vector3;
  40524. /** @hidden */
  40525. _transformedDirection: Vector3;
  40526. /**
  40527. * Instantiates a FlyCamera.
  40528. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40529. * such as in a 3D Space Shooter or a Flight Simulator.
  40530. * @param name Define the name of the camera in the scene.
  40531. * @param position Define the starting position of the camera in the scene.
  40532. * @param scene Define the scene the camera belongs to.
  40533. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40534. */
  40535. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40536. /**
  40537. * Attach a control to the HTML DOM element.
  40538. * @param element Defines the element that listens to the input events.
  40539. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40540. */
  40541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40542. /**
  40543. * Detach a control from the HTML DOM element.
  40544. * The camera will stop reacting to that input.
  40545. * @param element Defines the element that listens to the input events.
  40546. */
  40547. detachControl(element: HTMLElement): void;
  40548. private _collisionMask;
  40549. /**
  40550. * Get the mask that the camera ignores in collision events.
  40551. */
  40552. get collisionMask(): number;
  40553. /**
  40554. * Set the mask that the camera ignores in collision events.
  40555. */
  40556. set collisionMask(mask: number);
  40557. /** @hidden */
  40558. _collideWithWorld(displacement: Vector3): void;
  40559. /** @hidden */
  40560. private _onCollisionPositionChange;
  40561. /** @hidden */
  40562. _checkInputs(): void;
  40563. /** @hidden */
  40564. _decideIfNeedsToMove(): boolean;
  40565. /** @hidden */
  40566. _updatePosition(): void;
  40567. /**
  40568. * Restore the Roll to its target value at the rate specified.
  40569. * @param rate - Higher means slower restoring.
  40570. * @hidden
  40571. */
  40572. restoreRoll(rate: number): void;
  40573. /**
  40574. * Destroy the camera and release the current resources held by it.
  40575. */
  40576. dispose(): void;
  40577. /**
  40578. * Get the current object class name.
  40579. * @returns the class name.
  40580. */
  40581. getClassName(): string;
  40582. }
  40583. }
  40584. declare module BABYLON {
  40585. /**
  40586. * Listen to keyboard events to control the camera.
  40587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40588. */
  40589. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40590. /**
  40591. * Defines the camera the input is attached to.
  40592. */
  40593. camera: FlyCamera;
  40594. /**
  40595. * The list of keyboard keys used to control the forward move of the camera.
  40596. */
  40597. keysForward: number[];
  40598. /**
  40599. * The list of keyboard keys used to control the backward move of the camera.
  40600. */
  40601. keysBackward: number[];
  40602. /**
  40603. * The list of keyboard keys used to control the forward move of the camera.
  40604. */
  40605. keysUp: number[];
  40606. /**
  40607. * The list of keyboard keys used to control the backward move of the camera.
  40608. */
  40609. keysDown: number[];
  40610. /**
  40611. * The list of keyboard keys used to control the right strafe move of the camera.
  40612. */
  40613. keysRight: number[];
  40614. /**
  40615. * The list of keyboard keys used to control the left strafe move of the camera.
  40616. */
  40617. keysLeft: number[];
  40618. private _keys;
  40619. private _onCanvasBlurObserver;
  40620. private _onKeyboardObserver;
  40621. private _engine;
  40622. private _scene;
  40623. /**
  40624. * Attach the input controls to a specific dom element to get the input from.
  40625. * @param element Defines the element the controls should be listened from
  40626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40627. */
  40628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40629. /**
  40630. * Detach the current controls from the specified dom element.
  40631. * @param element Defines the element to stop listening the inputs from
  40632. */
  40633. detachControl(element: Nullable<HTMLElement>): void;
  40634. /**
  40635. * Gets the class name of the current intput.
  40636. * @returns the class name
  40637. */
  40638. getClassName(): string;
  40639. /** @hidden */
  40640. _onLostFocus(e: FocusEvent): void;
  40641. /**
  40642. * Get the friendly name associated with the input class.
  40643. * @returns the input friendly name
  40644. */
  40645. getSimpleName(): string;
  40646. /**
  40647. * Update the current camera state depending on the inputs that have been used this frame.
  40648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40649. */
  40650. checkInputs(): void;
  40651. }
  40652. }
  40653. declare module BABYLON {
  40654. /**
  40655. * Manage the mouse wheel inputs to control a follow camera.
  40656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40657. */
  40658. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40659. /**
  40660. * Defines the camera the input is attached to.
  40661. */
  40662. camera: FollowCamera;
  40663. /**
  40664. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40665. */
  40666. axisControlRadius: boolean;
  40667. /**
  40668. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40669. */
  40670. axisControlHeight: boolean;
  40671. /**
  40672. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40673. */
  40674. axisControlRotation: boolean;
  40675. /**
  40676. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40677. * relation to mouseWheel events.
  40678. */
  40679. wheelPrecision: number;
  40680. /**
  40681. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40682. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40683. */
  40684. wheelDeltaPercentage: number;
  40685. private _wheel;
  40686. private _observer;
  40687. /**
  40688. * Attach the input controls to a specific dom element to get the input from.
  40689. * @param element Defines the element the controls should be listened from
  40690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40691. */
  40692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40693. /**
  40694. * Detach the current controls from the specified dom element.
  40695. * @param element Defines the element to stop listening the inputs from
  40696. */
  40697. detachControl(element: Nullable<HTMLElement>): void;
  40698. /**
  40699. * Gets the class name of the current intput.
  40700. * @returns the class name
  40701. */
  40702. getClassName(): string;
  40703. /**
  40704. * Get the friendly name associated with the input class.
  40705. * @returns the input friendly name
  40706. */
  40707. getSimpleName(): string;
  40708. }
  40709. }
  40710. declare module BABYLON {
  40711. /**
  40712. * Manage the pointers inputs to control an follow camera.
  40713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40714. */
  40715. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40716. /**
  40717. * Defines the camera the input is attached to.
  40718. */
  40719. camera: FollowCamera;
  40720. /**
  40721. * Gets the class name of the current input.
  40722. * @returns the class name
  40723. */
  40724. getClassName(): string;
  40725. /**
  40726. * Defines the pointer angular sensibility along the X axis or how fast is
  40727. * the camera rotating.
  40728. * A negative number will reverse the axis direction.
  40729. */
  40730. angularSensibilityX: number;
  40731. /**
  40732. * Defines the pointer angular sensibility along the Y axis or how fast is
  40733. * the camera rotating.
  40734. * A negative number will reverse the axis direction.
  40735. */
  40736. angularSensibilityY: number;
  40737. /**
  40738. * Defines the pointer pinch precision or how fast is the camera zooming.
  40739. * A negative number will reverse the axis direction.
  40740. */
  40741. pinchPrecision: number;
  40742. /**
  40743. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40744. * from 0.
  40745. * It defines the percentage of current camera.radius to use as delta when
  40746. * pinch zoom is used.
  40747. */
  40748. pinchDeltaPercentage: number;
  40749. /**
  40750. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40751. */
  40752. axisXControlRadius: boolean;
  40753. /**
  40754. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40755. */
  40756. axisXControlHeight: boolean;
  40757. /**
  40758. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40759. */
  40760. axisXControlRotation: boolean;
  40761. /**
  40762. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40763. */
  40764. axisYControlRadius: boolean;
  40765. /**
  40766. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40767. */
  40768. axisYControlHeight: boolean;
  40769. /**
  40770. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40771. */
  40772. axisYControlRotation: boolean;
  40773. /**
  40774. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40775. */
  40776. axisPinchControlRadius: boolean;
  40777. /**
  40778. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40779. */
  40780. axisPinchControlHeight: boolean;
  40781. /**
  40782. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40783. */
  40784. axisPinchControlRotation: boolean;
  40785. /**
  40786. * Log error messages if basic misconfiguration has occurred.
  40787. */
  40788. warningEnable: boolean;
  40789. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40790. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40791. private _warningCounter;
  40792. private _warning;
  40793. }
  40794. }
  40795. declare module BABYLON {
  40796. /**
  40797. * Default Inputs manager for the FollowCamera.
  40798. * It groups all the default supported inputs for ease of use.
  40799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40800. */
  40801. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40802. /**
  40803. * Instantiates a new FollowCameraInputsManager.
  40804. * @param camera Defines the camera the inputs belong to
  40805. */
  40806. constructor(camera: FollowCamera);
  40807. /**
  40808. * Add keyboard input support to the input manager.
  40809. * @returns the current input manager
  40810. */
  40811. addKeyboard(): FollowCameraInputsManager;
  40812. /**
  40813. * Add mouse wheel input support to the input manager.
  40814. * @returns the current input manager
  40815. */
  40816. addMouseWheel(): FollowCameraInputsManager;
  40817. /**
  40818. * Add pointers input support to the input manager.
  40819. * @returns the current input manager
  40820. */
  40821. addPointers(): FollowCameraInputsManager;
  40822. /**
  40823. * Add orientation input support to the input manager.
  40824. * @returns the current input manager
  40825. */
  40826. addVRDeviceOrientation(): FollowCameraInputsManager;
  40827. }
  40828. }
  40829. declare module BABYLON {
  40830. /**
  40831. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40832. * an arc rotate version arcFollowCamera are available.
  40833. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40834. */
  40835. export class FollowCamera extends TargetCamera {
  40836. /**
  40837. * Distance the follow camera should follow an object at
  40838. */
  40839. radius: number;
  40840. /**
  40841. * Minimum allowed distance of the camera to the axis of rotation
  40842. * (The camera can not get closer).
  40843. * This can help limiting how the Camera is able to move in the scene.
  40844. */
  40845. lowerRadiusLimit: Nullable<number>;
  40846. /**
  40847. * Maximum allowed distance of the camera to the axis of rotation
  40848. * (The camera can not get further).
  40849. * This can help limiting how the Camera is able to move in the scene.
  40850. */
  40851. upperRadiusLimit: Nullable<number>;
  40852. /**
  40853. * Define a rotation offset between the camera and the object it follows
  40854. */
  40855. rotationOffset: number;
  40856. /**
  40857. * Minimum allowed angle to camera position relative to target object.
  40858. * This can help limiting how the Camera is able to move in the scene.
  40859. */
  40860. lowerRotationOffsetLimit: Nullable<number>;
  40861. /**
  40862. * Maximum allowed angle to camera position relative to target object.
  40863. * This can help limiting how the Camera is able to move in the scene.
  40864. */
  40865. upperRotationOffsetLimit: Nullable<number>;
  40866. /**
  40867. * Define a height offset between the camera and the object it follows.
  40868. * It can help following an object from the top (like a car chaing a plane)
  40869. */
  40870. heightOffset: number;
  40871. /**
  40872. * Minimum allowed height of camera position relative to target object.
  40873. * This can help limiting how the Camera is able to move in the scene.
  40874. */
  40875. lowerHeightOffsetLimit: Nullable<number>;
  40876. /**
  40877. * Maximum allowed height of camera position relative to target object.
  40878. * This can help limiting how the Camera is able to move in the scene.
  40879. */
  40880. upperHeightOffsetLimit: Nullable<number>;
  40881. /**
  40882. * Define how fast the camera can accelerate to follow it s target.
  40883. */
  40884. cameraAcceleration: number;
  40885. /**
  40886. * Define the speed limit of the camera following an object.
  40887. */
  40888. maxCameraSpeed: number;
  40889. /**
  40890. * Define the target of the camera.
  40891. */
  40892. lockedTarget: Nullable<AbstractMesh>;
  40893. /**
  40894. * Defines the input associated with the camera.
  40895. */
  40896. inputs: FollowCameraInputsManager;
  40897. /**
  40898. * Instantiates the follow camera.
  40899. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40900. * @param name Define the name of the camera in the scene
  40901. * @param position Define the position of the camera
  40902. * @param scene Define the scene the camera belong to
  40903. * @param lockedTarget Define the target of the camera
  40904. */
  40905. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40906. private _follow;
  40907. /**
  40908. * Attached controls to the current camera.
  40909. * @param element Defines the element the controls should be listened from
  40910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40911. */
  40912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40913. /**
  40914. * Detach the current controls from the camera.
  40915. * The camera will stop reacting to inputs.
  40916. * @param element Defines the element to stop listening the inputs from
  40917. */
  40918. detachControl(element: HTMLElement): void;
  40919. /** @hidden */
  40920. _checkInputs(): void;
  40921. private _checkLimits;
  40922. /**
  40923. * Gets the camera class name.
  40924. * @returns the class name
  40925. */
  40926. getClassName(): string;
  40927. }
  40928. /**
  40929. * Arc Rotate version of the follow camera.
  40930. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40931. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40932. */
  40933. export class ArcFollowCamera extends TargetCamera {
  40934. /** The longitudinal angle of the camera */
  40935. alpha: number;
  40936. /** The latitudinal angle of the camera */
  40937. beta: number;
  40938. /** The radius of the camera from its target */
  40939. radius: number;
  40940. /** Define the camera target (the messh it should follow) */
  40941. target: Nullable<AbstractMesh>;
  40942. private _cartesianCoordinates;
  40943. /**
  40944. * Instantiates a new ArcFollowCamera
  40945. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40946. * @param name Define the name of the camera
  40947. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40948. * @param beta Define the rotation angle of the camera around the elevation axis
  40949. * @param radius Define the radius of the camera from its target point
  40950. * @param target Define the target of the camera
  40951. * @param scene Define the scene the camera belongs to
  40952. */
  40953. constructor(name: string,
  40954. /** The longitudinal angle of the camera */
  40955. alpha: number,
  40956. /** The latitudinal angle of the camera */
  40957. beta: number,
  40958. /** The radius of the camera from its target */
  40959. radius: number,
  40960. /** Define the camera target (the messh it should follow) */
  40961. target: Nullable<AbstractMesh>, scene: Scene);
  40962. private _follow;
  40963. /** @hidden */
  40964. _checkInputs(): void;
  40965. /**
  40966. * Returns the class name of the object.
  40967. * It is mostly used internally for serialization purposes.
  40968. */
  40969. getClassName(): string;
  40970. }
  40971. }
  40972. declare module BABYLON {
  40973. /**
  40974. * Manage the keyboard inputs to control the movement of a follow camera.
  40975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40976. */
  40977. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40978. /**
  40979. * Defines the camera the input is attached to.
  40980. */
  40981. camera: FollowCamera;
  40982. /**
  40983. * Defines the list of key codes associated with the up action (increase heightOffset)
  40984. */
  40985. keysHeightOffsetIncr: number[];
  40986. /**
  40987. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40988. */
  40989. keysHeightOffsetDecr: number[];
  40990. /**
  40991. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40992. */
  40993. keysHeightOffsetModifierAlt: boolean;
  40994. /**
  40995. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40996. */
  40997. keysHeightOffsetModifierCtrl: boolean;
  40998. /**
  40999. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41000. */
  41001. keysHeightOffsetModifierShift: boolean;
  41002. /**
  41003. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41004. */
  41005. keysRotationOffsetIncr: number[];
  41006. /**
  41007. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41008. */
  41009. keysRotationOffsetDecr: number[];
  41010. /**
  41011. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41012. */
  41013. keysRotationOffsetModifierAlt: boolean;
  41014. /**
  41015. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41016. */
  41017. keysRotationOffsetModifierCtrl: boolean;
  41018. /**
  41019. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41020. */
  41021. keysRotationOffsetModifierShift: boolean;
  41022. /**
  41023. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41024. */
  41025. keysRadiusIncr: number[];
  41026. /**
  41027. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41028. */
  41029. keysRadiusDecr: number[];
  41030. /**
  41031. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41032. */
  41033. keysRadiusModifierAlt: boolean;
  41034. /**
  41035. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41036. */
  41037. keysRadiusModifierCtrl: boolean;
  41038. /**
  41039. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41040. */
  41041. keysRadiusModifierShift: boolean;
  41042. /**
  41043. * Defines the rate of change of heightOffset.
  41044. */
  41045. heightSensibility: number;
  41046. /**
  41047. * Defines the rate of change of rotationOffset.
  41048. */
  41049. rotationSensibility: number;
  41050. /**
  41051. * Defines the rate of change of radius.
  41052. */
  41053. radiusSensibility: number;
  41054. private _keys;
  41055. private _ctrlPressed;
  41056. private _altPressed;
  41057. private _shiftPressed;
  41058. private _onCanvasBlurObserver;
  41059. private _onKeyboardObserver;
  41060. private _engine;
  41061. private _scene;
  41062. /**
  41063. * Attach the input controls to a specific dom element to get the input from.
  41064. * @param element Defines the element the controls should be listened from
  41065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41066. */
  41067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41068. /**
  41069. * Detach the current controls from the specified dom element.
  41070. * @param element Defines the element to stop listening the inputs from
  41071. */
  41072. detachControl(element: Nullable<HTMLElement>): void;
  41073. /**
  41074. * Update the current camera state depending on the inputs that have been used this frame.
  41075. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41076. */
  41077. checkInputs(): void;
  41078. /**
  41079. * Gets the class name of the current input.
  41080. * @returns the class name
  41081. */
  41082. getClassName(): string;
  41083. /**
  41084. * Get the friendly name associated with the input class.
  41085. * @returns the input friendly name
  41086. */
  41087. getSimpleName(): string;
  41088. /**
  41089. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41090. * allow modification of the heightOffset value.
  41091. */
  41092. private _modifierHeightOffset;
  41093. /**
  41094. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41095. * allow modification of the rotationOffset value.
  41096. */
  41097. private _modifierRotationOffset;
  41098. /**
  41099. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41100. * allow modification of the radius value.
  41101. */
  41102. private _modifierRadius;
  41103. }
  41104. }
  41105. declare module BABYLON {
  41106. interface FreeCameraInputsManager {
  41107. /**
  41108. * @hidden
  41109. */
  41110. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41111. /**
  41112. * Add orientation input support to the input manager.
  41113. * @returns the current input manager
  41114. */
  41115. addDeviceOrientation(): FreeCameraInputsManager;
  41116. }
  41117. /**
  41118. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41119. * Screen rotation is taken into account.
  41120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41121. */
  41122. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41123. private _camera;
  41124. private _screenOrientationAngle;
  41125. private _constantTranform;
  41126. private _screenQuaternion;
  41127. private _alpha;
  41128. private _beta;
  41129. private _gamma;
  41130. /**
  41131. * Can be used to detect if a device orientation sensor is available on a device
  41132. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41133. * @returns a promise that will resolve on orientation change
  41134. */
  41135. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41136. /**
  41137. * @hidden
  41138. */
  41139. _onDeviceOrientationChangedObservable: Observable<void>;
  41140. /**
  41141. * Instantiates a new input
  41142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41143. */
  41144. constructor();
  41145. /**
  41146. * Define the camera controlled by the input.
  41147. */
  41148. get camera(): FreeCamera;
  41149. set camera(camera: FreeCamera);
  41150. /**
  41151. * Attach the input controls to a specific dom element to get the input from.
  41152. * @param element Defines the element the controls should be listened from
  41153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41154. */
  41155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41156. private _orientationChanged;
  41157. private _deviceOrientation;
  41158. /**
  41159. * Detach the current controls from the specified dom element.
  41160. * @param element Defines the element to stop listening the inputs from
  41161. */
  41162. detachControl(element: Nullable<HTMLElement>): void;
  41163. /**
  41164. * Update the current camera state depending on the inputs that have been used this frame.
  41165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41166. */
  41167. checkInputs(): void;
  41168. /**
  41169. * Gets the class name of the current intput.
  41170. * @returns the class name
  41171. */
  41172. getClassName(): string;
  41173. /**
  41174. * Get the friendly name associated with the input class.
  41175. * @returns the input friendly name
  41176. */
  41177. getSimpleName(): string;
  41178. }
  41179. }
  41180. declare module BABYLON {
  41181. /**
  41182. * Manage the gamepad inputs to control a free camera.
  41183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41184. */
  41185. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41186. /**
  41187. * Define the camera the input is attached to.
  41188. */
  41189. camera: FreeCamera;
  41190. /**
  41191. * Define the Gamepad controlling the input
  41192. */
  41193. gamepad: Nullable<Gamepad>;
  41194. /**
  41195. * Defines the gamepad rotation sensiblity.
  41196. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41197. */
  41198. gamepadAngularSensibility: number;
  41199. /**
  41200. * Defines the gamepad move sensiblity.
  41201. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41202. */
  41203. gamepadMoveSensibility: number;
  41204. private _yAxisScale;
  41205. /**
  41206. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41207. */
  41208. get invertYAxis(): boolean;
  41209. set invertYAxis(value: boolean);
  41210. private _onGamepadConnectedObserver;
  41211. private _onGamepadDisconnectedObserver;
  41212. private _cameraTransform;
  41213. private _deltaTransform;
  41214. private _vector3;
  41215. private _vector2;
  41216. /**
  41217. * Attach the input controls to a specific dom element to get the input from.
  41218. * @param element Defines the element the controls should be listened from
  41219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41220. */
  41221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41222. /**
  41223. * Detach the current controls from the specified dom element.
  41224. * @param element Defines the element to stop listening the inputs from
  41225. */
  41226. detachControl(element: Nullable<HTMLElement>): void;
  41227. /**
  41228. * Update the current camera state depending on the inputs that have been used this frame.
  41229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41230. */
  41231. checkInputs(): void;
  41232. /**
  41233. * Gets the class name of the current intput.
  41234. * @returns the class name
  41235. */
  41236. getClassName(): string;
  41237. /**
  41238. * Get the friendly name associated with the input class.
  41239. * @returns the input friendly name
  41240. */
  41241. getSimpleName(): string;
  41242. }
  41243. }
  41244. declare module BABYLON {
  41245. /**
  41246. * Defines the potential axis of a Joystick
  41247. */
  41248. export enum JoystickAxis {
  41249. /** X axis */
  41250. X = 0,
  41251. /** Y axis */
  41252. Y = 1,
  41253. /** Z axis */
  41254. Z = 2
  41255. }
  41256. /**
  41257. * Class used to define virtual joystick (used in touch mode)
  41258. */
  41259. export class VirtualJoystick {
  41260. /**
  41261. * Gets or sets a boolean indicating that left and right values must be inverted
  41262. */
  41263. reverseLeftRight: boolean;
  41264. /**
  41265. * Gets or sets a boolean indicating that up and down values must be inverted
  41266. */
  41267. reverseUpDown: boolean;
  41268. /**
  41269. * Gets the offset value for the position (ie. the change of the position value)
  41270. */
  41271. deltaPosition: Vector3;
  41272. /**
  41273. * Gets a boolean indicating if the virtual joystick was pressed
  41274. */
  41275. pressed: boolean;
  41276. /**
  41277. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41278. */
  41279. static Canvas: Nullable<HTMLCanvasElement>;
  41280. private static _globalJoystickIndex;
  41281. private static vjCanvasContext;
  41282. private static vjCanvasWidth;
  41283. private static vjCanvasHeight;
  41284. private static halfWidth;
  41285. private _action;
  41286. private _axisTargetedByLeftAndRight;
  41287. private _axisTargetedByUpAndDown;
  41288. private _joystickSensibility;
  41289. private _inversedSensibility;
  41290. private _joystickPointerID;
  41291. private _joystickColor;
  41292. private _joystickPointerPos;
  41293. private _joystickPreviousPointerPos;
  41294. private _joystickPointerStartPos;
  41295. private _deltaJoystickVector;
  41296. private _leftJoystick;
  41297. private _touches;
  41298. private _onPointerDownHandlerRef;
  41299. private _onPointerMoveHandlerRef;
  41300. private _onPointerUpHandlerRef;
  41301. private _onResize;
  41302. /**
  41303. * Creates a new virtual joystick
  41304. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41305. */
  41306. constructor(leftJoystick?: boolean);
  41307. /**
  41308. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41309. * @param newJoystickSensibility defines the new sensibility
  41310. */
  41311. setJoystickSensibility(newJoystickSensibility: number): void;
  41312. private _onPointerDown;
  41313. private _onPointerMove;
  41314. private _onPointerUp;
  41315. /**
  41316. * Change the color of the virtual joystick
  41317. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41318. */
  41319. setJoystickColor(newColor: string): void;
  41320. /**
  41321. * Defines a callback to call when the joystick is touched
  41322. * @param action defines the callback
  41323. */
  41324. setActionOnTouch(action: () => any): void;
  41325. /**
  41326. * Defines which axis you'd like to control for left & right
  41327. * @param axis defines the axis to use
  41328. */
  41329. setAxisForLeftRight(axis: JoystickAxis): void;
  41330. /**
  41331. * Defines which axis you'd like to control for up & down
  41332. * @param axis defines the axis to use
  41333. */
  41334. setAxisForUpDown(axis: JoystickAxis): void;
  41335. private _drawVirtualJoystick;
  41336. /**
  41337. * Release internal HTML canvas
  41338. */
  41339. releaseCanvas(): void;
  41340. }
  41341. }
  41342. declare module BABYLON {
  41343. interface FreeCameraInputsManager {
  41344. /**
  41345. * Add virtual joystick input support to the input manager.
  41346. * @returns the current input manager
  41347. */
  41348. addVirtualJoystick(): FreeCameraInputsManager;
  41349. }
  41350. /**
  41351. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41353. */
  41354. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41355. /**
  41356. * Defines the camera the input is attached to.
  41357. */
  41358. camera: FreeCamera;
  41359. private _leftjoystick;
  41360. private _rightjoystick;
  41361. /**
  41362. * Gets the left stick of the virtual joystick.
  41363. * @returns The virtual Joystick
  41364. */
  41365. getLeftJoystick(): VirtualJoystick;
  41366. /**
  41367. * Gets the right stick of the virtual joystick.
  41368. * @returns The virtual Joystick
  41369. */
  41370. getRightJoystick(): VirtualJoystick;
  41371. /**
  41372. * Update the current camera state depending on the inputs that have been used this frame.
  41373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41374. */
  41375. checkInputs(): void;
  41376. /**
  41377. * Attach the input controls to a specific dom element to get the input from.
  41378. * @param element Defines the element the controls should be listened from
  41379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41380. */
  41381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41382. /**
  41383. * Detach the current controls from the specified dom element.
  41384. * @param element Defines the element to stop listening the inputs from
  41385. */
  41386. detachControl(element: Nullable<HTMLElement>): void;
  41387. /**
  41388. * Gets the class name of the current intput.
  41389. * @returns the class name
  41390. */
  41391. getClassName(): string;
  41392. /**
  41393. * Get the friendly name associated with the input class.
  41394. * @returns the input friendly name
  41395. */
  41396. getSimpleName(): string;
  41397. }
  41398. }
  41399. declare module BABYLON {
  41400. /**
  41401. * This represents a FPS type of camera controlled by touch.
  41402. * This is like a universal camera minus the Gamepad controls.
  41403. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41404. */
  41405. export class TouchCamera extends FreeCamera {
  41406. /**
  41407. * Defines the touch sensibility for rotation.
  41408. * The higher the faster.
  41409. */
  41410. get touchAngularSensibility(): number;
  41411. set touchAngularSensibility(value: number);
  41412. /**
  41413. * Defines the touch sensibility for move.
  41414. * The higher the faster.
  41415. */
  41416. get touchMoveSensibility(): number;
  41417. set touchMoveSensibility(value: number);
  41418. /**
  41419. * Instantiates a new touch camera.
  41420. * This represents a FPS type of camera controlled by touch.
  41421. * This is like a universal camera minus the Gamepad controls.
  41422. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41423. * @param name Define the name of the camera in the scene
  41424. * @param position Define the start position of the camera in the scene
  41425. * @param scene Define the scene the camera belongs to
  41426. */
  41427. constructor(name: string, position: Vector3, scene: Scene);
  41428. /**
  41429. * Gets the current object class name.
  41430. * @return the class name
  41431. */
  41432. getClassName(): string;
  41433. /** @hidden */
  41434. _setupInputs(): void;
  41435. }
  41436. }
  41437. declare module BABYLON {
  41438. /**
  41439. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41440. * being tilted forward or back and left or right.
  41441. */
  41442. export class DeviceOrientationCamera extends FreeCamera {
  41443. private _initialQuaternion;
  41444. private _quaternionCache;
  41445. private _tmpDragQuaternion;
  41446. private _disablePointerInputWhenUsingDeviceOrientation;
  41447. /**
  41448. * Creates a new device orientation camera
  41449. * @param name The name of the camera
  41450. * @param position The start position camera
  41451. * @param scene The scene the camera belongs to
  41452. */
  41453. constructor(name: string, position: Vector3, scene: Scene);
  41454. /**
  41455. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41456. */
  41457. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41458. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41459. private _dragFactor;
  41460. /**
  41461. * Enabled turning on the y axis when the orientation sensor is active
  41462. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41463. */
  41464. enableHorizontalDragging(dragFactor?: number): void;
  41465. /**
  41466. * Gets the current instance class name ("DeviceOrientationCamera").
  41467. * This helps avoiding instanceof at run time.
  41468. * @returns the class name
  41469. */
  41470. getClassName(): string;
  41471. /**
  41472. * @hidden
  41473. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41474. */
  41475. _checkInputs(): void;
  41476. /**
  41477. * Reset the camera to its default orientation on the specified axis only.
  41478. * @param axis The axis to reset
  41479. */
  41480. resetToCurrentRotation(axis?: Axis): void;
  41481. }
  41482. }
  41483. declare module BABYLON {
  41484. /**
  41485. * Defines supported buttons for XBox360 compatible gamepads
  41486. */
  41487. export enum Xbox360Button {
  41488. /** A */
  41489. A = 0,
  41490. /** B */
  41491. B = 1,
  41492. /** X */
  41493. X = 2,
  41494. /** Y */
  41495. Y = 3,
  41496. /** Left button */
  41497. LB = 4,
  41498. /** Right button */
  41499. RB = 5,
  41500. /** Back */
  41501. Back = 8,
  41502. /** Start */
  41503. Start = 9,
  41504. /** Left stick */
  41505. LeftStick = 10,
  41506. /** Right stick */
  41507. RightStick = 11
  41508. }
  41509. /** Defines values for XBox360 DPad */
  41510. export enum Xbox360Dpad {
  41511. /** Up */
  41512. Up = 12,
  41513. /** Down */
  41514. Down = 13,
  41515. /** Left */
  41516. Left = 14,
  41517. /** Right */
  41518. Right = 15
  41519. }
  41520. /**
  41521. * Defines a XBox360 gamepad
  41522. */
  41523. export class Xbox360Pad extends Gamepad {
  41524. private _leftTrigger;
  41525. private _rightTrigger;
  41526. private _onlefttriggerchanged;
  41527. private _onrighttriggerchanged;
  41528. private _onbuttondown;
  41529. private _onbuttonup;
  41530. private _ondpaddown;
  41531. private _ondpadup;
  41532. /** Observable raised when a button is pressed */
  41533. onButtonDownObservable: Observable<Xbox360Button>;
  41534. /** Observable raised when a button is released */
  41535. onButtonUpObservable: Observable<Xbox360Button>;
  41536. /** Observable raised when a pad is pressed */
  41537. onPadDownObservable: Observable<Xbox360Dpad>;
  41538. /** Observable raised when a pad is released */
  41539. onPadUpObservable: Observable<Xbox360Dpad>;
  41540. private _buttonA;
  41541. private _buttonB;
  41542. private _buttonX;
  41543. private _buttonY;
  41544. private _buttonBack;
  41545. private _buttonStart;
  41546. private _buttonLB;
  41547. private _buttonRB;
  41548. private _buttonLeftStick;
  41549. private _buttonRightStick;
  41550. private _dPadUp;
  41551. private _dPadDown;
  41552. private _dPadLeft;
  41553. private _dPadRight;
  41554. private _isXboxOnePad;
  41555. /**
  41556. * Creates a new XBox360 gamepad object
  41557. * @param id defines the id of this gamepad
  41558. * @param index defines its index
  41559. * @param gamepad defines the internal HTML gamepad object
  41560. * @param xboxOne defines if it is a XBox One gamepad
  41561. */
  41562. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41563. /**
  41564. * Defines the callback to call when left trigger is pressed
  41565. * @param callback defines the callback to use
  41566. */
  41567. onlefttriggerchanged(callback: (value: number) => void): void;
  41568. /**
  41569. * Defines the callback to call when right trigger is pressed
  41570. * @param callback defines the callback to use
  41571. */
  41572. onrighttriggerchanged(callback: (value: number) => void): void;
  41573. /**
  41574. * Gets the left trigger value
  41575. */
  41576. get leftTrigger(): number;
  41577. /**
  41578. * Sets the left trigger value
  41579. */
  41580. set leftTrigger(newValue: number);
  41581. /**
  41582. * Gets the right trigger value
  41583. */
  41584. get rightTrigger(): number;
  41585. /**
  41586. * Sets the right trigger value
  41587. */
  41588. set rightTrigger(newValue: number);
  41589. /**
  41590. * Defines the callback to call when a button is pressed
  41591. * @param callback defines the callback to use
  41592. */
  41593. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41594. /**
  41595. * Defines the callback to call when a button is released
  41596. * @param callback defines the callback to use
  41597. */
  41598. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41599. /**
  41600. * Defines the callback to call when a pad is pressed
  41601. * @param callback defines the callback to use
  41602. */
  41603. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41604. /**
  41605. * Defines the callback to call when a pad is released
  41606. * @param callback defines the callback to use
  41607. */
  41608. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41609. private _setButtonValue;
  41610. private _setDPadValue;
  41611. /**
  41612. * Gets the value of the `A` button
  41613. */
  41614. get buttonA(): number;
  41615. /**
  41616. * Sets the value of the `A` button
  41617. */
  41618. set buttonA(value: number);
  41619. /**
  41620. * Gets the value of the `B` button
  41621. */
  41622. get buttonB(): number;
  41623. /**
  41624. * Sets the value of the `B` button
  41625. */
  41626. set buttonB(value: number);
  41627. /**
  41628. * Gets the value of the `X` button
  41629. */
  41630. get buttonX(): number;
  41631. /**
  41632. * Sets the value of the `X` button
  41633. */
  41634. set buttonX(value: number);
  41635. /**
  41636. * Gets the value of the `Y` button
  41637. */
  41638. get buttonY(): number;
  41639. /**
  41640. * Sets the value of the `Y` button
  41641. */
  41642. set buttonY(value: number);
  41643. /**
  41644. * Gets the value of the `Start` button
  41645. */
  41646. get buttonStart(): number;
  41647. /**
  41648. * Sets the value of the `Start` button
  41649. */
  41650. set buttonStart(value: number);
  41651. /**
  41652. * Gets the value of the `Back` button
  41653. */
  41654. get buttonBack(): number;
  41655. /**
  41656. * Sets the value of the `Back` button
  41657. */
  41658. set buttonBack(value: number);
  41659. /**
  41660. * Gets the value of the `Left` button
  41661. */
  41662. get buttonLB(): number;
  41663. /**
  41664. * Sets the value of the `Left` button
  41665. */
  41666. set buttonLB(value: number);
  41667. /**
  41668. * Gets the value of the `Right` button
  41669. */
  41670. get buttonRB(): number;
  41671. /**
  41672. * Sets the value of the `Right` button
  41673. */
  41674. set buttonRB(value: number);
  41675. /**
  41676. * Gets the value of the Left joystick
  41677. */
  41678. get buttonLeftStick(): number;
  41679. /**
  41680. * Sets the value of the Left joystick
  41681. */
  41682. set buttonLeftStick(value: number);
  41683. /**
  41684. * Gets the value of the Right joystick
  41685. */
  41686. get buttonRightStick(): number;
  41687. /**
  41688. * Sets the value of the Right joystick
  41689. */
  41690. set buttonRightStick(value: number);
  41691. /**
  41692. * Gets the value of D-pad up
  41693. */
  41694. get dPadUp(): number;
  41695. /**
  41696. * Sets the value of D-pad up
  41697. */
  41698. set dPadUp(value: number);
  41699. /**
  41700. * Gets the value of D-pad down
  41701. */
  41702. get dPadDown(): number;
  41703. /**
  41704. * Sets the value of D-pad down
  41705. */
  41706. set dPadDown(value: number);
  41707. /**
  41708. * Gets the value of D-pad left
  41709. */
  41710. get dPadLeft(): number;
  41711. /**
  41712. * Sets the value of D-pad left
  41713. */
  41714. set dPadLeft(value: number);
  41715. /**
  41716. * Gets the value of D-pad right
  41717. */
  41718. get dPadRight(): number;
  41719. /**
  41720. * Sets the value of D-pad right
  41721. */
  41722. set dPadRight(value: number);
  41723. /**
  41724. * Force the gamepad to synchronize with device values
  41725. */
  41726. update(): void;
  41727. /**
  41728. * Disposes the gamepad
  41729. */
  41730. dispose(): void;
  41731. }
  41732. }
  41733. declare module BABYLON {
  41734. /**
  41735. * Defines supported buttons for DualShock compatible gamepads
  41736. */
  41737. export enum DualShockButton {
  41738. /** Cross */
  41739. Cross = 0,
  41740. /** Circle */
  41741. Circle = 1,
  41742. /** Square */
  41743. Square = 2,
  41744. /** Triangle */
  41745. Triangle = 3,
  41746. /** L1 */
  41747. L1 = 4,
  41748. /** R1 */
  41749. R1 = 5,
  41750. /** Share */
  41751. Share = 8,
  41752. /** Options */
  41753. Options = 9,
  41754. /** Left stick */
  41755. LeftStick = 10,
  41756. /** Right stick */
  41757. RightStick = 11
  41758. }
  41759. /** Defines values for DualShock DPad */
  41760. export enum DualShockDpad {
  41761. /** Up */
  41762. Up = 12,
  41763. /** Down */
  41764. Down = 13,
  41765. /** Left */
  41766. Left = 14,
  41767. /** Right */
  41768. Right = 15
  41769. }
  41770. /**
  41771. * Defines a DualShock gamepad
  41772. */
  41773. export class DualShockPad extends Gamepad {
  41774. private _leftTrigger;
  41775. private _rightTrigger;
  41776. private _onlefttriggerchanged;
  41777. private _onrighttriggerchanged;
  41778. private _onbuttondown;
  41779. private _onbuttonup;
  41780. private _ondpaddown;
  41781. private _ondpadup;
  41782. /** Observable raised when a button is pressed */
  41783. onButtonDownObservable: Observable<DualShockButton>;
  41784. /** Observable raised when a button is released */
  41785. onButtonUpObservable: Observable<DualShockButton>;
  41786. /** Observable raised when a pad is pressed */
  41787. onPadDownObservable: Observable<DualShockDpad>;
  41788. /** Observable raised when a pad is released */
  41789. onPadUpObservable: Observable<DualShockDpad>;
  41790. private _buttonCross;
  41791. private _buttonCircle;
  41792. private _buttonSquare;
  41793. private _buttonTriangle;
  41794. private _buttonShare;
  41795. private _buttonOptions;
  41796. private _buttonL1;
  41797. private _buttonR1;
  41798. private _buttonLeftStick;
  41799. private _buttonRightStick;
  41800. private _dPadUp;
  41801. private _dPadDown;
  41802. private _dPadLeft;
  41803. private _dPadRight;
  41804. /**
  41805. * Creates a new DualShock gamepad object
  41806. * @param id defines the id of this gamepad
  41807. * @param index defines its index
  41808. * @param gamepad defines the internal HTML gamepad object
  41809. */
  41810. constructor(id: string, index: number, gamepad: any);
  41811. /**
  41812. * Defines the callback to call when left trigger is pressed
  41813. * @param callback defines the callback to use
  41814. */
  41815. onlefttriggerchanged(callback: (value: number) => void): void;
  41816. /**
  41817. * Defines the callback to call when right trigger is pressed
  41818. * @param callback defines the callback to use
  41819. */
  41820. onrighttriggerchanged(callback: (value: number) => void): void;
  41821. /**
  41822. * Gets the left trigger value
  41823. */
  41824. get leftTrigger(): number;
  41825. /**
  41826. * Sets the left trigger value
  41827. */
  41828. set leftTrigger(newValue: number);
  41829. /**
  41830. * Gets the right trigger value
  41831. */
  41832. get rightTrigger(): number;
  41833. /**
  41834. * Sets the right trigger value
  41835. */
  41836. set rightTrigger(newValue: number);
  41837. /**
  41838. * Defines the callback to call when a button is pressed
  41839. * @param callback defines the callback to use
  41840. */
  41841. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41842. /**
  41843. * Defines the callback to call when a button is released
  41844. * @param callback defines the callback to use
  41845. */
  41846. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41847. /**
  41848. * Defines the callback to call when a pad is pressed
  41849. * @param callback defines the callback to use
  41850. */
  41851. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41852. /**
  41853. * Defines the callback to call when a pad is released
  41854. * @param callback defines the callback to use
  41855. */
  41856. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41857. private _setButtonValue;
  41858. private _setDPadValue;
  41859. /**
  41860. * Gets the value of the `Cross` button
  41861. */
  41862. get buttonCross(): number;
  41863. /**
  41864. * Sets the value of the `Cross` button
  41865. */
  41866. set buttonCross(value: number);
  41867. /**
  41868. * Gets the value of the `Circle` button
  41869. */
  41870. get buttonCircle(): number;
  41871. /**
  41872. * Sets the value of the `Circle` button
  41873. */
  41874. set buttonCircle(value: number);
  41875. /**
  41876. * Gets the value of the `Square` button
  41877. */
  41878. get buttonSquare(): number;
  41879. /**
  41880. * Sets the value of the `Square` button
  41881. */
  41882. set buttonSquare(value: number);
  41883. /**
  41884. * Gets the value of the `Triangle` button
  41885. */
  41886. get buttonTriangle(): number;
  41887. /**
  41888. * Sets the value of the `Triangle` button
  41889. */
  41890. set buttonTriangle(value: number);
  41891. /**
  41892. * Gets the value of the `Options` button
  41893. */
  41894. get buttonOptions(): number;
  41895. /**
  41896. * Sets the value of the `Options` button
  41897. */
  41898. set buttonOptions(value: number);
  41899. /**
  41900. * Gets the value of the `Share` button
  41901. */
  41902. get buttonShare(): number;
  41903. /**
  41904. * Sets the value of the `Share` button
  41905. */
  41906. set buttonShare(value: number);
  41907. /**
  41908. * Gets the value of the `L1` button
  41909. */
  41910. get buttonL1(): number;
  41911. /**
  41912. * Sets the value of the `L1` button
  41913. */
  41914. set buttonL1(value: number);
  41915. /**
  41916. * Gets the value of the `R1` button
  41917. */
  41918. get buttonR1(): number;
  41919. /**
  41920. * Sets the value of the `R1` button
  41921. */
  41922. set buttonR1(value: number);
  41923. /**
  41924. * Gets the value of the Left joystick
  41925. */
  41926. get buttonLeftStick(): number;
  41927. /**
  41928. * Sets the value of the Left joystick
  41929. */
  41930. set buttonLeftStick(value: number);
  41931. /**
  41932. * Gets the value of the Right joystick
  41933. */
  41934. get buttonRightStick(): number;
  41935. /**
  41936. * Sets the value of the Right joystick
  41937. */
  41938. set buttonRightStick(value: number);
  41939. /**
  41940. * Gets the value of D-pad up
  41941. */
  41942. get dPadUp(): number;
  41943. /**
  41944. * Sets the value of D-pad up
  41945. */
  41946. set dPadUp(value: number);
  41947. /**
  41948. * Gets the value of D-pad down
  41949. */
  41950. get dPadDown(): number;
  41951. /**
  41952. * Sets the value of D-pad down
  41953. */
  41954. set dPadDown(value: number);
  41955. /**
  41956. * Gets the value of D-pad left
  41957. */
  41958. get dPadLeft(): number;
  41959. /**
  41960. * Sets the value of D-pad left
  41961. */
  41962. set dPadLeft(value: number);
  41963. /**
  41964. * Gets the value of D-pad right
  41965. */
  41966. get dPadRight(): number;
  41967. /**
  41968. * Sets the value of D-pad right
  41969. */
  41970. set dPadRight(value: number);
  41971. /**
  41972. * Force the gamepad to synchronize with device values
  41973. */
  41974. update(): void;
  41975. /**
  41976. * Disposes the gamepad
  41977. */
  41978. dispose(): void;
  41979. }
  41980. }
  41981. declare module BABYLON {
  41982. /**
  41983. * Manager for handling gamepads
  41984. */
  41985. export class GamepadManager {
  41986. private _scene?;
  41987. private _babylonGamepads;
  41988. private _oneGamepadConnected;
  41989. /** @hidden */
  41990. _isMonitoring: boolean;
  41991. private _gamepadEventSupported;
  41992. private _gamepadSupport?;
  41993. /**
  41994. * observable to be triggered when the gamepad controller has been connected
  41995. */
  41996. onGamepadConnectedObservable: Observable<Gamepad>;
  41997. /**
  41998. * observable to be triggered when the gamepad controller has been disconnected
  41999. */
  42000. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42001. private _onGamepadConnectedEvent;
  42002. private _onGamepadDisconnectedEvent;
  42003. /**
  42004. * Initializes the gamepad manager
  42005. * @param _scene BabylonJS scene
  42006. */
  42007. constructor(_scene?: Scene | undefined);
  42008. /**
  42009. * The gamepads in the game pad manager
  42010. */
  42011. get gamepads(): Gamepad[];
  42012. /**
  42013. * Get the gamepad controllers based on type
  42014. * @param type The type of gamepad controller
  42015. * @returns Nullable gamepad
  42016. */
  42017. getGamepadByType(type?: number): Nullable<Gamepad>;
  42018. /**
  42019. * Disposes the gamepad manager
  42020. */
  42021. dispose(): void;
  42022. private _addNewGamepad;
  42023. private _startMonitoringGamepads;
  42024. private _stopMonitoringGamepads;
  42025. /** @hidden */
  42026. _checkGamepadsStatus(): void;
  42027. private _updateGamepadObjects;
  42028. }
  42029. }
  42030. declare module BABYLON {
  42031. interface Scene {
  42032. /** @hidden */
  42033. _gamepadManager: Nullable<GamepadManager>;
  42034. /**
  42035. * Gets the gamepad manager associated with the scene
  42036. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42037. */
  42038. gamepadManager: GamepadManager;
  42039. }
  42040. /**
  42041. * Interface representing a free camera inputs manager
  42042. */
  42043. interface FreeCameraInputsManager {
  42044. /**
  42045. * Adds gamepad input support to the FreeCameraInputsManager.
  42046. * @returns the FreeCameraInputsManager
  42047. */
  42048. addGamepad(): FreeCameraInputsManager;
  42049. }
  42050. /**
  42051. * Interface representing an arc rotate camera inputs manager
  42052. */
  42053. interface ArcRotateCameraInputsManager {
  42054. /**
  42055. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42056. * @returns the camera inputs manager
  42057. */
  42058. addGamepad(): ArcRotateCameraInputsManager;
  42059. }
  42060. /**
  42061. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42062. */
  42063. export class GamepadSystemSceneComponent implements ISceneComponent {
  42064. /**
  42065. * The component name helpfull to identify the component in the list of scene components.
  42066. */
  42067. readonly name: string;
  42068. /**
  42069. * The scene the component belongs to.
  42070. */
  42071. scene: Scene;
  42072. /**
  42073. * Creates a new instance of the component for the given scene
  42074. * @param scene Defines the scene to register the component in
  42075. */
  42076. constructor(scene: Scene);
  42077. /**
  42078. * Registers the component in a given scene
  42079. */
  42080. register(): void;
  42081. /**
  42082. * Rebuilds the elements related to this component in case of
  42083. * context lost for instance.
  42084. */
  42085. rebuild(): void;
  42086. /**
  42087. * Disposes the component and the associated ressources
  42088. */
  42089. dispose(): void;
  42090. private _beforeCameraUpdate;
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * 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,
  42096. * which still works and will still be found in many Playgrounds.
  42097. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42098. */
  42099. export class UniversalCamera extends TouchCamera {
  42100. /**
  42101. * Defines the gamepad rotation sensiblity.
  42102. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42103. */
  42104. get gamepadAngularSensibility(): number;
  42105. set gamepadAngularSensibility(value: number);
  42106. /**
  42107. * Defines the gamepad move sensiblity.
  42108. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42109. */
  42110. get gamepadMoveSensibility(): number;
  42111. set gamepadMoveSensibility(value: number);
  42112. /**
  42113. * 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,
  42114. * which still works and will still be found in many Playgrounds.
  42115. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42116. * @param name Define the name of the camera in the scene
  42117. * @param position Define the start position of the camera in the scene
  42118. * @param scene Define the scene the camera belongs to
  42119. */
  42120. constructor(name: string, position: Vector3, scene: Scene);
  42121. /**
  42122. * Gets the current object class name.
  42123. * @return the class name
  42124. */
  42125. getClassName(): string;
  42126. }
  42127. }
  42128. declare module BABYLON {
  42129. /**
  42130. * This represents a FPS type of camera. This is only here for back compat purpose.
  42131. * Please use the UniversalCamera instead as both are identical.
  42132. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42133. */
  42134. export class GamepadCamera extends UniversalCamera {
  42135. /**
  42136. * Instantiates a new Gamepad Camera
  42137. * This represents a FPS type of camera. This is only here for back compat purpose.
  42138. * Please use the UniversalCamera instead as both are identical.
  42139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42140. * @param name Define the name of the camera in the scene
  42141. * @param position Define the start position of the camera in the scene
  42142. * @param scene Define the scene the camera belongs to
  42143. */
  42144. constructor(name: string, position: Vector3, scene: Scene);
  42145. /**
  42146. * Gets the current object class name.
  42147. * @return the class name
  42148. */
  42149. getClassName(): string;
  42150. }
  42151. }
  42152. declare module BABYLON {
  42153. /** @hidden */
  42154. export var passPixelShader: {
  42155. name: string;
  42156. shader: string;
  42157. };
  42158. }
  42159. declare module BABYLON {
  42160. /** @hidden */
  42161. export var passCubePixelShader: {
  42162. name: string;
  42163. shader: string;
  42164. };
  42165. }
  42166. declare module BABYLON {
  42167. /**
  42168. * PassPostProcess which produces an output the same as it's input
  42169. */
  42170. export class PassPostProcess extends PostProcess {
  42171. /**
  42172. * Creates the PassPostProcess
  42173. * @param name The name of the effect.
  42174. * @param options The required width/height ratio to downsize to before computing the render pass.
  42175. * @param camera The camera to apply the render pass to.
  42176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42177. * @param engine The engine which the post process will be applied. (default: current engine)
  42178. * @param reusable If the post process can be reused on the same frame. (default: false)
  42179. * @param textureType The type of texture to be used when performing the post processing.
  42180. * @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)
  42181. */
  42182. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42183. }
  42184. /**
  42185. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42186. */
  42187. export class PassCubePostProcess extends PostProcess {
  42188. private _face;
  42189. /**
  42190. * Gets or sets the cube face to display.
  42191. * * 0 is +X
  42192. * * 1 is -X
  42193. * * 2 is +Y
  42194. * * 3 is -Y
  42195. * * 4 is +Z
  42196. * * 5 is -Z
  42197. */
  42198. get face(): number;
  42199. set face(value: number);
  42200. /**
  42201. * Creates the PassCubePostProcess
  42202. * @param name The name of the effect.
  42203. * @param options The required width/height ratio to downsize to before computing the render pass.
  42204. * @param camera The camera to apply the render pass to.
  42205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42206. * @param engine The engine which the post process will be applied. (default: current engine)
  42207. * @param reusable If the post process can be reused on the same frame. (default: false)
  42208. * @param textureType The type of texture to be used when performing the post processing.
  42209. * @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)
  42210. */
  42211. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42212. }
  42213. }
  42214. declare module BABYLON {
  42215. /** @hidden */
  42216. export var anaglyphPixelShader: {
  42217. name: string;
  42218. shader: string;
  42219. };
  42220. }
  42221. declare module BABYLON {
  42222. /**
  42223. * Postprocess used to generate anaglyphic rendering
  42224. */
  42225. export class AnaglyphPostProcess extends PostProcess {
  42226. private _passedProcess;
  42227. /**
  42228. * Creates a new AnaglyphPostProcess
  42229. * @param name defines postprocess name
  42230. * @param options defines creation options or target ratio scale
  42231. * @param rigCameras defines cameras using this postprocess
  42232. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42233. * @param engine defines hosting engine
  42234. * @param reusable defines if the postprocess will be reused multiple times per frame
  42235. */
  42236. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42237. }
  42238. }
  42239. declare module BABYLON {
  42240. /**
  42241. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42242. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42243. */
  42244. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42245. /**
  42246. * Creates a new AnaglyphArcRotateCamera
  42247. * @param name defines camera name
  42248. * @param alpha defines alpha angle (in radians)
  42249. * @param beta defines beta angle (in radians)
  42250. * @param radius defines radius
  42251. * @param target defines camera target
  42252. * @param interaxialDistance defines distance between each color axis
  42253. * @param scene defines the hosting scene
  42254. */
  42255. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42256. /**
  42257. * Gets camera class name
  42258. * @returns AnaglyphArcRotateCamera
  42259. */
  42260. getClassName(): string;
  42261. }
  42262. }
  42263. declare module BABYLON {
  42264. /**
  42265. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42266. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42267. */
  42268. export class AnaglyphFreeCamera extends FreeCamera {
  42269. /**
  42270. * Creates a new AnaglyphFreeCamera
  42271. * @param name defines camera name
  42272. * @param position defines initial position
  42273. * @param interaxialDistance defines distance between each color axis
  42274. * @param scene defines the hosting scene
  42275. */
  42276. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42277. /**
  42278. * Gets camera class name
  42279. * @returns AnaglyphFreeCamera
  42280. */
  42281. getClassName(): string;
  42282. }
  42283. }
  42284. declare module BABYLON {
  42285. /**
  42286. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42287. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42288. */
  42289. export class AnaglyphGamepadCamera extends GamepadCamera {
  42290. /**
  42291. * Creates a new AnaglyphGamepadCamera
  42292. * @param name defines camera name
  42293. * @param position defines initial position
  42294. * @param interaxialDistance defines distance between each color axis
  42295. * @param scene defines the hosting scene
  42296. */
  42297. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42298. /**
  42299. * Gets camera class name
  42300. * @returns AnaglyphGamepadCamera
  42301. */
  42302. getClassName(): string;
  42303. }
  42304. }
  42305. declare module BABYLON {
  42306. /**
  42307. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42308. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42309. */
  42310. export class AnaglyphUniversalCamera extends UniversalCamera {
  42311. /**
  42312. * Creates a new AnaglyphUniversalCamera
  42313. * @param name defines camera name
  42314. * @param position defines initial position
  42315. * @param interaxialDistance defines distance between each color axis
  42316. * @param scene defines the hosting scene
  42317. */
  42318. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42319. /**
  42320. * Gets camera class name
  42321. * @returns AnaglyphUniversalCamera
  42322. */
  42323. getClassName(): string;
  42324. }
  42325. }
  42326. declare module BABYLON {
  42327. /**
  42328. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42329. * @see http://doc.babylonjs.com/features/cameras
  42330. */
  42331. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42332. /**
  42333. * Creates a new StereoscopicArcRotateCamera
  42334. * @param name defines camera name
  42335. * @param alpha defines alpha angle (in radians)
  42336. * @param beta defines beta angle (in radians)
  42337. * @param radius defines radius
  42338. * @param target defines camera target
  42339. * @param interaxialDistance defines distance between each color axis
  42340. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42341. * @param scene defines the hosting scene
  42342. */
  42343. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42344. /**
  42345. * Gets camera class name
  42346. * @returns StereoscopicArcRotateCamera
  42347. */
  42348. getClassName(): string;
  42349. }
  42350. }
  42351. declare module BABYLON {
  42352. /**
  42353. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42354. * @see http://doc.babylonjs.com/features/cameras
  42355. */
  42356. export class StereoscopicFreeCamera extends FreeCamera {
  42357. /**
  42358. * Creates a new StereoscopicFreeCamera
  42359. * @param name defines camera name
  42360. * @param position defines initial position
  42361. * @param interaxialDistance defines distance between each color axis
  42362. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42363. * @param scene defines the hosting scene
  42364. */
  42365. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42366. /**
  42367. * Gets camera class name
  42368. * @returns StereoscopicFreeCamera
  42369. */
  42370. getClassName(): string;
  42371. }
  42372. }
  42373. declare module BABYLON {
  42374. /**
  42375. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42376. * @see http://doc.babylonjs.com/features/cameras
  42377. */
  42378. export class StereoscopicGamepadCamera extends GamepadCamera {
  42379. /**
  42380. * Creates a new StereoscopicGamepadCamera
  42381. * @param name defines camera name
  42382. * @param position defines initial position
  42383. * @param interaxialDistance defines distance between each color axis
  42384. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42385. * @param scene defines the hosting scene
  42386. */
  42387. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42388. /**
  42389. * Gets camera class name
  42390. * @returns StereoscopicGamepadCamera
  42391. */
  42392. getClassName(): string;
  42393. }
  42394. }
  42395. declare module BABYLON {
  42396. /**
  42397. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42398. * @see http://doc.babylonjs.com/features/cameras
  42399. */
  42400. export class StereoscopicUniversalCamera extends UniversalCamera {
  42401. /**
  42402. * Creates a new StereoscopicUniversalCamera
  42403. * @param name defines camera name
  42404. * @param position defines initial position
  42405. * @param interaxialDistance defines distance between each color axis
  42406. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42407. * @param scene defines the hosting scene
  42408. */
  42409. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42410. /**
  42411. * Gets camera class name
  42412. * @returns StereoscopicUniversalCamera
  42413. */
  42414. getClassName(): string;
  42415. }
  42416. }
  42417. declare module BABYLON {
  42418. /**
  42419. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42420. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42421. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42422. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42423. */
  42424. export class VirtualJoysticksCamera extends FreeCamera {
  42425. /**
  42426. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42427. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42428. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42429. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42430. * @param name Define the name of the camera in the scene
  42431. * @param position Define the start position of the camera in the scene
  42432. * @param scene Define the scene the camera belongs to
  42433. */
  42434. constructor(name: string, position: Vector3, scene: Scene);
  42435. /**
  42436. * Gets the current object class name.
  42437. * @return the class name
  42438. */
  42439. getClassName(): string;
  42440. }
  42441. }
  42442. declare module BABYLON {
  42443. /**
  42444. * This represents all the required metrics to create a VR camera.
  42445. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42446. */
  42447. export class VRCameraMetrics {
  42448. /**
  42449. * Define the horizontal resolution off the screen.
  42450. */
  42451. hResolution: number;
  42452. /**
  42453. * Define the vertical resolution off the screen.
  42454. */
  42455. vResolution: number;
  42456. /**
  42457. * Define the horizontal screen size.
  42458. */
  42459. hScreenSize: number;
  42460. /**
  42461. * Define the vertical screen size.
  42462. */
  42463. vScreenSize: number;
  42464. /**
  42465. * Define the vertical screen center position.
  42466. */
  42467. vScreenCenter: number;
  42468. /**
  42469. * Define the distance of the eyes to the screen.
  42470. */
  42471. eyeToScreenDistance: number;
  42472. /**
  42473. * Define the distance between both lenses
  42474. */
  42475. lensSeparationDistance: number;
  42476. /**
  42477. * Define the distance between both viewer's eyes.
  42478. */
  42479. interpupillaryDistance: number;
  42480. /**
  42481. * Define the distortion factor of the VR postprocess.
  42482. * Please, touch with care.
  42483. */
  42484. distortionK: number[];
  42485. /**
  42486. * Define the chromatic aberration correction factors for the VR post process.
  42487. */
  42488. chromaAbCorrection: number[];
  42489. /**
  42490. * Define the scale factor of the post process.
  42491. * The smaller the better but the slower.
  42492. */
  42493. postProcessScaleFactor: number;
  42494. /**
  42495. * Define an offset for the lens center.
  42496. */
  42497. lensCenterOffset: number;
  42498. /**
  42499. * Define if the current vr camera should compensate the distortion of the lense or not.
  42500. */
  42501. compensateDistortion: boolean;
  42502. /**
  42503. * Defines if multiview should be enabled when rendering (Default: false)
  42504. */
  42505. multiviewEnabled: boolean;
  42506. /**
  42507. * Gets the rendering aspect ratio based on the provided resolutions.
  42508. */
  42509. get aspectRatio(): number;
  42510. /**
  42511. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42512. */
  42513. get aspectRatioFov(): number;
  42514. /**
  42515. * @hidden
  42516. */
  42517. get leftHMatrix(): Matrix;
  42518. /**
  42519. * @hidden
  42520. */
  42521. get rightHMatrix(): Matrix;
  42522. /**
  42523. * @hidden
  42524. */
  42525. get leftPreViewMatrix(): Matrix;
  42526. /**
  42527. * @hidden
  42528. */
  42529. get rightPreViewMatrix(): Matrix;
  42530. /**
  42531. * Get the default VRMetrics based on the most generic setup.
  42532. * @returns the default vr metrics
  42533. */
  42534. static GetDefault(): VRCameraMetrics;
  42535. }
  42536. }
  42537. declare module BABYLON {
  42538. /** @hidden */
  42539. export var vrDistortionCorrectionPixelShader: {
  42540. name: string;
  42541. shader: string;
  42542. };
  42543. }
  42544. declare module BABYLON {
  42545. /**
  42546. * VRDistortionCorrectionPostProcess used for mobile VR
  42547. */
  42548. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42549. private _isRightEye;
  42550. private _distortionFactors;
  42551. private _postProcessScaleFactor;
  42552. private _lensCenterOffset;
  42553. private _scaleIn;
  42554. private _scaleFactor;
  42555. private _lensCenter;
  42556. /**
  42557. * Initializes the VRDistortionCorrectionPostProcess
  42558. * @param name The name of the effect.
  42559. * @param camera The camera to apply the render pass to.
  42560. * @param isRightEye If this is for the right eye distortion
  42561. * @param vrMetrics All the required metrics for the VR camera
  42562. */
  42563. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42564. }
  42565. }
  42566. declare module BABYLON {
  42567. /**
  42568. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42569. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42570. */
  42571. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42572. /**
  42573. * Creates a new VRDeviceOrientationArcRotateCamera
  42574. * @param name defines camera name
  42575. * @param alpha defines the camera rotation along the logitudinal axis
  42576. * @param beta defines the camera rotation along the latitudinal axis
  42577. * @param radius defines the camera distance from its target
  42578. * @param target defines the camera target
  42579. * @param scene defines the scene the camera belongs to
  42580. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42581. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42582. */
  42583. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42584. /**
  42585. * Gets camera class name
  42586. * @returns VRDeviceOrientationArcRotateCamera
  42587. */
  42588. getClassName(): string;
  42589. }
  42590. }
  42591. declare module BABYLON {
  42592. /**
  42593. * Camera used to simulate VR rendering (based on FreeCamera)
  42594. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42595. */
  42596. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42597. /**
  42598. * Creates a new VRDeviceOrientationFreeCamera
  42599. * @param name defines camera name
  42600. * @param position defines the start position of the camera
  42601. * @param scene defines the scene the camera belongs to
  42602. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42603. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42604. */
  42605. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42606. /**
  42607. * Gets camera class name
  42608. * @returns VRDeviceOrientationFreeCamera
  42609. */
  42610. getClassName(): string;
  42611. }
  42612. }
  42613. declare module BABYLON {
  42614. /**
  42615. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42616. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42617. */
  42618. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42619. /**
  42620. * Creates a new VRDeviceOrientationGamepadCamera
  42621. * @param name defines camera name
  42622. * @param position defines the start position of the camera
  42623. * @param scene defines the scene the camera belongs to
  42624. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42625. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42626. */
  42627. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42628. /**
  42629. * Gets camera class name
  42630. * @returns VRDeviceOrientationGamepadCamera
  42631. */
  42632. getClassName(): string;
  42633. }
  42634. }
  42635. declare module BABYLON {
  42636. /** @hidden */
  42637. export var imageProcessingPixelShader: {
  42638. name: string;
  42639. shader: string;
  42640. };
  42641. }
  42642. declare module BABYLON {
  42643. /**
  42644. * ImageProcessingPostProcess
  42645. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42646. */
  42647. export class ImageProcessingPostProcess extends PostProcess {
  42648. /**
  42649. * Default configuration related to image processing available in the PBR Material.
  42650. */
  42651. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42652. /**
  42653. * Gets the image processing configuration used either in this material.
  42654. */
  42655. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42656. /**
  42657. * Sets the Default image processing configuration used either in the this material.
  42658. *
  42659. * If sets to null, the scene one is in use.
  42660. */
  42661. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42662. /**
  42663. * Keep track of the image processing observer to allow dispose and replace.
  42664. */
  42665. private _imageProcessingObserver;
  42666. /**
  42667. * Attaches a new image processing configuration to the PBR Material.
  42668. * @param configuration
  42669. */
  42670. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42671. /**
  42672. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42673. */
  42674. get colorCurves(): Nullable<ColorCurves>;
  42675. /**
  42676. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42677. */
  42678. set colorCurves(value: Nullable<ColorCurves>);
  42679. /**
  42680. * Gets wether the color curves effect is enabled.
  42681. */
  42682. get colorCurvesEnabled(): boolean;
  42683. /**
  42684. * Sets wether the color curves effect is enabled.
  42685. */
  42686. set colorCurvesEnabled(value: boolean);
  42687. /**
  42688. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42689. */
  42690. get colorGradingTexture(): Nullable<BaseTexture>;
  42691. /**
  42692. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42693. */
  42694. set colorGradingTexture(value: Nullable<BaseTexture>);
  42695. /**
  42696. * Gets wether the color grading effect is enabled.
  42697. */
  42698. get colorGradingEnabled(): boolean;
  42699. /**
  42700. * Gets wether the color grading effect is enabled.
  42701. */
  42702. set colorGradingEnabled(value: boolean);
  42703. /**
  42704. * Gets exposure used in the effect.
  42705. */
  42706. get exposure(): number;
  42707. /**
  42708. * Sets exposure used in the effect.
  42709. */
  42710. set exposure(value: number);
  42711. /**
  42712. * Gets wether tonemapping is enabled or not.
  42713. */
  42714. get toneMappingEnabled(): boolean;
  42715. /**
  42716. * Sets wether tonemapping is enabled or not
  42717. */
  42718. set toneMappingEnabled(value: boolean);
  42719. /**
  42720. * Gets the type of tone mapping effect.
  42721. */
  42722. get toneMappingType(): number;
  42723. /**
  42724. * Sets the type of tone mapping effect.
  42725. */
  42726. set toneMappingType(value: number);
  42727. /**
  42728. * Gets contrast used in the effect.
  42729. */
  42730. get contrast(): number;
  42731. /**
  42732. * Sets contrast used in the effect.
  42733. */
  42734. set contrast(value: number);
  42735. /**
  42736. * Gets Vignette stretch size.
  42737. */
  42738. get vignetteStretch(): number;
  42739. /**
  42740. * Sets Vignette stretch size.
  42741. */
  42742. set vignetteStretch(value: number);
  42743. /**
  42744. * Gets Vignette centre X Offset.
  42745. */
  42746. get vignetteCentreX(): number;
  42747. /**
  42748. * Sets Vignette centre X Offset.
  42749. */
  42750. set vignetteCentreX(value: number);
  42751. /**
  42752. * Gets Vignette centre Y Offset.
  42753. */
  42754. get vignetteCentreY(): number;
  42755. /**
  42756. * Sets Vignette centre Y Offset.
  42757. */
  42758. set vignetteCentreY(value: number);
  42759. /**
  42760. * Gets Vignette weight or intensity of the vignette effect.
  42761. */
  42762. get vignetteWeight(): number;
  42763. /**
  42764. * Sets Vignette weight or intensity of the vignette effect.
  42765. */
  42766. set vignetteWeight(value: number);
  42767. /**
  42768. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42769. * if vignetteEnabled is set to true.
  42770. */
  42771. get vignetteColor(): Color4;
  42772. /**
  42773. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42774. * if vignetteEnabled is set to true.
  42775. */
  42776. set vignetteColor(value: Color4);
  42777. /**
  42778. * Gets Camera field of view used by the Vignette effect.
  42779. */
  42780. get vignetteCameraFov(): number;
  42781. /**
  42782. * Sets Camera field of view used by the Vignette effect.
  42783. */
  42784. set vignetteCameraFov(value: number);
  42785. /**
  42786. * Gets the vignette blend mode allowing different kind of effect.
  42787. */
  42788. get vignetteBlendMode(): number;
  42789. /**
  42790. * Sets the vignette blend mode allowing different kind of effect.
  42791. */
  42792. set vignetteBlendMode(value: number);
  42793. /**
  42794. * Gets wether the vignette effect is enabled.
  42795. */
  42796. get vignetteEnabled(): boolean;
  42797. /**
  42798. * Sets wether the vignette effect is enabled.
  42799. */
  42800. set vignetteEnabled(value: boolean);
  42801. private _fromLinearSpace;
  42802. /**
  42803. * Gets wether the input of the processing is in Gamma or Linear Space.
  42804. */
  42805. get fromLinearSpace(): boolean;
  42806. /**
  42807. * Sets wether the input of the processing is in Gamma or Linear Space.
  42808. */
  42809. set fromLinearSpace(value: boolean);
  42810. /**
  42811. * Defines cache preventing GC.
  42812. */
  42813. private _defines;
  42814. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42815. /**
  42816. * "ImageProcessingPostProcess"
  42817. * @returns "ImageProcessingPostProcess"
  42818. */
  42819. getClassName(): string;
  42820. protected _updateParameters(): void;
  42821. dispose(camera?: Camera): void;
  42822. }
  42823. }
  42824. declare module BABYLON {
  42825. /**
  42826. * Class containing static functions to help procedurally build meshes
  42827. */
  42828. export class GroundBuilder {
  42829. /**
  42830. * Creates a ground mesh
  42831. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42832. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42834. * @param name defines the name of the mesh
  42835. * @param options defines the options used to create the mesh
  42836. * @param scene defines the hosting scene
  42837. * @returns the ground mesh
  42838. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42839. */
  42840. static CreateGround(name: string, options: {
  42841. width?: number;
  42842. height?: number;
  42843. subdivisions?: number;
  42844. subdivisionsX?: number;
  42845. subdivisionsY?: number;
  42846. updatable?: boolean;
  42847. }, scene: any): Mesh;
  42848. /**
  42849. * Creates a tiled ground mesh
  42850. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42851. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42852. * * 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
  42853. * * 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
  42854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42855. * @param name defines the name of the mesh
  42856. * @param options defines the options used to create the mesh
  42857. * @param scene defines the hosting scene
  42858. * @returns the tiled ground mesh
  42859. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42860. */
  42861. static CreateTiledGround(name: string, options: {
  42862. xmin: number;
  42863. zmin: number;
  42864. xmax: number;
  42865. zmax: number;
  42866. subdivisions?: {
  42867. w: number;
  42868. h: number;
  42869. };
  42870. precision?: {
  42871. w: number;
  42872. h: number;
  42873. };
  42874. updatable?: boolean;
  42875. }, scene?: Nullable<Scene>): Mesh;
  42876. /**
  42877. * Creates a ground mesh from a height map
  42878. * * The parameter `url` sets the URL of the height map image resource.
  42879. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42880. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42881. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42882. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42883. * * 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.
  42884. * * 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).
  42885. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42887. * @param name defines the name of the mesh
  42888. * @param url defines the url to the height map
  42889. * @param options defines the options used to create the mesh
  42890. * @param scene defines the hosting scene
  42891. * @returns the ground mesh
  42892. * @see https://doc.babylonjs.com/babylon101/height_map
  42893. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42894. */
  42895. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42896. width?: number;
  42897. height?: number;
  42898. subdivisions?: number;
  42899. minHeight?: number;
  42900. maxHeight?: number;
  42901. colorFilter?: Color3;
  42902. alphaFilter?: number;
  42903. updatable?: boolean;
  42904. onReady?: (mesh: GroundMesh) => void;
  42905. }, scene?: Nullable<Scene>): GroundMesh;
  42906. }
  42907. }
  42908. declare module BABYLON {
  42909. /**
  42910. * Class containing static functions to help procedurally build meshes
  42911. */
  42912. export class TorusBuilder {
  42913. /**
  42914. * Creates a torus mesh
  42915. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42916. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42917. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42919. * * 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
  42920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42921. * @param name defines the name of the mesh
  42922. * @param options defines the options used to create the mesh
  42923. * @param scene defines the hosting scene
  42924. * @returns the torus mesh
  42925. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42926. */
  42927. static CreateTorus(name: string, options: {
  42928. diameter?: number;
  42929. thickness?: number;
  42930. tessellation?: number;
  42931. updatable?: boolean;
  42932. sideOrientation?: number;
  42933. frontUVs?: Vector4;
  42934. backUVs?: Vector4;
  42935. }, scene: any): Mesh;
  42936. }
  42937. }
  42938. declare module BABYLON {
  42939. /**
  42940. * Class containing static functions to help procedurally build meshes
  42941. */
  42942. export class CylinderBuilder {
  42943. /**
  42944. * Creates a cylinder or a cone mesh
  42945. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42946. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42947. * * 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.
  42948. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42949. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42950. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42951. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42952. * * 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).
  42953. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42954. * * 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).
  42955. * * 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
  42956. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42957. * * 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
  42958. * * 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.
  42959. * * If `enclose` is false, a ring surface is one element.
  42960. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42961. * * 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
  42962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42963. * * 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
  42964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42965. * @param name defines the name of the mesh
  42966. * @param options defines the options used to create the mesh
  42967. * @param scene defines the hosting scene
  42968. * @returns the cylinder mesh
  42969. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42970. */
  42971. static CreateCylinder(name: string, options: {
  42972. height?: number;
  42973. diameterTop?: number;
  42974. diameterBottom?: number;
  42975. diameter?: number;
  42976. tessellation?: number;
  42977. subdivisions?: number;
  42978. arc?: number;
  42979. faceColors?: Color4[];
  42980. faceUV?: Vector4[];
  42981. updatable?: boolean;
  42982. hasRings?: boolean;
  42983. enclose?: boolean;
  42984. cap?: number;
  42985. sideOrientation?: number;
  42986. frontUVs?: Vector4;
  42987. backUVs?: Vector4;
  42988. }, scene: any): Mesh;
  42989. }
  42990. }
  42991. declare module BABYLON {
  42992. /**
  42993. * States of the webXR experience
  42994. */
  42995. export enum WebXRState {
  42996. /**
  42997. * Transitioning to being in XR mode
  42998. */
  42999. ENTERING_XR = 0,
  43000. /**
  43001. * Transitioning to non XR mode
  43002. */
  43003. EXITING_XR = 1,
  43004. /**
  43005. * In XR mode and presenting
  43006. */
  43007. IN_XR = 2,
  43008. /**
  43009. * Not entered XR mode
  43010. */
  43011. NOT_IN_XR = 3
  43012. }
  43013. /**
  43014. * Abstraction of the XR render target
  43015. */
  43016. export interface WebXRRenderTarget extends IDisposable {
  43017. /**
  43018. * xrpresent context of the canvas which can be used to display/mirror xr content
  43019. */
  43020. canvasContext: WebGLRenderingContext;
  43021. /**
  43022. * xr layer for the canvas
  43023. */
  43024. xrLayer: Nullable<XRWebGLLayer>;
  43025. /**
  43026. * Initializes the xr layer for the session
  43027. * @param xrSession xr session
  43028. * @returns a promise that will resolve once the XR Layer has been created
  43029. */
  43030. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43031. }
  43032. }
  43033. declare module BABYLON {
  43034. /**
  43035. * COnfiguration object for WebXR output canvas
  43036. */
  43037. export class WebXRManagedOutputCanvasOptions {
  43038. /**
  43039. * An optional canvas in case you wish to create it yourself and provide it here.
  43040. * If not provided, a new canvas will be created
  43041. */
  43042. canvasElement?: HTMLCanvasElement;
  43043. /**
  43044. * Options for this XR Layer output
  43045. */
  43046. canvasOptions?: XRWebGLLayerOptions;
  43047. /**
  43048. * CSS styling for a newly created canvas (if not provided)
  43049. */
  43050. newCanvasCssStyle?: string;
  43051. /**
  43052. * Get the default values of the configuration object
  43053. * @returns default values of this configuration object
  43054. */
  43055. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43056. }
  43057. /**
  43058. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43059. */
  43060. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43061. private _options;
  43062. private _canvas;
  43063. private _engine;
  43064. /**
  43065. * Rendering context of the canvas which can be used to display/mirror xr content
  43066. */
  43067. canvasContext: WebGLRenderingContext;
  43068. /**
  43069. * xr layer for the canvas
  43070. */
  43071. xrLayer: Nullable<XRWebGLLayer>;
  43072. /**
  43073. * Initializes the canvas to be added/removed upon entering/exiting xr
  43074. * @param _xrSessionManager The XR Session manager
  43075. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43076. */
  43077. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43078. /**
  43079. * Disposes of the object
  43080. */
  43081. dispose(): void;
  43082. /**
  43083. * Initializes the xr layer for the session
  43084. * @param xrSession xr session
  43085. * @returns a promise that will resolve once the XR Layer has been created
  43086. */
  43087. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43088. private _addCanvas;
  43089. private _removeCanvas;
  43090. private _setManagedOutputCanvas;
  43091. }
  43092. }
  43093. declare module BABYLON {
  43094. /**
  43095. * Manages an XRSession to work with Babylon's engine
  43096. * @see https://doc.babylonjs.com/how_to/webxr
  43097. */
  43098. export class WebXRSessionManager implements IDisposable {
  43099. /** The scene which the session should be created for */
  43100. scene: Scene;
  43101. private _referenceSpace;
  43102. private _rttProvider;
  43103. private _sessionEnded;
  43104. private _xrNavigator;
  43105. private baseLayer;
  43106. /**
  43107. * The base reference space from which the session started. good if you want to reset your
  43108. * reference space
  43109. */
  43110. baseReferenceSpace: XRReferenceSpace;
  43111. /**
  43112. * Current XR frame
  43113. */
  43114. currentFrame: Nullable<XRFrame>;
  43115. /** WebXR timestamp updated every frame */
  43116. currentTimestamp: number;
  43117. /**
  43118. * Used just in case of a failure to initialize an immersive session.
  43119. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43120. */
  43121. defaultHeightCompensation: number;
  43122. /**
  43123. * Fires every time a new xrFrame arrives which can be used to update the camera
  43124. */
  43125. onXRFrameObservable: Observable<XRFrame>;
  43126. /**
  43127. * Fires when the reference space changed
  43128. */
  43129. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43130. /**
  43131. * Fires when the xr session is ended either by the device or manually done
  43132. */
  43133. onXRSessionEnded: Observable<any>;
  43134. /**
  43135. * Fires when the xr session is ended either by the device or manually done
  43136. */
  43137. onXRSessionInit: Observable<XRSession>;
  43138. /**
  43139. * Underlying xr session
  43140. */
  43141. session: XRSession;
  43142. /**
  43143. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43144. * or get the offset the player is currently at.
  43145. */
  43146. viewerReferenceSpace: XRReferenceSpace;
  43147. /**
  43148. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43149. * @param scene The scene which the session should be created for
  43150. */
  43151. constructor(
  43152. /** The scene which the session should be created for */
  43153. scene: Scene);
  43154. /**
  43155. * The current reference space used in this session. This reference space can constantly change!
  43156. * It is mainly used to offset the camera's position.
  43157. */
  43158. get referenceSpace(): XRReferenceSpace;
  43159. /**
  43160. * Set a new reference space and triggers the observable
  43161. */
  43162. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43163. /**
  43164. * Disposes of the session manager
  43165. */
  43166. dispose(): void;
  43167. /**
  43168. * Stops the xrSession and restores the render loop
  43169. * @returns Promise which resolves after it exits XR
  43170. */
  43171. exitXRAsync(): Promise<void>;
  43172. /**
  43173. * Gets the correct render target texture to be rendered this frame for this eye
  43174. * @param eye the eye for which to get the render target
  43175. * @returns the render target for the specified eye
  43176. */
  43177. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43178. /**
  43179. * Creates a WebXRRenderTarget object for the XR session
  43180. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43181. * @param options optional options to provide when creating a new render target
  43182. * @returns a WebXR render target to which the session can render
  43183. */
  43184. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43185. /**
  43186. * Initializes the manager
  43187. * After initialization enterXR can be called to start an XR session
  43188. * @returns Promise which resolves after it is initialized
  43189. */
  43190. initializeAsync(): Promise<void>;
  43191. /**
  43192. * Initializes an xr session
  43193. * @param xrSessionMode mode to initialize
  43194. * @param xrSessionInit defines optional and required values to pass to the session builder
  43195. * @returns a promise which will resolve once the session has been initialized
  43196. */
  43197. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43198. /**
  43199. * Checks if a session would be supported for the creation options specified
  43200. * @param sessionMode session mode to check if supported eg. immersive-vr
  43201. * @returns A Promise that resolves to true if supported and false if not
  43202. */
  43203. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43204. /**
  43205. * Resets the reference space to the one started the session
  43206. */
  43207. resetReferenceSpace(): void;
  43208. /**
  43209. * Starts rendering to the xr layer
  43210. */
  43211. runXRRenderLoop(): void;
  43212. /**
  43213. * Sets the reference space on the xr session
  43214. * @param referenceSpaceType space to set
  43215. * @returns a promise that will resolve once the reference space has been set
  43216. */
  43217. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43218. /**
  43219. * Updates the render state of the session
  43220. * @param state state to set
  43221. * @returns a promise that resolves once the render state has been updated
  43222. */
  43223. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43224. /**
  43225. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43226. * @param sessionMode defines the session to test
  43227. * @returns a promise with boolean as final value
  43228. */
  43229. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43230. private _createRenderTargetTexture;
  43231. }
  43232. }
  43233. declare module BABYLON {
  43234. /**
  43235. * WebXR Camera which holds the views for the xrSession
  43236. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43237. */
  43238. export class WebXRCamera extends FreeCamera {
  43239. private _xrSessionManager;
  43240. private _firstFrame;
  43241. private _referenceQuaternion;
  43242. private _referencedPosition;
  43243. private _xrInvPositionCache;
  43244. private _xrInvQuaternionCache;
  43245. /**
  43246. * Should position compensation execute on first frame.
  43247. * This is used when copying the position from a native (non XR) camera
  43248. */
  43249. compensateOnFirstFrame: boolean;
  43250. /**
  43251. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43252. * @param name the name of the camera
  43253. * @param scene the scene to add the camera to
  43254. * @param _xrSessionManager a constructed xr session manager
  43255. */
  43256. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43257. /**
  43258. * Return the user's height, unrelated to the current ground.
  43259. * This will be the y position of this camera, when ground level is 0.
  43260. */
  43261. get realWorldHeight(): number;
  43262. /** @hidden */
  43263. _updateForDualEyeDebugging(): void;
  43264. /**
  43265. * Sets this camera's transformation based on a non-vr camera
  43266. * @param otherCamera the non-vr camera to copy the transformation from
  43267. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43268. */
  43269. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43270. /**
  43271. * Gets the current instance class name ("WebXRCamera").
  43272. * @returns the class name
  43273. */
  43274. getClassName(): string;
  43275. private _updateFromXRSession;
  43276. private _updateNumberOfRigCameras;
  43277. private _updateReferenceSpace;
  43278. private _updateReferenceSpaceOffset;
  43279. }
  43280. }
  43281. declare module BABYLON {
  43282. /**
  43283. * Defining the interface required for a (webxr) feature
  43284. */
  43285. export interface IWebXRFeature extends IDisposable {
  43286. /**
  43287. * Is this feature attached
  43288. */
  43289. attached: boolean;
  43290. /**
  43291. * Should auto-attach be disabled?
  43292. */
  43293. disableAutoAttach: boolean;
  43294. /**
  43295. * Attach the feature to the session
  43296. * Will usually be called by the features manager
  43297. *
  43298. * @param force should attachment be forced (even when already attached)
  43299. * @returns true if successful.
  43300. */
  43301. attach(force?: boolean): boolean;
  43302. /**
  43303. * Detach the feature from the session
  43304. * Will usually be called by the features manager
  43305. *
  43306. * @returns true if successful.
  43307. */
  43308. detach(): boolean;
  43309. }
  43310. /**
  43311. * A list of the currently available features without referencing them
  43312. */
  43313. export class WebXRFeatureName {
  43314. /**
  43315. * The name of the anchor system feature
  43316. */
  43317. static ANCHOR_SYSTEM: string;
  43318. /**
  43319. * The name of the background remover feature
  43320. */
  43321. static BACKGROUND_REMOVER: string;
  43322. /**
  43323. * The name of the hit test feature
  43324. */
  43325. static HIT_TEST: string;
  43326. /**
  43327. * physics impostors for xr controllers feature
  43328. */
  43329. static PHYSICS_CONTROLLERS: string;
  43330. /**
  43331. * The name of the plane detection feature
  43332. */
  43333. static PLANE_DETECTION: string;
  43334. /**
  43335. * The name of the pointer selection feature
  43336. */
  43337. static POINTER_SELECTION: string;
  43338. /**
  43339. * The name of the teleportation feature
  43340. */
  43341. static TELEPORTATION: string;
  43342. }
  43343. /**
  43344. * Defining the constructor of a feature. Used to register the modules.
  43345. */
  43346. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43347. /**
  43348. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43349. * It is mainly used in AR sessions.
  43350. *
  43351. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43352. */
  43353. export class WebXRFeaturesManager implements IDisposable {
  43354. private _xrSessionManager;
  43355. private static readonly _AvailableFeatures;
  43356. private _features;
  43357. /**
  43358. * constructs a new features manages.
  43359. *
  43360. * @param _xrSessionManager an instance of WebXRSessionManager
  43361. */
  43362. constructor(_xrSessionManager: WebXRSessionManager);
  43363. /**
  43364. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43365. * Mainly used internally.
  43366. *
  43367. * @param featureName the name of the feature to register
  43368. * @param constructorFunction the function used to construct the module
  43369. * @param version the (babylon) version of the module
  43370. * @param stable is that a stable version of this module
  43371. */
  43372. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43373. /**
  43374. * Returns a constructor of a specific feature.
  43375. *
  43376. * @param featureName the name of the feature to construct
  43377. * @param version the version of the feature to load
  43378. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43379. * @param options optional options provided to the module.
  43380. * @returns a function that, when called, will return a new instance of this feature
  43381. */
  43382. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43383. /**
  43384. * Can be used to return the list of features currently registered
  43385. *
  43386. * @returns an Array of available features
  43387. */
  43388. static GetAvailableFeatures(): string[];
  43389. /**
  43390. * Gets the versions available for a specific feature
  43391. * @param featureName the name of the feature
  43392. * @returns an array with the available versions
  43393. */
  43394. static GetAvailableVersions(featureName: string): string[];
  43395. /**
  43396. * Return the latest unstable version of this feature
  43397. * @param featureName the name of the feature to search
  43398. * @returns the version number. if not found will return -1
  43399. */
  43400. static GetLatestVersionOfFeature(featureName: string): number;
  43401. /**
  43402. * Return the latest stable version of this feature
  43403. * @param featureName the name of the feature to search
  43404. * @returns the version number. if not found will return -1
  43405. */
  43406. static GetStableVersionOfFeature(featureName: string): number;
  43407. /**
  43408. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43409. * Can be used during a session to start a feature
  43410. * @param featureName the name of feature to attach
  43411. */
  43412. attachFeature(featureName: string): void;
  43413. /**
  43414. * Can be used inside a session or when the session ends to detach a specific feature
  43415. * @param featureName the name of the feature to detach
  43416. */
  43417. detachFeature(featureName: string): void;
  43418. /**
  43419. * Used to disable an already-enabled feature
  43420. * The feature will be disposed and will be recreated once enabled.
  43421. * @param featureName the feature to disable
  43422. * @returns true if disable was successful
  43423. */
  43424. disableFeature(featureName: string | {
  43425. Name: string;
  43426. }): boolean;
  43427. /**
  43428. * dispose this features manager
  43429. */
  43430. dispose(): void;
  43431. /**
  43432. * 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.
  43433. * 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.
  43434. *
  43435. * @param featureName the name of the feature to load or the class of the feature
  43436. * @param version optional version to load. if not provided the latest version will be enabled
  43437. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43438. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43439. * @returns a new constructed feature or throws an error if feature not found.
  43440. */
  43441. enableFeature(featureName: string | {
  43442. Name: string;
  43443. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43444. /**
  43445. * get the implementation of an enabled feature.
  43446. * @param featureName the name of the feature to load
  43447. * @returns the feature class, if found
  43448. */
  43449. getEnabledFeature(featureName: string): IWebXRFeature;
  43450. /**
  43451. * Get the list of enabled features
  43452. * @returns an array of enabled features
  43453. */
  43454. getEnabledFeatures(): string[];
  43455. }
  43456. }
  43457. declare module BABYLON {
  43458. /**
  43459. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43460. * @see https://doc.babylonjs.com/how_to/webxr
  43461. */
  43462. export class WebXRExperienceHelper implements IDisposable {
  43463. private scene;
  43464. private _nonVRCamera;
  43465. private _originalSceneAutoClear;
  43466. private _supported;
  43467. /**
  43468. * Camera used to render xr content
  43469. */
  43470. camera: WebXRCamera;
  43471. /** A features manager for this xr session */
  43472. featuresManager: WebXRFeaturesManager;
  43473. /**
  43474. * Observers registered here will be triggered after the camera's initial transformation is set
  43475. * This can be used to set a different ground level or an extra rotation.
  43476. *
  43477. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43478. * to the position set after this observable is done executing.
  43479. */
  43480. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43481. /**
  43482. * Fires when the state of the experience helper has changed
  43483. */
  43484. onStateChangedObservable: Observable<WebXRState>;
  43485. /** Session manager used to keep track of xr session */
  43486. sessionManager: WebXRSessionManager;
  43487. /**
  43488. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43489. */
  43490. state: WebXRState;
  43491. /**
  43492. * Creates a WebXRExperienceHelper
  43493. * @param scene The scene the helper should be created in
  43494. */
  43495. private constructor();
  43496. /**
  43497. * Creates the experience helper
  43498. * @param scene the scene to attach the experience helper to
  43499. * @returns a promise for the experience helper
  43500. */
  43501. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43502. /**
  43503. * Disposes of the experience helper
  43504. */
  43505. dispose(): void;
  43506. /**
  43507. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43508. * @param sessionMode options for the XR session
  43509. * @param referenceSpaceType frame of reference of the XR session
  43510. * @param renderTarget the output canvas that will be used to enter XR mode
  43511. * @returns promise that resolves after xr mode has entered
  43512. */
  43513. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43514. /**
  43515. * Exits XR mode and returns the scene to its original state
  43516. * @returns promise that resolves after xr mode has exited
  43517. */
  43518. exitXRAsync(): Promise<void>;
  43519. private _nonXRToXRCamera;
  43520. private _setState;
  43521. }
  43522. }
  43523. declare module BABYLON {
  43524. /**
  43525. * X-Y values for axes in WebXR
  43526. */
  43527. export interface IWebXRMotionControllerAxesValue {
  43528. /**
  43529. * The value of the x axis
  43530. */
  43531. x: number;
  43532. /**
  43533. * The value of the y-axis
  43534. */
  43535. y: number;
  43536. }
  43537. /**
  43538. * changed / previous values for the values of this component
  43539. */
  43540. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43541. /**
  43542. * current (this frame) value
  43543. */
  43544. current: T;
  43545. /**
  43546. * previous (last change) value
  43547. */
  43548. previous: T;
  43549. }
  43550. /**
  43551. * Represents changes in the component between current frame and last values recorded
  43552. */
  43553. export interface IWebXRMotionControllerComponentChanges {
  43554. /**
  43555. * will be populated with previous and current values if axes changed
  43556. */
  43557. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43558. /**
  43559. * will be populated with previous and current values if pressed changed
  43560. */
  43561. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43562. /**
  43563. * will be populated with previous and current values if touched changed
  43564. */
  43565. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43566. /**
  43567. * will be populated with previous and current values if value changed
  43568. */
  43569. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43570. }
  43571. /**
  43572. * This class represents a single component (for example button or thumbstick) of a motion controller
  43573. */
  43574. export class WebXRControllerComponent implements IDisposable {
  43575. /**
  43576. * the id of this component
  43577. */
  43578. id: string;
  43579. /**
  43580. * the type of the component
  43581. */
  43582. type: MotionControllerComponentType;
  43583. private _buttonIndex;
  43584. private _axesIndices;
  43585. private _axes;
  43586. private _changes;
  43587. private _currentValue;
  43588. private _hasChanges;
  43589. private _pressed;
  43590. private _touched;
  43591. /**
  43592. * button component type
  43593. */
  43594. static BUTTON_TYPE: MotionControllerComponentType;
  43595. /**
  43596. * squeeze component type
  43597. */
  43598. static SQUEEZE_TYPE: MotionControllerComponentType;
  43599. /**
  43600. * Thumbstick component type
  43601. */
  43602. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43603. /**
  43604. * Touchpad component type
  43605. */
  43606. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43607. /**
  43608. * trigger component type
  43609. */
  43610. static TRIGGER_TYPE: MotionControllerComponentType;
  43611. /**
  43612. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43613. * the axes data changes
  43614. */
  43615. onAxisValueChangedObservable: Observable<{
  43616. x: number;
  43617. y: number;
  43618. }>;
  43619. /**
  43620. * Observers registered here will be triggered when the state of a button changes
  43621. * State change is either pressed / touched / value
  43622. */
  43623. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43624. /**
  43625. * Creates a new component for a motion controller.
  43626. * It is created by the motion controller itself
  43627. *
  43628. * @param id the id of this component
  43629. * @param type the type of the component
  43630. * @param _buttonIndex index in the buttons array of the gamepad
  43631. * @param _axesIndices indices of the values in the axes array of the gamepad
  43632. */
  43633. constructor(
  43634. /**
  43635. * the id of this component
  43636. */
  43637. id: string,
  43638. /**
  43639. * the type of the component
  43640. */
  43641. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43642. /**
  43643. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43644. */
  43645. get axes(): IWebXRMotionControllerAxesValue;
  43646. /**
  43647. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43648. */
  43649. get changes(): IWebXRMotionControllerComponentChanges;
  43650. /**
  43651. * Return whether or not the component changed the last frame
  43652. */
  43653. get hasChanges(): boolean;
  43654. /**
  43655. * is the button currently pressed
  43656. */
  43657. get pressed(): boolean;
  43658. /**
  43659. * is the button currently touched
  43660. */
  43661. get touched(): boolean;
  43662. /**
  43663. * Get the current value of this component
  43664. */
  43665. get value(): number;
  43666. /**
  43667. * Dispose this component
  43668. */
  43669. dispose(): void;
  43670. /**
  43671. * Are there axes correlating to this component
  43672. * @return true is axes data is available
  43673. */
  43674. isAxes(): boolean;
  43675. /**
  43676. * Is this component a button (hence - pressable)
  43677. * @returns true if can be pressed
  43678. */
  43679. isButton(): boolean;
  43680. /**
  43681. * update this component using the gamepad object it is in. Called on every frame
  43682. * @param nativeController the native gamepad controller object
  43683. */
  43684. update(nativeController: IMinimalMotionControllerObject): void;
  43685. }
  43686. }
  43687. declare module BABYLON {
  43688. /**
  43689. * Class used to represent data loading progression
  43690. */
  43691. export class SceneLoaderProgressEvent {
  43692. /** defines if data length to load can be evaluated */
  43693. readonly lengthComputable: boolean;
  43694. /** defines the loaded data length */
  43695. readonly loaded: number;
  43696. /** defines the data length to load */
  43697. readonly total: number;
  43698. /**
  43699. * Create a new progress event
  43700. * @param lengthComputable defines if data length to load can be evaluated
  43701. * @param loaded defines the loaded data length
  43702. * @param total defines the data length to load
  43703. */
  43704. constructor(
  43705. /** defines if data length to load can be evaluated */
  43706. lengthComputable: boolean,
  43707. /** defines the loaded data length */
  43708. loaded: number,
  43709. /** defines the data length to load */
  43710. total: number);
  43711. /**
  43712. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43713. * @param event defines the source event
  43714. * @returns a new SceneLoaderProgressEvent
  43715. */
  43716. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43717. }
  43718. /**
  43719. * Interface used by SceneLoader plugins to define supported file extensions
  43720. */
  43721. export interface ISceneLoaderPluginExtensions {
  43722. /**
  43723. * Defines the list of supported extensions
  43724. */
  43725. [extension: string]: {
  43726. isBinary: boolean;
  43727. };
  43728. }
  43729. /**
  43730. * Interface used by SceneLoader plugin factory
  43731. */
  43732. export interface ISceneLoaderPluginFactory {
  43733. /**
  43734. * Defines the name of the factory
  43735. */
  43736. name: string;
  43737. /**
  43738. * Function called to create a new plugin
  43739. * @return the new plugin
  43740. */
  43741. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43742. /**
  43743. * The callback that returns true if the data can be directly loaded.
  43744. * @param data string containing the file data
  43745. * @returns if the data can be loaded directly
  43746. */
  43747. canDirectLoad?(data: string): boolean;
  43748. }
  43749. /**
  43750. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43751. */
  43752. export interface ISceneLoaderPluginBase {
  43753. /**
  43754. * The friendly name of this plugin.
  43755. */
  43756. name: string;
  43757. /**
  43758. * The file extensions supported by this plugin.
  43759. */
  43760. extensions: string | ISceneLoaderPluginExtensions;
  43761. /**
  43762. * The callback called when loading from a url.
  43763. * @param scene scene loading this url
  43764. * @param url url to load
  43765. * @param onSuccess callback called when the file successfully loads
  43766. * @param onProgress callback called while file is loading (if the server supports this mode)
  43767. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43768. * @param onError callback called when the file fails to load
  43769. * @returns a file request object
  43770. */
  43771. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43772. /**
  43773. * The callback called when loading from a file object.
  43774. * @param scene scene loading this file
  43775. * @param file defines the file to load
  43776. * @param onSuccess defines the callback to call when data is loaded
  43777. * @param onProgress defines the callback to call during loading process
  43778. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43779. * @param onError defines the callback to call when an error occurs
  43780. * @returns a file request object
  43781. */
  43782. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43783. /**
  43784. * The callback that returns true if the data can be directly loaded.
  43785. * @param data string containing the file data
  43786. * @returns if the data can be loaded directly
  43787. */
  43788. canDirectLoad?(data: string): boolean;
  43789. /**
  43790. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43791. * @param scene scene loading this data
  43792. * @param data string containing the data
  43793. * @returns data to pass to the plugin
  43794. */
  43795. directLoad?(scene: Scene, data: string): any;
  43796. /**
  43797. * The callback that allows custom handling of the root url based on the response url.
  43798. * @param rootUrl the original root url
  43799. * @param responseURL the response url if available
  43800. * @returns the new root url
  43801. */
  43802. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43803. }
  43804. /**
  43805. * Interface used to define a SceneLoader plugin
  43806. */
  43807. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43808. /**
  43809. * Import meshes into a scene.
  43810. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43811. * @param scene The scene to import into
  43812. * @param data The data to import
  43813. * @param rootUrl The root url for scene and resources
  43814. * @param meshes The meshes array to import into
  43815. * @param particleSystems The particle systems array to import into
  43816. * @param skeletons The skeletons array to import into
  43817. * @param onError The callback when import fails
  43818. * @returns True if successful or false otherwise
  43819. */
  43820. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43821. /**
  43822. * Load into a scene.
  43823. * @param scene The scene to load into
  43824. * @param data The data to import
  43825. * @param rootUrl The root url for scene and resources
  43826. * @param onError The callback when import fails
  43827. * @returns True if successful or false otherwise
  43828. */
  43829. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43830. /**
  43831. * Load into an asset container.
  43832. * @param scene The scene to load into
  43833. * @param data The data to import
  43834. * @param rootUrl The root url for scene and resources
  43835. * @param onError The callback when import fails
  43836. * @returns The loaded asset container
  43837. */
  43838. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43839. }
  43840. /**
  43841. * Interface used to define an async SceneLoader plugin
  43842. */
  43843. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43844. /**
  43845. * Import meshes into a scene.
  43846. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43847. * @param scene The scene to import into
  43848. * @param data The data to import
  43849. * @param rootUrl The root url for scene and resources
  43850. * @param onProgress The callback when the load progresses
  43851. * @param fileName Defines the name of the file to load
  43852. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43853. */
  43854. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43855. meshes: AbstractMesh[];
  43856. particleSystems: IParticleSystem[];
  43857. skeletons: Skeleton[];
  43858. animationGroups: AnimationGroup[];
  43859. }>;
  43860. /**
  43861. * Load into a scene.
  43862. * @param scene The scene to load into
  43863. * @param data The data to import
  43864. * @param rootUrl The root url for scene and resources
  43865. * @param onProgress The callback when the load progresses
  43866. * @param fileName Defines the name of the file to load
  43867. * @returns Nothing
  43868. */
  43869. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43870. /**
  43871. * Load into an asset container.
  43872. * @param scene The scene to load into
  43873. * @param data The data to import
  43874. * @param rootUrl The root url for scene and resources
  43875. * @param onProgress The callback when the load progresses
  43876. * @param fileName Defines the name of the file to load
  43877. * @returns The loaded asset container
  43878. */
  43879. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43880. }
  43881. /**
  43882. * Mode that determines how to handle old animation groups before loading new ones.
  43883. */
  43884. export enum SceneLoaderAnimationGroupLoadingMode {
  43885. /**
  43886. * Reset all old animations to initial state then dispose them.
  43887. */
  43888. Clean = 0,
  43889. /**
  43890. * Stop all old animations.
  43891. */
  43892. Stop = 1,
  43893. /**
  43894. * Restart old animations from first frame.
  43895. */
  43896. Sync = 2,
  43897. /**
  43898. * Old animations remains untouched.
  43899. */
  43900. NoSync = 3
  43901. }
  43902. /**
  43903. * Class used to load scene from various file formats using registered plugins
  43904. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43905. */
  43906. export class SceneLoader {
  43907. /**
  43908. * No logging while loading
  43909. */
  43910. static readonly NO_LOGGING: number;
  43911. /**
  43912. * Minimal logging while loading
  43913. */
  43914. static readonly MINIMAL_LOGGING: number;
  43915. /**
  43916. * Summary logging while loading
  43917. */
  43918. static readonly SUMMARY_LOGGING: number;
  43919. /**
  43920. * Detailled logging while loading
  43921. */
  43922. static readonly DETAILED_LOGGING: number;
  43923. /**
  43924. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43925. */
  43926. static get ForceFullSceneLoadingForIncremental(): boolean;
  43927. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43928. /**
  43929. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43930. */
  43931. static get ShowLoadingScreen(): boolean;
  43932. static set ShowLoadingScreen(value: boolean);
  43933. /**
  43934. * Defines the current logging level (while loading the scene)
  43935. * @ignorenaming
  43936. */
  43937. static get loggingLevel(): number;
  43938. static set loggingLevel(value: number);
  43939. /**
  43940. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43941. */
  43942. static get CleanBoneMatrixWeights(): boolean;
  43943. static set CleanBoneMatrixWeights(value: boolean);
  43944. /**
  43945. * Event raised when a plugin is used to load a scene
  43946. */
  43947. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43948. private static _registeredPlugins;
  43949. private static _getDefaultPlugin;
  43950. private static _getPluginForExtension;
  43951. private static _getPluginForDirectLoad;
  43952. private static _getPluginForFilename;
  43953. private static _getDirectLoad;
  43954. private static _loadData;
  43955. private static _getFileInfo;
  43956. /**
  43957. * Gets a plugin that can load the given extension
  43958. * @param extension defines the extension to load
  43959. * @returns a plugin or null if none works
  43960. */
  43961. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43962. /**
  43963. * Gets a boolean indicating that the given extension can be loaded
  43964. * @param extension defines the extension to load
  43965. * @returns true if the extension is supported
  43966. */
  43967. static IsPluginForExtensionAvailable(extension: string): boolean;
  43968. /**
  43969. * Adds a new plugin to the list of registered plugins
  43970. * @param plugin defines the plugin to add
  43971. */
  43972. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43973. /**
  43974. * Import meshes into a scene
  43975. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43976. * @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)
  43977. * @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)
  43978. * @param scene the instance of BABYLON.Scene to append to
  43979. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43980. * @param onProgress a callback with a progress event for each file being loaded
  43981. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43982. * @param pluginExtension the extension used to determine the plugin
  43983. * @returns The loaded plugin
  43984. */
  43985. 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>;
  43986. /**
  43987. * Import meshes into a scene
  43988. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43989. * @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)
  43990. * @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)
  43991. * @param scene the instance of BABYLON.Scene to append to
  43992. * @param onProgress a callback with a progress event for each file being loaded
  43993. * @param pluginExtension the extension used to determine the plugin
  43994. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43995. */
  43996. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43997. meshes: AbstractMesh[];
  43998. particleSystems: IParticleSystem[];
  43999. skeletons: Skeleton[];
  44000. animationGroups: AnimationGroup[];
  44001. }>;
  44002. /**
  44003. * Load a scene
  44004. * @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)
  44005. * @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)
  44006. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44007. * @param onSuccess a callback with the scene when import succeeds
  44008. * @param onProgress a callback with a progress event for each file being loaded
  44009. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44010. * @param pluginExtension the extension used to determine the plugin
  44011. * @returns The loaded plugin
  44012. */
  44013. 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>;
  44014. /**
  44015. * Load a scene
  44016. * @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)
  44017. * @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)
  44018. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44019. * @param onProgress a callback with a progress event for each file being loaded
  44020. * @param pluginExtension the extension used to determine the plugin
  44021. * @returns The loaded scene
  44022. */
  44023. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44024. /**
  44025. * Append a scene
  44026. * @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)
  44027. * @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)
  44028. * @param scene is the instance of BABYLON.Scene to append to
  44029. * @param onSuccess a callback with the scene when import succeeds
  44030. * @param onProgress a callback with a progress event for each file being loaded
  44031. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44032. * @param pluginExtension the extension used to determine the plugin
  44033. * @returns The loaded plugin
  44034. */
  44035. 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>;
  44036. /**
  44037. * Append a scene
  44038. * @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)
  44039. * @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)
  44040. * @param scene is the instance of BABYLON.Scene to append to
  44041. * @param onProgress a callback with a progress event for each file being loaded
  44042. * @param pluginExtension the extension used to determine the plugin
  44043. * @returns The given scene
  44044. */
  44045. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44046. /**
  44047. * Load a scene into an asset container
  44048. * @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)
  44049. * @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)
  44050. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44051. * @param onSuccess a callback with the scene when import succeeds
  44052. * @param onProgress a callback with a progress event for each file being loaded
  44053. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44054. * @param pluginExtension the extension used to determine the plugin
  44055. * @returns The loaded plugin
  44056. */
  44057. 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>;
  44058. /**
  44059. * Load a scene into an asset container
  44060. * @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)
  44061. * @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)
  44062. * @param scene is the instance of Scene to append to
  44063. * @param onProgress a callback with a progress event for each file being loaded
  44064. * @param pluginExtension the extension used to determine the plugin
  44065. * @returns The loaded asset container
  44066. */
  44067. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44068. /**
  44069. * Import animations from a file into a scene
  44070. * @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)
  44071. * @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)
  44072. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44073. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44074. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44075. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44076. * @param onSuccess a callback with the scene when import succeeds
  44077. * @param onProgress a callback with a progress event for each file being loaded
  44078. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44079. */
  44080. 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;
  44081. /**
  44082. * Import animations from a file into a scene
  44083. * @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)
  44084. * @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)
  44085. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44086. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44087. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44088. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44089. * @param onSuccess a callback with the scene when import succeeds
  44090. * @param onProgress a callback with a progress event for each file being loaded
  44091. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44092. * @returns the updated scene with imported animations
  44093. */
  44094. 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>;
  44095. }
  44096. }
  44097. declare module BABYLON {
  44098. /**
  44099. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44100. */
  44101. export type MotionControllerHandness = "none" | "left" | "right";
  44102. /**
  44103. * The type of components available in motion controllers.
  44104. * This is not the name of the component.
  44105. */
  44106. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44107. /**
  44108. * The state of a controller component
  44109. */
  44110. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44111. /**
  44112. * The schema of motion controller layout.
  44113. * No object will be initialized using this interface
  44114. * This is used just to define the profile.
  44115. */
  44116. export interface IMotionControllerLayout {
  44117. /**
  44118. * Path to load the assets. Usually relative to the base path
  44119. */
  44120. assetPath: string;
  44121. /**
  44122. * Available components (unsorted)
  44123. */
  44124. components: {
  44125. /**
  44126. * A map of component Ids
  44127. */
  44128. [componentId: string]: {
  44129. /**
  44130. * The type of input the component outputs
  44131. */
  44132. type: MotionControllerComponentType;
  44133. /**
  44134. * The indices of this component in the gamepad object
  44135. */
  44136. gamepadIndices: {
  44137. /**
  44138. * Index of button
  44139. */
  44140. button?: number;
  44141. /**
  44142. * If available, index of x-axis
  44143. */
  44144. xAxis?: number;
  44145. /**
  44146. * If available, index of y-axis
  44147. */
  44148. yAxis?: number;
  44149. };
  44150. /**
  44151. * The mesh's root node name
  44152. */
  44153. rootNodeName: string;
  44154. /**
  44155. * Animation definitions for this model
  44156. */
  44157. visualResponses: {
  44158. [stateKey: string]: {
  44159. /**
  44160. * What property will be animated
  44161. */
  44162. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44163. /**
  44164. * What states influence this visual response
  44165. */
  44166. states: MotionControllerComponentStateType[];
  44167. /**
  44168. * Type of animation - movement or visibility
  44169. */
  44170. valueNodeProperty: "transform" | "visibility";
  44171. /**
  44172. * Base node name to move. Its position will be calculated according to the min and max nodes
  44173. */
  44174. valueNodeName?: string;
  44175. /**
  44176. * Minimum movement node
  44177. */
  44178. minNodeName?: string;
  44179. /**
  44180. * Max movement node
  44181. */
  44182. maxNodeName?: string;
  44183. };
  44184. };
  44185. /**
  44186. * If touch enabled, what is the name of node to display user feedback
  44187. */
  44188. touchPointNodeName?: string;
  44189. };
  44190. };
  44191. /**
  44192. * Is it xr standard mapping or not
  44193. */
  44194. gamepadMapping: "" | "xr-standard";
  44195. /**
  44196. * Base root node of this entire model
  44197. */
  44198. rootNodeName: string;
  44199. /**
  44200. * Defines the main button component id
  44201. */
  44202. selectComponentId: string;
  44203. }
  44204. /**
  44205. * A definition for the layout map in the input profile
  44206. */
  44207. export interface IMotionControllerLayoutMap {
  44208. /**
  44209. * Layouts with handness type as a key
  44210. */
  44211. [handness: string]: IMotionControllerLayout;
  44212. }
  44213. /**
  44214. * The XR Input profile schema
  44215. * Profiles can be found here:
  44216. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44217. */
  44218. export interface IMotionControllerProfile {
  44219. /**
  44220. * fallback profiles for this profileId
  44221. */
  44222. fallbackProfileIds: string[];
  44223. /**
  44224. * The layout map, with handness as key
  44225. */
  44226. layouts: IMotionControllerLayoutMap;
  44227. /**
  44228. * The id of this profile
  44229. * correlates to the profile(s) in the xrInput.profiles array
  44230. */
  44231. profileId: string;
  44232. }
  44233. /**
  44234. * A helper-interface for the 3 meshes needed for controller button animation
  44235. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44236. */
  44237. export interface IMotionControllerButtonMeshMap {
  44238. /**
  44239. * the mesh that defines the pressed value mesh position.
  44240. * This is used to find the max-position of this button
  44241. */
  44242. pressedMesh: AbstractMesh;
  44243. /**
  44244. * the mesh that defines the unpressed value mesh position.
  44245. * This is used to find the min (or initial) position of this button
  44246. */
  44247. unpressedMesh: AbstractMesh;
  44248. /**
  44249. * The mesh that will be changed when value changes
  44250. */
  44251. valueMesh: AbstractMesh;
  44252. }
  44253. /**
  44254. * A helper-interface for the 3 meshes needed for controller axis animation.
  44255. * This will be expanded when touchpad animations are fully supported
  44256. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44257. */
  44258. export interface IMotionControllerMeshMap {
  44259. /**
  44260. * the mesh that defines the maximum value mesh position.
  44261. */
  44262. maxMesh?: AbstractMesh;
  44263. /**
  44264. * the mesh that defines the minimum value mesh position.
  44265. */
  44266. minMesh?: AbstractMesh;
  44267. /**
  44268. * The mesh that will be changed when axis value changes
  44269. */
  44270. valueMesh: AbstractMesh;
  44271. }
  44272. /**
  44273. * The elements needed for change-detection of the gamepad objects in motion controllers
  44274. */
  44275. export interface IMinimalMotionControllerObject {
  44276. /**
  44277. * Available axes of this controller
  44278. */
  44279. axes: number[];
  44280. /**
  44281. * An array of available buttons
  44282. */
  44283. buttons: Array<{
  44284. /**
  44285. * Value of the button/trigger
  44286. */
  44287. value: number;
  44288. /**
  44289. * If the button/trigger is currently touched
  44290. */
  44291. touched: boolean;
  44292. /**
  44293. * If the button/trigger is currently pressed
  44294. */
  44295. pressed: boolean;
  44296. }>;
  44297. }
  44298. /**
  44299. * An Abstract Motion controller
  44300. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44301. * Each component has an observable to check for changes in value and state
  44302. */
  44303. export abstract class WebXRAbstractMotionController implements IDisposable {
  44304. protected scene: Scene;
  44305. protected layout: IMotionControllerLayout;
  44306. /**
  44307. * The gamepad object correlating to this controller
  44308. */
  44309. gamepadObject: IMinimalMotionControllerObject;
  44310. /**
  44311. * handness (left/right/none) of this controller
  44312. */
  44313. handness: MotionControllerHandness;
  44314. private _initComponent;
  44315. private _modelReady;
  44316. /**
  44317. * A map of components (WebXRControllerComponent) in this motion controller
  44318. * Components have a ComponentType and can also have both button and axis definitions
  44319. */
  44320. readonly components: {
  44321. [id: string]: WebXRControllerComponent;
  44322. };
  44323. /**
  44324. * Disable the model's animation. Can be set at any time.
  44325. */
  44326. disableAnimation: boolean;
  44327. /**
  44328. * Observers registered here will be triggered when the model of this controller is done loading
  44329. */
  44330. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44331. /**
  44332. * The profile id of this motion controller
  44333. */
  44334. abstract profileId: string;
  44335. /**
  44336. * The root mesh of the model. It is null if the model was not yet initialized
  44337. */
  44338. rootMesh: Nullable<AbstractMesh>;
  44339. /**
  44340. * constructs a new abstract motion controller
  44341. * @param scene the scene to which the model of the controller will be added
  44342. * @param layout The profile layout to load
  44343. * @param gamepadObject The gamepad object correlating to this controller
  44344. * @param handness handness (left/right/none) of this controller
  44345. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44346. */
  44347. constructor(scene: Scene, layout: IMotionControllerLayout,
  44348. /**
  44349. * The gamepad object correlating to this controller
  44350. */
  44351. gamepadObject: IMinimalMotionControllerObject,
  44352. /**
  44353. * handness (left/right/none) of this controller
  44354. */
  44355. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44356. /**
  44357. * Dispose this controller, the model mesh and all its components
  44358. */
  44359. dispose(): void;
  44360. /**
  44361. * Returns all components of specific type
  44362. * @param type the type to search for
  44363. * @return an array of components with this type
  44364. */
  44365. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44366. /**
  44367. * get a component based an its component id as defined in layout.components
  44368. * @param id the id of the component
  44369. * @returns the component correlates to the id or undefined if not found
  44370. */
  44371. getComponent(id: string): WebXRControllerComponent;
  44372. /**
  44373. * Get the list of components available in this motion controller
  44374. * @returns an array of strings correlating to available components
  44375. */
  44376. getComponentIds(): string[];
  44377. /**
  44378. * Get the first component of specific type
  44379. * @param type type of component to find
  44380. * @return a controller component or null if not found
  44381. */
  44382. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44383. /**
  44384. * Get the main (Select) component of this controller as defined in the layout
  44385. * @returns the main component of this controller
  44386. */
  44387. getMainComponent(): WebXRControllerComponent;
  44388. /**
  44389. * Loads the model correlating to this controller
  44390. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44391. * @returns A promise fulfilled with the result of the model loading
  44392. */
  44393. loadModel(): Promise<boolean>;
  44394. /**
  44395. * Update this model using the current XRFrame
  44396. * @param xrFrame the current xr frame to use and update the model
  44397. */
  44398. updateFromXRFrame(xrFrame: XRFrame): void;
  44399. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44400. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44401. /**
  44402. * Moves the axis on the controller mesh based on its current state
  44403. * @param axis the index of the axis
  44404. * @param axisValue the value of the axis which determines the meshes new position
  44405. * @hidden
  44406. */
  44407. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44408. /**
  44409. * Update the model itself with the current frame data
  44410. * @param xrFrame the frame to use for updating the model mesh
  44411. */
  44412. protected updateModel(xrFrame: XRFrame): void;
  44413. /**
  44414. * Get the filename and path for this controller's model
  44415. * @returns a map of filename and path
  44416. */
  44417. protected abstract _getFilenameAndPath(): {
  44418. filename: string;
  44419. path: string;
  44420. };
  44421. /**
  44422. * This function is called before the mesh is loaded. It checks for loading constraints.
  44423. * For example, this function can check if the GLB loader is available
  44424. * If this function returns false, the generic controller will be loaded instead
  44425. * @returns Is the client ready to load the mesh
  44426. */
  44427. protected abstract _getModelLoadingConstraints(): boolean;
  44428. /**
  44429. * This function will be called after the model was successfully loaded and can be used
  44430. * for mesh transformations before it is available for the user
  44431. * @param meshes the loaded meshes
  44432. */
  44433. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44434. /**
  44435. * Set the root mesh for this controller. Important for the WebXR controller class
  44436. * @param meshes the loaded meshes
  44437. */
  44438. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44439. /**
  44440. * A function executed each frame that updates the mesh (if needed)
  44441. * @param xrFrame the current xrFrame
  44442. */
  44443. protected abstract _updateModel(xrFrame: XRFrame): void;
  44444. private _getGenericFilenameAndPath;
  44445. private _getGenericParentMesh;
  44446. }
  44447. }
  44448. declare module BABYLON {
  44449. /**
  44450. * A generic trigger-only motion controller for WebXR
  44451. */
  44452. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44453. /**
  44454. * Static version of the profile id of this controller
  44455. */
  44456. static ProfileId: string;
  44457. profileId: string;
  44458. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44459. protected _getFilenameAndPath(): {
  44460. filename: string;
  44461. path: string;
  44462. };
  44463. protected _getModelLoadingConstraints(): boolean;
  44464. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44465. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44466. protected _updateModel(): void;
  44467. }
  44468. }
  44469. declare module BABYLON {
  44470. /**
  44471. * Class containing static functions to help procedurally build meshes
  44472. */
  44473. export class SphereBuilder {
  44474. /**
  44475. * Creates a sphere mesh
  44476. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44477. * * 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`)
  44478. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44479. * * 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
  44480. * * 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)
  44481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44482. * * 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
  44483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44484. * @param name defines the name of the mesh
  44485. * @param options defines the options used to create the mesh
  44486. * @param scene defines the hosting scene
  44487. * @returns the sphere mesh
  44488. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44489. */
  44490. static CreateSphere(name: string, options: {
  44491. segments?: number;
  44492. diameter?: number;
  44493. diameterX?: number;
  44494. diameterY?: number;
  44495. diameterZ?: number;
  44496. arc?: number;
  44497. slice?: number;
  44498. sideOrientation?: number;
  44499. frontUVs?: Vector4;
  44500. backUVs?: Vector4;
  44501. updatable?: boolean;
  44502. }, scene?: Nullable<Scene>): Mesh;
  44503. }
  44504. }
  44505. declare module BABYLON {
  44506. /**
  44507. * A profiled motion controller has its profile loaded from an online repository.
  44508. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44509. */
  44510. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44511. private _repositoryUrl;
  44512. private _buttonMeshMapping;
  44513. private _touchDots;
  44514. /**
  44515. * The profile ID of this controller. Will be populated when the controller initializes.
  44516. */
  44517. profileId: string;
  44518. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44519. dispose(): void;
  44520. protected _getFilenameAndPath(): {
  44521. filename: string;
  44522. path: string;
  44523. };
  44524. protected _getModelLoadingConstraints(): boolean;
  44525. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44526. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44527. protected _updateModel(_xrFrame: XRFrame): void;
  44528. }
  44529. }
  44530. declare module BABYLON {
  44531. /**
  44532. * A construction function type to create a new controller based on an xrInput object
  44533. */
  44534. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44535. /**
  44536. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44537. *
  44538. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44539. * it should be replaced with auto-loaded controllers.
  44540. *
  44541. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44542. */
  44543. export class WebXRMotionControllerManager {
  44544. private static _AvailableControllers;
  44545. private static _Fallbacks;
  44546. private static _ProfileLoadingPromises;
  44547. private static _ProfilesList;
  44548. /**
  44549. * The base URL of the online controller repository. Can be changed at any time.
  44550. */
  44551. static BaseRepositoryUrl: string;
  44552. /**
  44553. * Which repository gets priority - local or online
  44554. */
  44555. static PrioritizeOnlineRepository: boolean;
  44556. /**
  44557. * Use the online repository, or use only locally-defined controllers
  44558. */
  44559. static UseOnlineRepository: boolean;
  44560. /**
  44561. * Clear the cache used for profile loading and reload when requested again
  44562. */
  44563. static ClearProfilesCache(): void;
  44564. /**
  44565. * Register the default fallbacks.
  44566. * This function is called automatically when this file is imported.
  44567. */
  44568. static DefaultFallbacks(): void;
  44569. /**
  44570. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44571. * @param profileId the profile to which a fallback needs to be found
  44572. * @return an array with corresponding fallback profiles
  44573. */
  44574. static FindFallbackWithProfileId(profileId: string): string[];
  44575. /**
  44576. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44577. * The order of search:
  44578. *
  44579. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44580. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44581. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44582. * 4) return the generic trigger controller if none were found
  44583. *
  44584. * @param xrInput the xrInput to which a new controller is initialized
  44585. * @param scene the scene to which the model will be added
  44586. * @param forceProfile force a certain profile for this controller
  44587. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44588. */
  44589. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44590. /**
  44591. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44592. *
  44593. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44594. *
  44595. * @param type the profile type to register
  44596. * @param constructFunction the function to be called when loading this profile
  44597. */
  44598. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44599. /**
  44600. * Register a fallback to a specific profile.
  44601. * @param profileId the profileId that will receive the fallbacks
  44602. * @param fallbacks A list of fallback profiles
  44603. */
  44604. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44605. /**
  44606. * Will update the list of profiles available in the repository
  44607. * @return a promise that resolves to a map of profiles available online
  44608. */
  44609. static UpdateProfilesList(): Promise<{
  44610. [profile: string]: string;
  44611. }>;
  44612. private static _LoadProfileFromRepository;
  44613. private static _LoadProfilesFromAvailableControllers;
  44614. }
  44615. }
  44616. declare module BABYLON {
  44617. /**
  44618. * Configuration options for the WebXR controller creation
  44619. */
  44620. export interface IWebXRControllerOptions {
  44621. /**
  44622. * Should the controller mesh be animated when a user interacts with it
  44623. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44624. */
  44625. disableMotionControllerAnimation?: boolean;
  44626. /**
  44627. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44628. */
  44629. doNotLoadControllerMesh?: boolean;
  44630. /**
  44631. * Force a specific controller type for this controller.
  44632. * This can be used when creating your own profile or when testing different controllers
  44633. */
  44634. forceControllerProfile?: string;
  44635. }
  44636. /**
  44637. * Represents an XR controller
  44638. */
  44639. export class WebXRInputSource {
  44640. private _scene;
  44641. /** The underlying input source for the controller */
  44642. inputSource: XRInputSource;
  44643. private _options;
  44644. private _tmpQuaternion;
  44645. private _tmpVector;
  44646. private _uniqueId;
  44647. /**
  44648. * 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
  44649. */
  44650. grip?: AbstractMesh;
  44651. /**
  44652. * If available, this is the gamepad object related to this controller.
  44653. * Using this object it is possible to get click events and trackpad changes of the
  44654. * webxr controller that is currently being used.
  44655. */
  44656. motionController?: WebXRAbstractMotionController;
  44657. /**
  44658. * Event that fires when the controller is removed/disposed.
  44659. * The object provided as event data is this controller, after associated assets were disposed.
  44660. * uniqueId is still available.
  44661. */
  44662. onDisposeObservable: Observable<WebXRInputSource>;
  44663. /**
  44664. * Will be triggered when the mesh associated with the motion controller is done loading.
  44665. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44666. * A shortened version of controller -> motion controller -> on mesh loaded.
  44667. */
  44668. onMeshLoadedObservable: Observable<AbstractMesh>;
  44669. /**
  44670. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44671. */
  44672. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44673. /**
  44674. * Pointer which can be used to select objects or attach a visible laser to
  44675. */
  44676. pointer: AbstractMesh;
  44677. /**
  44678. * Creates the controller
  44679. * @see https://doc.babylonjs.com/how_to/webxr
  44680. * @param _scene the scene which the controller should be associated to
  44681. * @param inputSource the underlying input source for the controller
  44682. * @param _options options for this controller creation
  44683. */
  44684. constructor(_scene: Scene,
  44685. /** The underlying input source for the controller */
  44686. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44687. /**
  44688. * Get this controllers unique id
  44689. */
  44690. get uniqueId(): string;
  44691. /**
  44692. * Disposes of the object
  44693. */
  44694. dispose(): void;
  44695. /**
  44696. * Gets a world space ray coming from the pointer or grip
  44697. * @param result the resulting ray
  44698. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44699. */
  44700. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44701. /**
  44702. * Updates the controller pose based on the given XRFrame
  44703. * @param xrFrame xr frame to update the pose with
  44704. * @param referenceSpace reference space to use
  44705. */
  44706. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44707. }
  44708. }
  44709. declare module BABYLON {
  44710. /**
  44711. * The schema for initialization options of the XR Input class
  44712. */
  44713. export interface IWebXRInputOptions {
  44714. /**
  44715. * If set to true no model will be automatically loaded
  44716. */
  44717. doNotLoadControllerMeshes?: boolean;
  44718. /**
  44719. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44720. * If not found, the xr input profile data will be used.
  44721. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44722. */
  44723. forceInputProfile?: string;
  44724. /**
  44725. * Do not send a request to the controller repository to load the profile.
  44726. *
  44727. * Instead, use the controllers available in babylon itself.
  44728. */
  44729. disableOnlineControllerRepository?: boolean;
  44730. /**
  44731. * A custom URL for the controllers repository
  44732. */
  44733. customControllersRepositoryURL?: string;
  44734. /**
  44735. * Should the controller model's components not move according to the user input
  44736. */
  44737. disableControllerAnimation?: boolean;
  44738. }
  44739. /**
  44740. * XR input used to track XR inputs such as controllers/rays
  44741. */
  44742. export class WebXRInput implements IDisposable {
  44743. /**
  44744. * the xr session manager for this session
  44745. */
  44746. xrSessionManager: WebXRSessionManager;
  44747. /**
  44748. * the WebXR camera for this session. Mainly used for teleportation
  44749. */
  44750. xrCamera: WebXRCamera;
  44751. private readonly options;
  44752. /**
  44753. * XR controllers being tracked
  44754. */
  44755. controllers: Array<WebXRInputSource>;
  44756. private _frameObserver;
  44757. private _sessionEndedObserver;
  44758. private _sessionInitObserver;
  44759. /**
  44760. * Event when a controller has been connected/added
  44761. */
  44762. onControllerAddedObservable: Observable<WebXRInputSource>;
  44763. /**
  44764. * Event when a controller has been removed/disconnected
  44765. */
  44766. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44767. /**
  44768. * Initializes the WebXRInput
  44769. * @param xrSessionManager the xr session manager for this session
  44770. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44771. * @param options = initialization options for this xr input
  44772. */
  44773. constructor(
  44774. /**
  44775. * the xr session manager for this session
  44776. */
  44777. xrSessionManager: WebXRSessionManager,
  44778. /**
  44779. * the WebXR camera for this session. Mainly used for teleportation
  44780. */
  44781. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44782. private _onInputSourcesChange;
  44783. private _addAndRemoveControllers;
  44784. /**
  44785. * Disposes of the object
  44786. */
  44787. dispose(): void;
  44788. }
  44789. }
  44790. declare module BABYLON {
  44791. /**
  44792. * This is the base class for all WebXR features.
  44793. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44794. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44795. */
  44796. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44797. protected _xrSessionManager: WebXRSessionManager;
  44798. private _attached;
  44799. private _removeOnDetach;
  44800. /**
  44801. * Should auto-attach be disabled?
  44802. */
  44803. disableAutoAttach: boolean;
  44804. /**
  44805. * Construct a new (abstract) WebXR feature
  44806. * @param _xrSessionManager the xr session manager for this feature
  44807. */
  44808. constructor(_xrSessionManager: WebXRSessionManager);
  44809. /**
  44810. * Is this feature attached
  44811. */
  44812. get attached(): boolean;
  44813. /**
  44814. * attach this feature
  44815. *
  44816. * @param force should attachment be forced (even when already attached)
  44817. * @returns true if successful, false is failed or already attached
  44818. */
  44819. attach(force?: boolean): boolean;
  44820. /**
  44821. * detach this feature.
  44822. *
  44823. * @returns true if successful, false if failed or already detached
  44824. */
  44825. detach(): boolean;
  44826. /**
  44827. * Dispose this feature and all of the resources attached
  44828. */
  44829. dispose(): void;
  44830. /**
  44831. * This is used to register callbacks that will automatically be removed when detach is called.
  44832. * @param observable the observable to which the observer will be attached
  44833. * @param callback the callback to register
  44834. */
  44835. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44836. /**
  44837. * Code in this function will be executed on each xrFrame received from the browser.
  44838. * This function will not execute after the feature is detached.
  44839. * @param _xrFrame the current frame
  44840. */
  44841. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44842. }
  44843. }
  44844. declare module BABYLON {
  44845. /**
  44846. * Renders a layer on top of an existing scene
  44847. */
  44848. export class UtilityLayerRenderer implements IDisposable {
  44849. /** the original scene that will be rendered on top of */
  44850. originalScene: Scene;
  44851. private _pointerCaptures;
  44852. private _lastPointerEvents;
  44853. private static _DefaultUtilityLayer;
  44854. private static _DefaultKeepDepthUtilityLayer;
  44855. private _sharedGizmoLight;
  44856. private _renderCamera;
  44857. /**
  44858. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44859. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44860. * @returns the camera that is used when rendering the utility layer
  44861. */
  44862. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44863. /**
  44864. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44865. * @param cam the camera that should be used when rendering the utility layer
  44866. */
  44867. setRenderCamera(cam: Nullable<Camera>): void;
  44868. /**
  44869. * @hidden
  44870. * Light which used by gizmos to get light shading
  44871. */
  44872. _getSharedGizmoLight(): HemisphericLight;
  44873. /**
  44874. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44875. */
  44876. pickUtilitySceneFirst: boolean;
  44877. /**
  44878. * 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)
  44879. */
  44880. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44881. /**
  44882. * 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)
  44883. */
  44884. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44885. /**
  44886. * The scene that is rendered on top of the original scene
  44887. */
  44888. utilityLayerScene: Scene;
  44889. /**
  44890. * If the utility layer should automatically be rendered on top of existing scene
  44891. */
  44892. shouldRender: boolean;
  44893. /**
  44894. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44895. */
  44896. onlyCheckPointerDownEvents: boolean;
  44897. /**
  44898. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44899. */
  44900. processAllEvents: boolean;
  44901. /**
  44902. * Observable raised when the pointer move from the utility layer scene to the main scene
  44903. */
  44904. onPointerOutObservable: Observable<number>;
  44905. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44906. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44907. private _afterRenderObserver;
  44908. private _sceneDisposeObserver;
  44909. private _originalPointerObserver;
  44910. /**
  44911. * Instantiates a UtilityLayerRenderer
  44912. * @param originalScene the original scene that will be rendered on top of
  44913. * @param handleEvents boolean indicating if the utility layer should handle events
  44914. */
  44915. constructor(
  44916. /** the original scene that will be rendered on top of */
  44917. originalScene: Scene, handleEvents?: boolean);
  44918. private _notifyObservers;
  44919. /**
  44920. * Renders the utility layers scene on top of the original scene
  44921. */
  44922. render(): void;
  44923. /**
  44924. * Disposes of the renderer
  44925. */
  44926. dispose(): void;
  44927. private _updateCamera;
  44928. }
  44929. }
  44930. declare module BABYLON {
  44931. /**
  44932. * Options interface for the pointer selection module
  44933. */
  44934. export interface IWebXRControllerPointerSelectionOptions {
  44935. /**
  44936. * if provided, this scene will be used to render meshes.
  44937. */
  44938. customUtilityLayerScene?: Scene;
  44939. /**
  44940. * 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)
  44941. * If not disabled, the last picked point will be used to execute a pointer up event
  44942. * If disabled, pointer up event will be triggered right after the pointer down event.
  44943. * Used in screen and gaze target ray mode only
  44944. */
  44945. disablePointerUpOnTouchOut: boolean;
  44946. /**
  44947. * For gaze mode (time to select instead of press)
  44948. */
  44949. forceGazeMode: boolean;
  44950. /**
  44951. * 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
  44952. * to start a new countdown to the pointer down event.
  44953. * Defaults to 1.
  44954. */
  44955. gazeModePointerMovedFactor?: number;
  44956. /**
  44957. * Different button type to use instead of the main component
  44958. */
  44959. overrideButtonId?: string;
  44960. /**
  44961. * use this rendering group id for the meshes (optional)
  44962. */
  44963. renderingGroupId?: number;
  44964. /**
  44965. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44966. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44967. * 3000 means 3 seconds between pointing at something and selecting it
  44968. */
  44969. timeToSelect?: number;
  44970. /**
  44971. * Should meshes created here be added to a utility layer or the main scene
  44972. */
  44973. useUtilityLayer?: boolean;
  44974. /**
  44975. * the xr input to use with this pointer selection
  44976. */
  44977. xrInput: WebXRInput;
  44978. }
  44979. /**
  44980. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44981. */
  44982. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44983. private readonly _options;
  44984. private static _idCounter;
  44985. private _attachController;
  44986. private _controllers;
  44987. private _scene;
  44988. private _tmpVectorForPickCompare;
  44989. /**
  44990. * The module's name
  44991. */
  44992. static readonly Name: string;
  44993. /**
  44994. * The (Babylon) version of this module.
  44995. * This is an integer representing the implementation version.
  44996. * This number does not correspond to the WebXR specs version
  44997. */
  44998. static readonly Version: number;
  44999. /**
  45000. * Disable lighting on the laser pointer (so it will always be visible)
  45001. */
  45002. disablePointerLighting: boolean;
  45003. /**
  45004. * Disable lighting on the selection mesh (so it will always be visible)
  45005. */
  45006. disableSelectionMeshLighting: boolean;
  45007. /**
  45008. * Should the laser pointer be displayed
  45009. */
  45010. displayLaserPointer: boolean;
  45011. /**
  45012. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45013. */
  45014. displaySelectionMesh: boolean;
  45015. /**
  45016. * This color will be set to the laser pointer when selection is triggered
  45017. */
  45018. laserPointerPickedColor: Color3;
  45019. /**
  45020. * Default color of the laser pointer
  45021. */
  45022. lasterPointerDefaultColor: Color3;
  45023. /**
  45024. * default color of the selection ring
  45025. */
  45026. selectionMeshDefaultColor: Color3;
  45027. /**
  45028. * This color will be applied to the selection ring when selection is triggered
  45029. */
  45030. selectionMeshPickedColor: Color3;
  45031. /**
  45032. * Optional filter to be used for ray selection. This predicate shares behavior with
  45033. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45034. */
  45035. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45036. /**
  45037. * constructs a new background remover module
  45038. * @param _xrSessionManager the session manager for this module
  45039. * @param _options read-only options to be used in this module
  45040. */
  45041. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45042. /**
  45043. * attach this feature
  45044. * Will usually be called by the features manager
  45045. *
  45046. * @returns true if successful.
  45047. */
  45048. attach(): boolean;
  45049. /**
  45050. * detach this feature.
  45051. * Will usually be called by the features manager
  45052. *
  45053. * @returns true if successful.
  45054. */
  45055. detach(): boolean;
  45056. /**
  45057. * Will get the mesh under a specific pointer.
  45058. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45059. * @param controllerId the controllerId to check
  45060. * @returns The mesh under pointer or null if no mesh is under the pointer
  45061. */
  45062. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45063. /**
  45064. * Get the xr controller that correlates to the pointer id in the pointer event
  45065. *
  45066. * @param id the pointer id to search for
  45067. * @returns the controller that correlates to this id or null if not found
  45068. */
  45069. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45070. protected _onXRFrame(_xrFrame: XRFrame): void;
  45071. private _attachGazeMode;
  45072. private _attachScreenRayMode;
  45073. private _attachTrackedPointerRayMode;
  45074. private _convertNormalToDirectionOfRay;
  45075. private _detachController;
  45076. private _generateNewMeshPair;
  45077. private _pickingMoved;
  45078. private _updatePointerDistance;
  45079. }
  45080. }
  45081. declare module BABYLON {
  45082. /**
  45083. * Button which can be used to enter a different mode of XR
  45084. */
  45085. export class WebXREnterExitUIButton {
  45086. /** button element */
  45087. element: HTMLElement;
  45088. /** XR initialization options for the button */
  45089. sessionMode: XRSessionMode;
  45090. /** Reference space type */
  45091. referenceSpaceType: XRReferenceSpaceType;
  45092. /**
  45093. * Creates a WebXREnterExitUIButton
  45094. * @param element button element
  45095. * @param sessionMode XR initialization session mode
  45096. * @param referenceSpaceType the type of reference space to be used
  45097. */
  45098. constructor(
  45099. /** button element */
  45100. element: HTMLElement,
  45101. /** XR initialization options for the button */
  45102. sessionMode: XRSessionMode,
  45103. /** Reference space type */
  45104. referenceSpaceType: XRReferenceSpaceType);
  45105. /**
  45106. * Extendable function which can be used to update the button's visuals when the state changes
  45107. * @param activeButton the current active button in the UI
  45108. */
  45109. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45110. }
  45111. /**
  45112. * Options to create the webXR UI
  45113. */
  45114. export class WebXREnterExitUIOptions {
  45115. /**
  45116. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45117. */
  45118. customButtons?: Array<WebXREnterExitUIButton>;
  45119. /**
  45120. * A reference space type to use when creating the default button.
  45121. * Default is local-floor
  45122. */
  45123. referenceSpaceType?: XRReferenceSpaceType;
  45124. /**
  45125. * Context to enter xr with
  45126. */
  45127. renderTarget?: Nullable<WebXRRenderTarget>;
  45128. /**
  45129. * A session mode to use when creating the default button.
  45130. * Default is immersive-vr
  45131. */
  45132. sessionMode?: XRSessionMode;
  45133. }
  45134. /**
  45135. * UI to allow the user to enter/exit XR mode
  45136. */
  45137. export class WebXREnterExitUI implements IDisposable {
  45138. private scene;
  45139. /** version of the options passed to this UI */
  45140. options: WebXREnterExitUIOptions;
  45141. private _activeButton;
  45142. private _buttons;
  45143. private _overlay;
  45144. /**
  45145. * Fired every time the active button is changed.
  45146. *
  45147. * When xr is entered via a button that launches xr that button will be the callback parameter
  45148. *
  45149. * When exiting xr the callback parameter will be null)
  45150. */
  45151. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45152. /**
  45153. *
  45154. * @param scene babylon scene object to use
  45155. * @param options (read-only) version of the options passed to this UI
  45156. */
  45157. private constructor();
  45158. /**
  45159. * Creates UI to allow the user to enter/exit XR mode
  45160. * @param scene the scene to add the ui to
  45161. * @param helper the xr experience helper to enter/exit xr with
  45162. * @param options options to configure the UI
  45163. * @returns the created ui
  45164. */
  45165. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45166. /**
  45167. * Disposes of the XR UI component
  45168. */
  45169. dispose(): void;
  45170. private _updateButtons;
  45171. }
  45172. }
  45173. declare module BABYLON {
  45174. /**
  45175. * Class containing static functions to help procedurally build meshes
  45176. */
  45177. export class LinesBuilder {
  45178. /**
  45179. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45180. * * 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
  45181. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45182. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45183. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45184. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45185. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45186. * * 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
  45187. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45190. * @param name defines the name of the new line system
  45191. * @param options defines the options used to create the line system
  45192. * @param scene defines the hosting scene
  45193. * @returns a new line system mesh
  45194. */
  45195. static CreateLineSystem(name: string, options: {
  45196. lines: Vector3[][];
  45197. updatable?: boolean;
  45198. instance?: Nullable<LinesMesh>;
  45199. colors?: Nullable<Color4[][]>;
  45200. useVertexAlpha?: boolean;
  45201. }, scene: Nullable<Scene>): LinesMesh;
  45202. /**
  45203. * Creates a line mesh
  45204. * 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
  45205. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45206. * * The parameter `points` is an array successive Vector3
  45207. * * 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
  45208. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45209. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45210. * * When updating an instance, remember that only point positions can change, not the number of points
  45211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45213. * @param name defines the name of the new line system
  45214. * @param options defines the options used to create the line system
  45215. * @param scene defines the hosting scene
  45216. * @returns a new line mesh
  45217. */
  45218. static CreateLines(name: string, options: {
  45219. points: Vector3[];
  45220. updatable?: boolean;
  45221. instance?: Nullable<LinesMesh>;
  45222. colors?: Color4[];
  45223. useVertexAlpha?: boolean;
  45224. }, scene?: Nullable<Scene>): LinesMesh;
  45225. /**
  45226. * Creates a dashed line mesh
  45227. * * 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
  45228. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45229. * * The parameter `points` is an array successive Vector3
  45230. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45231. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45232. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45233. * * 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
  45234. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45235. * * When updating an instance, remember that only point positions can change, not the number of points
  45236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45237. * @param name defines the name of the mesh
  45238. * @param options defines the options used to create the mesh
  45239. * @param scene defines the hosting scene
  45240. * @returns the dashed line mesh
  45241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45242. */
  45243. static CreateDashedLines(name: string, options: {
  45244. points: Vector3[];
  45245. dashSize?: number;
  45246. gapSize?: number;
  45247. dashNb?: number;
  45248. updatable?: boolean;
  45249. instance?: LinesMesh;
  45250. useVertexAlpha?: boolean;
  45251. }, scene?: Nullable<Scene>): LinesMesh;
  45252. }
  45253. }
  45254. declare module BABYLON {
  45255. /**
  45256. * The options container for the teleportation module
  45257. */
  45258. export interface IWebXRTeleportationOptions {
  45259. /**
  45260. * if provided, this scene will be used to render meshes.
  45261. */
  45262. customUtilityLayerScene?: Scene;
  45263. /**
  45264. * Values to configure the default target mesh
  45265. */
  45266. defaultTargetMeshOptions?: {
  45267. /**
  45268. * Fill color of the teleportation area
  45269. */
  45270. teleportationFillColor?: string;
  45271. /**
  45272. * Border color for the teleportation area
  45273. */
  45274. teleportationBorderColor?: string;
  45275. /**
  45276. * Disable the mesh's animation sequence
  45277. */
  45278. disableAnimation?: boolean;
  45279. /**
  45280. * Disable lighting on the material or the ring and arrow
  45281. */
  45282. disableLighting?: boolean;
  45283. /**
  45284. * Override the default material of the torus and arrow
  45285. */
  45286. torusArrowMaterial?: Material;
  45287. };
  45288. /**
  45289. * A list of meshes to use as floor meshes.
  45290. * Meshes can be added and removed after initializing the feature using the
  45291. * addFloorMesh and removeFloorMesh functions
  45292. * If empty, rotation will still work
  45293. */
  45294. floorMeshes?: AbstractMesh[];
  45295. /**
  45296. * use this rendering group id for the meshes (optional)
  45297. */
  45298. renderingGroupId?: number;
  45299. /**
  45300. * Should teleportation move only to snap points
  45301. */
  45302. snapPointsOnly?: boolean;
  45303. /**
  45304. * An array of points to which the teleportation will snap to.
  45305. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45306. */
  45307. snapPositions?: Vector3[];
  45308. /**
  45309. * How close should the teleportation ray be in order to snap to position.
  45310. * Default to 0.8 units (meters)
  45311. */
  45312. snapToPositionRadius?: number;
  45313. /**
  45314. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45315. * If you want to support rotation, make sure your mesh has a direction indicator.
  45316. *
  45317. * When left untouched, the default mesh will be initialized.
  45318. */
  45319. teleportationTargetMesh?: AbstractMesh;
  45320. /**
  45321. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45322. */
  45323. timeToTeleport?: number;
  45324. /**
  45325. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45326. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45327. */
  45328. useMainComponentOnly?: boolean;
  45329. /**
  45330. * Should meshes created here be added to a utility layer or the main scene
  45331. */
  45332. useUtilityLayer?: boolean;
  45333. /**
  45334. * Babylon XR Input class for controller
  45335. */
  45336. xrInput: WebXRInput;
  45337. }
  45338. /**
  45339. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45340. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45341. * the input of the attached controllers.
  45342. */
  45343. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45344. private _options;
  45345. private _controllers;
  45346. private _currentTeleportationControllerId;
  45347. private _floorMeshes;
  45348. private _quadraticBezierCurve;
  45349. private _selectionFeature;
  45350. private _snapToPositions;
  45351. private _snappedToPoint;
  45352. private _teleportationRingMaterial?;
  45353. private _tmpRay;
  45354. private _tmpVector;
  45355. /**
  45356. * The module's name
  45357. */
  45358. static readonly Name: string;
  45359. /**
  45360. * The (Babylon) version of this module.
  45361. * This is an integer representing the implementation version.
  45362. * This number does not correspond to the webxr specs version
  45363. */
  45364. static readonly Version: number;
  45365. /**
  45366. * Is movement backwards enabled
  45367. */
  45368. backwardsMovementEnabled: boolean;
  45369. /**
  45370. * Distance to travel when moving backwards
  45371. */
  45372. backwardsTeleportationDistance: number;
  45373. /**
  45374. * The distance from the user to the inspection point in the direction of the controller
  45375. * A higher number will allow the user to move further
  45376. * defaults to 5 (meters, in xr units)
  45377. */
  45378. parabolicCheckRadius: number;
  45379. /**
  45380. * Should the module support parabolic ray on top of direct ray
  45381. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45382. * Very helpful when moving between floors / different heights
  45383. */
  45384. parabolicRayEnabled: boolean;
  45385. /**
  45386. * How much rotation should be applied when rotating right and left
  45387. */
  45388. rotationAngle: number;
  45389. /**
  45390. * Is rotation enabled when moving forward?
  45391. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45392. */
  45393. rotationEnabled: boolean;
  45394. /**
  45395. * constructs a new anchor system
  45396. * @param _xrSessionManager an instance of WebXRSessionManager
  45397. * @param _options configuration object for this feature
  45398. */
  45399. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45400. /**
  45401. * Get the snapPointsOnly flag
  45402. */
  45403. get snapPointsOnly(): boolean;
  45404. /**
  45405. * Sets the snapPointsOnly flag
  45406. * @param snapToPoints should teleportation be exclusively to snap points
  45407. */
  45408. set snapPointsOnly(snapToPoints: boolean);
  45409. /**
  45410. * Add a new mesh to the floor meshes array
  45411. * @param mesh the mesh to use as floor mesh
  45412. */
  45413. addFloorMesh(mesh: AbstractMesh): void;
  45414. /**
  45415. * Add a new snap-to point to fix teleportation to this position
  45416. * @param newSnapPoint The new Snap-To point
  45417. */
  45418. addSnapPoint(newSnapPoint: Vector3): void;
  45419. attach(): boolean;
  45420. detach(): boolean;
  45421. dispose(): void;
  45422. /**
  45423. * Remove a mesh from the floor meshes array
  45424. * @param mesh the mesh to remove
  45425. */
  45426. removeFloorMesh(mesh: AbstractMesh): void;
  45427. /**
  45428. * Remove a mesh from the floor meshes array using its name
  45429. * @param name the mesh name to remove
  45430. */
  45431. removeFloorMeshByName(name: string): void;
  45432. /**
  45433. * 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
  45434. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45435. * @returns was the point found and removed or not
  45436. */
  45437. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45438. /**
  45439. * This function sets a selection feature that will be disabled when
  45440. * the forward ray is shown and will be reattached when hidden.
  45441. * This is used to remove the selection rays when moving.
  45442. * @param selectionFeature the feature to disable when forward movement is enabled
  45443. */
  45444. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45445. protected _onXRFrame(_xrFrame: XRFrame): void;
  45446. private _attachController;
  45447. private _createDefaultTargetMesh;
  45448. private _detachController;
  45449. private _findClosestSnapPointWithRadius;
  45450. private _setTargetMeshPosition;
  45451. private _setTargetMeshVisibility;
  45452. private _showParabolicPath;
  45453. private _teleportForward;
  45454. }
  45455. }
  45456. declare module BABYLON {
  45457. /**
  45458. * Options for the default xr helper
  45459. */
  45460. export class WebXRDefaultExperienceOptions {
  45461. /**
  45462. * Enable or disable default UI to enter XR
  45463. */
  45464. disableDefaultUI?: boolean;
  45465. /**
  45466. * Should teleportation not initialize. defaults to false.
  45467. */
  45468. disableTeleportation?: boolean;
  45469. /**
  45470. * Floor meshes that will be used for teleport
  45471. */
  45472. floorMeshes?: Array<AbstractMesh>;
  45473. /**
  45474. * If set to true, the first frame will not be used to reset position
  45475. * The first frame is mainly used when copying transformation from the old camera
  45476. * Mainly used in AR
  45477. */
  45478. ignoreNativeCameraTransformation?: boolean;
  45479. /**
  45480. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45481. */
  45482. inputOptions?: IWebXRInputOptions;
  45483. /**
  45484. * optional configuration for the output canvas
  45485. */
  45486. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45487. /**
  45488. * optional UI options. This can be used among other to change session mode and reference space type
  45489. */
  45490. uiOptions?: WebXREnterExitUIOptions;
  45491. /**
  45492. * When loading teleportation and pointer select, use stable versions instead of latest.
  45493. */
  45494. useStablePlugins?: boolean;
  45495. }
  45496. /**
  45497. * Default experience which provides a similar setup to the previous webVRExperience
  45498. */
  45499. export class WebXRDefaultExperience {
  45500. /**
  45501. * Base experience
  45502. */
  45503. baseExperience: WebXRExperienceHelper;
  45504. /**
  45505. * Enables ui for entering/exiting xr
  45506. */
  45507. enterExitUI: WebXREnterExitUI;
  45508. /**
  45509. * Input experience extension
  45510. */
  45511. input: WebXRInput;
  45512. /**
  45513. * Enables laser pointer and selection
  45514. */
  45515. pointerSelection: WebXRControllerPointerSelection;
  45516. /**
  45517. * Default target xr should render to
  45518. */
  45519. renderTarget: WebXRRenderTarget;
  45520. /**
  45521. * Enables teleportation
  45522. */
  45523. teleportation: WebXRMotionControllerTeleportation;
  45524. private constructor();
  45525. /**
  45526. * Creates the default xr experience
  45527. * @param scene scene
  45528. * @param options options for basic configuration
  45529. * @returns resulting WebXRDefaultExperience
  45530. */
  45531. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45532. /**
  45533. * DIsposes of the experience helper
  45534. */
  45535. dispose(): void;
  45536. }
  45537. }
  45538. declare module BABYLON {
  45539. /**
  45540. * Options to modify the vr teleportation behavior.
  45541. */
  45542. export interface VRTeleportationOptions {
  45543. /**
  45544. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45545. */
  45546. floorMeshName?: string;
  45547. /**
  45548. * A list of meshes to be used as the teleportation floor. (default: empty)
  45549. */
  45550. floorMeshes?: Mesh[];
  45551. /**
  45552. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45553. */
  45554. teleportationMode?: number;
  45555. /**
  45556. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45557. */
  45558. teleportationTime?: number;
  45559. /**
  45560. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45561. */
  45562. teleportationSpeed?: number;
  45563. /**
  45564. * The easing function used in the animation or null for Linear. (default CircleEase)
  45565. */
  45566. easingFunction?: EasingFunction;
  45567. }
  45568. /**
  45569. * Options to modify the vr experience helper's behavior.
  45570. */
  45571. export interface VRExperienceHelperOptions extends WebVROptions {
  45572. /**
  45573. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45574. */
  45575. createDeviceOrientationCamera?: boolean;
  45576. /**
  45577. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45578. */
  45579. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45580. /**
  45581. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45582. */
  45583. laserToggle?: boolean;
  45584. /**
  45585. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45586. */
  45587. floorMeshes?: Mesh[];
  45588. /**
  45589. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45590. */
  45591. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45592. /**
  45593. * Defines if WebXR should be used instead of WebVR (if available)
  45594. */
  45595. useXR?: boolean;
  45596. }
  45597. /**
  45598. * Event containing information after VR has been entered
  45599. */
  45600. export class OnAfterEnteringVRObservableEvent {
  45601. /**
  45602. * If entering vr was successful
  45603. */
  45604. success: boolean;
  45605. }
  45606. /**
  45607. * Helps to quickly add VR support to an existing scene.
  45608. * See http://doc.babylonjs.com/how_to/webvr_helper
  45609. */
  45610. export class VRExperienceHelper {
  45611. /** Options to modify the vr experience helper's behavior. */
  45612. webVROptions: VRExperienceHelperOptions;
  45613. private _scene;
  45614. private _position;
  45615. private _btnVR;
  45616. private _btnVRDisplayed;
  45617. private _webVRsupported;
  45618. private _webVRready;
  45619. private _webVRrequesting;
  45620. private _webVRpresenting;
  45621. private _hasEnteredVR;
  45622. private _fullscreenVRpresenting;
  45623. private _inputElement;
  45624. private _webVRCamera;
  45625. private _vrDeviceOrientationCamera;
  45626. private _deviceOrientationCamera;
  45627. private _existingCamera;
  45628. private _onKeyDown;
  45629. private _onVrDisplayPresentChange;
  45630. private _onVRDisplayChanged;
  45631. private _onVRRequestPresentStart;
  45632. private _onVRRequestPresentComplete;
  45633. /**
  45634. * 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)
  45635. */
  45636. enableGazeEvenWhenNoPointerLock: boolean;
  45637. /**
  45638. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45639. */
  45640. exitVROnDoubleTap: boolean;
  45641. /**
  45642. * Observable raised right before entering VR.
  45643. */
  45644. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45645. /**
  45646. * Observable raised when entering VR has completed.
  45647. */
  45648. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45649. /**
  45650. * Observable raised when exiting VR.
  45651. */
  45652. onExitingVRObservable: Observable<VRExperienceHelper>;
  45653. /**
  45654. * Observable raised when controller mesh is loaded.
  45655. */
  45656. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45657. /** Return this.onEnteringVRObservable
  45658. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45659. */
  45660. get onEnteringVR(): Observable<VRExperienceHelper>;
  45661. /** Return this.onExitingVRObservable
  45662. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45663. */
  45664. get onExitingVR(): Observable<VRExperienceHelper>;
  45665. /** Return this.onControllerMeshLoadedObservable
  45666. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45667. */
  45668. get onControllerMeshLoaded(): Observable<WebVRController>;
  45669. private _rayLength;
  45670. private _useCustomVRButton;
  45671. private _teleportationRequested;
  45672. private _teleportActive;
  45673. private _floorMeshName;
  45674. private _floorMeshesCollection;
  45675. private _teleportationMode;
  45676. private _teleportationTime;
  45677. private _teleportationSpeed;
  45678. private _teleportationEasing;
  45679. private _rotationAllowed;
  45680. private _teleportBackwardsVector;
  45681. private _teleportationTarget;
  45682. private _isDefaultTeleportationTarget;
  45683. private _postProcessMove;
  45684. private _teleportationFillColor;
  45685. private _teleportationBorderColor;
  45686. private _rotationAngle;
  45687. private _haloCenter;
  45688. private _cameraGazer;
  45689. private _padSensibilityUp;
  45690. private _padSensibilityDown;
  45691. private _leftController;
  45692. private _rightController;
  45693. private _gazeColor;
  45694. private _laserColor;
  45695. private _pickedLaserColor;
  45696. private _pickedGazeColor;
  45697. /**
  45698. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45699. */
  45700. onNewMeshSelected: Observable<AbstractMesh>;
  45701. /**
  45702. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45703. * This observable will provide the mesh and the controller used to select the mesh
  45704. */
  45705. onMeshSelectedWithController: Observable<{
  45706. mesh: AbstractMesh;
  45707. controller: WebVRController;
  45708. }>;
  45709. /**
  45710. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45711. */
  45712. onNewMeshPicked: Observable<PickingInfo>;
  45713. private _circleEase;
  45714. /**
  45715. * Observable raised before camera teleportation
  45716. */
  45717. onBeforeCameraTeleport: Observable<Vector3>;
  45718. /**
  45719. * Observable raised after camera teleportation
  45720. */
  45721. onAfterCameraTeleport: Observable<Vector3>;
  45722. /**
  45723. * Observable raised when current selected mesh gets unselected
  45724. */
  45725. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45726. private _raySelectionPredicate;
  45727. /**
  45728. * To be optionaly changed by user to define custom ray selection
  45729. */
  45730. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45731. /**
  45732. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45733. */
  45734. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45735. /**
  45736. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45737. */
  45738. teleportationEnabled: boolean;
  45739. private _defaultHeight;
  45740. private _teleportationInitialized;
  45741. private _interactionsEnabled;
  45742. private _interactionsRequested;
  45743. private _displayGaze;
  45744. private _displayLaserPointer;
  45745. /**
  45746. * The mesh used to display where the user is going to teleport.
  45747. */
  45748. get teleportationTarget(): Mesh;
  45749. /**
  45750. * Sets the mesh to be used to display where the user is going to teleport.
  45751. */
  45752. set teleportationTarget(value: Mesh);
  45753. /**
  45754. * 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
  45755. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45756. * See http://doc.babylonjs.com/resources/baking_transformations
  45757. */
  45758. get gazeTrackerMesh(): Mesh;
  45759. set gazeTrackerMesh(value: Mesh);
  45760. /**
  45761. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45762. */
  45763. updateGazeTrackerScale: boolean;
  45764. /**
  45765. * If the gaze trackers color should be updated when selecting meshes
  45766. */
  45767. updateGazeTrackerColor: boolean;
  45768. /**
  45769. * If the controller laser color should be updated when selecting meshes
  45770. */
  45771. updateControllerLaserColor: boolean;
  45772. /**
  45773. * The gaze tracking mesh corresponding to the left controller
  45774. */
  45775. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45776. /**
  45777. * The gaze tracking mesh corresponding to the right controller
  45778. */
  45779. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45780. /**
  45781. * If the ray of the gaze should be displayed.
  45782. */
  45783. get displayGaze(): boolean;
  45784. /**
  45785. * Sets if the ray of the gaze should be displayed.
  45786. */
  45787. set displayGaze(value: boolean);
  45788. /**
  45789. * If the ray of the LaserPointer should be displayed.
  45790. */
  45791. get displayLaserPointer(): boolean;
  45792. /**
  45793. * Sets if the ray of the LaserPointer should be displayed.
  45794. */
  45795. set displayLaserPointer(value: boolean);
  45796. /**
  45797. * The deviceOrientationCamera used as the camera when not in VR.
  45798. */
  45799. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45800. /**
  45801. * Based on the current WebVR support, returns the current VR camera used.
  45802. */
  45803. get currentVRCamera(): Nullable<Camera>;
  45804. /**
  45805. * The webVRCamera which is used when in VR.
  45806. */
  45807. get webVRCamera(): WebVRFreeCamera;
  45808. /**
  45809. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45810. */
  45811. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45812. /**
  45813. * The html button that is used to trigger entering into VR.
  45814. */
  45815. get vrButton(): Nullable<HTMLButtonElement>;
  45816. private get _teleportationRequestInitiated();
  45817. /**
  45818. * Defines whether or not Pointer lock should be requested when switching to
  45819. * full screen.
  45820. */
  45821. requestPointerLockOnFullScreen: boolean;
  45822. /**
  45823. * If asking to force XR, this will be populated with the default xr experience
  45824. */
  45825. xr: WebXRDefaultExperience;
  45826. /**
  45827. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45828. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45829. */
  45830. xrTestDone: boolean;
  45831. /**
  45832. * Instantiates a VRExperienceHelper.
  45833. * Helps to quickly add VR support to an existing scene.
  45834. * @param scene The scene the VRExperienceHelper belongs to.
  45835. * @param webVROptions Options to modify the vr experience helper's behavior.
  45836. */
  45837. constructor(scene: Scene,
  45838. /** Options to modify the vr experience helper's behavior. */
  45839. webVROptions?: VRExperienceHelperOptions);
  45840. private completeVRInit;
  45841. private _onDefaultMeshLoaded;
  45842. private _onResize;
  45843. private _onFullscreenChange;
  45844. /**
  45845. * Gets a value indicating if we are currently in VR mode.
  45846. */
  45847. get isInVRMode(): boolean;
  45848. private onVrDisplayPresentChange;
  45849. private onVRDisplayChanged;
  45850. private moveButtonToBottomRight;
  45851. private displayVRButton;
  45852. private updateButtonVisibility;
  45853. private _cachedAngularSensibility;
  45854. /**
  45855. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45856. * Otherwise, will use the fullscreen API.
  45857. */
  45858. enterVR(): void;
  45859. /**
  45860. * Attempt to exit VR, or fullscreen.
  45861. */
  45862. exitVR(): void;
  45863. /**
  45864. * The position of the vr experience helper.
  45865. */
  45866. get position(): Vector3;
  45867. /**
  45868. * Sets the position of the vr experience helper.
  45869. */
  45870. set position(value: Vector3);
  45871. /**
  45872. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45873. */
  45874. enableInteractions(): void;
  45875. private get _noControllerIsActive();
  45876. private beforeRender;
  45877. private _isTeleportationFloor;
  45878. /**
  45879. * Adds a floor mesh to be used for teleportation.
  45880. * @param floorMesh the mesh to be used for teleportation.
  45881. */
  45882. addFloorMesh(floorMesh: Mesh): void;
  45883. /**
  45884. * Removes a floor mesh from being used for teleportation.
  45885. * @param floorMesh the mesh to be removed.
  45886. */
  45887. removeFloorMesh(floorMesh: Mesh): void;
  45888. /**
  45889. * Enables interactions and teleportation using the VR controllers and gaze.
  45890. * @param vrTeleportationOptions options to modify teleportation behavior.
  45891. */
  45892. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45893. private _onNewGamepadConnected;
  45894. private _tryEnableInteractionOnController;
  45895. private _onNewGamepadDisconnected;
  45896. private _enableInteractionOnController;
  45897. private _checkTeleportWithRay;
  45898. private _checkRotate;
  45899. private _checkTeleportBackwards;
  45900. private _enableTeleportationOnController;
  45901. private _createTeleportationCircles;
  45902. private _displayTeleportationTarget;
  45903. private _hideTeleportationTarget;
  45904. private _rotateCamera;
  45905. private _moveTeleportationSelectorTo;
  45906. private _workingVector;
  45907. private _workingQuaternion;
  45908. private _workingMatrix;
  45909. /**
  45910. * Time Constant Teleportation Mode
  45911. */
  45912. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45913. /**
  45914. * Speed Constant Teleportation Mode
  45915. */
  45916. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45917. /**
  45918. * Teleports the users feet to the desired location
  45919. * @param location The location where the user's feet should be placed
  45920. */
  45921. teleportCamera(location: Vector3): void;
  45922. private _convertNormalToDirectionOfRay;
  45923. private _castRayAndSelectObject;
  45924. private _notifySelectedMeshUnselected;
  45925. /**
  45926. * Permanently set new colors for the laser pointer
  45927. * @param color the new laser color
  45928. * @param pickedColor the new laser color when picked mesh detected
  45929. */
  45930. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45931. /**
  45932. * Set lighting enabled / disabled on the laser pointer of both controllers
  45933. * @param enabled should the lighting be enabled on the laser pointer
  45934. */
  45935. setLaserLightingState(enabled?: boolean): void;
  45936. /**
  45937. * Permanently set new colors for the gaze pointer
  45938. * @param color the new gaze color
  45939. * @param pickedColor the new gaze color when picked mesh detected
  45940. */
  45941. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45942. /**
  45943. * Sets the color of the laser ray from the vr controllers.
  45944. * @param color new color for the ray.
  45945. */
  45946. changeLaserColor(color: Color3): void;
  45947. /**
  45948. * Sets the color of the ray from the vr headsets gaze.
  45949. * @param color new color for the ray.
  45950. */
  45951. changeGazeColor(color: Color3): void;
  45952. /**
  45953. * Exits VR and disposes of the vr experience helper
  45954. */
  45955. dispose(): void;
  45956. /**
  45957. * Gets the name of the VRExperienceHelper class
  45958. * @returns "VRExperienceHelper"
  45959. */
  45960. getClassName(): string;
  45961. }
  45962. }
  45963. declare module BABYLON {
  45964. /**
  45965. * Contains an array of blocks representing the octree
  45966. */
  45967. export interface IOctreeContainer<T> {
  45968. /**
  45969. * Blocks within the octree
  45970. */
  45971. blocks: Array<OctreeBlock<T>>;
  45972. }
  45973. /**
  45974. * Class used to store a cell in an octree
  45975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45976. */
  45977. export class OctreeBlock<T> {
  45978. /**
  45979. * Gets the content of the current block
  45980. */
  45981. entries: T[];
  45982. /**
  45983. * Gets the list of block children
  45984. */
  45985. blocks: Array<OctreeBlock<T>>;
  45986. private _depth;
  45987. private _maxDepth;
  45988. private _capacity;
  45989. private _minPoint;
  45990. private _maxPoint;
  45991. private _boundingVectors;
  45992. private _creationFunc;
  45993. /**
  45994. * Creates a new block
  45995. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45996. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45997. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45998. * @param depth defines the current depth of this block in the octree
  45999. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46000. * @param creationFunc defines a callback to call when an element is added to the block
  46001. */
  46002. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46003. /**
  46004. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46005. */
  46006. get capacity(): number;
  46007. /**
  46008. * Gets the minimum vector (in world space) of the block's bounding box
  46009. */
  46010. get minPoint(): Vector3;
  46011. /**
  46012. * Gets the maximum vector (in world space) of the block's bounding box
  46013. */
  46014. get maxPoint(): Vector3;
  46015. /**
  46016. * Add a new element to this block
  46017. * @param entry defines the element to add
  46018. */
  46019. addEntry(entry: T): void;
  46020. /**
  46021. * Remove an element from this block
  46022. * @param entry defines the element to remove
  46023. */
  46024. removeEntry(entry: T): void;
  46025. /**
  46026. * Add an array of elements to this block
  46027. * @param entries defines the array of elements to add
  46028. */
  46029. addEntries(entries: T[]): void;
  46030. /**
  46031. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46032. * @param frustumPlanes defines the frustum planes to test
  46033. * @param selection defines the array to store current content if selection is positive
  46034. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46035. */
  46036. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46037. /**
  46038. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46039. * @param sphereCenter defines the bounding sphere center
  46040. * @param sphereRadius defines the bounding sphere radius
  46041. * @param selection defines the array to store current content if selection is positive
  46042. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46043. */
  46044. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46045. /**
  46046. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46047. * @param ray defines the ray to test with
  46048. * @param selection defines the array to store current content if selection is positive
  46049. */
  46050. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46051. /**
  46052. * Subdivide the content into child blocks (this block will then be empty)
  46053. */
  46054. createInnerBlocks(): void;
  46055. /**
  46056. * @hidden
  46057. */
  46058. 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;
  46059. }
  46060. }
  46061. declare module BABYLON {
  46062. /**
  46063. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46064. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46065. */
  46066. export class Octree<T> {
  46067. /** 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.) */
  46068. maxDepth: number;
  46069. /**
  46070. * Blocks within the octree containing objects
  46071. */
  46072. blocks: Array<OctreeBlock<T>>;
  46073. /**
  46074. * Content stored in the octree
  46075. */
  46076. dynamicContent: T[];
  46077. private _maxBlockCapacity;
  46078. private _selectionContent;
  46079. private _creationFunc;
  46080. /**
  46081. * Creates a octree
  46082. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46083. * @param creationFunc function to be used to instatiate the octree
  46084. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46085. * @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.)
  46086. */
  46087. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46088. /** 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.) */
  46089. maxDepth?: number);
  46090. /**
  46091. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46092. * @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);
  46093. * @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);
  46094. * @param entries meshes to be added to the octree blocks
  46095. */
  46096. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46097. /**
  46098. * Adds a mesh to the octree
  46099. * @param entry Mesh to add to the octree
  46100. */
  46101. addMesh(entry: T): void;
  46102. /**
  46103. * Remove an element from the octree
  46104. * @param entry defines the element to remove
  46105. */
  46106. removeMesh(entry: T): void;
  46107. /**
  46108. * Selects an array of meshes within the frustum
  46109. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46110. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46111. * @returns array of meshes within the frustum
  46112. */
  46113. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46114. /**
  46115. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46116. * @param sphereCenter defines the bounding sphere center
  46117. * @param sphereRadius defines the bounding sphere radius
  46118. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46119. * @returns an array of objects that intersect the sphere
  46120. */
  46121. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46122. /**
  46123. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46124. * @param ray defines the ray to test with
  46125. * @returns array of intersected objects
  46126. */
  46127. intersectsRay(ray: Ray): SmartArray<T>;
  46128. /**
  46129. * Adds a mesh into the octree block if it intersects the block
  46130. */
  46131. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46132. /**
  46133. * Adds a submesh into the octree block if it intersects the block
  46134. */
  46135. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46136. }
  46137. }
  46138. declare module BABYLON {
  46139. interface Scene {
  46140. /**
  46141. * @hidden
  46142. * Backing Filed
  46143. */
  46144. _selectionOctree: Octree<AbstractMesh>;
  46145. /**
  46146. * Gets the octree used to boost mesh selection (picking)
  46147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46148. */
  46149. selectionOctree: Octree<AbstractMesh>;
  46150. /**
  46151. * Creates or updates the octree used to boost selection (picking)
  46152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46153. * @param maxCapacity defines the maximum capacity per leaf
  46154. * @param maxDepth defines the maximum depth of the octree
  46155. * @returns an octree of AbstractMesh
  46156. */
  46157. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46158. }
  46159. interface AbstractMesh {
  46160. /**
  46161. * @hidden
  46162. * Backing Field
  46163. */
  46164. _submeshesOctree: Octree<SubMesh>;
  46165. /**
  46166. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46167. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46168. * @param maxCapacity defines the maximum size of each block (64 by default)
  46169. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46170. * @returns the new octree
  46171. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46173. */
  46174. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46175. }
  46176. /**
  46177. * Defines the octree scene component responsible to manage any octrees
  46178. * in a given scene.
  46179. */
  46180. export class OctreeSceneComponent {
  46181. /**
  46182. * The component name help to identify the component in the list of scene components.
  46183. */
  46184. readonly name: string;
  46185. /**
  46186. * The scene the component belongs to.
  46187. */
  46188. scene: Scene;
  46189. /**
  46190. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46191. */
  46192. readonly checksIsEnabled: boolean;
  46193. /**
  46194. * Creates a new instance of the component for the given scene
  46195. * @param scene Defines the scene to register the component in
  46196. */
  46197. constructor(scene: Scene);
  46198. /**
  46199. * Registers the component in a given scene
  46200. */
  46201. register(): void;
  46202. /**
  46203. * Return the list of active meshes
  46204. * @returns the list of active meshes
  46205. */
  46206. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46207. /**
  46208. * Return the list of active sub meshes
  46209. * @param mesh The mesh to get the candidates sub meshes from
  46210. * @returns the list of active sub meshes
  46211. */
  46212. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46213. private _tempRay;
  46214. /**
  46215. * Return the list of sub meshes intersecting with a given local ray
  46216. * @param mesh defines the mesh to find the submesh for
  46217. * @param localRay defines the ray in local space
  46218. * @returns the list of intersecting sub meshes
  46219. */
  46220. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46221. /**
  46222. * Return the list of sub meshes colliding with a collider
  46223. * @param mesh defines the mesh to find the submesh for
  46224. * @param collider defines the collider to evaluate the collision against
  46225. * @returns the list of colliding sub meshes
  46226. */
  46227. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46228. /**
  46229. * Rebuilds the elements related to this component in case of
  46230. * context lost for instance.
  46231. */
  46232. rebuild(): void;
  46233. /**
  46234. * Disposes the component and the associated ressources.
  46235. */
  46236. dispose(): void;
  46237. }
  46238. }
  46239. declare module BABYLON {
  46240. /**
  46241. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46242. */
  46243. export class Gizmo implements IDisposable {
  46244. /** The utility layer the gizmo will be added to */
  46245. gizmoLayer: UtilityLayerRenderer;
  46246. /**
  46247. * The root mesh of the gizmo
  46248. */
  46249. _rootMesh: Mesh;
  46250. private _attachedMesh;
  46251. /**
  46252. * Ratio for the scale of the gizmo (Default: 1)
  46253. */
  46254. scaleRatio: number;
  46255. /**
  46256. * If a custom mesh has been set (Default: false)
  46257. */
  46258. protected _customMeshSet: boolean;
  46259. /**
  46260. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46261. * * When set, interactions will be enabled
  46262. */
  46263. get attachedMesh(): Nullable<AbstractMesh>;
  46264. set attachedMesh(value: Nullable<AbstractMesh>);
  46265. /**
  46266. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46267. * @param mesh The mesh to replace the default mesh of the gizmo
  46268. */
  46269. setCustomMesh(mesh: Mesh): void;
  46270. /**
  46271. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46272. */
  46273. updateGizmoRotationToMatchAttachedMesh: boolean;
  46274. /**
  46275. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46276. */
  46277. updateGizmoPositionToMatchAttachedMesh: boolean;
  46278. /**
  46279. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46280. */
  46281. updateScale: boolean;
  46282. protected _interactionsEnabled: boolean;
  46283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46284. private _beforeRenderObserver;
  46285. private _tempVector;
  46286. /**
  46287. * Creates a gizmo
  46288. * @param gizmoLayer The utility layer the gizmo will be added to
  46289. */
  46290. constructor(
  46291. /** The utility layer the gizmo will be added to */
  46292. gizmoLayer?: UtilityLayerRenderer);
  46293. /**
  46294. * Updates the gizmo to match the attached mesh's position/rotation
  46295. */
  46296. protected _update(): void;
  46297. /**
  46298. * Disposes of the gizmo
  46299. */
  46300. dispose(): void;
  46301. }
  46302. }
  46303. declare module BABYLON {
  46304. /**
  46305. * Single plane drag gizmo
  46306. */
  46307. export class PlaneDragGizmo extends Gizmo {
  46308. /**
  46309. * Drag behavior responsible for the gizmos dragging interactions
  46310. */
  46311. dragBehavior: PointerDragBehavior;
  46312. private _pointerObserver;
  46313. /**
  46314. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46315. */
  46316. snapDistance: number;
  46317. /**
  46318. * Event that fires each time the gizmo snaps to a new location.
  46319. * * snapDistance is the the change in distance
  46320. */
  46321. onSnapObservable: Observable<{
  46322. snapDistance: number;
  46323. }>;
  46324. private _plane;
  46325. private _coloredMaterial;
  46326. private _hoverMaterial;
  46327. private _isEnabled;
  46328. private _parent;
  46329. /** @hidden */
  46330. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46331. /** @hidden */
  46332. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46333. /**
  46334. * Creates a PlaneDragGizmo
  46335. * @param gizmoLayer The utility layer the gizmo will be added to
  46336. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46337. * @param color The color of the gizmo
  46338. */
  46339. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46340. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46341. /**
  46342. * If the gizmo is enabled
  46343. */
  46344. set isEnabled(value: boolean);
  46345. get isEnabled(): boolean;
  46346. /**
  46347. * Disposes of the gizmo
  46348. */
  46349. dispose(): void;
  46350. }
  46351. }
  46352. declare module BABYLON {
  46353. /**
  46354. * Gizmo that enables dragging a mesh along 3 axis
  46355. */
  46356. export class PositionGizmo extends Gizmo {
  46357. /**
  46358. * Internal gizmo used for interactions on the x axis
  46359. */
  46360. xGizmo: AxisDragGizmo;
  46361. /**
  46362. * Internal gizmo used for interactions on the y axis
  46363. */
  46364. yGizmo: AxisDragGizmo;
  46365. /**
  46366. * Internal gizmo used for interactions on the z axis
  46367. */
  46368. zGizmo: AxisDragGizmo;
  46369. /**
  46370. * Internal gizmo used for interactions on the yz plane
  46371. */
  46372. xPlaneGizmo: PlaneDragGizmo;
  46373. /**
  46374. * Internal gizmo used for interactions on the xz plane
  46375. */
  46376. yPlaneGizmo: PlaneDragGizmo;
  46377. /**
  46378. * Internal gizmo used for interactions on the xy plane
  46379. */
  46380. zPlaneGizmo: PlaneDragGizmo;
  46381. /**
  46382. * private variables
  46383. */
  46384. private _meshAttached;
  46385. private _updateGizmoRotationToMatchAttachedMesh;
  46386. private _snapDistance;
  46387. private _scaleRatio;
  46388. /** Fires an event when any of it's sub gizmos are dragged */
  46389. onDragStartObservable: Observable<unknown>;
  46390. /** Fires an event when any of it's sub gizmos are released from dragging */
  46391. onDragEndObservable: Observable<unknown>;
  46392. /**
  46393. * If set to true, planar drag is enabled
  46394. */
  46395. private _planarGizmoEnabled;
  46396. get attachedMesh(): Nullable<AbstractMesh>;
  46397. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46398. /**
  46399. * Creates a PositionGizmo
  46400. * @param gizmoLayer The utility layer the gizmo will be added to
  46401. */
  46402. constructor(gizmoLayer?: UtilityLayerRenderer);
  46403. /**
  46404. * If the planar drag gizmo is enabled
  46405. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46406. */
  46407. set planarGizmoEnabled(value: boolean);
  46408. get planarGizmoEnabled(): boolean;
  46409. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46410. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46411. /**
  46412. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46413. */
  46414. set snapDistance(value: number);
  46415. get snapDistance(): number;
  46416. /**
  46417. * Ratio for the scale of the gizmo (Default: 1)
  46418. */
  46419. set scaleRatio(value: number);
  46420. get scaleRatio(): number;
  46421. /**
  46422. * Disposes of the gizmo
  46423. */
  46424. dispose(): void;
  46425. /**
  46426. * CustomMeshes are not supported by this gizmo
  46427. * @param mesh The mesh to replace the default mesh of the gizmo
  46428. */
  46429. setCustomMesh(mesh: Mesh): void;
  46430. }
  46431. }
  46432. declare module BABYLON {
  46433. /**
  46434. * Single axis drag gizmo
  46435. */
  46436. export class AxisDragGizmo extends Gizmo {
  46437. /**
  46438. * Drag behavior responsible for the gizmos dragging interactions
  46439. */
  46440. dragBehavior: PointerDragBehavior;
  46441. private _pointerObserver;
  46442. /**
  46443. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46444. */
  46445. snapDistance: number;
  46446. /**
  46447. * Event that fires each time the gizmo snaps to a new location.
  46448. * * snapDistance is the the change in distance
  46449. */
  46450. onSnapObservable: Observable<{
  46451. snapDistance: number;
  46452. }>;
  46453. private _isEnabled;
  46454. private _parent;
  46455. private _arrow;
  46456. private _coloredMaterial;
  46457. private _hoverMaterial;
  46458. /** @hidden */
  46459. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46460. /** @hidden */
  46461. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46462. /**
  46463. * Creates an AxisDragGizmo
  46464. * @param gizmoLayer The utility layer the gizmo will be added to
  46465. * @param dragAxis The axis which the gizmo will be able to drag on
  46466. * @param color The color of the gizmo
  46467. */
  46468. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46469. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46470. /**
  46471. * If the gizmo is enabled
  46472. */
  46473. set isEnabled(value: boolean);
  46474. get isEnabled(): boolean;
  46475. /**
  46476. * Disposes of the gizmo
  46477. */
  46478. dispose(): void;
  46479. }
  46480. }
  46481. declare module BABYLON.Debug {
  46482. /**
  46483. * The Axes viewer will show 3 axes in a specific point in space
  46484. */
  46485. export class AxesViewer {
  46486. private _xAxis;
  46487. private _yAxis;
  46488. private _zAxis;
  46489. private _scaleLinesFactor;
  46490. private _instanced;
  46491. /**
  46492. * Gets the hosting scene
  46493. */
  46494. scene: Scene;
  46495. /**
  46496. * Gets or sets a number used to scale line length
  46497. */
  46498. scaleLines: number;
  46499. /** Gets the node hierarchy used to render x-axis */
  46500. get xAxis(): TransformNode;
  46501. /** Gets the node hierarchy used to render y-axis */
  46502. get yAxis(): TransformNode;
  46503. /** Gets the node hierarchy used to render z-axis */
  46504. get zAxis(): TransformNode;
  46505. /**
  46506. * Creates a new AxesViewer
  46507. * @param scene defines the hosting scene
  46508. * @param scaleLines defines a number used to scale line length (1 by default)
  46509. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46510. * @param xAxis defines the node hierarchy used to render the x-axis
  46511. * @param yAxis defines the node hierarchy used to render the y-axis
  46512. * @param zAxis defines the node hierarchy used to render the z-axis
  46513. */
  46514. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46515. /**
  46516. * Force the viewer to update
  46517. * @param position defines the position of the viewer
  46518. * @param xaxis defines the x axis of the viewer
  46519. * @param yaxis defines the y axis of the viewer
  46520. * @param zaxis defines the z axis of the viewer
  46521. */
  46522. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46523. /**
  46524. * Creates an instance of this axes viewer.
  46525. * @returns a new axes viewer with instanced meshes
  46526. */
  46527. createInstance(): AxesViewer;
  46528. /** Releases resources */
  46529. dispose(): void;
  46530. private static _SetRenderingGroupId;
  46531. }
  46532. }
  46533. declare module BABYLON.Debug {
  46534. /**
  46535. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46536. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46537. */
  46538. export class BoneAxesViewer extends AxesViewer {
  46539. /**
  46540. * Gets or sets the target mesh where to display the axes viewer
  46541. */
  46542. mesh: Nullable<Mesh>;
  46543. /**
  46544. * Gets or sets the target bone where to display the axes viewer
  46545. */
  46546. bone: Nullable<Bone>;
  46547. /** Gets current position */
  46548. pos: Vector3;
  46549. /** Gets direction of X axis */
  46550. xaxis: Vector3;
  46551. /** Gets direction of Y axis */
  46552. yaxis: Vector3;
  46553. /** Gets direction of Z axis */
  46554. zaxis: Vector3;
  46555. /**
  46556. * Creates a new BoneAxesViewer
  46557. * @param scene defines the hosting scene
  46558. * @param bone defines the target bone
  46559. * @param mesh defines the target mesh
  46560. * @param scaleLines defines a scaling factor for line length (1 by default)
  46561. */
  46562. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46563. /**
  46564. * Force the viewer to update
  46565. */
  46566. update(): void;
  46567. /** Releases resources */
  46568. dispose(): void;
  46569. }
  46570. }
  46571. declare module BABYLON {
  46572. /**
  46573. * Interface used to define scene explorer extensibility option
  46574. */
  46575. export interface IExplorerExtensibilityOption {
  46576. /**
  46577. * Define the option label
  46578. */
  46579. label: string;
  46580. /**
  46581. * Defines the action to execute on click
  46582. */
  46583. action: (entity: any) => void;
  46584. }
  46585. /**
  46586. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46587. */
  46588. export interface IExplorerExtensibilityGroup {
  46589. /**
  46590. * Defines a predicate to test if a given type mut be extended
  46591. */
  46592. predicate: (entity: any) => boolean;
  46593. /**
  46594. * Gets the list of options added to a type
  46595. */
  46596. entries: IExplorerExtensibilityOption[];
  46597. }
  46598. /**
  46599. * Interface used to define the options to use to create the Inspector
  46600. */
  46601. export interface IInspectorOptions {
  46602. /**
  46603. * Display in overlay mode (default: false)
  46604. */
  46605. overlay?: boolean;
  46606. /**
  46607. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46608. */
  46609. globalRoot?: HTMLElement;
  46610. /**
  46611. * Display the Scene explorer
  46612. */
  46613. showExplorer?: boolean;
  46614. /**
  46615. * Display the property inspector
  46616. */
  46617. showInspector?: boolean;
  46618. /**
  46619. * Display in embed mode (both panes on the right)
  46620. */
  46621. embedMode?: boolean;
  46622. /**
  46623. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46624. */
  46625. handleResize?: boolean;
  46626. /**
  46627. * Allow the panes to popup (default: true)
  46628. */
  46629. enablePopup?: boolean;
  46630. /**
  46631. * Allow the panes to be closed by users (default: true)
  46632. */
  46633. enableClose?: boolean;
  46634. /**
  46635. * Optional list of extensibility entries
  46636. */
  46637. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46638. /**
  46639. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46640. */
  46641. inspectorURL?: string;
  46642. /**
  46643. * Optional initial tab (default to DebugLayerTab.Properties)
  46644. */
  46645. initialTab?: DebugLayerTab;
  46646. }
  46647. interface Scene {
  46648. /**
  46649. * @hidden
  46650. * Backing field
  46651. */
  46652. _debugLayer: DebugLayer;
  46653. /**
  46654. * Gets the debug layer (aka Inspector) associated with the scene
  46655. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46656. */
  46657. debugLayer: DebugLayer;
  46658. }
  46659. /**
  46660. * Enum of inspector action tab
  46661. */
  46662. export enum DebugLayerTab {
  46663. /**
  46664. * Properties tag (default)
  46665. */
  46666. Properties = 0,
  46667. /**
  46668. * Debug tab
  46669. */
  46670. Debug = 1,
  46671. /**
  46672. * Statistics tab
  46673. */
  46674. Statistics = 2,
  46675. /**
  46676. * Tools tab
  46677. */
  46678. Tools = 3,
  46679. /**
  46680. * Settings tab
  46681. */
  46682. Settings = 4
  46683. }
  46684. /**
  46685. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46686. * what is happening in your scene
  46687. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46688. */
  46689. export class DebugLayer {
  46690. /**
  46691. * Define the url to get the inspector script from.
  46692. * By default it uses the babylonjs CDN.
  46693. * @ignoreNaming
  46694. */
  46695. static InspectorURL: string;
  46696. private _scene;
  46697. private BJSINSPECTOR;
  46698. private _onPropertyChangedObservable?;
  46699. /**
  46700. * Observable triggered when a property is changed through the inspector.
  46701. */
  46702. get onPropertyChangedObservable(): any;
  46703. /**
  46704. * Instantiates a new debug layer.
  46705. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46706. * what is happening in your scene
  46707. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46708. * @param scene Defines the scene to inspect
  46709. */
  46710. constructor(scene: Scene);
  46711. /** Creates the inspector window. */
  46712. private _createInspector;
  46713. /**
  46714. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46715. * @param entity defines the entity to select
  46716. * @param lineContainerTitle defines the specific block to highlight
  46717. */
  46718. select(entity: any, lineContainerTitle?: string): void;
  46719. /** Get the inspector from bundle or global */
  46720. private _getGlobalInspector;
  46721. /**
  46722. * Get if the inspector is visible or not.
  46723. * @returns true if visible otherwise, false
  46724. */
  46725. isVisible(): boolean;
  46726. /**
  46727. * Hide the inspector and close its window.
  46728. */
  46729. hide(): void;
  46730. /**
  46731. * Launch the debugLayer.
  46732. * @param config Define the configuration of the inspector
  46733. * @return a promise fulfilled when the debug layer is visible
  46734. */
  46735. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46736. }
  46737. }
  46738. declare module BABYLON {
  46739. /**
  46740. * Class containing static functions to help procedurally build meshes
  46741. */
  46742. export class BoxBuilder {
  46743. /**
  46744. * Creates a box mesh
  46745. * * The parameter `size` sets the size (float) of each box side (default 1)
  46746. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46747. * * 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)
  46748. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46750. * * 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
  46751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46752. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46753. * @param name defines the name of the mesh
  46754. * @param options defines the options used to create the mesh
  46755. * @param scene defines the hosting scene
  46756. * @returns the box mesh
  46757. */
  46758. static CreateBox(name: string, options: {
  46759. size?: number;
  46760. width?: number;
  46761. height?: number;
  46762. depth?: number;
  46763. faceUV?: Vector4[];
  46764. faceColors?: Color4[];
  46765. sideOrientation?: number;
  46766. frontUVs?: Vector4;
  46767. backUVs?: Vector4;
  46768. wrap?: boolean;
  46769. topBaseAt?: number;
  46770. bottomBaseAt?: number;
  46771. updatable?: boolean;
  46772. }, scene?: Nullable<Scene>): Mesh;
  46773. }
  46774. }
  46775. declare module BABYLON.Debug {
  46776. /**
  46777. * Used to show the physics impostor around the specific mesh
  46778. */
  46779. export class PhysicsViewer {
  46780. /** @hidden */
  46781. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46782. /** @hidden */
  46783. protected _meshes: Array<Nullable<AbstractMesh>>;
  46784. /** @hidden */
  46785. protected _scene: Nullable<Scene>;
  46786. /** @hidden */
  46787. protected _numMeshes: number;
  46788. /** @hidden */
  46789. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46790. private _renderFunction;
  46791. private _utilityLayer;
  46792. private _debugBoxMesh;
  46793. private _debugSphereMesh;
  46794. private _debugCylinderMesh;
  46795. private _debugMaterial;
  46796. private _debugMeshMeshes;
  46797. /**
  46798. * Creates a new PhysicsViewer
  46799. * @param scene defines the hosting scene
  46800. */
  46801. constructor(scene: Scene);
  46802. /** @hidden */
  46803. protected _updateDebugMeshes(): void;
  46804. /**
  46805. * Renders a specified physic impostor
  46806. * @param impostor defines the impostor to render
  46807. * @param targetMesh defines the mesh represented by the impostor
  46808. * @returns the new debug mesh used to render the impostor
  46809. */
  46810. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46811. /**
  46812. * Hides a specified physic impostor
  46813. * @param impostor defines the impostor to hide
  46814. */
  46815. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46816. private _getDebugMaterial;
  46817. private _getDebugBoxMesh;
  46818. private _getDebugSphereMesh;
  46819. private _getDebugCylinderMesh;
  46820. private _getDebugMeshMesh;
  46821. private _getDebugMesh;
  46822. /** Releases all resources */
  46823. dispose(): void;
  46824. }
  46825. }
  46826. declare module BABYLON {
  46827. /**
  46828. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46829. * in order to better appreciate the issue one might have.
  46830. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46831. */
  46832. export class RayHelper {
  46833. /**
  46834. * Defines the ray we are currently tryin to visualize.
  46835. */
  46836. ray: Nullable<Ray>;
  46837. private _renderPoints;
  46838. private _renderLine;
  46839. private _renderFunction;
  46840. private _scene;
  46841. private _updateToMeshFunction;
  46842. private _attachedToMesh;
  46843. private _meshSpaceDirection;
  46844. private _meshSpaceOrigin;
  46845. /**
  46846. * Helper function to create a colored helper in a scene in one line.
  46847. * @param ray Defines the ray we are currently tryin to visualize
  46848. * @param scene Defines the scene the ray is used in
  46849. * @param color Defines the color we want to see the ray in
  46850. * @returns The newly created ray helper.
  46851. */
  46852. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46853. /**
  46854. * Instantiate a new ray helper.
  46855. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46856. * in order to better appreciate the issue one might have.
  46857. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46858. * @param ray Defines the ray we are currently tryin to visualize
  46859. */
  46860. constructor(ray: Ray);
  46861. /**
  46862. * Shows the ray we are willing to debug.
  46863. * @param scene Defines the scene the ray needs to be rendered in
  46864. * @param color Defines the color the ray needs to be rendered in
  46865. */
  46866. show(scene: Scene, color?: Color3): void;
  46867. /**
  46868. * Hides the ray we are debugging.
  46869. */
  46870. hide(): void;
  46871. private _render;
  46872. /**
  46873. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46874. * @param mesh Defines the mesh we want the helper attached to
  46875. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46876. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46877. * @param length Defines the length of the ray
  46878. */
  46879. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46880. /**
  46881. * Detach the ray helper from the mesh it has previously been attached to.
  46882. */
  46883. detachFromMesh(): void;
  46884. private _updateToMesh;
  46885. /**
  46886. * Dispose the helper and release its associated resources.
  46887. */
  46888. dispose(): void;
  46889. }
  46890. }
  46891. declare module BABYLON.Debug {
  46892. /**
  46893. * Class used to render a debug view of a given skeleton
  46894. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46895. */
  46896. export class SkeletonViewer {
  46897. /** defines the skeleton to render */
  46898. skeleton: Skeleton;
  46899. /** defines the mesh attached to the skeleton */
  46900. mesh: AbstractMesh;
  46901. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46902. autoUpdateBonesMatrices: boolean;
  46903. /** defines the rendering group id to use with the viewer */
  46904. renderingGroupId: number;
  46905. /** Gets or sets the color used to render the skeleton */
  46906. color: Color3;
  46907. private _scene;
  46908. private _debugLines;
  46909. private _debugMesh;
  46910. private _isEnabled;
  46911. private _renderFunction;
  46912. private _utilityLayer;
  46913. /**
  46914. * Returns the mesh used to render the bones
  46915. */
  46916. get debugMesh(): Nullable<LinesMesh>;
  46917. /**
  46918. * Creates a new SkeletonViewer
  46919. * @param skeleton defines the skeleton to render
  46920. * @param mesh defines the mesh attached to the skeleton
  46921. * @param scene defines the hosting scene
  46922. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46923. * @param renderingGroupId defines the rendering group id to use with the viewer
  46924. */
  46925. constructor(
  46926. /** defines the skeleton to render */
  46927. skeleton: Skeleton,
  46928. /** defines the mesh attached to the skeleton */
  46929. mesh: AbstractMesh, scene: Scene,
  46930. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46931. autoUpdateBonesMatrices?: boolean,
  46932. /** defines the rendering group id to use with the viewer */
  46933. renderingGroupId?: number);
  46934. /** Gets or sets a boolean indicating if the viewer is enabled */
  46935. set isEnabled(value: boolean);
  46936. get isEnabled(): boolean;
  46937. private _getBonePosition;
  46938. private _getLinesForBonesWithLength;
  46939. private _getLinesForBonesNoLength;
  46940. /** Update the viewer to sync with current skeleton state */
  46941. update(): void;
  46942. /** Release associated resources */
  46943. dispose(): void;
  46944. }
  46945. }
  46946. declare module BABYLON {
  46947. /**
  46948. * This class will take all inputs from Keyboard, Pointer, and
  46949. * any Gamepads and provide a polling system that all devices
  46950. * will use. This class assumes that there will only be one
  46951. * pointer device and one keyboard.
  46952. */
  46953. export class DeviceInputSystem implements IDisposable {
  46954. /** POINTER_DEVICE */
  46955. static readonly POINTER_DEVICE: string;
  46956. /** KEYBOARD_DEVICE */
  46957. static readonly KEYBOARD_DEVICE: string;
  46958. /**
  46959. * Observable to be triggered when a device is connected
  46960. */
  46961. onDeviceConnectedObservable: Observable<string>;
  46962. /**
  46963. * Observable to be triggered when a device is disconnected
  46964. */
  46965. onDeviceDisconnectedObservable: Observable<string>;
  46966. private _inputs;
  46967. private _gamepads;
  46968. private _keyboardActive;
  46969. private _pointerActive;
  46970. private _elementToAttachTo;
  46971. private _keyboardDownEvent;
  46972. private _keyboardUpEvent;
  46973. private _pointerMoveEvent;
  46974. private _pointerDownEvent;
  46975. private _pointerUpEvent;
  46976. private _gamepadConnectedEvent;
  46977. private _gamepadDisconnectedEvent;
  46978. private static _MAX_KEYCODES;
  46979. private static _MAX_POINTER_INPUTS;
  46980. /**
  46981. * Default Constructor
  46982. * @param engine - engine to pull input element from
  46983. */
  46984. constructor(engine: Engine);
  46985. /**
  46986. * Checks for current device input value, given an id and input index
  46987. * @param deviceName Id of connected device
  46988. * @param inputIndex Index of device input
  46989. * @returns Current value of input
  46990. */
  46991. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  46992. /**
  46993. * Dispose of all the eventlisteners and clears the observables
  46994. */
  46995. dispose(): void;
  46996. /**
  46997. * Add device and inputs to device map
  46998. * @param deviceName Assigned name of device (may be SN)
  46999. * @param numberOfInputs Number of input entries to create for given device
  47000. */
  47001. private _registerDevice;
  47002. /**
  47003. * Given a specific device name, remove that device from the device map
  47004. * @param deviceName Name of device to be removed
  47005. */
  47006. private _unregisterDevice;
  47007. /**
  47008. * Handle all actions that come from keyboard interaction
  47009. */
  47010. private _handleKeyActions;
  47011. /**
  47012. * Handle all actions that come from pointer interaction
  47013. */
  47014. private _handlePointerActions;
  47015. /**
  47016. * Handle all actions that come from gamepad interaction
  47017. */
  47018. private _handleGamepadActions;
  47019. /**
  47020. * Update all non-event based devices with each frame
  47021. */
  47022. private _updateDevice;
  47023. }
  47024. }
  47025. declare module BABYLON {
  47026. /**
  47027. * Options to create the null engine
  47028. */
  47029. export class NullEngineOptions {
  47030. /**
  47031. * Render width (Default: 512)
  47032. */
  47033. renderWidth: number;
  47034. /**
  47035. * Render height (Default: 256)
  47036. */
  47037. renderHeight: number;
  47038. /**
  47039. * Texture size (Default: 512)
  47040. */
  47041. textureSize: number;
  47042. /**
  47043. * If delta time between frames should be constant
  47044. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47045. */
  47046. deterministicLockstep: boolean;
  47047. /**
  47048. * Maximum about of steps between frames (Default: 4)
  47049. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47050. */
  47051. lockstepMaxSteps: number;
  47052. }
  47053. /**
  47054. * The null engine class provides support for headless version of babylon.js.
  47055. * This can be used in server side scenario or for testing purposes
  47056. */
  47057. export class NullEngine extends Engine {
  47058. private _options;
  47059. /**
  47060. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47061. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47062. * @returns true if engine is in deterministic lock step mode
  47063. */
  47064. isDeterministicLockStep(): boolean;
  47065. /**
  47066. * Gets the max steps when engine is running in deterministic lock step
  47067. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47068. * @returns the max steps
  47069. */
  47070. getLockstepMaxSteps(): number;
  47071. /**
  47072. * Gets the current hardware scaling level.
  47073. * By default the hardware scaling level is computed from the window device ratio.
  47074. * 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.
  47075. * @returns a number indicating the current hardware scaling level
  47076. */
  47077. getHardwareScalingLevel(): number;
  47078. constructor(options?: NullEngineOptions);
  47079. /**
  47080. * Creates a vertex buffer
  47081. * @param vertices the data for the vertex buffer
  47082. * @returns the new WebGL static buffer
  47083. */
  47084. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47085. /**
  47086. * Creates a new index buffer
  47087. * @param indices defines the content of the index buffer
  47088. * @param updatable defines if the index buffer must be updatable
  47089. * @returns a new webGL buffer
  47090. */
  47091. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47092. /**
  47093. * Clear the current render buffer or the current render target (if any is set up)
  47094. * @param color defines the color to use
  47095. * @param backBuffer defines if the back buffer must be cleared
  47096. * @param depth defines if the depth buffer must be cleared
  47097. * @param stencil defines if the stencil buffer must be cleared
  47098. */
  47099. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47100. /**
  47101. * Gets the current render width
  47102. * @param useScreen defines if screen size must be used (or the current render target if any)
  47103. * @returns a number defining the current render width
  47104. */
  47105. getRenderWidth(useScreen?: boolean): number;
  47106. /**
  47107. * Gets the current render height
  47108. * @param useScreen defines if screen size must be used (or the current render target if any)
  47109. * @returns a number defining the current render height
  47110. */
  47111. getRenderHeight(useScreen?: boolean): number;
  47112. /**
  47113. * Set the WebGL's viewport
  47114. * @param viewport defines the viewport element to be used
  47115. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47116. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47117. */
  47118. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47119. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47120. /**
  47121. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47122. * @param pipelineContext defines the pipeline context to use
  47123. * @param uniformsNames defines the list of uniform names
  47124. * @returns an array of webGL uniform locations
  47125. */
  47126. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47127. /**
  47128. * Gets the lsit of active attributes for a given webGL program
  47129. * @param pipelineContext defines the pipeline context to use
  47130. * @param attributesNames defines the list of attribute names to get
  47131. * @returns an array of indices indicating the offset of each attribute
  47132. */
  47133. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47134. /**
  47135. * Binds an effect to the webGL context
  47136. * @param effect defines the effect to bind
  47137. */
  47138. bindSamplers(effect: Effect): void;
  47139. /**
  47140. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47141. * @param effect defines the effect to activate
  47142. */
  47143. enableEffect(effect: Effect): void;
  47144. /**
  47145. * Set various states to the webGL context
  47146. * @param culling defines backface culling state
  47147. * @param zOffset defines the value to apply to zOffset (0 by default)
  47148. * @param force defines if states must be applied even if cache is up to date
  47149. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47150. */
  47151. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47152. /**
  47153. * Set the value of an uniform to an array of int32
  47154. * @param uniform defines the webGL uniform location where to store the value
  47155. * @param array defines the array of int32 to store
  47156. */
  47157. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47158. /**
  47159. * Set the value of an uniform to an array of int32 (stored as vec2)
  47160. * @param uniform defines the webGL uniform location where to store the value
  47161. * @param array defines the array of int32 to store
  47162. */
  47163. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47164. /**
  47165. * Set the value of an uniform to an array of int32 (stored as vec3)
  47166. * @param uniform defines the webGL uniform location where to store the value
  47167. * @param array defines the array of int32 to store
  47168. */
  47169. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47170. /**
  47171. * Set the value of an uniform to an array of int32 (stored as vec4)
  47172. * @param uniform defines the webGL uniform location where to store the value
  47173. * @param array defines the array of int32 to store
  47174. */
  47175. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47176. /**
  47177. * Set the value of an uniform to an array of float32
  47178. * @param uniform defines the webGL uniform location where to store the value
  47179. * @param array defines the array of float32 to store
  47180. */
  47181. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47182. /**
  47183. * Set the value of an uniform to an array of float32 (stored as vec2)
  47184. * @param uniform defines the webGL uniform location where to store the value
  47185. * @param array defines the array of float32 to store
  47186. */
  47187. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47188. /**
  47189. * Set the value of an uniform to an array of float32 (stored as vec3)
  47190. * @param uniform defines the webGL uniform location where to store the value
  47191. * @param array defines the array of float32 to store
  47192. */
  47193. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47194. /**
  47195. * Set the value of an uniform to an array of float32 (stored as vec4)
  47196. * @param uniform defines the webGL uniform location where to store the value
  47197. * @param array defines the array of float32 to store
  47198. */
  47199. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47200. /**
  47201. * Set the value of an uniform to an array of number
  47202. * @param uniform defines the webGL uniform location where to store the value
  47203. * @param array defines the array of number to store
  47204. */
  47205. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47206. /**
  47207. * Set the value of an uniform to an array of number (stored as vec2)
  47208. * @param uniform defines the webGL uniform location where to store the value
  47209. * @param array defines the array of number to store
  47210. */
  47211. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47212. /**
  47213. * Set the value of an uniform to an array of number (stored as vec3)
  47214. * @param uniform defines the webGL uniform location where to store the value
  47215. * @param array defines the array of number to store
  47216. */
  47217. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47218. /**
  47219. * Set the value of an uniform to an array of number (stored as vec4)
  47220. * @param uniform defines the webGL uniform location where to store the value
  47221. * @param array defines the array of number to store
  47222. */
  47223. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47224. /**
  47225. * Set the value of an uniform to an array of float32 (stored as matrices)
  47226. * @param uniform defines the webGL uniform location where to store the value
  47227. * @param matrices defines the array of float32 to store
  47228. */
  47229. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47230. /**
  47231. * Set the value of an uniform to a matrix (3x3)
  47232. * @param uniform defines the webGL uniform location where to store the value
  47233. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47234. */
  47235. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47236. /**
  47237. * Set the value of an uniform to a matrix (2x2)
  47238. * @param uniform defines the webGL uniform location where to store the value
  47239. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47240. */
  47241. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47242. /**
  47243. * Set the value of an uniform to a number (float)
  47244. * @param uniform defines the webGL uniform location where to store the value
  47245. * @param value defines the float number to store
  47246. */
  47247. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47248. /**
  47249. * Set the value of an uniform to a vec2
  47250. * @param uniform defines the webGL uniform location where to store the value
  47251. * @param x defines the 1st component of the value
  47252. * @param y defines the 2nd component of the value
  47253. */
  47254. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47255. /**
  47256. * Set the value of an uniform to a vec3
  47257. * @param uniform defines the webGL uniform location where to store the value
  47258. * @param x defines the 1st component of the value
  47259. * @param y defines the 2nd component of the value
  47260. * @param z defines the 3rd component of the value
  47261. */
  47262. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47263. /**
  47264. * Set the value of an uniform to a boolean
  47265. * @param uniform defines the webGL uniform location where to store the value
  47266. * @param bool defines the boolean to store
  47267. */
  47268. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47269. /**
  47270. * Set the value of an uniform to a vec4
  47271. * @param uniform defines the webGL uniform location where to store the value
  47272. * @param x defines the 1st component of the value
  47273. * @param y defines the 2nd component of the value
  47274. * @param z defines the 3rd component of the value
  47275. * @param w defines the 4th component of the value
  47276. */
  47277. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47278. /**
  47279. * Sets the current alpha mode
  47280. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47281. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47282. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47283. */
  47284. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47285. /**
  47286. * Bind webGl buffers directly to the webGL context
  47287. * @param vertexBuffers defines the vertex buffer to bind
  47288. * @param indexBuffer defines the index buffer to bind
  47289. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47290. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47291. * @param effect defines the effect associated with the vertex buffer
  47292. */
  47293. bindBuffers(vertexBuffers: {
  47294. [key: string]: VertexBuffer;
  47295. }, indexBuffer: DataBuffer, effect: Effect): void;
  47296. /**
  47297. * Force the entire cache to be cleared
  47298. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47299. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47300. */
  47301. wipeCaches(bruteForce?: boolean): void;
  47302. /**
  47303. * Send a draw order
  47304. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47305. * @param indexStart defines the starting index
  47306. * @param indexCount defines the number of index to draw
  47307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47308. */
  47309. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47310. /**
  47311. * Draw a list of indexed primitives
  47312. * @param fillMode defines the primitive to use
  47313. * @param indexStart defines the starting index
  47314. * @param indexCount defines the number of index to draw
  47315. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47316. */
  47317. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47318. /**
  47319. * Draw a list of unindexed primitives
  47320. * @param fillMode defines the primitive to use
  47321. * @param verticesStart defines the index of first vertex to draw
  47322. * @param verticesCount defines the count of vertices to draw
  47323. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47324. */
  47325. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47326. /** @hidden */
  47327. _createTexture(): WebGLTexture;
  47328. /** @hidden */
  47329. _releaseTexture(texture: InternalTexture): void;
  47330. /**
  47331. * Usually called from Texture.ts.
  47332. * Passed information to create a WebGLTexture
  47333. * @param urlArg defines a value which contains one of the following:
  47334. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47335. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47336. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47337. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47338. * @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)
  47339. * @param scene needed for loading to the correct scene
  47340. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47341. * @param onLoad optional callback to be called upon successful completion
  47342. * @param onError optional callback to be called upon failure
  47343. * @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
  47344. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47345. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47346. * @param forcedExtension defines the extension to use to pick the right loader
  47347. * @param mimeType defines an optional mime type
  47348. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47349. */
  47350. 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;
  47351. /**
  47352. * Creates a new render target texture
  47353. * @param size defines the size of the texture
  47354. * @param options defines the options used to create the texture
  47355. * @returns a new render target texture stored in an InternalTexture
  47356. */
  47357. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47358. /**
  47359. * Update the sampling mode of a given texture
  47360. * @param samplingMode defines the required sampling mode
  47361. * @param texture defines the texture to update
  47362. */
  47363. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47364. /**
  47365. * Binds the frame buffer to the specified texture.
  47366. * @param texture The texture to render to or null for the default canvas
  47367. * @param faceIndex The face of the texture to render to in case of cube texture
  47368. * @param requiredWidth The width of the target to render to
  47369. * @param requiredHeight The height of the target to render to
  47370. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47371. * @param lodLevel defines le lod level to bind to the frame buffer
  47372. */
  47373. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47374. /**
  47375. * Unbind the current render target texture from the webGL context
  47376. * @param texture defines the render target texture to unbind
  47377. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47378. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47379. */
  47380. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47381. /**
  47382. * Creates a dynamic vertex buffer
  47383. * @param vertices the data for the dynamic vertex buffer
  47384. * @returns the new WebGL dynamic buffer
  47385. */
  47386. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47387. /**
  47388. * Update the content of a dynamic texture
  47389. * @param texture defines the texture to update
  47390. * @param canvas defines the canvas containing the source
  47391. * @param invertY defines if data must be stored with Y axis inverted
  47392. * @param premulAlpha defines if alpha is stored as premultiplied
  47393. * @param format defines the format of the data
  47394. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47395. */
  47396. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47397. /**
  47398. * Gets a boolean indicating if all created effects are ready
  47399. * @returns true if all effects are ready
  47400. */
  47401. areAllEffectsReady(): boolean;
  47402. /**
  47403. * @hidden
  47404. * Get the current error code of the webGL context
  47405. * @returns the error code
  47406. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47407. */
  47408. getError(): number;
  47409. /** @hidden */
  47410. _getUnpackAlignement(): number;
  47411. /** @hidden */
  47412. _unpackFlipY(value: boolean): void;
  47413. /**
  47414. * Update a dynamic index buffer
  47415. * @param indexBuffer defines the target index buffer
  47416. * @param indices defines the data to update
  47417. * @param offset defines the offset in the target index buffer where update should start
  47418. */
  47419. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47420. /**
  47421. * Updates a dynamic vertex buffer.
  47422. * @param vertexBuffer the vertex buffer to update
  47423. * @param vertices the data used to update the vertex buffer
  47424. * @param byteOffset the byte offset of the data (optional)
  47425. * @param byteLength the byte length of the data (optional)
  47426. */
  47427. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47428. /** @hidden */
  47429. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47430. /** @hidden */
  47431. _bindTexture(channel: number, texture: InternalTexture): void;
  47432. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47433. /**
  47434. * 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
  47435. */
  47436. releaseEffects(): void;
  47437. displayLoadingUI(): void;
  47438. hideLoadingUI(): void;
  47439. /** @hidden */
  47440. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47441. /** @hidden */
  47442. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47443. /** @hidden */
  47444. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47445. /** @hidden */
  47446. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47447. }
  47448. }
  47449. declare module BABYLON {
  47450. /**
  47451. * @hidden
  47452. **/
  47453. export class _TimeToken {
  47454. _startTimeQuery: Nullable<WebGLQuery>;
  47455. _endTimeQuery: Nullable<WebGLQuery>;
  47456. _timeElapsedQuery: Nullable<WebGLQuery>;
  47457. _timeElapsedQueryEnded: boolean;
  47458. }
  47459. }
  47460. declare module BABYLON {
  47461. /** @hidden */
  47462. export class _OcclusionDataStorage {
  47463. /** @hidden */
  47464. occlusionInternalRetryCounter: number;
  47465. /** @hidden */
  47466. isOcclusionQueryInProgress: boolean;
  47467. /** @hidden */
  47468. isOccluded: boolean;
  47469. /** @hidden */
  47470. occlusionRetryCount: number;
  47471. /** @hidden */
  47472. occlusionType: number;
  47473. /** @hidden */
  47474. occlusionQueryAlgorithmType: number;
  47475. }
  47476. interface Engine {
  47477. /**
  47478. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47479. * @return the new query
  47480. */
  47481. createQuery(): WebGLQuery;
  47482. /**
  47483. * Delete and release a webGL query
  47484. * @param query defines the query to delete
  47485. * @return the current engine
  47486. */
  47487. deleteQuery(query: WebGLQuery): Engine;
  47488. /**
  47489. * Check if a given query has resolved and got its value
  47490. * @param query defines the query to check
  47491. * @returns true if the query got its value
  47492. */
  47493. isQueryResultAvailable(query: WebGLQuery): boolean;
  47494. /**
  47495. * Gets the value of a given query
  47496. * @param query defines the query to check
  47497. * @returns the value of the query
  47498. */
  47499. getQueryResult(query: WebGLQuery): number;
  47500. /**
  47501. * Initiates an occlusion query
  47502. * @param algorithmType defines the algorithm to use
  47503. * @param query defines the query to use
  47504. * @returns the current engine
  47505. * @see http://doc.babylonjs.com/features/occlusionquery
  47506. */
  47507. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47508. /**
  47509. * Ends an occlusion query
  47510. * @see http://doc.babylonjs.com/features/occlusionquery
  47511. * @param algorithmType defines the algorithm to use
  47512. * @returns the current engine
  47513. */
  47514. endOcclusionQuery(algorithmType: number): Engine;
  47515. /**
  47516. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47517. * Please note that only one query can be issued at a time
  47518. * @returns a time token used to track the time span
  47519. */
  47520. startTimeQuery(): Nullable<_TimeToken>;
  47521. /**
  47522. * Ends a time query
  47523. * @param token defines the token used to measure the time span
  47524. * @returns the time spent (in ns)
  47525. */
  47526. endTimeQuery(token: _TimeToken): int;
  47527. /** @hidden */
  47528. _currentNonTimestampToken: Nullable<_TimeToken>;
  47529. /** @hidden */
  47530. _createTimeQuery(): WebGLQuery;
  47531. /** @hidden */
  47532. _deleteTimeQuery(query: WebGLQuery): void;
  47533. /** @hidden */
  47534. _getGlAlgorithmType(algorithmType: number): number;
  47535. /** @hidden */
  47536. _getTimeQueryResult(query: WebGLQuery): any;
  47537. /** @hidden */
  47538. _getTimeQueryAvailability(query: WebGLQuery): any;
  47539. }
  47540. interface AbstractMesh {
  47541. /**
  47542. * Backing filed
  47543. * @hidden
  47544. */
  47545. __occlusionDataStorage: _OcclusionDataStorage;
  47546. /**
  47547. * Access property
  47548. * @hidden
  47549. */
  47550. _occlusionDataStorage: _OcclusionDataStorage;
  47551. /**
  47552. * 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.
  47553. * The default value is -1 which means don't break the query and wait till the result
  47554. * @see http://doc.babylonjs.com/features/occlusionquery
  47555. */
  47556. occlusionRetryCount: number;
  47557. /**
  47558. * 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:
  47559. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47560. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47561. * * 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.
  47562. * @see http://doc.babylonjs.com/features/occlusionquery
  47563. */
  47564. occlusionType: number;
  47565. /**
  47566. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47567. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47568. * * 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.
  47569. * @see http://doc.babylonjs.com/features/occlusionquery
  47570. */
  47571. occlusionQueryAlgorithmType: number;
  47572. /**
  47573. * 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
  47574. * @see http://doc.babylonjs.com/features/occlusionquery
  47575. */
  47576. isOccluded: boolean;
  47577. /**
  47578. * Flag to check the progress status of the query
  47579. * @see http://doc.babylonjs.com/features/occlusionquery
  47580. */
  47581. isOcclusionQueryInProgress: boolean;
  47582. }
  47583. }
  47584. declare module BABYLON {
  47585. /** @hidden */
  47586. export var _forceTransformFeedbackToBundle: boolean;
  47587. interface Engine {
  47588. /**
  47589. * Creates a webGL transform feedback object
  47590. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47591. * @returns the webGL transform feedback object
  47592. */
  47593. createTransformFeedback(): WebGLTransformFeedback;
  47594. /**
  47595. * Delete a webGL transform feedback object
  47596. * @param value defines the webGL transform feedback object to delete
  47597. */
  47598. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47599. /**
  47600. * Bind a webGL transform feedback object to the webgl context
  47601. * @param value defines the webGL transform feedback object to bind
  47602. */
  47603. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47604. /**
  47605. * Begins a transform feedback operation
  47606. * @param usePoints defines if points or triangles must be used
  47607. */
  47608. beginTransformFeedback(usePoints: boolean): void;
  47609. /**
  47610. * Ends a transform feedback operation
  47611. */
  47612. endTransformFeedback(): void;
  47613. /**
  47614. * Specify the varyings to use with transform feedback
  47615. * @param program defines the associated webGL program
  47616. * @param value defines the list of strings representing the varying names
  47617. */
  47618. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47619. /**
  47620. * Bind a webGL buffer for a transform feedback operation
  47621. * @param value defines the webGL buffer to bind
  47622. */
  47623. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47624. }
  47625. }
  47626. declare module BABYLON {
  47627. /**
  47628. * Creation options of the multi render target texture.
  47629. */
  47630. export interface IMultiRenderTargetOptions {
  47631. /**
  47632. * Define if the texture needs to create mip maps after render.
  47633. */
  47634. generateMipMaps?: boolean;
  47635. /**
  47636. * Define the types of all the draw buffers we want to create
  47637. */
  47638. types?: number[];
  47639. /**
  47640. * Define the sampling modes of all the draw buffers we want to create
  47641. */
  47642. samplingModes?: number[];
  47643. /**
  47644. * Define if a depth buffer is required
  47645. */
  47646. generateDepthBuffer?: boolean;
  47647. /**
  47648. * Define if a stencil buffer is required
  47649. */
  47650. generateStencilBuffer?: boolean;
  47651. /**
  47652. * Define if a depth texture is required instead of a depth buffer
  47653. */
  47654. generateDepthTexture?: boolean;
  47655. /**
  47656. * Define the number of desired draw buffers
  47657. */
  47658. textureCount?: number;
  47659. /**
  47660. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47661. */
  47662. doNotChangeAspectRatio?: boolean;
  47663. /**
  47664. * Define the default type of the buffers we are creating
  47665. */
  47666. defaultType?: number;
  47667. }
  47668. /**
  47669. * A multi render target, like a render target provides the ability to render to a texture.
  47670. * Unlike the render target, it can render to several draw buffers in one draw.
  47671. * This is specially interesting in deferred rendering or for any effects requiring more than
  47672. * just one color from a single pass.
  47673. */
  47674. export class MultiRenderTarget extends RenderTargetTexture {
  47675. private _internalTextures;
  47676. private _textures;
  47677. private _multiRenderTargetOptions;
  47678. /**
  47679. * Get if draw buffers are currently supported by the used hardware and browser.
  47680. */
  47681. get isSupported(): boolean;
  47682. /**
  47683. * Get the list of textures generated by the multi render target.
  47684. */
  47685. get textures(): Texture[];
  47686. /**
  47687. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47688. */
  47689. get depthTexture(): Texture;
  47690. /**
  47691. * Set the wrapping mode on U of all the textures we are rendering to.
  47692. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47693. */
  47694. set wrapU(wrap: number);
  47695. /**
  47696. * Set the wrapping mode on V of all the textures we are rendering to.
  47697. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47698. */
  47699. set wrapV(wrap: number);
  47700. /**
  47701. * Instantiate a new multi render target texture.
  47702. * A multi render target, like a render target provides the ability to render to a texture.
  47703. * Unlike the render target, it can render to several draw buffers in one draw.
  47704. * This is specially interesting in deferred rendering or for any effects requiring more than
  47705. * just one color from a single pass.
  47706. * @param name Define the name of the texture
  47707. * @param size Define the size of the buffers to render to
  47708. * @param count Define the number of target we are rendering into
  47709. * @param scene Define the scene the texture belongs to
  47710. * @param options Define the options used to create the multi render target
  47711. */
  47712. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47713. /** @hidden */
  47714. _rebuild(): void;
  47715. private _createInternalTextures;
  47716. private _createTextures;
  47717. /**
  47718. * Define the number of samples used if MSAA is enabled.
  47719. */
  47720. get samples(): number;
  47721. set samples(value: number);
  47722. /**
  47723. * Resize all the textures in the multi render target.
  47724. * Be carrefull as it will recreate all the data in the new texture.
  47725. * @param size Define the new size
  47726. */
  47727. resize(size: any): void;
  47728. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47729. /**
  47730. * Dispose the render targets and their associated resources
  47731. */
  47732. dispose(): void;
  47733. /**
  47734. * Release all the underlying texture used as draw buffers.
  47735. */
  47736. releaseInternalTextures(): void;
  47737. }
  47738. }
  47739. declare module BABYLON {
  47740. interface ThinEngine {
  47741. /**
  47742. * Unbind a list of render target textures from the webGL context
  47743. * This is used only when drawBuffer extension or webGL2 are active
  47744. * @param textures defines the render target textures to unbind
  47745. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47746. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47747. */
  47748. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47749. /**
  47750. * Create a multi render target texture
  47751. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47752. * @param size defines the size of the texture
  47753. * @param options defines the creation options
  47754. * @returns the cube texture as an InternalTexture
  47755. */
  47756. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47757. /**
  47758. * Update the sample count for a given multiple render target texture
  47759. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47760. * @param textures defines the textures to update
  47761. * @param samples defines the sample count to set
  47762. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47763. */
  47764. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47765. }
  47766. }
  47767. declare module BABYLON {
  47768. /**
  47769. * Class used to define an additional view for the engine
  47770. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47771. */
  47772. export class EngineView {
  47773. /** Defines the canvas where to render the view */
  47774. target: HTMLCanvasElement;
  47775. /** Defines an optional camera used to render the view (will use active camera else) */
  47776. camera?: Camera;
  47777. }
  47778. interface Engine {
  47779. /**
  47780. * Gets or sets the HTML element to use for attaching events
  47781. */
  47782. inputElement: Nullable<HTMLElement>;
  47783. /**
  47784. * Gets the current engine view
  47785. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47786. */
  47787. activeView: Nullable<EngineView>;
  47788. /** Gets or sets the list of views */
  47789. views: EngineView[];
  47790. /**
  47791. * Register a new child canvas
  47792. * @param canvas defines the canvas to register
  47793. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47794. * @returns the associated view
  47795. */
  47796. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47797. /**
  47798. * Remove a registered child canvas
  47799. * @param canvas defines the canvas to remove
  47800. * @returns the current engine
  47801. */
  47802. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47803. }
  47804. }
  47805. declare module BABYLON {
  47806. interface Engine {
  47807. /** @hidden */
  47808. _excludedCompressedTextures: string[];
  47809. /** @hidden */
  47810. _textureFormatInUse: string;
  47811. /**
  47812. * Gets the list of texture formats supported
  47813. */
  47814. readonly texturesSupported: Array<string>;
  47815. /**
  47816. * Gets the texture format in use
  47817. */
  47818. readonly textureFormatInUse: Nullable<string>;
  47819. /**
  47820. * Set the compressed texture extensions or file names to skip.
  47821. *
  47822. * @param skippedFiles defines the list of those texture files you want to skip
  47823. * Example: [".dds", ".env", "myfile.png"]
  47824. */
  47825. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47826. /**
  47827. * Set the compressed texture format to use, based on the formats you have, and the formats
  47828. * supported by the hardware / browser.
  47829. *
  47830. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47831. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47832. * to API arguments needed to compressed textures. This puts the burden on the container
  47833. * generator to house the arcane code for determining these for current & future formats.
  47834. *
  47835. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47836. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47837. *
  47838. * Note: The result of this call is not taken into account when a texture is base64.
  47839. *
  47840. * @param formatsAvailable defines the list of those format families you have created
  47841. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47842. *
  47843. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47844. * @returns The extension selected.
  47845. */
  47846. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47847. }
  47848. }
  47849. declare module BABYLON {
  47850. /**
  47851. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47852. */
  47853. export interface CubeMapInfo {
  47854. /**
  47855. * The pixel array for the front face.
  47856. * This is stored in format, left to right, up to down format.
  47857. */
  47858. front: Nullable<ArrayBufferView>;
  47859. /**
  47860. * The pixel array for the back face.
  47861. * This is stored in format, left to right, up to down format.
  47862. */
  47863. back: Nullable<ArrayBufferView>;
  47864. /**
  47865. * The pixel array for the left face.
  47866. * This is stored in format, left to right, up to down format.
  47867. */
  47868. left: Nullable<ArrayBufferView>;
  47869. /**
  47870. * The pixel array for the right face.
  47871. * This is stored in format, left to right, up to down format.
  47872. */
  47873. right: Nullable<ArrayBufferView>;
  47874. /**
  47875. * The pixel array for the up face.
  47876. * This is stored in format, left to right, up to down format.
  47877. */
  47878. up: Nullable<ArrayBufferView>;
  47879. /**
  47880. * The pixel array for the down face.
  47881. * This is stored in format, left to right, up to down format.
  47882. */
  47883. down: Nullable<ArrayBufferView>;
  47884. /**
  47885. * The size of the cubemap stored.
  47886. *
  47887. * Each faces will be size * size pixels.
  47888. */
  47889. size: number;
  47890. /**
  47891. * The format of the texture.
  47892. *
  47893. * RGBA, RGB.
  47894. */
  47895. format: number;
  47896. /**
  47897. * The type of the texture data.
  47898. *
  47899. * UNSIGNED_INT, FLOAT.
  47900. */
  47901. type: number;
  47902. /**
  47903. * Specifies whether the texture is in gamma space.
  47904. */
  47905. gammaSpace: boolean;
  47906. }
  47907. /**
  47908. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47909. */
  47910. export class PanoramaToCubeMapTools {
  47911. private static FACE_FRONT;
  47912. private static FACE_BACK;
  47913. private static FACE_RIGHT;
  47914. private static FACE_LEFT;
  47915. private static FACE_DOWN;
  47916. private static FACE_UP;
  47917. /**
  47918. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47919. *
  47920. * @param float32Array The source data.
  47921. * @param inputWidth The width of the input panorama.
  47922. * @param inputHeight The height of the input panorama.
  47923. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47924. * @return The cubemap data
  47925. */
  47926. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47927. private static CreateCubemapTexture;
  47928. private static CalcProjectionSpherical;
  47929. }
  47930. }
  47931. declare module BABYLON {
  47932. /**
  47933. * Helper class dealing with the extraction of spherical polynomial dataArray
  47934. * from a cube map.
  47935. */
  47936. export class CubeMapToSphericalPolynomialTools {
  47937. private static FileFaces;
  47938. /**
  47939. * Converts a texture to the according Spherical Polynomial data.
  47940. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47941. *
  47942. * @param texture The texture to extract the information from.
  47943. * @return The Spherical Polynomial data.
  47944. */
  47945. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47946. /**
  47947. * Converts a cubemap to the according Spherical Polynomial data.
  47948. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47949. *
  47950. * @param cubeInfo The Cube map to extract the information from.
  47951. * @return The Spherical Polynomial data.
  47952. */
  47953. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47954. }
  47955. }
  47956. declare module BABYLON {
  47957. interface BaseTexture {
  47958. /**
  47959. * Get the polynomial representation of the texture data.
  47960. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47961. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47962. */
  47963. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47964. }
  47965. }
  47966. declare module BABYLON {
  47967. /** @hidden */
  47968. export var rgbdEncodePixelShader: {
  47969. name: string;
  47970. shader: string;
  47971. };
  47972. }
  47973. declare module BABYLON {
  47974. /** @hidden */
  47975. export var rgbdDecodePixelShader: {
  47976. name: string;
  47977. shader: string;
  47978. };
  47979. }
  47980. declare module BABYLON {
  47981. /**
  47982. * Raw texture data and descriptor sufficient for WebGL texture upload
  47983. */
  47984. export interface EnvironmentTextureInfo {
  47985. /**
  47986. * Version of the environment map
  47987. */
  47988. version: number;
  47989. /**
  47990. * Width of image
  47991. */
  47992. width: number;
  47993. /**
  47994. * Irradiance information stored in the file.
  47995. */
  47996. irradiance: any;
  47997. /**
  47998. * Specular information stored in the file.
  47999. */
  48000. specular: any;
  48001. }
  48002. /**
  48003. * Defines One Image in the file. It requires only the position in the file
  48004. * as well as the length.
  48005. */
  48006. interface BufferImageData {
  48007. /**
  48008. * Length of the image data.
  48009. */
  48010. length: number;
  48011. /**
  48012. * Position of the data from the null terminator delimiting the end of the JSON.
  48013. */
  48014. position: number;
  48015. }
  48016. /**
  48017. * Defines the specular data enclosed in the file.
  48018. * This corresponds to the version 1 of the data.
  48019. */
  48020. export interface EnvironmentTextureSpecularInfoV1 {
  48021. /**
  48022. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48023. */
  48024. specularDataPosition?: number;
  48025. /**
  48026. * This contains all the images data needed to reconstruct the cubemap.
  48027. */
  48028. mipmaps: Array<BufferImageData>;
  48029. /**
  48030. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48031. */
  48032. lodGenerationScale: number;
  48033. }
  48034. /**
  48035. * Sets of helpers addressing the serialization and deserialization of environment texture
  48036. * stored in a BabylonJS env file.
  48037. * Those files are usually stored as .env files.
  48038. */
  48039. export class EnvironmentTextureTools {
  48040. /**
  48041. * Magic number identifying the env file.
  48042. */
  48043. private static _MagicBytes;
  48044. /**
  48045. * Gets the environment info from an env file.
  48046. * @param data The array buffer containing the .env bytes.
  48047. * @returns the environment file info (the json header) if successfully parsed.
  48048. */
  48049. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48050. /**
  48051. * Creates an environment texture from a loaded cube texture.
  48052. * @param texture defines the cube texture to convert in env file
  48053. * @return a promise containing the environment data if succesfull.
  48054. */
  48055. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48056. /**
  48057. * Creates a JSON representation of the spherical data.
  48058. * @param texture defines the texture containing the polynomials
  48059. * @return the JSON representation of the spherical info
  48060. */
  48061. private static _CreateEnvTextureIrradiance;
  48062. /**
  48063. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48064. * @param data the image data
  48065. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48066. * @return the views described by info providing access to the underlying buffer
  48067. */
  48068. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48069. /**
  48070. * Uploads the texture info contained in the env file to the GPU.
  48071. * @param texture defines the internal texture to upload to
  48072. * @param data defines the data to load
  48073. * @param info defines the texture info retrieved through the GetEnvInfo method
  48074. * @returns a promise
  48075. */
  48076. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48077. private static _OnImageReadyAsync;
  48078. /**
  48079. * Uploads the levels of image data to the GPU.
  48080. * @param texture defines the internal texture to upload to
  48081. * @param imageData defines the array buffer views of image data [mipmap][face]
  48082. * @returns a promise
  48083. */
  48084. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48085. /**
  48086. * Uploads spherical polynomials information to the texture.
  48087. * @param texture defines the texture we are trying to upload the information to
  48088. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48089. */
  48090. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48091. /** @hidden */
  48092. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48093. }
  48094. }
  48095. declare module BABYLON {
  48096. /**
  48097. * Contains position and normal vectors for a vertex
  48098. */
  48099. export class PositionNormalVertex {
  48100. /** the position of the vertex (defaut: 0,0,0) */
  48101. position: Vector3;
  48102. /** the normal of the vertex (defaut: 0,1,0) */
  48103. normal: Vector3;
  48104. /**
  48105. * Creates a PositionNormalVertex
  48106. * @param position the position of the vertex (defaut: 0,0,0)
  48107. * @param normal the normal of the vertex (defaut: 0,1,0)
  48108. */
  48109. constructor(
  48110. /** the position of the vertex (defaut: 0,0,0) */
  48111. position?: Vector3,
  48112. /** the normal of the vertex (defaut: 0,1,0) */
  48113. normal?: Vector3);
  48114. /**
  48115. * Clones the PositionNormalVertex
  48116. * @returns the cloned PositionNormalVertex
  48117. */
  48118. clone(): PositionNormalVertex;
  48119. }
  48120. /**
  48121. * Contains position, normal and uv vectors for a vertex
  48122. */
  48123. export class PositionNormalTextureVertex {
  48124. /** the position of the vertex (defaut: 0,0,0) */
  48125. position: Vector3;
  48126. /** the normal of the vertex (defaut: 0,1,0) */
  48127. normal: Vector3;
  48128. /** the uv of the vertex (default: 0,0) */
  48129. uv: Vector2;
  48130. /**
  48131. * Creates a PositionNormalTextureVertex
  48132. * @param position the position of the vertex (defaut: 0,0,0)
  48133. * @param normal the normal of the vertex (defaut: 0,1,0)
  48134. * @param uv the uv of the vertex (default: 0,0)
  48135. */
  48136. constructor(
  48137. /** the position of the vertex (defaut: 0,0,0) */
  48138. position?: Vector3,
  48139. /** the normal of the vertex (defaut: 0,1,0) */
  48140. normal?: Vector3,
  48141. /** the uv of the vertex (default: 0,0) */
  48142. uv?: Vector2);
  48143. /**
  48144. * Clones the PositionNormalTextureVertex
  48145. * @returns the cloned PositionNormalTextureVertex
  48146. */
  48147. clone(): PositionNormalTextureVertex;
  48148. }
  48149. }
  48150. declare module BABYLON {
  48151. /** @hidden */
  48152. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48153. private _genericAttributeLocation;
  48154. private _varyingLocationCount;
  48155. private _varyingLocationMap;
  48156. private _replacements;
  48157. private _textureCount;
  48158. private _uniforms;
  48159. lineProcessor(line: string): string;
  48160. attributeProcessor(attribute: string): string;
  48161. varyingProcessor(varying: string, isFragment: boolean): string;
  48162. uniformProcessor(uniform: string): string;
  48163. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48164. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48165. }
  48166. }
  48167. declare module BABYLON {
  48168. /**
  48169. * Container for accessors for natively-stored mesh data buffers.
  48170. */
  48171. class NativeDataBuffer extends DataBuffer {
  48172. /**
  48173. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48174. */
  48175. nativeIndexBuffer?: any;
  48176. /**
  48177. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48178. */
  48179. nativeVertexBuffer?: any;
  48180. }
  48181. /** @hidden */
  48182. class NativeTexture extends InternalTexture {
  48183. getInternalTexture(): InternalTexture;
  48184. getViewCount(): number;
  48185. }
  48186. /** @hidden */
  48187. export class NativeEngine extends Engine {
  48188. private readonly _native;
  48189. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48190. private readonly INVALID_HANDLE;
  48191. getHardwareScalingLevel(): number;
  48192. constructor();
  48193. dispose(): void;
  48194. /**
  48195. * Can be used to override the current requestAnimationFrame requester.
  48196. * @hidden
  48197. */
  48198. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48199. /**
  48200. * Override default engine behavior.
  48201. * @param color
  48202. * @param backBuffer
  48203. * @param depth
  48204. * @param stencil
  48205. */
  48206. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48207. /**
  48208. * Gets host document
  48209. * @returns the host document object
  48210. */
  48211. getHostDocument(): Nullable<Document>;
  48212. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48213. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48214. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48215. recordVertexArrayObject(vertexBuffers: {
  48216. [key: string]: VertexBuffer;
  48217. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48218. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48219. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48220. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48221. /**
  48222. * Draw a list of indexed primitives
  48223. * @param fillMode defines the primitive to use
  48224. * @param indexStart defines the starting index
  48225. * @param indexCount defines the number of index to draw
  48226. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48227. */
  48228. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48229. /**
  48230. * Draw a list of unindexed primitives
  48231. * @param fillMode defines the primitive to use
  48232. * @param verticesStart defines the index of first vertex to draw
  48233. * @param verticesCount defines the count of vertices to draw
  48234. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48235. */
  48236. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48237. createPipelineContext(): IPipelineContext;
  48238. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48239. /** @hidden */
  48240. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48241. /** @hidden */
  48242. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48243. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48244. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48245. protected _setProgram(program: WebGLProgram): void;
  48246. _releaseEffect(effect: Effect): void;
  48247. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48248. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48249. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48250. bindSamplers(effect: Effect): void;
  48251. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48252. getRenderWidth(useScreen?: boolean): number;
  48253. getRenderHeight(useScreen?: boolean): number;
  48254. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48255. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48256. /**
  48257. * Set the z offset to apply to current rendering
  48258. * @param value defines the offset to apply
  48259. */
  48260. setZOffset(value: number): void;
  48261. /**
  48262. * Gets the current value of the zOffset
  48263. * @returns the current zOffset state
  48264. */
  48265. getZOffset(): number;
  48266. /**
  48267. * Enable or disable depth buffering
  48268. * @param enable defines the state to set
  48269. */
  48270. setDepthBuffer(enable: boolean): void;
  48271. /**
  48272. * Gets a boolean indicating if depth writing is enabled
  48273. * @returns the current depth writing state
  48274. */
  48275. getDepthWrite(): boolean;
  48276. /**
  48277. * Enable or disable depth writing
  48278. * @param enable defines the state to set
  48279. */
  48280. setDepthWrite(enable: boolean): void;
  48281. /**
  48282. * Enable or disable color writing
  48283. * @param enable defines the state to set
  48284. */
  48285. setColorWrite(enable: boolean): void;
  48286. /**
  48287. * Gets a boolean indicating if color writing is enabled
  48288. * @returns the current color writing state
  48289. */
  48290. getColorWrite(): boolean;
  48291. /**
  48292. * Sets alpha constants used by some alpha blending modes
  48293. * @param r defines the red component
  48294. * @param g defines the green component
  48295. * @param b defines the blue component
  48296. * @param a defines the alpha component
  48297. */
  48298. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48299. /**
  48300. * Sets the current alpha mode
  48301. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48302. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48303. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48304. */
  48305. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48306. /**
  48307. * Gets the current alpha mode
  48308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48309. * @returns the current alpha mode
  48310. */
  48311. getAlphaMode(): number;
  48312. setInt(uniform: WebGLUniformLocation, int: number): void;
  48313. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48314. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48315. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48316. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48317. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48318. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48319. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48320. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48321. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48322. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48323. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48324. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48325. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48326. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48327. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48328. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48329. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48330. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48331. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48332. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48333. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48334. wipeCaches(bruteForce?: boolean): void;
  48335. _createTexture(): WebGLTexture;
  48336. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48337. /**
  48338. * Usually called from Texture.ts.
  48339. * Passed information to create a WebGLTexture
  48340. * @param url defines a value which contains one of the following:
  48341. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48342. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48343. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48344. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48345. * @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)
  48346. * @param scene needed for loading to the correct scene
  48347. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48348. * @param onLoad optional callback to be called upon successful completion
  48349. * @param onError optional callback to be called upon failure
  48350. * @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
  48351. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48352. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48353. * @param forcedExtension defines the extension to use to pick the right loader
  48354. * @param mimeType defines an optional mime type
  48355. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48356. */
  48357. 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;
  48358. /**
  48359. * Creates a cube texture
  48360. * @param rootUrl defines the url where the files to load is located
  48361. * @param scene defines the current scene
  48362. * @param files defines the list of files to load (1 per face)
  48363. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48364. * @param onLoad defines an optional callback raised when the texture is loaded
  48365. * @param onError defines an optional callback raised if there is an issue to load the texture
  48366. * @param format defines the format of the data
  48367. * @param forcedExtension defines the extension to use to pick the right loader
  48368. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48369. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48370. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48371. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48372. * @returns the cube texture as an InternalTexture
  48373. */
  48374. 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;
  48375. private _getSamplingFilter;
  48376. private static _GetNativeTextureFormat;
  48377. createRenderTargetTexture(size: number | {
  48378. width: number;
  48379. height: number;
  48380. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48381. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48382. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48383. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48384. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48385. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48386. /**
  48387. * Updates a dynamic vertex buffer.
  48388. * @param vertexBuffer the vertex buffer to update
  48389. * @param data the data used to update the vertex buffer
  48390. * @param byteOffset the byte offset of the data (optional)
  48391. * @param byteLength the byte length of the data (optional)
  48392. */
  48393. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48394. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48395. private _updateAnisotropicLevel;
  48396. private _getAddressMode;
  48397. /** @hidden */
  48398. _bindTexture(channel: number, texture: InternalTexture): void;
  48399. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48400. releaseEffects(): void;
  48401. /** @hidden */
  48402. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48403. /** @hidden */
  48404. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48405. /** @hidden */
  48406. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48407. /** @hidden */
  48408. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48409. }
  48410. }
  48411. declare module BABYLON {
  48412. /**
  48413. * Gather the list of clipboard event types as constants.
  48414. */
  48415. export class ClipboardEventTypes {
  48416. /**
  48417. * The clipboard event is fired when a copy command is active (pressed).
  48418. */
  48419. static readonly COPY: number;
  48420. /**
  48421. * The clipboard event is fired when a cut command is active (pressed).
  48422. */
  48423. static readonly CUT: number;
  48424. /**
  48425. * The clipboard event is fired when a paste command is active (pressed).
  48426. */
  48427. static readonly PASTE: number;
  48428. }
  48429. /**
  48430. * This class is used to store clipboard related info for the onClipboardObservable event.
  48431. */
  48432. export class ClipboardInfo {
  48433. /**
  48434. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48435. */
  48436. type: number;
  48437. /**
  48438. * Defines the related dom event
  48439. */
  48440. event: ClipboardEvent;
  48441. /**
  48442. *Creates an instance of ClipboardInfo.
  48443. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48444. * @param event Defines the related dom event
  48445. */
  48446. constructor(
  48447. /**
  48448. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48449. */
  48450. type: number,
  48451. /**
  48452. * Defines the related dom event
  48453. */
  48454. event: ClipboardEvent);
  48455. /**
  48456. * Get the clipboard event's type from the keycode.
  48457. * @param keyCode Defines the keyCode for the current keyboard event.
  48458. * @return {number}
  48459. */
  48460. static GetTypeFromCharacter(keyCode: number): number;
  48461. }
  48462. }
  48463. declare module BABYLON {
  48464. /**
  48465. * Google Daydream controller
  48466. */
  48467. export class DaydreamController extends WebVRController {
  48468. /**
  48469. * Base Url for the controller model.
  48470. */
  48471. static MODEL_BASE_URL: string;
  48472. /**
  48473. * File name for the controller model.
  48474. */
  48475. static MODEL_FILENAME: string;
  48476. /**
  48477. * Gamepad Id prefix used to identify Daydream Controller.
  48478. */
  48479. static readonly GAMEPAD_ID_PREFIX: string;
  48480. /**
  48481. * Creates a new DaydreamController from a gamepad
  48482. * @param vrGamepad the gamepad that the controller should be created from
  48483. */
  48484. constructor(vrGamepad: any);
  48485. /**
  48486. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48487. * @param scene scene in which to add meshes
  48488. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48489. */
  48490. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48491. /**
  48492. * Called once for each button that changed state since the last frame
  48493. * @param buttonIdx Which button index changed
  48494. * @param state New state of the button
  48495. * @param changes Which properties on the state changed since last frame
  48496. */
  48497. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48498. }
  48499. }
  48500. declare module BABYLON {
  48501. /**
  48502. * Gear VR Controller
  48503. */
  48504. export class GearVRController extends WebVRController {
  48505. /**
  48506. * Base Url for the controller model.
  48507. */
  48508. static MODEL_BASE_URL: string;
  48509. /**
  48510. * File name for the controller model.
  48511. */
  48512. static MODEL_FILENAME: string;
  48513. /**
  48514. * Gamepad Id prefix used to identify this controller.
  48515. */
  48516. static readonly GAMEPAD_ID_PREFIX: string;
  48517. private readonly _buttonIndexToObservableNameMap;
  48518. /**
  48519. * Creates a new GearVRController from a gamepad
  48520. * @param vrGamepad the gamepad that the controller should be created from
  48521. */
  48522. constructor(vrGamepad: any);
  48523. /**
  48524. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48525. * @param scene scene in which to add meshes
  48526. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48527. */
  48528. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48529. /**
  48530. * Called once for each button that changed state since the last frame
  48531. * @param buttonIdx Which button index changed
  48532. * @param state New state of the button
  48533. * @param changes Which properties on the state changed since last frame
  48534. */
  48535. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48536. }
  48537. }
  48538. declare module BABYLON {
  48539. /**
  48540. * Generic Controller
  48541. */
  48542. export class GenericController extends WebVRController {
  48543. /**
  48544. * Base Url for the controller model.
  48545. */
  48546. static readonly MODEL_BASE_URL: string;
  48547. /**
  48548. * File name for the controller model.
  48549. */
  48550. static readonly MODEL_FILENAME: string;
  48551. /**
  48552. * Creates a new GenericController from a gamepad
  48553. * @param vrGamepad the gamepad that the controller should be created from
  48554. */
  48555. constructor(vrGamepad: any);
  48556. /**
  48557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48558. * @param scene scene in which to add meshes
  48559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48560. */
  48561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48562. /**
  48563. * Called once for each button that changed state since the last frame
  48564. * @param buttonIdx Which button index changed
  48565. * @param state New state of the button
  48566. * @param changes Which properties on the state changed since last frame
  48567. */
  48568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48569. }
  48570. }
  48571. declare module BABYLON {
  48572. /**
  48573. * Oculus Touch Controller
  48574. */
  48575. export class OculusTouchController extends WebVRController {
  48576. /**
  48577. * Base Url for the controller model.
  48578. */
  48579. static MODEL_BASE_URL: string;
  48580. /**
  48581. * File name for the left controller model.
  48582. */
  48583. static MODEL_LEFT_FILENAME: string;
  48584. /**
  48585. * File name for the right controller model.
  48586. */
  48587. static MODEL_RIGHT_FILENAME: string;
  48588. /**
  48589. * Base Url for the Quest controller model.
  48590. */
  48591. static QUEST_MODEL_BASE_URL: string;
  48592. /**
  48593. * @hidden
  48594. * If the controllers are running on a device that needs the updated Quest controller models
  48595. */
  48596. static _IsQuest: boolean;
  48597. /**
  48598. * Fired when the secondary trigger on this controller is modified
  48599. */
  48600. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48601. /**
  48602. * Fired when the thumb rest on this controller is modified
  48603. */
  48604. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48605. /**
  48606. * Creates a new OculusTouchController from a gamepad
  48607. * @param vrGamepad the gamepad that the controller should be created from
  48608. */
  48609. constructor(vrGamepad: any);
  48610. /**
  48611. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48612. * @param scene scene in which to add meshes
  48613. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48614. */
  48615. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48616. /**
  48617. * Fired when the A button on this controller is modified
  48618. */
  48619. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48620. /**
  48621. * Fired when the B button on this controller is modified
  48622. */
  48623. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48624. /**
  48625. * Fired when the X button on this controller is modified
  48626. */
  48627. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48628. /**
  48629. * Fired when the Y button on this controller is modified
  48630. */
  48631. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48632. /**
  48633. * Called once for each button that changed state since the last frame
  48634. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48635. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48636. * 2) secondary trigger (same)
  48637. * 3) A (right) X (left), touch, pressed = value
  48638. * 4) B / Y
  48639. * 5) thumb rest
  48640. * @param buttonIdx Which button index changed
  48641. * @param state New state of the button
  48642. * @param changes Which properties on the state changed since last frame
  48643. */
  48644. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48645. }
  48646. }
  48647. declare module BABYLON {
  48648. /**
  48649. * Vive Controller
  48650. */
  48651. export class ViveController extends WebVRController {
  48652. /**
  48653. * Base Url for the controller model.
  48654. */
  48655. static MODEL_BASE_URL: string;
  48656. /**
  48657. * File name for the controller model.
  48658. */
  48659. static MODEL_FILENAME: string;
  48660. /**
  48661. * Creates a new ViveController from a gamepad
  48662. * @param vrGamepad the gamepad that the controller should be created from
  48663. */
  48664. constructor(vrGamepad: any);
  48665. /**
  48666. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48667. * @param scene scene in which to add meshes
  48668. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48669. */
  48670. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48671. /**
  48672. * Fired when the left button on this controller is modified
  48673. */
  48674. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48675. /**
  48676. * Fired when the right button on this controller is modified
  48677. */
  48678. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48679. /**
  48680. * Fired when the menu button on this controller is modified
  48681. */
  48682. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48683. /**
  48684. * Called once for each button that changed state since the last frame
  48685. * Vive mapping:
  48686. * 0: touchpad
  48687. * 1: trigger
  48688. * 2: left AND right buttons
  48689. * 3: menu button
  48690. * @param buttonIdx Which button index changed
  48691. * @param state New state of the button
  48692. * @param changes Which properties on the state changed since last frame
  48693. */
  48694. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48695. }
  48696. }
  48697. declare module BABYLON {
  48698. /**
  48699. * Defines the WindowsMotionController object that the state of the windows motion controller
  48700. */
  48701. export class WindowsMotionController extends WebVRController {
  48702. /**
  48703. * The base url used to load the left and right controller models
  48704. */
  48705. static MODEL_BASE_URL: string;
  48706. /**
  48707. * The name of the left controller model file
  48708. */
  48709. static MODEL_LEFT_FILENAME: string;
  48710. /**
  48711. * The name of the right controller model file
  48712. */
  48713. static MODEL_RIGHT_FILENAME: string;
  48714. /**
  48715. * The controller name prefix for this controller type
  48716. */
  48717. static readonly GAMEPAD_ID_PREFIX: string;
  48718. /**
  48719. * The controller id pattern for this controller type
  48720. */
  48721. private static readonly GAMEPAD_ID_PATTERN;
  48722. private _loadedMeshInfo;
  48723. protected readonly _mapping: {
  48724. buttons: string[];
  48725. buttonMeshNames: {
  48726. trigger: string;
  48727. menu: string;
  48728. grip: string;
  48729. thumbstick: string;
  48730. trackpad: string;
  48731. };
  48732. buttonObservableNames: {
  48733. trigger: string;
  48734. menu: string;
  48735. grip: string;
  48736. thumbstick: string;
  48737. trackpad: string;
  48738. };
  48739. axisMeshNames: string[];
  48740. pointingPoseMeshName: string;
  48741. };
  48742. /**
  48743. * Fired when the trackpad on this controller is clicked
  48744. */
  48745. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48746. /**
  48747. * Fired when the trackpad on this controller is modified
  48748. */
  48749. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48750. /**
  48751. * The current x and y values of this controller's trackpad
  48752. */
  48753. trackpad: StickValues;
  48754. /**
  48755. * Creates a new WindowsMotionController from a gamepad
  48756. * @param vrGamepad the gamepad that the controller should be created from
  48757. */
  48758. constructor(vrGamepad: any);
  48759. /**
  48760. * Fired when the trigger on this controller is modified
  48761. */
  48762. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48763. /**
  48764. * Fired when the menu button on this controller is modified
  48765. */
  48766. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48767. /**
  48768. * Fired when the grip button on this controller is modified
  48769. */
  48770. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48771. /**
  48772. * Fired when the thumbstick button on this controller is modified
  48773. */
  48774. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48775. /**
  48776. * Fired when the touchpad button on this controller is modified
  48777. */
  48778. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48779. /**
  48780. * Fired when the touchpad values on this controller are modified
  48781. */
  48782. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48783. protected _updateTrackpad(): void;
  48784. /**
  48785. * Called once per frame by the engine.
  48786. */
  48787. update(): void;
  48788. /**
  48789. * Called once for each button that changed state since the last frame
  48790. * @param buttonIdx Which button index changed
  48791. * @param state New state of the button
  48792. * @param changes Which properties on the state changed since last frame
  48793. */
  48794. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48795. /**
  48796. * Moves the buttons on the controller mesh based on their current state
  48797. * @param buttonName the name of the button to move
  48798. * @param buttonValue the value of the button which determines the buttons new position
  48799. */
  48800. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48801. /**
  48802. * Moves the axis on the controller mesh based on its current state
  48803. * @param axis the index of the axis
  48804. * @param axisValue the value of the axis which determines the meshes new position
  48805. * @hidden
  48806. */
  48807. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48808. /**
  48809. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48810. * @param scene scene in which to add meshes
  48811. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48812. */
  48813. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48814. /**
  48815. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48816. * can be transformed by button presses and axes values, based on this._mapping.
  48817. *
  48818. * @param scene scene in which the meshes exist
  48819. * @param meshes list of meshes that make up the controller model to process
  48820. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48821. */
  48822. private processModel;
  48823. private createMeshInfo;
  48824. /**
  48825. * Gets the ray of the controller in the direction the controller is pointing
  48826. * @param length the length the resulting ray should be
  48827. * @returns a ray in the direction the controller is pointing
  48828. */
  48829. getForwardRay(length?: number): Ray;
  48830. /**
  48831. * Disposes of the controller
  48832. */
  48833. dispose(): void;
  48834. }
  48835. /**
  48836. * This class represents a new windows motion controller in XR.
  48837. */
  48838. export class XRWindowsMotionController extends WindowsMotionController {
  48839. /**
  48840. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48841. */
  48842. protected readonly _mapping: {
  48843. buttons: string[];
  48844. buttonMeshNames: {
  48845. trigger: string;
  48846. menu: string;
  48847. grip: string;
  48848. thumbstick: string;
  48849. trackpad: string;
  48850. };
  48851. buttonObservableNames: {
  48852. trigger: string;
  48853. menu: string;
  48854. grip: string;
  48855. thumbstick: string;
  48856. trackpad: string;
  48857. };
  48858. axisMeshNames: string[];
  48859. pointingPoseMeshName: string;
  48860. };
  48861. /**
  48862. * Construct a new XR-Based windows motion controller
  48863. *
  48864. * @param gamepadInfo the gamepad object from the browser
  48865. */
  48866. constructor(gamepadInfo: any);
  48867. /**
  48868. * holds the thumbstick values (X,Y)
  48869. */
  48870. thumbstickValues: StickValues;
  48871. /**
  48872. * Fired when the thumbstick on this controller is clicked
  48873. */
  48874. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48875. /**
  48876. * Fired when the thumbstick on this controller is modified
  48877. */
  48878. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48879. /**
  48880. * Fired when the touchpad button on this controller is modified
  48881. */
  48882. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48883. /**
  48884. * Fired when the touchpad values on this controller are modified
  48885. */
  48886. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48887. /**
  48888. * Fired when the thumbstick button on this controller is modified
  48889. * here to prevent breaking changes
  48890. */
  48891. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48892. /**
  48893. * updating the thumbstick(!) and not the trackpad.
  48894. * This is named this way due to the difference between WebVR and XR and to avoid
  48895. * changing the parent class.
  48896. */
  48897. protected _updateTrackpad(): void;
  48898. /**
  48899. * Disposes the class with joy
  48900. */
  48901. dispose(): void;
  48902. }
  48903. }
  48904. declare module BABYLON {
  48905. /**
  48906. * Class containing static functions to help procedurally build meshes
  48907. */
  48908. export class PolyhedronBuilder {
  48909. /**
  48910. * Creates a polyhedron mesh
  48911. * * 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
  48912. * * The parameter `size` (positive float, default 1) sets the polygon size
  48913. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48914. * * 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`
  48915. * * 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
  48916. * * 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)`)
  48917. * * 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
  48918. * * 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
  48919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48920. * * 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
  48921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48922. * @param name defines the name of the mesh
  48923. * @param options defines the options used to create the mesh
  48924. * @param scene defines the hosting scene
  48925. * @returns the polyhedron mesh
  48926. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48927. */
  48928. static CreatePolyhedron(name: string, options: {
  48929. type?: number;
  48930. size?: number;
  48931. sizeX?: number;
  48932. sizeY?: number;
  48933. sizeZ?: number;
  48934. custom?: any;
  48935. faceUV?: Vector4[];
  48936. faceColors?: Color4[];
  48937. flat?: boolean;
  48938. updatable?: boolean;
  48939. sideOrientation?: number;
  48940. frontUVs?: Vector4;
  48941. backUVs?: Vector4;
  48942. }, scene?: Nullable<Scene>): Mesh;
  48943. }
  48944. }
  48945. declare module BABYLON {
  48946. /**
  48947. * Gizmo that enables scaling a mesh along 3 axis
  48948. */
  48949. export class ScaleGizmo extends Gizmo {
  48950. /**
  48951. * Internal gizmo used for interactions on the x axis
  48952. */
  48953. xGizmo: AxisScaleGizmo;
  48954. /**
  48955. * Internal gizmo used for interactions on the y axis
  48956. */
  48957. yGizmo: AxisScaleGizmo;
  48958. /**
  48959. * Internal gizmo used for interactions on the z axis
  48960. */
  48961. zGizmo: AxisScaleGizmo;
  48962. /**
  48963. * Internal gizmo used to scale all axis equally
  48964. */
  48965. uniformScaleGizmo: AxisScaleGizmo;
  48966. private _meshAttached;
  48967. private _updateGizmoRotationToMatchAttachedMesh;
  48968. private _snapDistance;
  48969. private _scaleRatio;
  48970. private _uniformScalingMesh;
  48971. private _octahedron;
  48972. private _sensitivity;
  48973. /** Fires an event when any of it's sub gizmos are dragged */
  48974. onDragStartObservable: Observable<unknown>;
  48975. /** Fires an event when any of it's sub gizmos are released from dragging */
  48976. onDragEndObservable: Observable<unknown>;
  48977. get attachedMesh(): Nullable<AbstractMesh>;
  48978. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48979. /**
  48980. * Creates a ScaleGizmo
  48981. * @param gizmoLayer The utility layer the gizmo will be added to
  48982. */
  48983. constructor(gizmoLayer?: UtilityLayerRenderer);
  48984. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48985. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48986. /**
  48987. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48988. */
  48989. set snapDistance(value: number);
  48990. get snapDistance(): number;
  48991. /**
  48992. * Ratio for the scale of the gizmo (Default: 1)
  48993. */
  48994. set scaleRatio(value: number);
  48995. get scaleRatio(): number;
  48996. /**
  48997. * Sensitivity factor for dragging (Default: 1)
  48998. */
  48999. set sensitivity(value: number);
  49000. get sensitivity(): number;
  49001. /**
  49002. * Disposes of the gizmo
  49003. */
  49004. dispose(): void;
  49005. }
  49006. }
  49007. declare module BABYLON {
  49008. /**
  49009. * Single axis scale gizmo
  49010. */
  49011. export class AxisScaleGizmo extends Gizmo {
  49012. /**
  49013. * Drag behavior responsible for the gizmos dragging interactions
  49014. */
  49015. dragBehavior: PointerDragBehavior;
  49016. private _pointerObserver;
  49017. /**
  49018. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49019. */
  49020. snapDistance: number;
  49021. /**
  49022. * Event that fires each time the gizmo snaps to a new location.
  49023. * * snapDistance is the the change in distance
  49024. */
  49025. onSnapObservable: Observable<{
  49026. snapDistance: number;
  49027. }>;
  49028. /**
  49029. * If the scaling operation should be done on all axis (default: false)
  49030. */
  49031. uniformScaling: boolean;
  49032. /**
  49033. * Custom sensitivity value for the drag strength
  49034. */
  49035. sensitivity: number;
  49036. private _isEnabled;
  49037. private _parent;
  49038. private _arrow;
  49039. private _coloredMaterial;
  49040. private _hoverMaterial;
  49041. /**
  49042. * Creates an AxisScaleGizmo
  49043. * @param gizmoLayer The utility layer the gizmo will be added to
  49044. * @param dragAxis The axis which the gizmo will be able to scale on
  49045. * @param color The color of the gizmo
  49046. */
  49047. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49048. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49049. /**
  49050. * If the gizmo is enabled
  49051. */
  49052. set isEnabled(value: boolean);
  49053. get isEnabled(): boolean;
  49054. /**
  49055. * Disposes of the gizmo
  49056. */
  49057. dispose(): void;
  49058. /**
  49059. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49060. * @param mesh The mesh to replace the default mesh of the gizmo
  49061. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49062. */
  49063. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49064. }
  49065. }
  49066. declare module BABYLON {
  49067. /**
  49068. * Bounding box gizmo
  49069. */
  49070. export class BoundingBoxGizmo extends Gizmo {
  49071. private _lineBoundingBox;
  49072. private _rotateSpheresParent;
  49073. private _scaleBoxesParent;
  49074. private _boundingDimensions;
  49075. private _renderObserver;
  49076. private _pointerObserver;
  49077. private _scaleDragSpeed;
  49078. private _tmpQuaternion;
  49079. private _tmpVector;
  49080. private _tmpRotationMatrix;
  49081. /**
  49082. * 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)
  49083. */
  49084. ignoreChildren: boolean;
  49085. /**
  49086. * 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)
  49087. */
  49088. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49089. /**
  49090. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49091. */
  49092. rotationSphereSize: number;
  49093. /**
  49094. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49095. */
  49096. scaleBoxSize: number;
  49097. /**
  49098. * 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)
  49099. */
  49100. fixedDragMeshScreenSize: boolean;
  49101. /**
  49102. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49103. */
  49104. fixedDragMeshScreenSizeDistanceFactor: number;
  49105. /**
  49106. * Fired when a rotation sphere or scale box is dragged
  49107. */
  49108. onDragStartObservable: Observable<{}>;
  49109. /**
  49110. * Fired when a scale box is dragged
  49111. */
  49112. onScaleBoxDragObservable: Observable<{}>;
  49113. /**
  49114. * Fired when a scale box drag is ended
  49115. */
  49116. onScaleBoxDragEndObservable: Observable<{}>;
  49117. /**
  49118. * Fired when a rotation sphere is dragged
  49119. */
  49120. onRotationSphereDragObservable: Observable<{}>;
  49121. /**
  49122. * Fired when a rotation sphere drag is ended
  49123. */
  49124. onRotationSphereDragEndObservable: Observable<{}>;
  49125. /**
  49126. * 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)
  49127. */
  49128. scalePivot: Nullable<Vector3>;
  49129. /**
  49130. * Mesh used as a pivot to rotate the attached mesh
  49131. */
  49132. private _anchorMesh;
  49133. private _existingMeshScale;
  49134. private _dragMesh;
  49135. private pointerDragBehavior;
  49136. private coloredMaterial;
  49137. private hoverColoredMaterial;
  49138. /**
  49139. * Sets the color of the bounding box gizmo
  49140. * @param color the color to set
  49141. */
  49142. setColor(color: Color3): void;
  49143. /**
  49144. * Creates an BoundingBoxGizmo
  49145. * @param gizmoLayer The utility layer the gizmo will be added to
  49146. * @param color The color of the gizmo
  49147. */
  49148. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49149. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49150. private _selectNode;
  49151. /**
  49152. * Updates the bounding box information for the Gizmo
  49153. */
  49154. updateBoundingBox(): void;
  49155. private _updateRotationSpheres;
  49156. private _updateScaleBoxes;
  49157. /**
  49158. * Enables rotation on the specified axis and disables rotation on the others
  49159. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49160. */
  49161. setEnabledRotationAxis(axis: string): void;
  49162. /**
  49163. * Enables/disables scaling
  49164. * @param enable if scaling should be enabled
  49165. * @param homogeneousScaling defines if scaling should only be homogeneous
  49166. */
  49167. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49168. private _updateDummy;
  49169. /**
  49170. * Enables a pointer drag behavior on the bounding box of the gizmo
  49171. */
  49172. enableDragBehavior(): void;
  49173. /**
  49174. * Disposes of the gizmo
  49175. */
  49176. dispose(): void;
  49177. /**
  49178. * 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)
  49179. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49180. * @returns the bounding box mesh with the passed in mesh as a child
  49181. */
  49182. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49183. /**
  49184. * CustomMeshes are not supported by this gizmo
  49185. * @param mesh The mesh to replace the default mesh of the gizmo
  49186. */
  49187. setCustomMesh(mesh: Mesh): void;
  49188. }
  49189. }
  49190. declare module BABYLON {
  49191. /**
  49192. * Single plane rotation gizmo
  49193. */
  49194. export class PlaneRotationGizmo extends Gizmo {
  49195. /**
  49196. * Drag behavior responsible for the gizmos dragging interactions
  49197. */
  49198. dragBehavior: PointerDragBehavior;
  49199. private _pointerObserver;
  49200. /**
  49201. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49202. */
  49203. snapDistance: number;
  49204. /**
  49205. * Event that fires each time the gizmo snaps to a new location.
  49206. * * snapDistance is the the change in distance
  49207. */
  49208. onSnapObservable: Observable<{
  49209. snapDistance: number;
  49210. }>;
  49211. private _isEnabled;
  49212. private _parent;
  49213. /**
  49214. * Creates a PlaneRotationGizmo
  49215. * @param gizmoLayer The utility layer the gizmo will be added to
  49216. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49217. * @param color The color of the gizmo
  49218. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49219. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49220. */
  49221. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49222. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49223. /**
  49224. * If the gizmo is enabled
  49225. */
  49226. set isEnabled(value: boolean);
  49227. get isEnabled(): boolean;
  49228. /**
  49229. * Disposes of the gizmo
  49230. */
  49231. dispose(): void;
  49232. }
  49233. }
  49234. declare module BABYLON {
  49235. /**
  49236. * Gizmo that enables rotating a mesh along 3 axis
  49237. */
  49238. export class RotationGizmo extends Gizmo {
  49239. /**
  49240. * Internal gizmo used for interactions on the x axis
  49241. */
  49242. xGizmo: PlaneRotationGizmo;
  49243. /**
  49244. * Internal gizmo used for interactions on the y axis
  49245. */
  49246. yGizmo: PlaneRotationGizmo;
  49247. /**
  49248. * Internal gizmo used for interactions on the z axis
  49249. */
  49250. zGizmo: PlaneRotationGizmo;
  49251. /** Fires an event when any of it's sub gizmos are dragged */
  49252. onDragStartObservable: Observable<unknown>;
  49253. /** Fires an event when any of it's sub gizmos are released from dragging */
  49254. onDragEndObservable: Observable<unknown>;
  49255. private _meshAttached;
  49256. get attachedMesh(): Nullable<AbstractMesh>;
  49257. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49258. /**
  49259. * Creates a RotationGizmo
  49260. * @param gizmoLayer The utility layer the gizmo will be added to
  49261. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49262. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49263. */
  49264. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49265. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49266. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49267. /**
  49268. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49269. */
  49270. set snapDistance(value: number);
  49271. get snapDistance(): number;
  49272. /**
  49273. * Ratio for the scale of the gizmo (Default: 1)
  49274. */
  49275. set scaleRatio(value: number);
  49276. get scaleRatio(): number;
  49277. /**
  49278. * Disposes of the gizmo
  49279. */
  49280. dispose(): void;
  49281. /**
  49282. * CustomMeshes are not supported by this gizmo
  49283. * @param mesh The mesh to replace the default mesh of the gizmo
  49284. */
  49285. setCustomMesh(mesh: Mesh): void;
  49286. }
  49287. }
  49288. declare module BABYLON {
  49289. /**
  49290. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49291. */
  49292. export class GizmoManager implements IDisposable {
  49293. private scene;
  49294. /**
  49295. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49296. */
  49297. gizmos: {
  49298. positionGizmo: Nullable<PositionGizmo>;
  49299. rotationGizmo: Nullable<RotationGizmo>;
  49300. scaleGizmo: Nullable<ScaleGizmo>;
  49301. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49302. };
  49303. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49304. clearGizmoOnEmptyPointerEvent: boolean;
  49305. /** Fires an event when the manager is attached to a mesh */
  49306. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49307. private _gizmosEnabled;
  49308. private _pointerObserver;
  49309. private _attachedMesh;
  49310. private _boundingBoxColor;
  49311. private _defaultUtilityLayer;
  49312. private _defaultKeepDepthUtilityLayer;
  49313. /**
  49314. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49315. */
  49316. boundingBoxDragBehavior: SixDofDragBehavior;
  49317. /**
  49318. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49319. */
  49320. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49321. /**
  49322. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49323. */
  49324. usePointerToAttachGizmos: boolean;
  49325. /**
  49326. * Utility layer that the bounding box gizmo belongs to
  49327. */
  49328. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49329. /**
  49330. * Utility layer that all gizmos besides bounding box belong to
  49331. */
  49332. get utilityLayer(): UtilityLayerRenderer;
  49333. /**
  49334. * Instatiates a gizmo manager
  49335. * @param scene the scene to overlay the gizmos on top of
  49336. */
  49337. constructor(scene: Scene);
  49338. /**
  49339. * Attaches a set of gizmos to the specified mesh
  49340. * @param mesh The mesh the gizmo's should be attached to
  49341. */
  49342. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49343. /**
  49344. * If the position gizmo is enabled
  49345. */
  49346. set positionGizmoEnabled(value: boolean);
  49347. get positionGizmoEnabled(): boolean;
  49348. /**
  49349. * If the rotation gizmo is enabled
  49350. */
  49351. set rotationGizmoEnabled(value: boolean);
  49352. get rotationGizmoEnabled(): boolean;
  49353. /**
  49354. * If the scale gizmo is enabled
  49355. */
  49356. set scaleGizmoEnabled(value: boolean);
  49357. get scaleGizmoEnabled(): boolean;
  49358. /**
  49359. * If the boundingBox gizmo is enabled
  49360. */
  49361. set boundingBoxGizmoEnabled(value: boolean);
  49362. get boundingBoxGizmoEnabled(): boolean;
  49363. /**
  49364. * Disposes of the gizmo manager
  49365. */
  49366. dispose(): void;
  49367. }
  49368. }
  49369. declare module BABYLON {
  49370. /**
  49371. * A directional light is defined by a direction (what a surprise!).
  49372. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49373. * 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.
  49374. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49375. */
  49376. export class DirectionalLight extends ShadowLight {
  49377. private _shadowFrustumSize;
  49378. /**
  49379. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49380. */
  49381. get shadowFrustumSize(): number;
  49382. /**
  49383. * Specifies a fix frustum size for the shadow generation.
  49384. */
  49385. set shadowFrustumSize(value: number);
  49386. private _shadowOrthoScale;
  49387. /**
  49388. * Gets the shadow projection scale against the optimal computed one.
  49389. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49390. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49391. */
  49392. get shadowOrthoScale(): number;
  49393. /**
  49394. * Sets the shadow projection scale against the optimal computed one.
  49395. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49396. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49397. */
  49398. set shadowOrthoScale(value: number);
  49399. /**
  49400. * Automatically compute the projection matrix to best fit (including all the casters)
  49401. * on each frame.
  49402. */
  49403. autoUpdateExtends: boolean;
  49404. /**
  49405. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49406. * on each frame. autoUpdateExtends must be set to true for this to work
  49407. */
  49408. autoCalcShadowZBounds: boolean;
  49409. private _orthoLeft;
  49410. private _orthoRight;
  49411. private _orthoTop;
  49412. private _orthoBottom;
  49413. /**
  49414. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49415. * The directional light is emitted from everywhere in the given direction.
  49416. * It can cast shadows.
  49417. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49418. * @param name The friendly name of the light
  49419. * @param direction The direction of the light
  49420. * @param scene The scene the light belongs to
  49421. */
  49422. constructor(name: string, direction: Vector3, scene: Scene);
  49423. /**
  49424. * Returns the string "DirectionalLight".
  49425. * @return The class name
  49426. */
  49427. getClassName(): string;
  49428. /**
  49429. * Returns the integer 1.
  49430. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49431. */
  49432. getTypeID(): number;
  49433. /**
  49434. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49435. * Returns the DirectionalLight Shadow projection matrix.
  49436. */
  49437. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49438. /**
  49439. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49440. * Returns the DirectionalLight Shadow projection matrix.
  49441. */
  49442. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49443. /**
  49444. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49445. * Returns the DirectionalLight Shadow projection matrix.
  49446. */
  49447. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49448. protected _buildUniformLayout(): void;
  49449. /**
  49450. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49451. * @param effect The effect to update
  49452. * @param lightIndex The index of the light in the effect to update
  49453. * @returns The directional light
  49454. */
  49455. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49456. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49457. /**
  49458. * Gets the minZ used for shadow according to both the scene and the light.
  49459. *
  49460. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49461. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49462. * @param activeCamera The camera we are returning the min for
  49463. * @returns the depth min z
  49464. */
  49465. getDepthMinZ(activeCamera: Camera): number;
  49466. /**
  49467. * Gets the maxZ used for shadow according to both the scene and the light.
  49468. *
  49469. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49470. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49471. * @param activeCamera The camera we are returning the max for
  49472. * @returns the depth max z
  49473. */
  49474. getDepthMaxZ(activeCamera: Camera): number;
  49475. /**
  49476. * Prepares the list of defines specific to the light type.
  49477. * @param defines the list of defines
  49478. * @param lightIndex defines the index of the light for the effect
  49479. */
  49480. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49481. }
  49482. }
  49483. declare module BABYLON {
  49484. /**
  49485. * Class containing static functions to help procedurally build meshes
  49486. */
  49487. export class HemisphereBuilder {
  49488. /**
  49489. * Creates a hemisphere mesh
  49490. * @param name defines the name of the mesh
  49491. * @param options defines the options used to create the mesh
  49492. * @param scene defines the hosting scene
  49493. * @returns the hemisphere mesh
  49494. */
  49495. static CreateHemisphere(name: string, options: {
  49496. segments?: number;
  49497. diameter?: number;
  49498. sideOrientation?: number;
  49499. }, scene: any): Mesh;
  49500. }
  49501. }
  49502. declare module BABYLON {
  49503. /**
  49504. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49505. * These values define a cone of light starting from the position, emitting toward the direction.
  49506. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49507. * and the exponent defines the speed of the decay of the light with distance (reach).
  49508. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49509. */
  49510. export class SpotLight extends ShadowLight {
  49511. private _angle;
  49512. private _innerAngle;
  49513. private _cosHalfAngle;
  49514. private _lightAngleScale;
  49515. private _lightAngleOffset;
  49516. /**
  49517. * Gets the cone angle of the spot light in Radians.
  49518. */
  49519. get angle(): number;
  49520. /**
  49521. * Sets the cone angle of the spot light in Radians.
  49522. */
  49523. set angle(value: number);
  49524. /**
  49525. * Only used in gltf falloff mode, this defines the angle where
  49526. * the directional falloff will start before cutting at angle which could be seen
  49527. * as outer angle.
  49528. */
  49529. get innerAngle(): number;
  49530. /**
  49531. * Only used in gltf falloff mode, this defines the angle where
  49532. * the directional falloff will start before cutting at angle which could be seen
  49533. * as outer angle.
  49534. */
  49535. set innerAngle(value: number);
  49536. private _shadowAngleScale;
  49537. /**
  49538. * Allows scaling the angle of the light for shadow generation only.
  49539. */
  49540. get shadowAngleScale(): number;
  49541. /**
  49542. * Allows scaling the angle of the light for shadow generation only.
  49543. */
  49544. set shadowAngleScale(value: number);
  49545. /**
  49546. * The light decay speed with the distance from the emission spot.
  49547. */
  49548. exponent: number;
  49549. private _projectionTextureMatrix;
  49550. /**
  49551. * Allows reading the projecton texture
  49552. */
  49553. get projectionTextureMatrix(): Matrix;
  49554. protected _projectionTextureLightNear: number;
  49555. /**
  49556. * Gets the near clip of the Spotlight for texture projection.
  49557. */
  49558. get projectionTextureLightNear(): number;
  49559. /**
  49560. * Sets the near clip of the Spotlight for texture projection.
  49561. */
  49562. set projectionTextureLightNear(value: number);
  49563. protected _projectionTextureLightFar: number;
  49564. /**
  49565. * Gets the far clip of the Spotlight for texture projection.
  49566. */
  49567. get projectionTextureLightFar(): number;
  49568. /**
  49569. * Sets the far clip of the Spotlight for texture projection.
  49570. */
  49571. set projectionTextureLightFar(value: number);
  49572. protected _projectionTextureUpDirection: Vector3;
  49573. /**
  49574. * Gets the Up vector of the Spotlight for texture projection.
  49575. */
  49576. get projectionTextureUpDirection(): Vector3;
  49577. /**
  49578. * Sets the Up vector of the Spotlight for texture projection.
  49579. */
  49580. set projectionTextureUpDirection(value: Vector3);
  49581. private _projectionTexture;
  49582. /**
  49583. * Gets the projection texture of the light.
  49584. */
  49585. get projectionTexture(): Nullable<BaseTexture>;
  49586. /**
  49587. * Sets the projection texture of the light.
  49588. */
  49589. set projectionTexture(value: Nullable<BaseTexture>);
  49590. private _projectionTextureViewLightDirty;
  49591. private _projectionTextureProjectionLightDirty;
  49592. private _projectionTextureDirty;
  49593. private _projectionTextureViewTargetVector;
  49594. private _projectionTextureViewLightMatrix;
  49595. private _projectionTextureProjectionLightMatrix;
  49596. private _projectionTextureScalingMatrix;
  49597. /**
  49598. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49599. * It can cast shadows.
  49600. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49601. * @param name The light friendly name
  49602. * @param position The position of the spot light in the scene
  49603. * @param direction The direction of the light in the scene
  49604. * @param angle The cone angle of the light in Radians
  49605. * @param exponent The light decay speed with the distance from the emission spot
  49606. * @param scene The scene the lights belongs to
  49607. */
  49608. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49609. /**
  49610. * Returns the string "SpotLight".
  49611. * @returns the class name
  49612. */
  49613. getClassName(): string;
  49614. /**
  49615. * Returns the integer 2.
  49616. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49617. */
  49618. getTypeID(): number;
  49619. /**
  49620. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49621. */
  49622. protected _setDirection(value: Vector3): void;
  49623. /**
  49624. * Overrides the position setter to recompute the projection texture view light Matrix.
  49625. */
  49626. protected _setPosition(value: Vector3): void;
  49627. /**
  49628. * 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.
  49629. * Returns the SpotLight.
  49630. */
  49631. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49632. protected _computeProjectionTextureViewLightMatrix(): void;
  49633. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49634. /**
  49635. * Main function for light texture projection matrix computing.
  49636. */
  49637. protected _computeProjectionTextureMatrix(): void;
  49638. protected _buildUniformLayout(): void;
  49639. private _computeAngleValues;
  49640. /**
  49641. * Sets the passed Effect "effect" with the Light textures.
  49642. * @param effect The effect to update
  49643. * @param lightIndex The index of the light in the effect to update
  49644. * @returns The light
  49645. */
  49646. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49647. /**
  49648. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49649. * @param effect The effect to update
  49650. * @param lightIndex The index of the light in the effect to update
  49651. * @returns The spot light
  49652. */
  49653. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49654. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49655. /**
  49656. * Disposes the light and the associated resources.
  49657. */
  49658. dispose(): void;
  49659. /**
  49660. * Prepares the list of defines specific to the light type.
  49661. * @param defines the list of defines
  49662. * @param lightIndex defines the index of the light for the effect
  49663. */
  49664. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49665. }
  49666. }
  49667. declare module BABYLON {
  49668. /**
  49669. * Gizmo that enables viewing a light
  49670. */
  49671. export class LightGizmo extends Gizmo {
  49672. private _lightMesh;
  49673. private _material;
  49674. private _cachedPosition;
  49675. private _cachedForward;
  49676. private _attachedMeshParent;
  49677. /**
  49678. * Creates a LightGizmo
  49679. * @param gizmoLayer The utility layer the gizmo will be added to
  49680. */
  49681. constructor(gizmoLayer?: UtilityLayerRenderer);
  49682. private _light;
  49683. /**
  49684. * The light that the gizmo is attached to
  49685. */
  49686. set light(light: Nullable<Light>);
  49687. get light(): Nullable<Light>;
  49688. /**
  49689. * Gets the material used to render the light gizmo
  49690. */
  49691. get material(): StandardMaterial;
  49692. /**
  49693. * @hidden
  49694. * Updates the gizmo to match the attached mesh's position/rotation
  49695. */
  49696. protected _update(): void;
  49697. private static _Scale;
  49698. /**
  49699. * Creates the lines for a light mesh
  49700. */
  49701. private static _CreateLightLines;
  49702. /**
  49703. * Disposes of the light gizmo
  49704. */
  49705. dispose(): void;
  49706. private static _CreateHemisphericLightMesh;
  49707. private static _CreatePointLightMesh;
  49708. private static _CreateSpotLightMesh;
  49709. private static _CreateDirectionalLightMesh;
  49710. }
  49711. }
  49712. declare module BABYLON {
  49713. /** @hidden */
  49714. export var backgroundFragmentDeclaration: {
  49715. name: string;
  49716. shader: string;
  49717. };
  49718. }
  49719. declare module BABYLON {
  49720. /** @hidden */
  49721. export var backgroundUboDeclaration: {
  49722. name: string;
  49723. shader: string;
  49724. };
  49725. }
  49726. declare module BABYLON {
  49727. /** @hidden */
  49728. export var backgroundPixelShader: {
  49729. name: string;
  49730. shader: string;
  49731. };
  49732. }
  49733. declare module BABYLON {
  49734. /** @hidden */
  49735. export var backgroundVertexDeclaration: {
  49736. name: string;
  49737. shader: string;
  49738. };
  49739. }
  49740. declare module BABYLON {
  49741. /** @hidden */
  49742. export var backgroundVertexShader: {
  49743. name: string;
  49744. shader: string;
  49745. };
  49746. }
  49747. declare module BABYLON {
  49748. /**
  49749. * Background material used to create an efficient environement around your scene.
  49750. */
  49751. export class BackgroundMaterial extends PushMaterial {
  49752. /**
  49753. * Standard reflectance value at parallel view angle.
  49754. */
  49755. static StandardReflectance0: number;
  49756. /**
  49757. * Standard reflectance value at grazing angle.
  49758. */
  49759. static StandardReflectance90: number;
  49760. protected _primaryColor: Color3;
  49761. /**
  49762. * Key light Color (multiply against the environement texture)
  49763. */
  49764. primaryColor: Color3;
  49765. protected __perceptualColor: Nullable<Color3>;
  49766. /**
  49767. * Experimental Internal Use Only.
  49768. *
  49769. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49770. * This acts as a helper to set the primary color to a more "human friendly" value.
  49771. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49772. * output color as close as possible from the chosen value.
  49773. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49774. * part of lighting setup.)
  49775. */
  49776. get _perceptualColor(): Nullable<Color3>;
  49777. set _perceptualColor(value: Nullable<Color3>);
  49778. protected _primaryColorShadowLevel: float;
  49779. /**
  49780. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49781. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49782. */
  49783. get primaryColorShadowLevel(): float;
  49784. set primaryColorShadowLevel(value: float);
  49785. protected _primaryColorHighlightLevel: float;
  49786. /**
  49787. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49788. * The primary color is used at the level chosen to define what the white area would look.
  49789. */
  49790. get primaryColorHighlightLevel(): float;
  49791. set primaryColorHighlightLevel(value: float);
  49792. protected _reflectionTexture: Nullable<BaseTexture>;
  49793. /**
  49794. * Reflection Texture used in the material.
  49795. * Should be author in a specific way for the best result (refer to the documentation).
  49796. */
  49797. reflectionTexture: Nullable<BaseTexture>;
  49798. protected _reflectionBlur: float;
  49799. /**
  49800. * Reflection Texture level of blur.
  49801. *
  49802. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49803. * texture twice.
  49804. */
  49805. reflectionBlur: float;
  49806. protected _diffuseTexture: Nullable<BaseTexture>;
  49807. /**
  49808. * Diffuse Texture used in the material.
  49809. * Should be author in a specific way for the best result (refer to the documentation).
  49810. */
  49811. diffuseTexture: Nullable<BaseTexture>;
  49812. protected _shadowLights: Nullable<IShadowLight[]>;
  49813. /**
  49814. * Specify the list of lights casting shadow on the material.
  49815. * All scene shadow lights will be included if null.
  49816. */
  49817. shadowLights: Nullable<IShadowLight[]>;
  49818. protected _shadowLevel: float;
  49819. /**
  49820. * Helps adjusting the shadow to a softer level if required.
  49821. * 0 means black shadows and 1 means no shadows.
  49822. */
  49823. shadowLevel: float;
  49824. protected _sceneCenter: Vector3;
  49825. /**
  49826. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49827. * It is usually zero but might be interesting to modify according to your setup.
  49828. */
  49829. sceneCenter: Vector3;
  49830. protected _opacityFresnel: boolean;
  49831. /**
  49832. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49833. * This helps ensuring a nice transition when the camera goes under the ground.
  49834. */
  49835. opacityFresnel: boolean;
  49836. protected _reflectionFresnel: boolean;
  49837. /**
  49838. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49839. * This helps adding a mirror texture on the ground.
  49840. */
  49841. reflectionFresnel: boolean;
  49842. protected _reflectionFalloffDistance: number;
  49843. /**
  49844. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49845. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49846. */
  49847. reflectionFalloffDistance: number;
  49848. protected _reflectionAmount: number;
  49849. /**
  49850. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49851. */
  49852. reflectionAmount: number;
  49853. protected _reflectionReflectance0: number;
  49854. /**
  49855. * This specifies the weight of the reflection at grazing angle.
  49856. */
  49857. reflectionReflectance0: number;
  49858. protected _reflectionReflectance90: number;
  49859. /**
  49860. * This specifies the weight of the reflection at a perpendicular point of view.
  49861. */
  49862. reflectionReflectance90: number;
  49863. /**
  49864. * Sets the reflection reflectance fresnel values according to the default standard
  49865. * empirically know to work well :-)
  49866. */
  49867. set reflectionStandardFresnelWeight(value: number);
  49868. protected _useRGBColor: boolean;
  49869. /**
  49870. * Helps to directly use the maps channels instead of their level.
  49871. */
  49872. useRGBColor: boolean;
  49873. protected _enableNoise: boolean;
  49874. /**
  49875. * This helps reducing the banding effect that could occur on the background.
  49876. */
  49877. enableNoise: boolean;
  49878. /**
  49879. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49880. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49881. * Recommended to be keep at 1.0 except for special cases.
  49882. */
  49883. get fovMultiplier(): number;
  49884. set fovMultiplier(value: number);
  49885. private _fovMultiplier;
  49886. /**
  49887. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49888. */
  49889. useEquirectangularFOV: boolean;
  49890. private _maxSimultaneousLights;
  49891. /**
  49892. * Number of Simultaneous lights allowed on the material.
  49893. */
  49894. maxSimultaneousLights: int;
  49895. /**
  49896. * Default configuration related to image processing available in the Background Material.
  49897. */
  49898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49899. /**
  49900. * Keep track of the image processing observer to allow dispose and replace.
  49901. */
  49902. private _imageProcessingObserver;
  49903. /**
  49904. * Attaches a new image processing configuration to the PBR Material.
  49905. * @param configuration (if null the scene configuration will be use)
  49906. */
  49907. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49908. /**
  49909. * Gets the image processing configuration used either in this material.
  49910. */
  49911. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49912. /**
  49913. * Sets the Default image processing configuration used either in the this material.
  49914. *
  49915. * If sets to null, the scene one is in use.
  49916. */
  49917. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49918. /**
  49919. * Gets wether the color curves effect is enabled.
  49920. */
  49921. get cameraColorCurvesEnabled(): boolean;
  49922. /**
  49923. * Sets wether the color curves effect is enabled.
  49924. */
  49925. set cameraColorCurvesEnabled(value: boolean);
  49926. /**
  49927. * Gets wether the color grading effect is enabled.
  49928. */
  49929. get cameraColorGradingEnabled(): boolean;
  49930. /**
  49931. * Gets wether the color grading effect is enabled.
  49932. */
  49933. set cameraColorGradingEnabled(value: boolean);
  49934. /**
  49935. * Gets wether tonemapping is enabled or not.
  49936. */
  49937. get cameraToneMappingEnabled(): boolean;
  49938. /**
  49939. * Sets wether tonemapping is enabled or not
  49940. */
  49941. set cameraToneMappingEnabled(value: boolean);
  49942. /**
  49943. * The camera exposure used on this material.
  49944. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49945. * This corresponds to a photographic exposure.
  49946. */
  49947. get cameraExposure(): float;
  49948. /**
  49949. * The camera exposure used on this material.
  49950. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49951. * This corresponds to a photographic exposure.
  49952. */
  49953. set cameraExposure(value: float);
  49954. /**
  49955. * Gets The camera contrast used on this material.
  49956. */
  49957. get cameraContrast(): float;
  49958. /**
  49959. * Sets The camera contrast used on this material.
  49960. */
  49961. set cameraContrast(value: float);
  49962. /**
  49963. * Gets the Color Grading 2D Lookup Texture.
  49964. */
  49965. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49966. /**
  49967. * Sets the Color Grading 2D Lookup Texture.
  49968. */
  49969. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49970. /**
  49971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49973. * 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;
  49974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49975. */
  49976. get cameraColorCurves(): Nullable<ColorCurves>;
  49977. /**
  49978. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49979. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49980. * 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;
  49981. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49982. */
  49983. set cameraColorCurves(value: Nullable<ColorCurves>);
  49984. /**
  49985. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49986. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49987. */
  49988. switchToBGR: boolean;
  49989. private _renderTargets;
  49990. private _reflectionControls;
  49991. private _white;
  49992. private _primaryShadowColor;
  49993. private _primaryHighlightColor;
  49994. /**
  49995. * Instantiates a Background Material in the given scene
  49996. * @param name The friendly name of the material
  49997. * @param scene The scene to add the material to
  49998. */
  49999. constructor(name: string, scene: Scene);
  50000. /**
  50001. * Gets a boolean indicating that current material needs to register RTT
  50002. */
  50003. get hasRenderTargetTextures(): boolean;
  50004. /**
  50005. * The entire material has been created in order to prevent overdraw.
  50006. * @returns false
  50007. */
  50008. needAlphaTesting(): boolean;
  50009. /**
  50010. * The entire material has been created in order to prevent overdraw.
  50011. * @returns true if blending is enable
  50012. */
  50013. needAlphaBlending(): boolean;
  50014. /**
  50015. * Checks wether the material is ready to be rendered for a given mesh.
  50016. * @param mesh The mesh to render
  50017. * @param subMesh The submesh to check against
  50018. * @param useInstances Specify wether or not the material is used with instances
  50019. * @returns true if all the dependencies are ready (Textures, Effects...)
  50020. */
  50021. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50022. /**
  50023. * Compute the primary color according to the chosen perceptual color.
  50024. */
  50025. private _computePrimaryColorFromPerceptualColor;
  50026. /**
  50027. * Compute the highlights and shadow colors according to their chosen levels.
  50028. */
  50029. private _computePrimaryColors;
  50030. /**
  50031. * Build the uniform buffer used in the material.
  50032. */
  50033. buildUniformLayout(): void;
  50034. /**
  50035. * Unbind the material.
  50036. */
  50037. unbind(): void;
  50038. /**
  50039. * Bind only the world matrix to the material.
  50040. * @param world The world matrix to bind.
  50041. */
  50042. bindOnlyWorldMatrix(world: Matrix): void;
  50043. /**
  50044. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50045. * @param world The world matrix to bind.
  50046. * @param subMesh The submesh to bind for.
  50047. */
  50048. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50049. /**
  50050. * Checks to see if a texture is used in the material.
  50051. * @param texture - Base texture to use.
  50052. * @returns - Boolean specifying if a texture is used in the material.
  50053. */
  50054. hasTexture(texture: BaseTexture): boolean;
  50055. /**
  50056. * Dispose the material.
  50057. * @param forceDisposeEffect Force disposal of the associated effect.
  50058. * @param forceDisposeTextures Force disposal of the associated textures.
  50059. */
  50060. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50061. /**
  50062. * Clones the material.
  50063. * @param name The cloned name.
  50064. * @returns The cloned material.
  50065. */
  50066. clone(name: string): BackgroundMaterial;
  50067. /**
  50068. * Serializes the current material to its JSON representation.
  50069. * @returns The JSON representation.
  50070. */
  50071. serialize(): any;
  50072. /**
  50073. * Gets the class name of the material
  50074. * @returns "BackgroundMaterial"
  50075. */
  50076. getClassName(): string;
  50077. /**
  50078. * Parse a JSON input to create back a background material.
  50079. * @param source The JSON data to parse
  50080. * @param scene The scene to create the parsed material in
  50081. * @param rootUrl The root url of the assets the material depends upon
  50082. * @returns the instantiated BackgroundMaterial.
  50083. */
  50084. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50085. }
  50086. }
  50087. declare module BABYLON {
  50088. /**
  50089. * Represents the different options available during the creation of
  50090. * a Environment helper.
  50091. *
  50092. * This can control the default ground, skybox and image processing setup of your scene.
  50093. */
  50094. export interface IEnvironmentHelperOptions {
  50095. /**
  50096. * Specifies whether or not to create a ground.
  50097. * True by default.
  50098. */
  50099. createGround: boolean;
  50100. /**
  50101. * Specifies the ground size.
  50102. * 15 by default.
  50103. */
  50104. groundSize: number;
  50105. /**
  50106. * The texture used on the ground for the main color.
  50107. * Comes from the BabylonJS CDN by default.
  50108. *
  50109. * Remarks: Can be either a texture or a url.
  50110. */
  50111. groundTexture: string | BaseTexture;
  50112. /**
  50113. * The color mixed in the ground texture by default.
  50114. * BabylonJS clearColor by default.
  50115. */
  50116. groundColor: Color3;
  50117. /**
  50118. * Specifies the ground opacity.
  50119. * 1 by default.
  50120. */
  50121. groundOpacity: number;
  50122. /**
  50123. * Enables the ground to receive shadows.
  50124. * True by default.
  50125. */
  50126. enableGroundShadow: boolean;
  50127. /**
  50128. * Helps preventing the shadow to be fully black on the ground.
  50129. * 0.5 by default.
  50130. */
  50131. groundShadowLevel: number;
  50132. /**
  50133. * Creates a mirror texture attach to the ground.
  50134. * false by default.
  50135. */
  50136. enableGroundMirror: boolean;
  50137. /**
  50138. * Specifies the ground mirror size ratio.
  50139. * 0.3 by default as the default kernel is 64.
  50140. */
  50141. groundMirrorSizeRatio: number;
  50142. /**
  50143. * Specifies the ground mirror blur kernel size.
  50144. * 64 by default.
  50145. */
  50146. groundMirrorBlurKernel: number;
  50147. /**
  50148. * Specifies the ground mirror visibility amount.
  50149. * 1 by default
  50150. */
  50151. groundMirrorAmount: number;
  50152. /**
  50153. * Specifies the ground mirror reflectance weight.
  50154. * This uses the standard weight of the background material to setup the fresnel effect
  50155. * of the mirror.
  50156. * 1 by default.
  50157. */
  50158. groundMirrorFresnelWeight: number;
  50159. /**
  50160. * Specifies the ground mirror Falloff distance.
  50161. * This can helps reducing the size of the reflection.
  50162. * 0 by Default.
  50163. */
  50164. groundMirrorFallOffDistance: number;
  50165. /**
  50166. * Specifies the ground mirror texture type.
  50167. * Unsigned Int by Default.
  50168. */
  50169. groundMirrorTextureType: number;
  50170. /**
  50171. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50172. * the shown objects.
  50173. */
  50174. groundYBias: number;
  50175. /**
  50176. * Specifies whether or not to create a skybox.
  50177. * True by default.
  50178. */
  50179. createSkybox: boolean;
  50180. /**
  50181. * Specifies the skybox size.
  50182. * 20 by default.
  50183. */
  50184. skyboxSize: number;
  50185. /**
  50186. * The texture used on the skybox for the main color.
  50187. * Comes from the BabylonJS CDN by default.
  50188. *
  50189. * Remarks: Can be either a texture or a url.
  50190. */
  50191. skyboxTexture: string | BaseTexture;
  50192. /**
  50193. * The color mixed in the skybox texture by default.
  50194. * BabylonJS clearColor by default.
  50195. */
  50196. skyboxColor: Color3;
  50197. /**
  50198. * The background rotation around the Y axis of the scene.
  50199. * This helps aligning the key lights of your scene with the background.
  50200. * 0 by default.
  50201. */
  50202. backgroundYRotation: number;
  50203. /**
  50204. * Compute automatically the size of the elements to best fit with the scene.
  50205. */
  50206. sizeAuto: boolean;
  50207. /**
  50208. * Default position of the rootMesh if autoSize is not true.
  50209. */
  50210. rootPosition: Vector3;
  50211. /**
  50212. * Sets up the image processing in the scene.
  50213. * true by default.
  50214. */
  50215. setupImageProcessing: boolean;
  50216. /**
  50217. * The texture used as your environment texture in the scene.
  50218. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50219. *
  50220. * Remarks: Can be either a texture or a url.
  50221. */
  50222. environmentTexture: string | BaseTexture;
  50223. /**
  50224. * The value of the exposure to apply to the scene.
  50225. * 0.6 by default if setupImageProcessing is true.
  50226. */
  50227. cameraExposure: number;
  50228. /**
  50229. * The value of the contrast to apply to the scene.
  50230. * 1.6 by default if setupImageProcessing is true.
  50231. */
  50232. cameraContrast: number;
  50233. /**
  50234. * Specifies whether or not tonemapping should be enabled in the scene.
  50235. * true by default if setupImageProcessing is true.
  50236. */
  50237. toneMappingEnabled: boolean;
  50238. }
  50239. /**
  50240. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50241. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50242. * It also helps with the default setup of your imageProcessing configuration.
  50243. */
  50244. export class EnvironmentHelper {
  50245. /**
  50246. * Default ground texture URL.
  50247. */
  50248. private static _groundTextureCDNUrl;
  50249. /**
  50250. * Default skybox texture URL.
  50251. */
  50252. private static _skyboxTextureCDNUrl;
  50253. /**
  50254. * Default environment texture URL.
  50255. */
  50256. private static _environmentTextureCDNUrl;
  50257. /**
  50258. * Creates the default options for the helper.
  50259. */
  50260. private static _getDefaultOptions;
  50261. private _rootMesh;
  50262. /**
  50263. * Gets the root mesh created by the helper.
  50264. */
  50265. get rootMesh(): Mesh;
  50266. private _skybox;
  50267. /**
  50268. * Gets the skybox created by the helper.
  50269. */
  50270. get skybox(): Nullable<Mesh>;
  50271. private _skyboxTexture;
  50272. /**
  50273. * Gets the skybox texture created by the helper.
  50274. */
  50275. get skyboxTexture(): Nullable<BaseTexture>;
  50276. private _skyboxMaterial;
  50277. /**
  50278. * Gets the skybox material created by the helper.
  50279. */
  50280. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50281. private _ground;
  50282. /**
  50283. * Gets the ground mesh created by the helper.
  50284. */
  50285. get ground(): Nullable<Mesh>;
  50286. private _groundTexture;
  50287. /**
  50288. * Gets the ground texture created by the helper.
  50289. */
  50290. get groundTexture(): Nullable<BaseTexture>;
  50291. private _groundMirror;
  50292. /**
  50293. * Gets the ground mirror created by the helper.
  50294. */
  50295. get groundMirror(): Nullable<MirrorTexture>;
  50296. /**
  50297. * Gets the ground mirror render list to helps pushing the meshes
  50298. * you wish in the ground reflection.
  50299. */
  50300. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50301. private _groundMaterial;
  50302. /**
  50303. * Gets the ground material created by the helper.
  50304. */
  50305. get groundMaterial(): Nullable<BackgroundMaterial>;
  50306. /**
  50307. * Stores the creation options.
  50308. */
  50309. private readonly _scene;
  50310. private _options;
  50311. /**
  50312. * This observable will be notified with any error during the creation of the environment,
  50313. * mainly texture creation errors.
  50314. */
  50315. onErrorObservable: Observable<{
  50316. message?: string;
  50317. exception?: any;
  50318. }>;
  50319. /**
  50320. * constructor
  50321. * @param options Defines the options we want to customize the helper
  50322. * @param scene The scene to add the material to
  50323. */
  50324. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50325. /**
  50326. * Updates the background according to the new options
  50327. * @param options
  50328. */
  50329. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50330. /**
  50331. * Sets the primary color of all the available elements.
  50332. * @param color the main color to affect to the ground and the background
  50333. */
  50334. setMainColor(color: Color3): void;
  50335. /**
  50336. * Setup the image processing according to the specified options.
  50337. */
  50338. private _setupImageProcessing;
  50339. /**
  50340. * Setup the environment texture according to the specified options.
  50341. */
  50342. private _setupEnvironmentTexture;
  50343. /**
  50344. * Setup the background according to the specified options.
  50345. */
  50346. private _setupBackground;
  50347. /**
  50348. * Get the scene sizes according to the setup.
  50349. */
  50350. private _getSceneSize;
  50351. /**
  50352. * Setup the ground according to the specified options.
  50353. */
  50354. private _setupGround;
  50355. /**
  50356. * Setup the ground material according to the specified options.
  50357. */
  50358. private _setupGroundMaterial;
  50359. /**
  50360. * Setup the ground diffuse texture according to the specified options.
  50361. */
  50362. private _setupGroundDiffuseTexture;
  50363. /**
  50364. * Setup the ground mirror texture according to the specified options.
  50365. */
  50366. private _setupGroundMirrorTexture;
  50367. /**
  50368. * Setup the ground to receive the mirror texture.
  50369. */
  50370. private _setupMirrorInGroundMaterial;
  50371. /**
  50372. * Setup the skybox according to the specified options.
  50373. */
  50374. private _setupSkybox;
  50375. /**
  50376. * Setup the skybox material according to the specified options.
  50377. */
  50378. private _setupSkyboxMaterial;
  50379. /**
  50380. * Setup the skybox reflection texture according to the specified options.
  50381. */
  50382. private _setupSkyboxReflectionTexture;
  50383. private _errorHandler;
  50384. /**
  50385. * Dispose all the elements created by the Helper.
  50386. */
  50387. dispose(): void;
  50388. }
  50389. }
  50390. declare module BABYLON {
  50391. /**
  50392. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50393. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50394. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50395. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50396. */
  50397. export class PhotoDome extends TransformNode {
  50398. /**
  50399. * Define the image as a Monoscopic panoramic 360 image.
  50400. */
  50401. static readonly MODE_MONOSCOPIC: number;
  50402. /**
  50403. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50404. */
  50405. static readonly MODE_TOPBOTTOM: number;
  50406. /**
  50407. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50408. */
  50409. static readonly MODE_SIDEBYSIDE: number;
  50410. private _useDirectMapping;
  50411. /**
  50412. * The texture being displayed on the sphere
  50413. */
  50414. protected _photoTexture: Texture;
  50415. /**
  50416. * Gets or sets the texture being displayed on the sphere
  50417. */
  50418. get photoTexture(): Texture;
  50419. set photoTexture(value: Texture);
  50420. /**
  50421. * Observable raised when an error occured while loading the 360 image
  50422. */
  50423. onLoadErrorObservable: Observable<string>;
  50424. /**
  50425. * The skybox material
  50426. */
  50427. protected _material: BackgroundMaterial;
  50428. /**
  50429. * The surface used for the skybox
  50430. */
  50431. protected _mesh: Mesh;
  50432. /**
  50433. * Gets the mesh used for the skybox.
  50434. */
  50435. get mesh(): Mesh;
  50436. /**
  50437. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50438. * Also see the options.resolution property.
  50439. */
  50440. get fovMultiplier(): number;
  50441. set fovMultiplier(value: number);
  50442. private _imageMode;
  50443. /**
  50444. * Gets or set the current video mode for the video. It can be:
  50445. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50446. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50447. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50448. */
  50449. get imageMode(): number;
  50450. set imageMode(value: number);
  50451. /**
  50452. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50453. * @param name Element's name, child elements will append suffixes for their own names.
  50454. * @param urlsOfPhoto defines the url of the photo to display
  50455. * @param options defines an object containing optional or exposed sub element properties
  50456. * @param onError defines a callback called when an error occured while loading the texture
  50457. */
  50458. constructor(name: string, urlOfPhoto: string, options: {
  50459. resolution?: number;
  50460. size?: number;
  50461. useDirectMapping?: boolean;
  50462. faceForward?: boolean;
  50463. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50464. private _onBeforeCameraRenderObserver;
  50465. private _changeImageMode;
  50466. /**
  50467. * Releases resources associated with this node.
  50468. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50469. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50470. */
  50471. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50472. }
  50473. }
  50474. declare module BABYLON {
  50475. /**
  50476. * Class used to host RGBD texture specific utilities
  50477. */
  50478. export class RGBDTextureTools {
  50479. /**
  50480. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50481. * @param texture the texture to expand.
  50482. */
  50483. static ExpandRGBDTexture(texture: Texture): void;
  50484. }
  50485. }
  50486. declare module BABYLON {
  50487. /**
  50488. * Class used to host texture specific utilities
  50489. */
  50490. export class BRDFTextureTools {
  50491. /**
  50492. * Prevents texture cache collision
  50493. */
  50494. private static _instanceNumber;
  50495. /**
  50496. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50497. * @param scene defines the hosting scene
  50498. * @returns the environment BRDF texture
  50499. */
  50500. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50501. private static _environmentBRDFBase64Texture;
  50502. }
  50503. }
  50504. declare module BABYLON {
  50505. /**
  50506. * @hidden
  50507. */
  50508. export interface IMaterialClearCoatDefines {
  50509. CLEARCOAT: boolean;
  50510. CLEARCOAT_DEFAULTIOR: boolean;
  50511. CLEARCOAT_TEXTURE: boolean;
  50512. CLEARCOAT_TEXTUREDIRECTUV: number;
  50513. CLEARCOAT_BUMP: boolean;
  50514. CLEARCOAT_BUMPDIRECTUV: number;
  50515. CLEARCOAT_TINT: boolean;
  50516. CLEARCOAT_TINT_TEXTURE: boolean;
  50517. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50518. /** @hidden */
  50519. _areTexturesDirty: boolean;
  50520. }
  50521. /**
  50522. * Define the code related to the clear coat parameters of the pbr material.
  50523. */
  50524. export class PBRClearCoatConfiguration {
  50525. /**
  50526. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50527. * The default fits with a polyurethane material.
  50528. */
  50529. private static readonly _DefaultIndexOfRefraction;
  50530. private _isEnabled;
  50531. /**
  50532. * Defines if the clear coat is enabled in the material.
  50533. */
  50534. isEnabled: boolean;
  50535. /**
  50536. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50537. */
  50538. intensity: number;
  50539. /**
  50540. * Defines the clear coat layer roughness.
  50541. */
  50542. roughness: number;
  50543. private _indexOfRefraction;
  50544. /**
  50545. * Defines the index of refraction of the clear coat.
  50546. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50547. * The default fits with a polyurethane material.
  50548. * Changing the default value is more performance intensive.
  50549. */
  50550. indexOfRefraction: number;
  50551. private _texture;
  50552. /**
  50553. * Stores the clear coat values in a texture.
  50554. */
  50555. texture: Nullable<BaseTexture>;
  50556. private _bumpTexture;
  50557. /**
  50558. * Define the clear coat specific bump texture.
  50559. */
  50560. bumpTexture: Nullable<BaseTexture>;
  50561. private _isTintEnabled;
  50562. /**
  50563. * Defines if the clear coat tint is enabled in the material.
  50564. */
  50565. isTintEnabled: boolean;
  50566. /**
  50567. * Defines the clear coat tint of the material.
  50568. * This is only use if tint is enabled
  50569. */
  50570. tintColor: Color3;
  50571. /**
  50572. * Defines the distance at which the tint color should be found in the
  50573. * clear coat media.
  50574. * This is only use if tint is enabled
  50575. */
  50576. tintColorAtDistance: number;
  50577. /**
  50578. * Defines the clear coat layer thickness.
  50579. * This is only use if tint is enabled
  50580. */
  50581. tintThickness: number;
  50582. private _tintTexture;
  50583. /**
  50584. * Stores the clear tint values in a texture.
  50585. * rgb is tint
  50586. * a is a thickness factor
  50587. */
  50588. tintTexture: Nullable<BaseTexture>;
  50589. /** @hidden */
  50590. private _internalMarkAllSubMeshesAsTexturesDirty;
  50591. /** @hidden */
  50592. _markAllSubMeshesAsTexturesDirty(): void;
  50593. /**
  50594. * Instantiate a new istance of clear coat configuration.
  50595. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50596. */
  50597. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50598. /**
  50599. * Gets wehter the submesh is ready to be used or not.
  50600. * @param defines the list of "defines" to update.
  50601. * @param scene defines the scene the material belongs to.
  50602. * @param engine defines the engine the material belongs to.
  50603. * @param disableBumpMap defines wether the material disables bump or not.
  50604. * @returns - boolean indicating that the submesh is ready or not.
  50605. */
  50606. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50607. /**
  50608. * Checks to see if a texture is used in the material.
  50609. * @param defines the list of "defines" to update.
  50610. * @param scene defines the scene to the material belongs to.
  50611. */
  50612. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50613. /**
  50614. * Binds the material data.
  50615. * @param uniformBuffer defines the Uniform buffer to fill in.
  50616. * @param scene defines the scene the material belongs to.
  50617. * @param engine defines the engine the material belongs to.
  50618. * @param disableBumpMap defines wether the material disables bump or not.
  50619. * @param isFrozen defines wether the material is frozen or not.
  50620. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50621. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50622. */
  50623. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50624. /**
  50625. * Checks to see if a texture is used in the material.
  50626. * @param texture - Base texture to use.
  50627. * @returns - Boolean specifying if a texture is used in the material.
  50628. */
  50629. hasTexture(texture: BaseTexture): boolean;
  50630. /**
  50631. * Returns an array of the actively used textures.
  50632. * @param activeTextures Array of BaseTextures
  50633. */
  50634. getActiveTextures(activeTextures: BaseTexture[]): void;
  50635. /**
  50636. * Returns the animatable textures.
  50637. * @param animatables Array of animatable textures.
  50638. */
  50639. getAnimatables(animatables: IAnimatable[]): void;
  50640. /**
  50641. * Disposes the resources of the material.
  50642. * @param forceDisposeTextures - Forces the disposal of all textures.
  50643. */
  50644. dispose(forceDisposeTextures?: boolean): void;
  50645. /**
  50646. * Get the current class name of the texture useful for serialization or dynamic coding.
  50647. * @returns "PBRClearCoatConfiguration"
  50648. */
  50649. getClassName(): string;
  50650. /**
  50651. * Add fallbacks to the effect fallbacks list.
  50652. * @param defines defines the Base texture to use.
  50653. * @param fallbacks defines the current fallback list.
  50654. * @param currentRank defines the current fallback rank.
  50655. * @returns the new fallback rank.
  50656. */
  50657. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50658. /**
  50659. * Add the required uniforms to the current list.
  50660. * @param uniforms defines the current uniform list.
  50661. */
  50662. static AddUniforms(uniforms: string[]): void;
  50663. /**
  50664. * Add the required samplers to the current list.
  50665. * @param samplers defines the current sampler list.
  50666. */
  50667. static AddSamplers(samplers: string[]): void;
  50668. /**
  50669. * Add the required uniforms to the current buffer.
  50670. * @param uniformBuffer defines the current uniform buffer.
  50671. */
  50672. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50673. /**
  50674. * Makes a duplicate of the current configuration into another one.
  50675. * @param clearCoatConfiguration define the config where to copy the info
  50676. */
  50677. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50678. /**
  50679. * Serializes this clear coat configuration.
  50680. * @returns - An object with the serialized config.
  50681. */
  50682. serialize(): any;
  50683. /**
  50684. * Parses a anisotropy Configuration from a serialized object.
  50685. * @param source - Serialized object.
  50686. * @param scene Defines the scene we are parsing for
  50687. * @param rootUrl Defines the rootUrl to load from
  50688. */
  50689. parse(source: any, scene: Scene, rootUrl: string): void;
  50690. }
  50691. }
  50692. declare module BABYLON {
  50693. /**
  50694. * @hidden
  50695. */
  50696. export interface IMaterialAnisotropicDefines {
  50697. ANISOTROPIC: boolean;
  50698. ANISOTROPIC_TEXTURE: boolean;
  50699. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50700. MAINUV1: boolean;
  50701. _areTexturesDirty: boolean;
  50702. _needUVs: boolean;
  50703. }
  50704. /**
  50705. * Define the code related to the anisotropic parameters of the pbr material.
  50706. */
  50707. export class PBRAnisotropicConfiguration {
  50708. private _isEnabled;
  50709. /**
  50710. * Defines if the anisotropy is enabled in the material.
  50711. */
  50712. isEnabled: boolean;
  50713. /**
  50714. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50715. */
  50716. intensity: number;
  50717. /**
  50718. * Defines if the effect is along the tangents, bitangents or in between.
  50719. * By default, the effect is "strectching" the highlights along the tangents.
  50720. */
  50721. direction: Vector2;
  50722. private _texture;
  50723. /**
  50724. * Stores the anisotropy values in a texture.
  50725. * rg is direction (like normal from -1 to 1)
  50726. * b is a intensity
  50727. */
  50728. texture: Nullable<BaseTexture>;
  50729. /** @hidden */
  50730. private _internalMarkAllSubMeshesAsTexturesDirty;
  50731. /** @hidden */
  50732. _markAllSubMeshesAsTexturesDirty(): void;
  50733. /**
  50734. * Instantiate a new istance of anisotropy configuration.
  50735. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50736. */
  50737. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50738. /**
  50739. * Specifies that the submesh is ready to be used.
  50740. * @param defines the list of "defines" to update.
  50741. * @param scene defines the scene the material belongs to.
  50742. * @returns - boolean indicating that the submesh is ready or not.
  50743. */
  50744. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50745. /**
  50746. * Checks to see if a texture is used in the material.
  50747. * @param defines the list of "defines" to update.
  50748. * @param mesh the mesh we are preparing the defines for.
  50749. * @param scene defines the scene the material belongs to.
  50750. */
  50751. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50752. /**
  50753. * Binds the material data.
  50754. * @param uniformBuffer defines the Uniform buffer to fill in.
  50755. * @param scene defines the scene the material belongs to.
  50756. * @param isFrozen defines wether the material is frozen or not.
  50757. */
  50758. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50759. /**
  50760. * Checks to see if a texture is used in the material.
  50761. * @param texture - Base texture to use.
  50762. * @returns - Boolean specifying if a texture is used in the material.
  50763. */
  50764. hasTexture(texture: BaseTexture): boolean;
  50765. /**
  50766. * Returns an array of the actively used textures.
  50767. * @param activeTextures Array of BaseTextures
  50768. */
  50769. getActiveTextures(activeTextures: BaseTexture[]): void;
  50770. /**
  50771. * Returns the animatable textures.
  50772. * @param animatables Array of animatable textures.
  50773. */
  50774. getAnimatables(animatables: IAnimatable[]): void;
  50775. /**
  50776. * Disposes the resources of the material.
  50777. * @param forceDisposeTextures - Forces the disposal of all textures.
  50778. */
  50779. dispose(forceDisposeTextures?: boolean): void;
  50780. /**
  50781. * Get the current class name of the texture useful for serialization or dynamic coding.
  50782. * @returns "PBRAnisotropicConfiguration"
  50783. */
  50784. getClassName(): string;
  50785. /**
  50786. * Add fallbacks to the effect fallbacks list.
  50787. * @param defines defines the Base texture to use.
  50788. * @param fallbacks defines the current fallback list.
  50789. * @param currentRank defines the current fallback rank.
  50790. * @returns the new fallback rank.
  50791. */
  50792. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50793. /**
  50794. * Add the required uniforms to the current list.
  50795. * @param uniforms defines the current uniform list.
  50796. */
  50797. static AddUniforms(uniforms: string[]): void;
  50798. /**
  50799. * Add the required uniforms to the current buffer.
  50800. * @param uniformBuffer defines the current uniform buffer.
  50801. */
  50802. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50803. /**
  50804. * Add the required samplers to the current list.
  50805. * @param samplers defines the current sampler list.
  50806. */
  50807. static AddSamplers(samplers: string[]): void;
  50808. /**
  50809. * Makes a duplicate of the current configuration into another one.
  50810. * @param anisotropicConfiguration define the config where to copy the info
  50811. */
  50812. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50813. /**
  50814. * Serializes this anisotropy configuration.
  50815. * @returns - An object with the serialized config.
  50816. */
  50817. serialize(): any;
  50818. /**
  50819. * Parses a anisotropy Configuration from a serialized object.
  50820. * @param source - Serialized object.
  50821. * @param scene Defines the scene we are parsing for
  50822. * @param rootUrl Defines the rootUrl to load from
  50823. */
  50824. parse(source: any, scene: Scene, rootUrl: string): void;
  50825. }
  50826. }
  50827. declare module BABYLON {
  50828. /**
  50829. * @hidden
  50830. */
  50831. export interface IMaterialBRDFDefines {
  50832. BRDF_V_HEIGHT_CORRELATED: boolean;
  50833. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50834. SPHERICAL_HARMONICS: boolean;
  50835. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50836. /** @hidden */
  50837. _areMiscDirty: boolean;
  50838. }
  50839. /**
  50840. * Define the code related to the BRDF parameters of the pbr material.
  50841. */
  50842. export class PBRBRDFConfiguration {
  50843. /**
  50844. * Default value used for the energy conservation.
  50845. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50846. */
  50847. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50848. /**
  50849. * Default value used for the Smith Visibility Height Correlated mode.
  50850. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50851. */
  50852. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50853. /**
  50854. * Default value used for the IBL diffuse part.
  50855. * This can help switching back to the polynomials mode globally which is a tiny bit
  50856. * less GPU intensive at the drawback of a lower quality.
  50857. */
  50858. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50859. /**
  50860. * Default value used for activating energy conservation for the specular workflow.
  50861. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50862. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50863. */
  50864. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50865. private _useEnergyConservation;
  50866. /**
  50867. * Defines if the material uses energy conservation.
  50868. */
  50869. useEnergyConservation: boolean;
  50870. private _useSmithVisibilityHeightCorrelated;
  50871. /**
  50872. * LEGACY Mode set to false
  50873. * Defines if the material uses height smith correlated visibility term.
  50874. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50875. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50876. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50877. * Not relying on height correlated will also disable energy conservation.
  50878. */
  50879. useSmithVisibilityHeightCorrelated: boolean;
  50880. private _useSphericalHarmonics;
  50881. /**
  50882. * LEGACY Mode set to false
  50883. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50884. * diffuse part of the IBL.
  50885. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50886. * to the ground truth.
  50887. */
  50888. useSphericalHarmonics: boolean;
  50889. private _useSpecularGlossinessInputEnergyConservation;
  50890. /**
  50891. * Defines if the material uses energy conservation, when the specular workflow is active.
  50892. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50893. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50894. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50895. */
  50896. useSpecularGlossinessInputEnergyConservation: boolean;
  50897. /** @hidden */
  50898. private _internalMarkAllSubMeshesAsMiscDirty;
  50899. /** @hidden */
  50900. _markAllSubMeshesAsMiscDirty(): void;
  50901. /**
  50902. * Instantiate a new istance of clear coat configuration.
  50903. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50904. */
  50905. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50906. /**
  50907. * Checks to see if a texture is used in the material.
  50908. * @param defines the list of "defines" to update.
  50909. */
  50910. prepareDefines(defines: IMaterialBRDFDefines): void;
  50911. /**
  50912. * Get the current class name of the texture useful for serialization or dynamic coding.
  50913. * @returns "PBRClearCoatConfiguration"
  50914. */
  50915. getClassName(): string;
  50916. /**
  50917. * Makes a duplicate of the current configuration into another one.
  50918. * @param brdfConfiguration define the config where to copy the info
  50919. */
  50920. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50921. /**
  50922. * Serializes this BRDF configuration.
  50923. * @returns - An object with the serialized config.
  50924. */
  50925. serialize(): any;
  50926. /**
  50927. * Parses a anisotropy Configuration from a serialized object.
  50928. * @param source - Serialized object.
  50929. * @param scene Defines the scene we are parsing for
  50930. * @param rootUrl Defines the rootUrl to load from
  50931. */
  50932. parse(source: any, scene: Scene, rootUrl: string): void;
  50933. }
  50934. }
  50935. declare module BABYLON {
  50936. /**
  50937. * @hidden
  50938. */
  50939. export interface IMaterialSheenDefines {
  50940. SHEEN: boolean;
  50941. SHEEN_TEXTURE: boolean;
  50942. SHEEN_TEXTUREDIRECTUV: number;
  50943. SHEEN_LINKWITHALBEDO: boolean;
  50944. SHEEN_ROUGHNESS: boolean;
  50945. SHEEN_ALBEDOSCALING: boolean;
  50946. /** @hidden */
  50947. _areTexturesDirty: boolean;
  50948. }
  50949. /**
  50950. * Define the code related to the Sheen parameters of the pbr material.
  50951. */
  50952. export class PBRSheenConfiguration {
  50953. private _isEnabled;
  50954. /**
  50955. * Defines if the material uses sheen.
  50956. */
  50957. isEnabled: boolean;
  50958. private _linkSheenWithAlbedo;
  50959. /**
  50960. * Defines if the sheen is linked to the sheen color.
  50961. */
  50962. linkSheenWithAlbedo: boolean;
  50963. /**
  50964. * Defines the sheen intensity.
  50965. */
  50966. intensity: number;
  50967. /**
  50968. * Defines the sheen color.
  50969. */
  50970. color: Color3;
  50971. private _texture;
  50972. /**
  50973. * Stores the sheen tint values in a texture.
  50974. * rgb is tint
  50975. * a is a intensity
  50976. */
  50977. texture: Nullable<BaseTexture>;
  50978. private _roughness;
  50979. /**
  50980. * Defines the sheen roughness.
  50981. * It is not taken into account if linkSheenWithAlbedo is true.
  50982. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50983. */
  50984. roughness: Nullable<number>;
  50985. private _albedoScaling;
  50986. /**
  50987. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50988. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50989. * making it easier to setup and tweak the effect
  50990. */
  50991. albedoScaling: boolean;
  50992. /** @hidden */
  50993. private _internalMarkAllSubMeshesAsTexturesDirty;
  50994. /** @hidden */
  50995. _markAllSubMeshesAsTexturesDirty(): void;
  50996. /**
  50997. * Instantiate a new istance of clear coat configuration.
  50998. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50999. */
  51000. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51001. /**
  51002. * Specifies that the submesh is ready to be used.
  51003. * @param defines the list of "defines" to update.
  51004. * @param scene defines the scene the material belongs to.
  51005. * @returns - boolean indicating that the submesh is ready or not.
  51006. */
  51007. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51008. /**
  51009. * Checks to see if a texture is used in the material.
  51010. * @param defines the list of "defines" to update.
  51011. * @param scene defines the scene the material belongs to.
  51012. */
  51013. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51014. /**
  51015. * Binds the material data.
  51016. * @param uniformBuffer defines the Uniform buffer to fill in.
  51017. * @param scene defines the scene the material belongs to.
  51018. * @param isFrozen defines wether the material is frozen or not.
  51019. */
  51020. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51021. /**
  51022. * Checks to see if a texture is used in the material.
  51023. * @param texture - Base texture to use.
  51024. * @returns - Boolean specifying if a texture is used in the material.
  51025. */
  51026. hasTexture(texture: BaseTexture): boolean;
  51027. /**
  51028. * Returns an array of the actively used textures.
  51029. * @param activeTextures Array of BaseTextures
  51030. */
  51031. getActiveTextures(activeTextures: BaseTexture[]): void;
  51032. /**
  51033. * Returns the animatable textures.
  51034. * @param animatables Array of animatable textures.
  51035. */
  51036. getAnimatables(animatables: IAnimatable[]): void;
  51037. /**
  51038. * Disposes the resources of the material.
  51039. * @param forceDisposeTextures - Forces the disposal of all textures.
  51040. */
  51041. dispose(forceDisposeTextures?: boolean): void;
  51042. /**
  51043. * Get the current class name of the texture useful for serialization or dynamic coding.
  51044. * @returns "PBRSheenConfiguration"
  51045. */
  51046. getClassName(): string;
  51047. /**
  51048. * Add fallbacks to the effect fallbacks list.
  51049. * @param defines defines the Base texture to use.
  51050. * @param fallbacks defines the current fallback list.
  51051. * @param currentRank defines the current fallback rank.
  51052. * @returns the new fallback rank.
  51053. */
  51054. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51055. /**
  51056. * Add the required uniforms to the current list.
  51057. * @param uniforms defines the current uniform list.
  51058. */
  51059. static AddUniforms(uniforms: string[]): void;
  51060. /**
  51061. * Add the required uniforms to the current buffer.
  51062. * @param uniformBuffer defines the current uniform buffer.
  51063. */
  51064. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51065. /**
  51066. * Add the required samplers to the current list.
  51067. * @param samplers defines the current sampler list.
  51068. */
  51069. static AddSamplers(samplers: string[]): void;
  51070. /**
  51071. * Makes a duplicate of the current configuration into another one.
  51072. * @param sheenConfiguration define the config where to copy the info
  51073. */
  51074. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51075. /**
  51076. * Serializes this BRDF configuration.
  51077. * @returns - An object with the serialized config.
  51078. */
  51079. serialize(): any;
  51080. /**
  51081. * Parses a anisotropy Configuration from a serialized object.
  51082. * @param source - Serialized object.
  51083. * @param scene Defines the scene we are parsing for
  51084. * @param rootUrl Defines the rootUrl to load from
  51085. */
  51086. parse(source: any, scene: Scene, rootUrl: string): void;
  51087. }
  51088. }
  51089. declare module BABYLON {
  51090. /**
  51091. * @hidden
  51092. */
  51093. export interface IMaterialSubSurfaceDefines {
  51094. SUBSURFACE: boolean;
  51095. SS_REFRACTION: boolean;
  51096. SS_TRANSLUCENCY: boolean;
  51097. SS_SCATERRING: boolean;
  51098. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51099. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51100. SS_REFRACTIONMAP_3D: boolean;
  51101. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51102. SS_LODINREFRACTIONALPHA: boolean;
  51103. SS_GAMMAREFRACTION: boolean;
  51104. SS_RGBDREFRACTION: boolean;
  51105. SS_LINEARSPECULARREFRACTION: boolean;
  51106. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51107. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51108. /** @hidden */
  51109. _areTexturesDirty: boolean;
  51110. }
  51111. /**
  51112. * Define the code related to the sub surface parameters of the pbr material.
  51113. */
  51114. export class PBRSubSurfaceConfiguration {
  51115. private _isRefractionEnabled;
  51116. /**
  51117. * Defines if the refraction is enabled in the material.
  51118. */
  51119. isRefractionEnabled: boolean;
  51120. private _isTranslucencyEnabled;
  51121. /**
  51122. * Defines if the translucency is enabled in the material.
  51123. */
  51124. isTranslucencyEnabled: boolean;
  51125. private _isScatteringEnabled;
  51126. /**
  51127. * Defines the refraction intensity of the material.
  51128. * The refraction when enabled replaces the Diffuse part of the material.
  51129. * The intensity helps transitionning between diffuse and refraction.
  51130. */
  51131. refractionIntensity: number;
  51132. /**
  51133. * Defines the translucency intensity of the material.
  51134. * When translucency has been enabled, this defines how much of the "translucency"
  51135. * is addded to the diffuse part of the material.
  51136. */
  51137. translucencyIntensity: number;
  51138. /**
  51139. * Defines the scattering intensity of the material.
  51140. * When scattering has been enabled, this defines how much of the "scattered light"
  51141. * is addded to the diffuse part of the material.
  51142. */
  51143. scatteringIntensity: number;
  51144. private _thicknessTexture;
  51145. /**
  51146. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51147. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51148. * 0 would mean minimumThickness
  51149. * 1 would mean maximumThickness
  51150. * The other channels might be use as a mask to vary the different effects intensity.
  51151. */
  51152. thicknessTexture: Nullable<BaseTexture>;
  51153. private _refractionTexture;
  51154. /**
  51155. * Defines the texture to use for refraction.
  51156. */
  51157. refractionTexture: Nullable<BaseTexture>;
  51158. private _indexOfRefraction;
  51159. /**
  51160. * Defines the index of refraction used in the material.
  51161. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51162. */
  51163. indexOfRefraction: number;
  51164. private _invertRefractionY;
  51165. /**
  51166. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51167. */
  51168. invertRefractionY: boolean;
  51169. private _linkRefractionWithTransparency;
  51170. /**
  51171. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51172. * Materials half opaque for instance using refraction could benefit from this control.
  51173. */
  51174. linkRefractionWithTransparency: boolean;
  51175. /**
  51176. * Defines the minimum thickness stored in the thickness map.
  51177. * If no thickness map is defined, this value will be used to simulate thickness.
  51178. */
  51179. minimumThickness: number;
  51180. /**
  51181. * Defines the maximum thickness stored in the thickness map.
  51182. */
  51183. maximumThickness: number;
  51184. /**
  51185. * Defines the volume tint of the material.
  51186. * This is used for both translucency and scattering.
  51187. */
  51188. tintColor: Color3;
  51189. /**
  51190. * Defines the distance at which the tint color should be found in the media.
  51191. * This is used for refraction only.
  51192. */
  51193. tintColorAtDistance: number;
  51194. /**
  51195. * Defines how far each channel transmit through the media.
  51196. * It is defined as a color to simplify it selection.
  51197. */
  51198. diffusionDistance: Color3;
  51199. private _useMaskFromThicknessTexture;
  51200. /**
  51201. * Stores the intensity of the different subsurface effects in the thickness texture.
  51202. * * the green channel is the translucency intensity.
  51203. * * the blue channel is the scattering intensity.
  51204. * * the alpha channel is the refraction intensity.
  51205. */
  51206. useMaskFromThicknessTexture: boolean;
  51207. /** @hidden */
  51208. private _internalMarkAllSubMeshesAsTexturesDirty;
  51209. /** @hidden */
  51210. _markAllSubMeshesAsTexturesDirty(): void;
  51211. /**
  51212. * Instantiate a new istance of sub surface configuration.
  51213. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51214. */
  51215. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51216. /**
  51217. * Gets wehter the submesh is ready to be used or not.
  51218. * @param defines the list of "defines" to update.
  51219. * @param scene defines the scene the material belongs to.
  51220. * @returns - boolean indicating that the submesh is ready or not.
  51221. */
  51222. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51223. /**
  51224. * Checks to see if a texture is used in the material.
  51225. * @param defines the list of "defines" to update.
  51226. * @param scene defines the scene to the material belongs to.
  51227. */
  51228. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51229. /**
  51230. * Binds the material data.
  51231. * @param uniformBuffer defines the Uniform buffer to fill in.
  51232. * @param scene defines the scene the material belongs to.
  51233. * @param engine defines the engine the material belongs to.
  51234. * @param isFrozen defines wether the material is frozen or not.
  51235. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51236. */
  51237. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51238. /**
  51239. * Unbinds the material from the mesh.
  51240. * @param activeEffect defines the effect that should be unbound from.
  51241. * @returns true if unbound, otherwise false
  51242. */
  51243. unbind(activeEffect: Effect): boolean;
  51244. /**
  51245. * Returns the texture used for refraction or null if none is used.
  51246. * @param scene defines the scene the material belongs to.
  51247. * @returns - Refraction texture if present. If no refraction texture and refraction
  51248. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51249. */
  51250. private _getRefractionTexture;
  51251. /**
  51252. * Returns true if alpha blending should be disabled.
  51253. */
  51254. get disableAlphaBlending(): boolean;
  51255. /**
  51256. * Fills the list of render target textures.
  51257. * @param renderTargets the list of render targets to update
  51258. */
  51259. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51260. /**
  51261. * Checks to see if a texture is used in the material.
  51262. * @param texture - Base texture to use.
  51263. * @returns - Boolean specifying if a texture is used in the material.
  51264. */
  51265. hasTexture(texture: BaseTexture): boolean;
  51266. /**
  51267. * Gets a boolean indicating that current material needs to register RTT
  51268. * @returns true if this uses a render target otherwise false.
  51269. */
  51270. hasRenderTargetTextures(): boolean;
  51271. /**
  51272. * Returns an array of the actively used textures.
  51273. * @param activeTextures Array of BaseTextures
  51274. */
  51275. getActiveTextures(activeTextures: BaseTexture[]): void;
  51276. /**
  51277. * Returns the animatable textures.
  51278. * @param animatables Array of animatable textures.
  51279. */
  51280. getAnimatables(animatables: IAnimatable[]): void;
  51281. /**
  51282. * Disposes the resources of the material.
  51283. * @param forceDisposeTextures - Forces the disposal of all textures.
  51284. */
  51285. dispose(forceDisposeTextures?: boolean): void;
  51286. /**
  51287. * Get the current class name of the texture useful for serialization or dynamic coding.
  51288. * @returns "PBRSubSurfaceConfiguration"
  51289. */
  51290. getClassName(): string;
  51291. /**
  51292. * Add fallbacks to the effect fallbacks list.
  51293. * @param defines defines the Base texture to use.
  51294. * @param fallbacks defines the current fallback list.
  51295. * @param currentRank defines the current fallback rank.
  51296. * @returns the new fallback rank.
  51297. */
  51298. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51299. /**
  51300. * Add the required uniforms to the current list.
  51301. * @param uniforms defines the current uniform list.
  51302. */
  51303. static AddUniforms(uniforms: string[]): void;
  51304. /**
  51305. * Add the required samplers to the current list.
  51306. * @param samplers defines the current sampler list.
  51307. */
  51308. static AddSamplers(samplers: string[]): void;
  51309. /**
  51310. * Add the required uniforms to the current buffer.
  51311. * @param uniformBuffer defines the current uniform buffer.
  51312. */
  51313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51314. /**
  51315. * Makes a duplicate of the current configuration into another one.
  51316. * @param configuration define the config where to copy the info
  51317. */
  51318. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51319. /**
  51320. * Serializes this Sub Surface configuration.
  51321. * @returns - An object with the serialized config.
  51322. */
  51323. serialize(): any;
  51324. /**
  51325. * Parses a anisotropy Configuration from a serialized object.
  51326. * @param source - Serialized object.
  51327. * @param scene Defines the scene we are parsing for
  51328. * @param rootUrl Defines the rootUrl to load from
  51329. */
  51330. parse(source: any, scene: Scene, rootUrl: string): void;
  51331. }
  51332. }
  51333. declare module BABYLON {
  51334. /** @hidden */
  51335. export var pbrFragmentDeclaration: {
  51336. name: string;
  51337. shader: string;
  51338. };
  51339. }
  51340. declare module BABYLON {
  51341. /** @hidden */
  51342. export var pbrUboDeclaration: {
  51343. name: string;
  51344. shader: string;
  51345. };
  51346. }
  51347. declare module BABYLON {
  51348. /** @hidden */
  51349. export var pbrFragmentExtraDeclaration: {
  51350. name: string;
  51351. shader: string;
  51352. };
  51353. }
  51354. declare module BABYLON {
  51355. /** @hidden */
  51356. export var pbrFragmentSamplersDeclaration: {
  51357. name: string;
  51358. shader: string;
  51359. };
  51360. }
  51361. declare module BABYLON {
  51362. /** @hidden */
  51363. export var pbrHelperFunctions: {
  51364. name: string;
  51365. shader: string;
  51366. };
  51367. }
  51368. declare module BABYLON {
  51369. /** @hidden */
  51370. export var harmonicsFunctions: {
  51371. name: string;
  51372. shader: string;
  51373. };
  51374. }
  51375. declare module BABYLON {
  51376. /** @hidden */
  51377. export var pbrDirectLightingSetupFunctions: {
  51378. name: string;
  51379. shader: string;
  51380. };
  51381. }
  51382. declare module BABYLON {
  51383. /** @hidden */
  51384. export var pbrDirectLightingFalloffFunctions: {
  51385. name: string;
  51386. shader: string;
  51387. };
  51388. }
  51389. declare module BABYLON {
  51390. /** @hidden */
  51391. export var pbrBRDFFunctions: {
  51392. name: string;
  51393. shader: string;
  51394. };
  51395. }
  51396. declare module BABYLON {
  51397. /** @hidden */
  51398. export var pbrDirectLightingFunctions: {
  51399. name: string;
  51400. shader: string;
  51401. };
  51402. }
  51403. declare module BABYLON {
  51404. /** @hidden */
  51405. export var pbrIBLFunctions: {
  51406. name: string;
  51407. shader: string;
  51408. };
  51409. }
  51410. declare module BABYLON {
  51411. /** @hidden */
  51412. export var pbrBlockAlbedoOpacity: {
  51413. name: string;
  51414. shader: string;
  51415. };
  51416. }
  51417. declare module BABYLON {
  51418. /** @hidden */
  51419. export var pbrBlockReflectivity: {
  51420. name: string;
  51421. shader: string;
  51422. };
  51423. }
  51424. declare module BABYLON {
  51425. /** @hidden */
  51426. export var pbrBlockAmbientOcclusion: {
  51427. name: string;
  51428. shader: string;
  51429. };
  51430. }
  51431. declare module BABYLON {
  51432. /** @hidden */
  51433. export var pbrBlockAlphaFresnel: {
  51434. name: string;
  51435. shader: string;
  51436. };
  51437. }
  51438. declare module BABYLON {
  51439. /** @hidden */
  51440. export var pbrBlockAnisotropic: {
  51441. name: string;
  51442. shader: string;
  51443. };
  51444. }
  51445. declare module BABYLON {
  51446. /** @hidden */
  51447. export var pbrBlockReflection: {
  51448. name: string;
  51449. shader: string;
  51450. };
  51451. }
  51452. declare module BABYLON {
  51453. /** @hidden */
  51454. export var pbrBlockSheen: {
  51455. name: string;
  51456. shader: string;
  51457. };
  51458. }
  51459. declare module BABYLON {
  51460. /** @hidden */
  51461. export var pbrBlockClearcoat: {
  51462. name: string;
  51463. shader: string;
  51464. };
  51465. }
  51466. declare module BABYLON {
  51467. /** @hidden */
  51468. export var pbrBlockSubSurface: {
  51469. name: string;
  51470. shader: string;
  51471. };
  51472. }
  51473. declare module BABYLON {
  51474. /** @hidden */
  51475. export var pbrBlockNormalGeometric: {
  51476. name: string;
  51477. shader: string;
  51478. };
  51479. }
  51480. declare module BABYLON {
  51481. /** @hidden */
  51482. export var pbrBlockNormalFinal: {
  51483. name: string;
  51484. shader: string;
  51485. };
  51486. }
  51487. declare module BABYLON {
  51488. /** @hidden */
  51489. export var pbrBlockGeometryInfo: {
  51490. name: string;
  51491. shader: string;
  51492. };
  51493. }
  51494. declare module BABYLON {
  51495. /** @hidden */
  51496. export var pbrBlockReflectance0: {
  51497. name: string;
  51498. shader: string;
  51499. };
  51500. }
  51501. declare module BABYLON {
  51502. /** @hidden */
  51503. export var pbrBlockReflectance: {
  51504. name: string;
  51505. shader: string;
  51506. };
  51507. }
  51508. declare module BABYLON {
  51509. /** @hidden */
  51510. export var pbrBlockDirectLighting: {
  51511. name: string;
  51512. shader: string;
  51513. };
  51514. }
  51515. declare module BABYLON {
  51516. /** @hidden */
  51517. export var pbrBlockFinalLitComponents: {
  51518. name: string;
  51519. shader: string;
  51520. };
  51521. }
  51522. declare module BABYLON {
  51523. /** @hidden */
  51524. export var pbrBlockFinalUnlitComponents: {
  51525. name: string;
  51526. shader: string;
  51527. };
  51528. }
  51529. declare module BABYLON {
  51530. /** @hidden */
  51531. export var pbrBlockFinalColorComposition: {
  51532. name: string;
  51533. shader: string;
  51534. };
  51535. }
  51536. declare module BABYLON {
  51537. /** @hidden */
  51538. export var pbrBlockImageProcessing: {
  51539. name: string;
  51540. shader: string;
  51541. };
  51542. }
  51543. declare module BABYLON {
  51544. /** @hidden */
  51545. export var pbrDebug: {
  51546. name: string;
  51547. shader: string;
  51548. };
  51549. }
  51550. declare module BABYLON {
  51551. /** @hidden */
  51552. export var pbrPixelShader: {
  51553. name: string;
  51554. shader: string;
  51555. };
  51556. }
  51557. declare module BABYLON {
  51558. /** @hidden */
  51559. export var pbrVertexDeclaration: {
  51560. name: string;
  51561. shader: string;
  51562. };
  51563. }
  51564. declare module BABYLON {
  51565. /** @hidden */
  51566. export var pbrVertexShader: {
  51567. name: string;
  51568. shader: string;
  51569. };
  51570. }
  51571. declare module BABYLON {
  51572. /**
  51573. * Manages the defines for the PBR Material.
  51574. * @hidden
  51575. */
  51576. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51577. PBR: boolean;
  51578. MAINUV1: boolean;
  51579. MAINUV2: boolean;
  51580. UV1: boolean;
  51581. UV2: boolean;
  51582. ALBEDO: boolean;
  51583. GAMMAALBEDO: boolean;
  51584. ALBEDODIRECTUV: number;
  51585. VERTEXCOLOR: boolean;
  51586. AMBIENT: boolean;
  51587. AMBIENTDIRECTUV: number;
  51588. AMBIENTINGRAYSCALE: boolean;
  51589. OPACITY: boolean;
  51590. VERTEXALPHA: boolean;
  51591. OPACITYDIRECTUV: number;
  51592. OPACITYRGB: boolean;
  51593. ALPHATEST: boolean;
  51594. DEPTHPREPASS: boolean;
  51595. ALPHABLEND: boolean;
  51596. ALPHAFROMALBEDO: boolean;
  51597. ALPHATESTVALUE: string;
  51598. SPECULAROVERALPHA: boolean;
  51599. RADIANCEOVERALPHA: boolean;
  51600. ALPHAFRESNEL: boolean;
  51601. LINEARALPHAFRESNEL: boolean;
  51602. PREMULTIPLYALPHA: boolean;
  51603. EMISSIVE: boolean;
  51604. EMISSIVEDIRECTUV: number;
  51605. REFLECTIVITY: boolean;
  51606. REFLECTIVITYDIRECTUV: number;
  51607. SPECULARTERM: boolean;
  51608. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51609. MICROSURFACEAUTOMATIC: boolean;
  51610. LODBASEDMICROSFURACE: boolean;
  51611. MICROSURFACEMAP: boolean;
  51612. MICROSURFACEMAPDIRECTUV: number;
  51613. METALLICWORKFLOW: boolean;
  51614. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51615. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51616. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51617. AOSTOREINMETALMAPRED: boolean;
  51618. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51619. ENVIRONMENTBRDF: boolean;
  51620. ENVIRONMENTBRDF_RGBD: boolean;
  51621. NORMAL: boolean;
  51622. TANGENT: boolean;
  51623. BUMP: boolean;
  51624. BUMPDIRECTUV: number;
  51625. OBJECTSPACE_NORMALMAP: boolean;
  51626. PARALLAX: boolean;
  51627. PARALLAXOCCLUSION: boolean;
  51628. NORMALXYSCALE: boolean;
  51629. LIGHTMAP: boolean;
  51630. LIGHTMAPDIRECTUV: number;
  51631. USELIGHTMAPASSHADOWMAP: boolean;
  51632. GAMMALIGHTMAP: boolean;
  51633. RGBDLIGHTMAP: boolean;
  51634. REFLECTION: boolean;
  51635. REFLECTIONMAP_3D: boolean;
  51636. REFLECTIONMAP_SPHERICAL: boolean;
  51637. REFLECTIONMAP_PLANAR: boolean;
  51638. REFLECTIONMAP_CUBIC: boolean;
  51639. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51640. REFLECTIONMAP_PROJECTION: boolean;
  51641. REFLECTIONMAP_SKYBOX: boolean;
  51642. REFLECTIONMAP_EXPLICIT: boolean;
  51643. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51644. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51645. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51646. INVERTCUBICMAP: boolean;
  51647. USESPHERICALFROMREFLECTIONMAP: boolean;
  51648. USEIRRADIANCEMAP: boolean;
  51649. SPHERICAL_HARMONICS: boolean;
  51650. USESPHERICALINVERTEX: boolean;
  51651. REFLECTIONMAP_OPPOSITEZ: boolean;
  51652. LODINREFLECTIONALPHA: boolean;
  51653. GAMMAREFLECTION: boolean;
  51654. RGBDREFLECTION: boolean;
  51655. LINEARSPECULARREFLECTION: boolean;
  51656. RADIANCEOCCLUSION: boolean;
  51657. HORIZONOCCLUSION: boolean;
  51658. INSTANCES: boolean;
  51659. NUM_BONE_INFLUENCERS: number;
  51660. BonesPerMesh: number;
  51661. BONETEXTURE: boolean;
  51662. NONUNIFORMSCALING: boolean;
  51663. MORPHTARGETS: boolean;
  51664. MORPHTARGETS_NORMAL: boolean;
  51665. MORPHTARGETS_TANGENT: boolean;
  51666. MORPHTARGETS_UV: boolean;
  51667. NUM_MORPH_INFLUENCERS: number;
  51668. IMAGEPROCESSING: boolean;
  51669. VIGNETTE: boolean;
  51670. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51671. VIGNETTEBLENDMODEOPAQUE: boolean;
  51672. TONEMAPPING: boolean;
  51673. TONEMAPPING_ACES: boolean;
  51674. CONTRAST: boolean;
  51675. COLORCURVES: boolean;
  51676. COLORGRADING: boolean;
  51677. COLORGRADING3D: boolean;
  51678. SAMPLER3DGREENDEPTH: boolean;
  51679. SAMPLER3DBGRMAP: boolean;
  51680. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51681. EXPOSURE: boolean;
  51682. MULTIVIEW: boolean;
  51683. USEPHYSICALLIGHTFALLOFF: boolean;
  51684. USEGLTFLIGHTFALLOFF: boolean;
  51685. TWOSIDEDLIGHTING: boolean;
  51686. SHADOWFLOAT: boolean;
  51687. CLIPPLANE: boolean;
  51688. CLIPPLANE2: boolean;
  51689. CLIPPLANE3: boolean;
  51690. CLIPPLANE4: boolean;
  51691. CLIPPLANE5: boolean;
  51692. CLIPPLANE6: boolean;
  51693. POINTSIZE: boolean;
  51694. FOG: boolean;
  51695. LOGARITHMICDEPTH: boolean;
  51696. FORCENORMALFORWARD: boolean;
  51697. SPECULARAA: boolean;
  51698. CLEARCOAT: boolean;
  51699. CLEARCOAT_DEFAULTIOR: boolean;
  51700. CLEARCOAT_TEXTURE: boolean;
  51701. CLEARCOAT_TEXTUREDIRECTUV: number;
  51702. CLEARCOAT_BUMP: boolean;
  51703. CLEARCOAT_BUMPDIRECTUV: number;
  51704. CLEARCOAT_TINT: boolean;
  51705. CLEARCOAT_TINT_TEXTURE: boolean;
  51706. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51707. ANISOTROPIC: boolean;
  51708. ANISOTROPIC_TEXTURE: boolean;
  51709. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51710. BRDF_V_HEIGHT_CORRELATED: boolean;
  51711. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51712. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51713. SHEEN: boolean;
  51714. SHEEN_TEXTURE: boolean;
  51715. SHEEN_TEXTUREDIRECTUV: number;
  51716. SHEEN_LINKWITHALBEDO: boolean;
  51717. SHEEN_ROUGHNESS: boolean;
  51718. SHEEN_ALBEDOSCALING: boolean;
  51719. SUBSURFACE: boolean;
  51720. SS_REFRACTION: boolean;
  51721. SS_TRANSLUCENCY: boolean;
  51722. SS_SCATERRING: boolean;
  51723. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51724. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51725. SS_REFRACTIONMAP_3D: boolean;
  51726. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51727. SS_LODINREFRACTIONALPHA: boolean;
  51728. SS_GAMMAREFRACTION: boolean;
  51729. SS_RGBDREFRACTION: boolean;
  51730. SS_LINEARSPECULARREFRACTION: boolean;
  51731. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51732. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51733. UNLIT: boolean;
  51734. DEBUGMODE: number;
  51735. /**
  51736. * Initializes the PBR Material defines.
  51737. */
  51738. constructor();
  51739. /**
  51740. * Resets the PBR Material defines.
  51741. */
  51742. reset(): void;
  51743. }
  51744. /**
  51745. * The Physically based material base class of BJS.
  51746. *
  51747. * This offers the main features of a standard PBR material.
  51748. * For more information, please refer to the documentation :
  51749. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51750. */
  51751. export abstract class PBRBaseMaterial extends PushMaterial {
  51752. /**
  51753. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51754. */
  51755. static readonly PBRMATERIAL_OPAQUE: number;
  51756. /**
  51757. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51758. */
  51759. static readonly PBRMATERIAL_ALPHATEST: number;
  51760. /**
  51761. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51762. */
  51763. static readonly PBRMATERIAL_ALPHABLEND: number;
  51764. /**
  51765. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51766. * They are also discarded below the alpha cutoff threshold to improve performances.
  51767. */
  51768. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51769. /**
  51770. * Defines the default value of how much AO map is occluding the analytical lights
  51771. * (point spot...).
  51772. */
  51773. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51774. /**
  51775. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51776. */
  51777. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51778. /**
  51779. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51780. * to enhance interoperability with other engines.
  51781. */
  51782. static readonly LIGHTFALLOFF_GLTF: number;
  51783. /**
  51784. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51785. * to enhance interoperability with other materials.
  51786. */
  51787. static readonly LIGHTFALLOFF_STANDARD: number;
  51788. /**
  51789. * Intensity of the direct lights e.g. the four lights available in your scene.
  51790. * This impacts both the direct diffuse and specular highlights.
  51791. */
  51792. protected _directIntensity: number;
  51793. /**
  51794. * Intensity of the emissive part of the material.
  51795. * This helps controlling the emissive effect without modifying the emissive color.
  51796. */
  51797. protected _emissiveIntensity: number;
  51798. /**
  51799. * Intensity of the environment e.g. how much the environment will light the object
  51800. * either through harmonics for rough material or through the refelction for shiny ones.
  51801. */
  51802. protected _environmentIntensity: number;
  51803. /**
  51804. * This is a special control allowing the reduction of the specular highlights coming from the
  51805. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51806. */
  51807. protected _specularIntensity: number;
  51808. /**
  51809. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51810. */
  51811. private _lightingInfos;
  51812. /**
  51813. * Debug Control allowing disabling the bump map on this material.
  51814. */
  51815. protected _disableBumpMap: boolean;
  51816. /**
  51817. * AKA Diffuse Texture in standard nomenclature.
  51818. */
  51819. protected _albedoTexture: Nullable<BaseTexture>;
  51820. /**
  51821. * AKA Occlusion Texture in other nomenclature.
  51822. */
  51823. protected _ambientTexture: Nullable<BaseTexture>;
  51824. /**
  51825. * AKA Occlusion Texture Intensity in other nomenclature.
  51826. */
  51827. protected _ambientTextureStrength: number;
  51828. /**
  51829. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51830. * 1 means it completely occludes it
  51831. * 0 mean it has no impact
  51832. */
  51833. protected _ambientTextureImpactOnAnalyticalLights: number;
  51834. /**
  51835. * Stores the alpha values in a texture.
  51836. */
  51837. protected _opacityTexture: Nullable<BaseTexture>;
  51838. /**
  51839. * Stores the reflection values in a texture.
  51840. */
  51841. protected _reflectionTexture: Nullable<BaseTexture>;
  51842. /**
  51843. * Stores the emissive values in a texture.
  51844. */
  51845. protected _emissiveTexture: Nullable<BaseTexture>;
  51846. /**
  51847. * AKA Specular texture in other nomenclature.
  51848. */
  51849. protected _reflectivityTexture: Nullable<BaseTexture>;
  51850. /**
  51851. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51852. */
  51853. protected _metallicTexture: Nullable<BaseTexture>;
  51854. /**
  51855. * Specifies the metallic scalar of the metallic/roughness workflow.
  51856. * Can also be used to scale the metalness values of the metallic texture.
  51857. */
  51858. protected _metallic: Nullable<number>;
  51859. /**
  51860. * Specifies the roughness scalar of the metallic/roughness workflow.
  51861. * Can also be used to scale the roughness values of the metallic texture.
  51862. */
  51863. protected _roughness: Nullable<number>;
  51864. /**
  51865. * Specifies the an F0 factor to help configuring the material F0.
  51866. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51867. * to 0.5 the previously hard coded value stays the same.
  51868. * Can also be used to scale the F0 values of the metallic texture.
  51869. */
  51870. protected _metallicF0Factor: number;
  51871. /**
  51872. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51873. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51874. * your expectation as it multiplies with the texture data.
  51875. */
  51876. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51877. /**
  51878. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51879. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51880. */
  51881. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51882. /**
  51883. * Stores surface normal data used to displace a mesh in a texture.
  51884. */
  51885. protected _bumpTexture: Nullable<BaseTexture>;
  51886. /**
  51887. * Stores the pre-calculated light information of a mesh in a texture.
  51888. */
  51889. protected _lightmapTexture: Nullable<BaseTexture>;
  51890. /**
  51891. * The color of a material in ambient lighting.
  51892. */
  51893. protected _ambientColor: Color3;
  51894. /**
  51895. * AKA Diffuse Color in other nomenclature.
  51896. */
  51897. protected _albedoColor: Color3;
  51898. /**
  51899. * AKA Specular Color in other nomenclature.
  51900. */
  51901. protected _reflectivityColor: Color3;
  51902. /**
  51903. * The color applied when light is reflected from a material.
  51904. */
  51905. protected _reflectionColor: Color3;
  51906. /**
  51907. * The color applied when light is emitted from a material.
  51908. */
  51909. protected _emissiveColor: Color3;
  51910. /**
  51911. * AKA Glossiness in other nomenclature.
  51912. */
  51913. protected _microSurface: number;
  51914. /**
  51915. * Specifies that the material will use the light map as a show map.
  51916. */
  51917. protected _useLightmapAsShadowmap: boolean;
  51918. /**
  51919. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51920. * makes the reflect vector face the model (under horizon).
  51921. */
  51922. protected _useHorizonOcclusion: boolean;
  51923. /**
  51924. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51925. * too much the area relying on ambient texture to define their ambient occlusion.
  51926. */
  51927. protected _useRadianceOcclusion: boolean;
  51928. /**
  51929. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51930. */
  51931. protected _useAlphaFromAlbedoTexture: boolean;
  51932. /**
  51933. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51934. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51935. */
  51936. protected _useSpecularOverAlpha: boolean;
  51937. /**
  51938. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51939. */
  51940. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51941. /**
  51942. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51943. */
  51944. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51945. /**
  51946. * Specifies if the metallic texture contains the roughness information in its green channel.
  51947. */
  51948. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51949. /**
  51950. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51951. */
  51952. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51953. /**
  51954. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51955. */
  51956. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51957. /**
  51958. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51959. */
  51960. protected _useAmbientInGrayScale: boolean;
  51961. /**
  51962. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51963. * The material will try to infer what glossiness each pixel should be.
  51964. */
  51965. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51966. /**
  51967. * Defines the falloff type used in this material.
  51968. * It by default is Physical.
  51969. */
  51970. protected _lightFalloff: number;
  51971. /**
  51972. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51973. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51974. */
  51975. protected _useRadianceOverAlpha: boolean;
  51976. /**
  51977. * Allows using an object space normal map (instead of tangent space).
  51978. */
  51979. protected _useObjectSpaceNormalMap: boolean;
  51980. /**
  51981. * Allows using the bump map in parallax mode.
  51982. */
  51983. protected _useParallax: boolean;
  51984. /**
  51985. * Allows using the bump map in parallax occlusion mode.
  51986. */
  51987. protected _useParallaxOcclusion: boolean;
  51988. /**
  51989. * Controls the scale bias of the parallax mode.
  51990. */
  51991. protected _parallaxScaleBias: number;
  51992. /**
  51993. * If sets to true, disables all the lights affecting the material.
  51994. */
  51995. protected _disableLighting: boolean;
  51996. /**
  51997. * Number of Simultaneous lights allowed on the material.
  51998. */
  51999. protected _maxSimultaneousLights: number;
  52000. /**
  52001. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52002. */
  52003. protected _invertNormalMapX: boolean;
  52004. /**
  52005. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52006. */
  52007. protected _invertNormalMapY: boolean;
  52008. /**
  52009. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52010. */
  52011. protected _twoSidedLighting: boolean;
  52012. /**
  52013. * Defines the alpha limits in alpha test mode.
  52014. */
  52015. protected _alphaCutOff: number;
  52016. /**
  52017. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52018. */
  52019. protected _forceAlphaTest: boolean;
  52020. /**
  52021. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52022. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52023. */
  52024. protected _useAlphaFresnel: boolean;
  52025. /**
  52026. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52027. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52028. */
  52029. protected _useLinearAlphaFresnel: boolean;
  52030. /**
  52031. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52032. * from cos thetav and roughness:
  52033. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52034. */
  52035. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52036. /**
  52037. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52038. */
  52039. protected _forceIrradianceInFragment: boolean;
  52040. /**
  52041. * Force normal to face away from face.
  52042. */
  52043. protected _forceNormalForward: boolean;
  52044. /**
  52045. * Enables specular anti aliasing in the PBR shader.
  52046. * It will both interacts on the Geometry for analytical and IBL lighting.
  52047. * It also prefilter the roughness map based on the bump values.
  52048. */
  52049. protected _enableSpecularAntiAliasing: boolean;
  52050. /**
  52051. * Default configuration related to image processing available in the PBR Material.
  52052. */
  52053. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52054. /**
  52055. * Keep track of the image processing observer to allow dispose and replace.
  52056. */
  52057. private _imageProcessingObserver;
  52058. /**
  52059. * Attaches a new image processing configuration to the PBR Material.
  52060. * @param configuration
  52061. */
  52062. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52063. /**
  52064. * Stores the available render targets.
  52065. */
  52066. private _renderTargets;
  52067. /**
  52068. * Sets the global ambient color for the material used in lighting calculations.
  52069. */
  52070. private _globalAmbientColor;
  52071. /**
  52072. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52073. */
  52074. private _useLogarithmicDepth;
  52075. /**
  52076. * If set to true, no lighting calculations will be applied.
  52077. */
  52078. private _unlit;
  52079. private _debugMode;
  52080. /**
  52081. * @hidden
  52082. * This is reserved for the inspector.
  52083. * Defines the material debug mode.
  52084. * It helps seeing only some components of the material while troubleshooting.
  52085. */
  52086. debugMode: number;
  52087. /**
  52088. * @hidden
  52089. * This is reserved for the inspector.
  52090. * Specify from where on screen the debug mode should start.
  52091. * The value goes from -1 (full screen) to 1 (not visible)
  52092. * It helps with side by side comparison against the final render
  52093. * This defaults to -1
  52094. */
  52095. private debugLimit;
  52096. /**
  52097. * @hidden
  52098. * This is reserved for the inspector.
  52099. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52100. * You can use the factor to better multiply the final value.
  52101. */
  52102. private debugFactor;
  52103. /**
  52104. * Defines the clear coat layer parameters for the material.
  52105. */
  52106. readonly clearCoat: PBRClearCoatConfiguration;
  52107. /**
  52108. * Defines the anisotropic parameters for the material.
  52109. */
  52110. readonly anisotropy: PBRAnisotropicConfiguration;
  52111. /**
  52112. * Defines the BRDF parameters for the material.
  52113. */
  52114. readonly brdf: PBRBRDFConfiguration;
  52115. /**
  52116. * Defines the Sheen parameters for the material.
  52117. */
  52118. readonly sheen: PBRSheenConfiguration;
  52119. /**
  52120. * Defines the SubSurface parameters for the material.
  52121. */
  52122. readonly subSurface: PBRSubSurfaceConfiguration;
  52123. protected _rebuildInParallel: boolean;
  52124. /**
  52125. * Instantiates a new PBRMaterial instance.
  52126. *
  52127. * @param name The material name
  52128. * @param scene The scene the material will be use in.
  52129. */
  52130. constructor(name: string, scene: Scene);
  52131. /**
  52132. * Gets a boolean indicating that current material needs to register RTT
  52133. */
  52134. get hasRenderTargetTextures(): boolean;
  52135. /**
  52136. * Gets the name of the material class.
  52137. */
  52138. getClassName(): string;
  52139. /**
  52140. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52141. */
  52142. get useLogarithmicDepth(): boolean;
  52143. /**
  52144. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52145. */
  52146. set useLogarithmicDepth(value: boolean);
  52147. /**
  52148. * Returns true if alpha blending should be disabled.
  52149. */
  52150. protected get _disableAlphaBlending(): boolean;
  52151. /**
  52152. * Specifies whether or not this material should be rendered in alpha blend mode.
  52153. */
  52154. needAlphaBlending(): boolean;
  52155. /**
  52156. * Specifies whether or not this material should be rendered in alpha test mode.
  52157. */
  52158. needAlphaTesting(): boolean;
  52159. /**
  52160. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52161. */
  52162. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52163. /**
  52164. * Gets the texture used for the alpha test.
  52165. */
  52166. getAlphaTestTexture(): Nullable<BaseTexture>;
  52167. /**
  52168. * Specifies that the submesh is ready to be used.
  52169. * @param mesh - BJS mesh.
  52170. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52171. * @param useInstances - Specifies that instances should be used.
  52172. * @returns - boolean indicating that the submesh is ready or not.
  52173. */
  52174. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52175. /**
  52176. * Specifies if the material uses metallic roughness workflow.
  52177. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52178. */
  52179. isMetallicWorkflow(): boolean;
  52180. private _prepareEffect;
  52181. private _prepareDefines;
  52182. /**
  52183. * Force shader compilation
  52184. */
  52185. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52186. /**
  52187. * Initializes the uniform buffer layout for the shader.
  52188. */
  52189. buildUniformLayout(): void;
  52190. /**
  52191. * Unbinds the material from the mesh
  52192. */
  52193. unbind(): void;
  52194. /**
  52195. * Binds the submesh data.
  52196. * @param world - The world matrix.
  52197. * @param mesh - The BJS mesh.
  52198. * @param subMesh - A submesh of the BJS mesh.
  52199. */
  52200. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52201. /**
  52202. * Returns the animatable textures.
  52203. * @returns - Array of animatable textures.
  52204. */
  52205. getAnimatables(): IAnimatable[];
  52206. /**
  52207. * Returns the texture used for reflections.
  52208. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52209. */
  52210. private _getReflectionTexture;
  52211. /**
  52212. * Returns an array of the actively used textures.
  52213. * @returns - Array of BaseTextures
  52214. */
  52215. getActiveTextures(): BaseTexture[];
  52216. /**
  52217. * Checks to see if a texture is used in the material.
  52218. * @param texture - Base texture to use.
  52219. * @returns - Boolean specifying if a texture is used in the material.
  52220. */
  52221. hasTexture(texture: BaseTexture): boolean;
  52222. /**
  52223. * Disposes the resources of the material.
  52224. * @param forceDisposeEffect - Forces the disposal of effects.
  52225. * @param forceDisposeTextures - Forces the disposal of all textures.
  52226. */
  52227. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52228. }
  52229. }
  52230. declare module BABYLON {
  52231. /**
  52232. * The Physically based material of BJS.
  52233. *
  52234. * This offers the main features of a standard PBR material.
  52235. * For more information, please refer to the documentation :
  52236. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52237. */
  52238. export class PBRMaterial extends PBRBaseMaterial {
  52239. /**
  52240. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52241. */
  52242. static readonly PBRMATERIAL_OPAQUE: number;
  52243. /**
  52244. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52245. */
  52246. static readonly PBRMATERIAL_ALPHATEST: number;
  52247. /**
  52248. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52249. */
  52250. static readonly PBRMATERIAL_ALPHABLEND: number;
  52251. /**
  52252. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52253. * They are also discarded below the alpha cutoff threshold to improve performances.
  52254. */
  52255. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52256. /**
  52257. * Defines the default value of how much AO map is occluding the analytical lights
  52258. * (point spot...).
  52259. */
  52260. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52261. /**
  52262. * Intensity of the direct lights e.g. the four lights available in your scene.
  52263. * This impacts both the direct diffuse and specular highlights.
  52264. */
  52265. directIntensity: number;
  52266. /**
  52267. * Intensity of the emissive part of the material.
  52268. * This helps controlling the emissive effect without modifying the emissive color.
  52269. */
  52270. emissiveIntensity: number;
  52271. /**
  52272. * Intensity of the environment e.g. how much the environment will light the object
  52273. * either through harmonics for rough material or through the refelction for shiny ones.
  52274. */
  52275. environmentIntensity: number;
  52276. /**
  52277. * This is a special control allowing the reduction of the specular highlights coming from the
  52278. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52279. */
  52280. specularIntensity: number;
  52281. /**
  52282. * Debug Control allowing disabling the bump map on this material.
  52283. */
  52284. disableBumpMap: boolean;
  52285. /**
  52286. * AKA Diffuse Texture in standard nomenclature.
  52287. */
  52288. albedoTexture: BaseTexture;
  52289. /**
  52290. * AKA Occlusion Texture in other nomenclature.
  52291. */
  52292. ambientTexture: BaseTexture;
  52293. /**
  52294. * AKA Occlusion Texture Intensity in other nomenclature.
  52295. */
  52296. ambientTextureStrength: number;
  52297. /**
  52298. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52299. * 1 means it completely occludes it
  52300. * 0 mean it has no impact
  52301. */
  52302. ambientTextureImpactOnAnalyticalLights: number;
  52303. /**
  52304. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52305. */
  52306. opacityTexture: BaseTexture;
  52307. /**
  52308. * Stores the reflection values in a texture.
  52309. */
  52310. reflectionTexture: Nullable<BaseTexture>;
  52311. /**
  52312. * Stores the emissive values in a texture.
  52313. */
  52314. emissiveTexture: BaseTexture;
  52315. /**
  52316. * AKA Specular texture in other nomenclature.
  52317. */
  52318. reflectivityTexture: BaseTexture;
  52319. /**
  52320. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52321. */
  52322. metallicTexture: BaseTexture;
  52323. /**
  52324. * Specifies the metallic scalar of the metallic/roughness workflow.
  52325. * Can also be used to scale the metalness values of the metallic texture.
  52326. */
  52327. metallic: Nullable<number>;
  52328. /**
  52329. * Specifies the roughness scalar of the metallic/roughness workflow.
  52330. * Can also be used to scale the roughness values of the metallic texture.
  52331. */
  52332. roughness: Nullable<number>;
  52333. /**
  52334. * Specifies the an F0 factor to help configuring the material F0.
  52335. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52336. * to 0.5 the previously hard coded value stays the same.
  52337. * Can also be used to scale the F0 values of the metallic texture.
  52338. */
  52339. metallicF0Factor: number;
  52340. /**
  52341. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52342. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52343. * your expectation as it multiplies with the texture data.
  52344. */
  52345. useMetallicF0FactorFromMetallicTexture: boolean;
  52346. /**
  52347. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52348. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52349. */
  52350. microSurfaceTexture: BaseTexture;
  52351. /**
  52352. * Stores surface normal data used to displace a mesh in a texture.
  52353. */
  52354. bumpTexture: BaseTexture;
  52355. /**
  52356. * Stores the pre-calculated light information of a mesh in a texture.
  52357. */
  52358. lightmapTexture: BaseTexture;
  52359. /**
  52360. * Stores the refracted light information in a texture.
  52361. */
  52362. get refractionTexture(): Nullable<BaseTexture>;
  52363. set refractionTexture(value: Nullable<BaseTexture>);
  52364. /**
  52365. * The color of a material in ambient lighting.
  52366. */
  52367. ambientColor: Color3;
  52368. /**
  52369. * AKA Diffuse Color in other nomenclature.
  52370. */
  52371. albedoColor: Color3;
  52372. /**
  52373. * AKA Specular Color in other nomenclature.
  52374. */
  52375. reflectivityColor: Color3;
  52376. /**
  52377. * The color reflected from the material.
  52378. */
  52379. reflectionColor: Color3;
  52380. /**
  52381. * The color emitted from the material.
  52382. */
  52383. emissiveColor: Color3;
  52384. /**
  52385. * AKA Glossiness in other nomenclature.
  52386. */
  52387. microSurface: number;
  52388. /**
  52389. * source material index of refraction (IOR)' / 'destination material IOR.
  52390. */
  52391. get indexOfRefraction(): number;
  52392. set indexOfRefraction(value: number);
  52393. /**
  52394. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52395. */
  52396. get invertRefractionY(): boolean;
  52397. set invertRefractionY(value: boolean);
  52398. /**
  52399. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52400. * Materials half opaque for instance using refraction could benefit from this control.
  52401. */
  52402. get linkRefractionWithTransparency(): boolean;
  52403. set linkRefractionWithTransparency(value: boolean);
  52404. /**
  52405. * If true, the light map contains occlusion information instead of lighting info.
  52406. */
  52407. useLightmapAsShadowmap: boolean;
  52408. /**
  52409. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52410. */
  52411. useAlphaFromAlbedoTexture: boolean;
  52412. /**
  52413. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52414. */
  52415. forceAlphaTest: boolean;
  52416. /**
  52417. * Defines the alpha limits in alpha test mode.
  52418. */
  52419. alphaCutOff: number;
  52420. /**
  52421. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52422. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52423. */
  52424. useSpecularOverAlpha: boolean;
  52425. /**
  52426. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52427. */
  52428. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52429. /**
  52430. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52431. */
  52432. useRoughnessFromMetallicTextureAlpha: boolean;
  52433. /**
  52434. * Specifies if the metallic texture contains the roughness information in its green channel.
  52435. */
  52436. useRoughnessFromMetallicTextureGreen: boolean;
  52437. /**
  52438. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52439. */
  52440. useMetallnessFromMetallicTextureBlue: boolean;
  52441. /**
  52442. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52443. */
  52444. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52445. /**
  52446. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52447. */
  52448. useAmbientInGrayScale: boolean;
  52449. /**
  52450. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52451. * The material will try to infer what glossiness each pixel should be.
  52452. */
  52453. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52454. /**
  52455. * BJS is using an harcoded light falloff based on a manually sets up range.
  52456. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52457. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52458. */
  52459. get usePhysicalLightFalloff(): boolean;
  52460. /**
  52461. * BJS is using an harcoded light falloff based on a manually sets up range.
  52462. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52463. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52464. */
  52465. set usePhysicalLightFalloff(value: boolean);
  52466. /**
  52467. * In order to support the falloff compatibility with gltf, a special mode has been added
  52468. * to reproduce the gltf light falloff.
  52469. */
  52470. get useGLTFLightFalloff(): boolean;
  52471. /**
  52472. * In order to support the falloff compatibility with gltf, a special mode has been added
  52473. * to reproduce the gltf light falloff.
  52474. */
  52475. set useGLTFLightFalloff(value: boolean);
  52476. /**
  52477. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52478. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52479. */
  52480. useRadianceOverAlpha: boolean;
  52481. /**
  52482. * Allows using an object space normal map (instead of tangent space).
  52483. */
  52484. useObjectSpaceNormalMap: boolean;
  52485. /**
  52486. * Allows using the bump map in parallax mode.
  52487. */
  52488. useParallax: boolean;
  52489. /**
  52490. * Allows using the bump map in parallax occlusion mode.
  52491. */
  52492. useParallaxOcclusion: boolean;
  52493. /**
  52494. * Controls the scale bias of the parallax mode.
  52495. */
  52496. parallaxScaleBias: number;
  52497. /**
  52498. * If sets to true, disables all the lights affecting the material.
  52499. */
  52500. disableLighting: boolean;
  52501. /**
  52502. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52503. */
  52504. forceIrradianceInFragment: boolean;
  52505. /**
  52506. * Number of Simultaneous lights allowed on the material.
  52507. */
  52508. maxSimultaneousLights: number;
  52509. /**
  52510. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52511. */
  52512. invertNormalMapX: boolean;
  52513. /**
  52514. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52515. */
  52516. invertNormalMapY: boolean;
  52517. /**
  52518. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52519. */
  52520. twoSidedLighting: boolean;
  52521. /**
  52522. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52523. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52524. */
  52525. useAlphaFresnel: boolean;
  52526. /**
  52527. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52528. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52529. */
  52530. useLinearAlphaFresnel: boolean;
  52531. /**
  52532. * Let user defines the brdf lookup texture used for IBL.
  52533. * A default 8bit version is embedded but you could point at :
  52534. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52535. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52536. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52537. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52538. */
  52539. environmentBRDFTexture: Nullable<BaseTexture>;
  52540. /**
  52541. * Force normal to face away from face.
  52542. */
  52543. forceNormalForward: boolean;
  52544. /**
  52545. * Enables specular anti aliasing in the PBR shader.
  52546. * It will both interacts on the Geometry for analytical and IBL lighting.
  52547. * It also prefilter the roughness map based on the bump values.
  52548. */
  52549. enableSpecularAntiAliasing: boolean;
  52550. /**
  52551. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52552. * makes the reflect vector face the model (under horizon).
  52553. */
  52554. useHorizonOcclusion: boolean;
  52555. /**
  52556. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52557. * too much the area relying on ambient texture to define their ambient occlusion.
  52558. */
  52559. useRadianceOcclusion: boolean;
  52560. /**
  52561. * If set to true, no lighting calculations will be applied.
  52562. */
  52563. unlit: boolean;
  52564. /**
  52565. * Gets the image processing configuration used either in this material.
  52566. */
  52567. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52568. /**
  52569. * Sets the Default image processing configuration used either in the this material.
  52570. *
  52571. * If sets to null, the scene one is in use.
  52572. */
  52573. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52574. /**
  52575. * Gets wether the color curves effect is enabled.
  52576. */
  52577. get cameraColorCurvesEnabled(): boolean;
  52578. /**
  52579. * Sets wether the color curves effect is enabled.
  52580. */
  52581. set cameraColorCurvesEnabled(value: boolean);
  52582. /**
  52583. * Gets wether the color grading effect is enabled.
  52584. */
  52585. get cameraColorGradingEnabled(): boolean;
  52586. /**
  52587. * Gets wether the color grading effect is enabled.
  52588. */
  52589. set cameraColorGradingEnabled(value: boolean);
  52590. /**
  52591. * Gets wether tonemapping is enabled or not.
  52592. */
  52593. get cameraToneMappingEnabled(): boolean;
  52594. /**
  52595. * Sets wether tonemapping is enabled or not
  52596. */
  52597. set cameraToneMappingEnabled(value: boolean);
  52598. /**
  52599. * The camera exposure used on this material.
  52600. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52601. * This corresponds to a photographic exposure.
  52602. */
  52603. get cameraExposure(): number;
  52604. /**
  52605. * The camera exposure used on this material.
  52606. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52607. * This corresponds to a photographic exposure.
  52608. */
  52609. set cameraExposure(value: number);
  52610. /**
  52611. * Gets The camera contrast used on this material.
  52612. */
  52613. get cameraContrast(): number;
  52614. /**
  52615. * Sets The camera contrast used on this material.
  52616. */
  52617. set cameraContrast(value: number);
  52618. /**
  52619. * Gets the Color Grading 2D Lookup Texture.
  52620. */
  52621. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52622. /**
  52623. * Sets the Color Grading 2D Lookup Texture.
  52624. */
  52625. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52626. /**
  52627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52629. * 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;
  52630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52631. */
  52632. get cameraColorCurves(): Nullable<ColorCurves>;
  52633. /**
  52634. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52636. * 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;
  52637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52638. */
  52639. set cameraColorCurves(value: Nullable<ColorCurves>);
  52640. /**
  52641. * Instantiates a new PBRMaterial instance.
  52642. *
  52643. * @param name The material name
  52644. * @param scene The scene the material will be use in.
  52645. */
  52646. constructor(name: string, scene: Scene);
  52647. /**
  52648. * Returns the name of this material class.
  52649. */
  52650. getClassName(): string;
  52651. /**
  52652. * Makes a duplicate of the current material.
  52653. * @param name - name to use for the new material.
  52654. */
  52655. clone(name: string): PBRMaterial;
  52656. /**
  52657. * Serializes this PBR Material.
  52658. * @returns - An object with the serialized material.
  52659. */
  52660. serialize(): any;
  52661. /**
  52662. * Parses a PBR Material from a serialized object.
  52663. * @param source - Serialized object.
  52664. * @param scene - BJS scene instance.
  52665. * @param rootUrl - url for the scene object
  52666. * @returns - PBRMaterial
  52667. */
  52668. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52669. }
  52670. }
  52671. declare module BABYLON {
  52672. /**
  52673. * Direct draw surface info
  52674. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52675. */
  52676. export interface DDSInfo {
  52677. /**
  52678. * Width of the texture
  52679. */
  52680. width: number;
  52681. /**
  52682. * Width of the texture
  52683. */
  52684. height: number;
  52685. /**
  52686. * Number of Mipmaps for the texture
  52687. * @see https://en.wikipedia.org/wiki/Mipmap
  52688. */
  52689. mipmapCount: number;
  52690. /**
  52691. * If the textures format is a known fourCC format
  52692. * @see https://www.fourcc.org/
  52693. */
  52694. isFourCC: boolean;
  52695. /**
  52696. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52697. */
  52698. isRGB: boolean;
  52699. /**
  52700. * If the texture is a lumincance format
  52701. */
  52702. isLuminance: boolean;
  52703. /**
  52704. * If this is a cube texture
  52705. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52706. */
  52707. isCube: boolean;
  52708. /**
  52709. * If the texture is a compressed format eg. FOURCC_DXT1
  52710. */
  52711. isCompressed: boolean;
  52712. /**
  52713. * The dxgiFormat of the texture
  52714. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52715. */
  52716. dxgiFormat: number;
  52717. /**
  52718. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52719. */
  52720. textureType: number;
  52721. /**
  52722. * Sphericle polynomial created for the dds texture
  52723. */
  52724. sphericalPolynomial?: SphericalPolynomial;
  52725. }
  52726. /**
  52727. * Class used to provide DDS decompression tools
  52728. */
  52729. export class DDSTools {
  52730. /**
  52731. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52732. */
  52733. static StoreLODInAlphaChannel: boolean;
  52734. /**
  52735. * Gets DDS information from an array buffer
  52736. * @param data defines the array buffer view to read data from
  52737. * @returns the DDS information
  52738. */
  52739. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52740. private static _FloatView;
  52741. private static _Int32View;
  52742. private static _ToHalfFloat;
  52743. private static _FromHalfFloat;
  52744. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52745. private static _GetHalfFloatRGBAArrayBuffer;
  52746. private static _GetFloatRGBAArrayBuffer;
  52747. private static _GetFloatAsUIntRGBAArrayBuffer;
  52748. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52749. private static _GetRGBAArrayBuffer;
  52750. private static _ExtractLongWordOrder;
  52751. private static _GetRGBArrayBuffer;
  52752. private static _GetLuminanceArrayBuffer;
  52753. /**
  52754. * Uploads DDS Levels to a Babylon Texture
  52755. * @hidden
  52756. */
  52757. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52758. }
  52759. interface ThinEngine {
  52760. /**
  52761. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52762. * @param rootUrl defines the url where the file to load is located
  52763. * @param scene defines the current scene
  52764. * @param lodScale defines scale to apply to the mip map selection
  52765. * @param lodOffset defines offset to apply to the mip map selection
  52766. * @param onLoad defines an optional callback raised when the texture is loaded
  52767. * @param onError defines an optional callback raised if there is an issue to load the texture
  52768. * @param format defines the format of the data
  52769. * @param forcedExtension defines the extension to use to pick the right loader
  52770. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52771. * @returns the cube texture as an InternalTexture
  52772. */
  52773. 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;
  52774. }
  52775. }
  52776. declare module BABYLON {
  52777. /**
  52778. * Implementation of the DDS Texture Loader.
  52779. * @hidden
  52780. */
  52781. export class _DDSTextureLoader implements IInternalTextureLoader {
  52782. /**
  52783. * Defines wether the loader supports cascade loading the different faces.
  52784. */
  52785. readonly supportCascades: boolean;
  52786. /**
  52787. * This returns if the loader support the current file information.
  52788. * @param extension defines the file extension of the file being loaded
  52789. * @returns true if the loader can load the specified file
  52790. */
  52791. canLoad(extension: string): boolean;
  52792. /**
  52793. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52794. * @param data contains the texture data
  52795. * @param texture defines the BabylonJS internal texture
  52796. * @param createPolynomials will be true if polynomials have been requested
  52797. * @param onLoad defines the callback to trigger once the texture is ready
  52798. * @param onError defines the callback to trigger in case of error
  52799. */
  52800. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52801. /**
  52802. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52803. * @param data contains the texture data
  52804. * @param texture defines the BabylonJS internal texture
  52805. * @param callback defines the method to call once ready to upload
  52806. */
  52807. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52808. }
  52809. }
  52810. declare module BABYLON {
  52811. /**
  52812. * Implementation of the ENV Texture Loader.
  52813. * @hidden
  52814. */
  52815. export class _ENVTextureLoader implements IInternalTextureLoader {
  52816. /**
  52817. * Defines wether the loader supports cascade loading the different faces.
  52818. */
  52819. readonly supportCascades: boolean;
  52820. /**
  52821. * This returns if the loader support the current file information.
  52822. * @param extension defines the file extension of the file being loaded
  52823. * @returns true if the loader can load the specified file
  52824. */
  52825. canLoad(extension: string): boolean;
  52826. /**
  52827. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52828. * @param data contains the texture data
  52829. * @param texture defines the BabylonJS internal texture
  52830. * @param createPolynomials will be true if polynomials have been requested
  52831. * @param onLoad defines the callback to trigger once the texture is ready
  52832. * @param onError defines the callback to trigger in case of error
  52833. */
  52834. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52835. /**
  52836. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52837. * @param data contains the texture data
  52838. * @param texture defines the BabylonJS internal texture
  52839. * @param callback defines the method to call once ready to upload
  52840. */
  52841. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52842. }
  52843. }
  52844. declare module BABYLON {
  52845. /**
  52846. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52847. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52848. */
  52849. export class KhronosTextureContainer {
  52850. /** contents of the KTX container file */
  52851. data: ArrayBufferView;
  52852. private static HEADER_LEN;
  52853. private static COMPRESSED_2D;
  52854. private static COMPRESSED_3D;
  52855. private static TEX_2D;
  52856. private static TEX_3D;
  52857. /**
  52858. * Gets the openGL type
  52859. */
  52860. glType: number;
  52861. /**
  52862. * Gets the openGL type size
  52863. */
  52864. glTypeSize: number;
  52865. /**
  52866. * Gets the openGL format
  52867. */
  52868. glFormat: number;
  52869. /**
  52870. * Gets the openGL internal format
  52871. */
  52872. glInternalFormat: number;
  52873. /**
  52874. * Gets the base internal format
  52875. */
  52876. glBaseInternalFormat: number;
  52877. /**
  52878. * Gets image width in pixel
  52879. */
  52880. pixelWidth: number;
  52881. /**
  52882. * Gets image height in pixel
  52883. */
  52884. pixelHeight: number;
  52885. /**
  52886. * Gets image depth in pixels
  52887. */
  52888. pixelDepth: number;
  52889. /**
  52890. * Gets the number of array elements
  52891. */
  52892. numberOfArrayElements: number;
  52893. /**
  52894. * Gets the number of faces
  52895. */
  52896. numberOfFaces: number;
  52897. /**
  52898. * Gets the number of mipmap levels
  52899. */
  52900. numberOfMipmapLevels: number;
  52901. /**
  52902. * Gets the bytes of key value data
  52903. */
  52904. bytesOfKeyValueData: number;
  52905. /**
  52906. * Gets the load type
  52907. */
  52908. loadType: number;
  52909. /**
  52910. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52911. */
  52912. isInvalid: boolean;
  52913. /**
  52914. * Creates a new KhronosTextureContainer
  52915. * @param data contents of the KTX container file
  52916. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52917. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52918. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52919. */
  52920. constructor(
  52921. /** contents of the KTX container file */
  52922. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52923. /**
  52924. * Uploads KTX content to a Babylon Texture.
  52925. * It is assumed that the texture has already been created & is currently bound
  52926. * @hidden
  52927. */
  52928. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52929. private _upload2DCompressedLevels;
  52930. /**
  52931. * Checks if the given data starts with a KTX file identifier.
  52932. * @param data the data to check
  52933. * @returns true if the data is a KTX file or false otherwise
  52934. */
  52935. static IsValid(data: ArrayBufferView): boolean;
  52936. }
  52937. }
  52938. declare module BABYLON {
  52939. /**
  52940. * Class for loading KTX2 files
  52941. * !!! Experimental Extension Subject to Changes !!!
  52942. * @hidden
  52943. */
  52944. export class KhronosTextureContainer2 {
  52945. private static _ModulePromise;
  52946. private static _TranscodeFormat;
  52947. constructor(engine: ThinEngine);
  52948. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52949. private _determineTranscodeFormat;
  52950. /**
  52951. * Checks if the given data starts with a KTX2 file identifier.
  52952. * @param data the data to check
  52953. * @returns true if the data is a KTX2 file or false otherwise
  52954. */
  52955. static IsValid(data: ArrayBufferView): boolean;
  52956. }
  52957. }
  52958. declare module BABYLON {
  52959. /**
  52960. * Implementation of the KTX Texture Loader.
  52961. * @hidden
  52962. */
  52963. export class _KTXTextureLoader implements IInternalTextureLoader {
  52964. /**
  52965. * Defines wether the loader supports cascade loading the different faces.
  52966. */
  52967. readonly supportCascades: boolean;
  52968. /**
  52969. * This returns if the loader support the current file information.
  52970. * @param extension defines the file extension of the file being loaded
  52971. * @returns true if the loader can load the specified file
  52972. */
  52973. canLoad(extension: string): boolean;
  52974. /**
  52975. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52976. * @param data contains the texture data
  52977. * @param texture defines the BabylonJS internal texture
  52978. * @param createPolynomials will be true if polynomials have been requested
  52979. * @param onLoad defines the callback to trigger once the texture is ready
  52980. * @param onError defines the callback to trigger in case of error
  52981. */
  52982. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52983. /**
  52984. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52985. * @param data contains the texture data
  52986. * @param texture defines the BabylonJS internal texture
  52987. * @param callback defines the method to call once ready to upload
  52988. */
  52989. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52990. }
  52991. }
  52992. declare module BABYLON {
  52993. /** @hidden */
  52994. export var _forceSceneHelpersToBundle: boolean;
  52995. interface Scene {
  52996. /**
  52997. * Creates a default light for the scene.
  52998. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52999. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53000. */
  53001. createDefaultLight(replace?: boolean): void;
  53002. /**
  53003. * Creates a default camera for the scene.
  53004. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53005. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53006. * @param replace has default false, when true replaces the active camera in the scene
  53007. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53008. */
  53009. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53010. /**
  53011. * Creates a default camera and a default light.
  53012. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53013. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53014. * @param replace has the default false, when true replaces the active camera/light in the scene
  53015. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53016. */
  53017. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53018. /**
  53019. * Creates a new sky box
  53020. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53021. * @param environmentTexture defines the texture to use as environment texture
  53022. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53023. * @param scale defines the overall scale of the skybox
  53024. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53025. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53026. * @returns a new mesh holding the sky box
  53027. */
  53028. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53029. /**
  53030. * Creates a new environment
  53031. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53032. * @param options defines the options you can use to configure the environment
  53033. * @returns the new EnvironmentHelper
  53034. */
  53035. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53036. /**
  53037. * Creates a new VREXperienceHelper
  53038. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53039. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53040. * @returns a new VREXperienceHelper
  53041. */
  53042. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53043. /**
  53044. * Creates a new WebXRDefaultExperience
  53045. * @see http://doc.babylonjs.com/how_to/webxr
  53046. * @param options experience options
  53047. * @returns a promise for a new WebXRDefaultExperience
  53048. */
  53049. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53050. }
  53051. }
  53052. declare module BABYLON {
  53053. /**
  53054. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53055. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53056. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53057. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53058. */
  53059. export class VideoDome extends TransformNode {
  53060. /**
  53061. * Define the video source as a Monoscopic panoramic 360 video.
  53062. */
  53063. static readonly MODE_MONOSCOPIC: number;
  53064. /**
  53065. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53066. */
  53067. static readonly MODE_TOPBOTTOM: number;
  53068. /**
  53069. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53070. */
  53071. static readonly MODE_SIDEBYSIDE: number;
  53072. private _halfDome;
  53073. private _useDirectMapping;
  53074. /**
  53075. * The video texture being displayed on the sphere
  53076. */
  53077. protected _videoTexture: VideoTexture;
  53078. /**
  53079. * Gets the video texture being displayed on the sphere
  53080. */
  53081. get videoTexture(): VideoTexture;
  53082. /**
  53083. * The skybox material
  53084. */
  53085. protected _material: BackgroundMaterial;
  53086. /**
  53087. * The surface used for the skybox
  53088. */
  53089. protected _mesh: Mesh;
  53090. /**
  53091. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53092. */
  53093. private _halfDomeMask;
  53094. /**
  53095. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53096. * Also see the options.resolution property.
  53097. */
  53098. get fovMultiplier(): number;
  53099. set fovMultiplier(value: number);
  53100. private _videoMode;
  53101. /**
  53102. * Gets or set the current video mode for the video. It can be:
  53103. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53104. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53105. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53106. */
  53107. get videoMode(): number;
  53108. set videoMode(value: number);
  53109. /**
  53110. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53111. *
  53112. */
  53113. get halfDome(): boolean;
  53114. /**
  53115. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53116. */
  53117. set halfDome(enabled: boolean);
  53118. /**
  53119. * Oberserver used in Stereoscopic VR Mode.
  53120. */
  53121. private _onBeforeCameraRenderObserver;
  53122. /**
  53123. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53124. * @param name Element's name, child elements will append suffixes for their own names.
  53125. * @param urlsOrVideo defines the url(s) or the video element to use
  53126. * @param options An object containing optional or exposed sub element properties
  53127. */
  53128. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53129. resolution?: number;
  53130. clickToPlay?: boolean;
  53131. autoPlay?: boolean;
  53132. loop?: boolean;
  53133. size?: number;
  53134. poster?: string;
  53135. faceForward?: boolean;
  53136. useDirectMapping?: boolean;
  53137. halfDomeMode?: boolean;
  53138. }, scene: Scene);
  53139. private _changeVideoMode;
  53140. /**
  53141. * Releases resources associated with this node.
  53142. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53143. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53144. */
  53145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53146. }
  53147. }
  53148. declare module BABYLON {
  53149. /**
  53150. * This class can be used to get instrumentation data from a Babylon engine
  53151. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53152. */
  53153. export class EngineInstrumentation implements IDisposable {
  53154. /**
  53155. * Define the instrumented engine.
  53156. */
  53157. engine: Engine;
  53158. private _captureGPUFrameTime;
  53159. private _gpuFrameTimeToken;
  53160. private _gpuFrameTime;
  53161. private _captureShaderCompilationTime;
  53162. private _shaderCompilationTime;
  53163. private _onBeginFrameObserver;
  53164. private _onEndFrameObserver;
  53165. private _onBeforeShaderCompilationObserver;
  53166. private _onAfterShaderCompilationObserver;
  53167. /**
  53168. * Gets the perf counter used for GPU frame time
  53169. */
  53170. get gpuFrameTimeCounter(): PerfCounter;
  53171. /**
  53172. * Gets the GPU frame time capture status
  53173. */
  53174. get captureGPUFrameTime(): boolean;
  53175. /**
  53176. * Enable or disable the GPU frame time capture
  53177. */
  53178. set captureGPUFrameTime(value: boolean);
  53179. /**
  53180. * Gets the perf counter used for shader compilation time
  53181. */
  53182. get shaderCompilationTimeCounter(): PerfCounter;
  53183. /**
  53184. * Gets the shader compilation time capture status
  53185. */
  53186. get captureShaderCompilationTime(): boolean;
  53187. /**
  53188. * Enable or disable the shader compilation time capture
  53189. */
  53190. set captureShaderCompilationTime(value: boolean);
  53191. /**
  53192. * Instantiates a new engine instrumentation.
  53193. * This class can be used to get instrumentation data from a Babylon engine
  53194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53195. * @param engine Defines the engine to instrument
  53196. */
  53197. constructor(
  53198. /**
  53199. * Define the instrumented engine.
  53200. */
  53201. engine: Engine);
  53202. /**
  53203. * Dispose and release associated resources.
  53204. */
  53205. dispose(): void;
  53206. }
  53207. }
  53208. declare module BABYLON {
  53209. /**
  53210. * This class can be used to get instrumentation data from a Babylon engine
  53211. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53212. */
  53213. export class SceneInstrumentation implements IDisposable {
  53214. /**
  53215. * Defines the scene to instrument
  53216. */
  53217. scene: Scene;
  53218. private _captureActiveMeshesEvaluationTime;
  53219. private _activeMeshesEvaluationTime;
  53220. private _captureRenderTargetsRenderTime;
  53221. private _renderTargetsRenderTime;
  53222. private _captureFrameTime;
  53223. private _frameTime;
  53224. private _captureRenderTime;
  53225. private _renderTime;
  53226. private _captureInterFrameTime;
  53227. private _interFrameTime;
  53228. private _captureParticlesRenderTime;
  53229. private _particlesRenderTime;
  53230. private _captureSpritesRenderTime;
  53231. private _spritesRenderTime;
  53232. private _capturePhysicsTime;
  53233. private _physicsTime;
  53234. private _captureAnimationsTime;
  53235. private _animationsTime;
  53236. private _captureCameraRenderTime;
  53237. private _cameraRenderTime;
  53238. private _onBeforeActiveMeshesEvaluationObserver;
  53239. private _onAfterActiveMeshesEvaluationObserver;
  53240. private _onBeforeRenderTargetsRenderObserver;
  53241. private _onAfterRenderTargetsRenderObserver;
  53242. private _onAfterRenderObserver;
  53243. private _onBeforeDrawPhaseObserver;
  53244. private _onAfterDrawPhaseObserver;
  53245. private _onBeforeAnimationsObserver;
  53246. private _onBeforeParticlesRenderingObserver;
  53247. private _onAfterParticlesRenderingObserver;
  53248. private _onBeforeSpritesRenderingObserver;
  53249. private _onAfterSpritesRenderingObserver;
  53250. private _onBeforePhysicsObserver;
  53251. private _onAfterPhysicsObserver;
  53252. private _onAfterAnimationsObserver;
  53253. private _onBeforeCameraRenderObserver;
  53254. private _onAfterCameraRenderObserver;
  53255. /**
  53256. * Gets the perf counter used for active meshes evaluation time
  53257. */
  53258. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53259. /**
  53260. * Gets the active meshes evaluation time capture status
  53261. */
  53262. get captureActiveMeshesEvaluationTime(): boolean;
  53263. /**
  53264. * Enable or disable the active meshes evaluation time capture
  53265. */
  53266. set captureActiveMeshesEvaluationTime(value: boolean);
  53267. /**
  53268. * Gets the perf counter used for render targets render time
  53269. */
  53270. get renderTargetsRenderTimeCounter(): PerfCounter;
  53271. /**
  53272. * Gets the render targets render time capture status
  53273. */
  53274. get captureRenderTargetsRenderTime(): boolean;
  53275. /**
  53276. * Enable or disable the render targets render time capture
  53277. */
  53278. set captureRenderTargetsRenderTime(value: boolean);
  53279. /**
  53280. * Gets the perf counter used for particles render time
  53281. */
  53282. get particlesRenderTimeCounter(): PerfCounter;
  53283. /**
  53284. * Gets the particles render time capture status
  53285. */
  53286. get captureParticlesRenderTime(): boolean;
  53287. /**
  53288. * Enable or disable the particles render time capture
  53289. */
  53290. set captureParticlesRenderTime(value: boolean);
  53291. /**
  53292. * Gets the perf counter used for sprites render time
  53293. */
  53294. get spritesRenderTimeCounter(): PerfCounter;
  53295. /**
  53296. * Gets the sprites render time capture status
  53297. */
  53298. get captureSpritesRenderTime(): boolean;
  53299. /**
  53300. * Enable or disable the sprites render time capture
  53301. */
  53302. set captureSpritesRenderTime(value: boolean);
  53303. /**
  53304. * Gets the perf counter used for physics time
  53305. */
  53306. get physicsTimeCounter(): PerfCounter;
  53307. /**
  53308. * Gets the physics time capture status
  53309. */
  53310. get capturePhysicsTime(): boolean;
  53311. /**
  53312. * Enable or disable the physics time capture
  53313. */
  53314. set capturePhysicsTime(value: boolean);
  53315. /**
  53316. * Gets the perf counter used for animations time
  53317. */
  53318. get animationsTimeCounter(): PerfCounter;
  53319. /**
  53320. * Gets the animations time capture status
  53321. */
  53322. get captureAnimationsTime(): boolean;
  53323. /**
  53324. * Enable or disable the animations time capture
  53325. */
  53326. set captureAnimationsTime(value: boolean);
  53327. /**
  53328. * Gets the perf counter used for frame time capture
  53329. */
  53330. get frameTimeCounter(): PerfCounter;
  53331. /**
  53332. * Gets the frame time capture status
  53333. */
  53334. get captureFrameTime(): boolean;
  53335. /**
  53336. * Enable or disable the frame time capture
  53337. */
  53338. set captureFrameTime(value: boolean);
  53339. /**
  53340. * Gets the perf counter used for inter-frames time capture
  53341. */
  53342. get interFrameTimeCounter(): PerfCounter;
  53343. /**
  53344. * Gets the inter-frames time capture status
  53345. */
  53346. get captureInterFrameTime(): boolean;
  53347. /**
  53348. * Enable or disable the inter-frames time capture
  53349. */
  53350. set captureInterFrameTime(value: boolean);
  53351. /**
  53352. * Gets the perf counter used for render time capture
  53353. */
  53354. get renderTimeCounter(): PerfCounter;
  53355. /**
  53356. * Gets the render time capture status
  53357. */
  53358. get captureRenderTime(): boolean;
  53359. /**
  53360. * Enable or disable the render time capture
  53361. */
  53362. set captureRenderTime(value: boolean);
  53363. /**
  53364. * Gets the perf counter used for camera render time capture
  53365. */
  53366. get cameraRenderTimeCounter(): PerfCounter;
  53367. /**
  53368. * Gets the camera render time capture status
  53369. */
  53370. get captureCameraRenderTime(): boolean;
  53371. /**
  53372. * Enable or disable the camera render time capture
  53373. */
  53374. set captureCameraRenderTime(value: boolean);
  53375. /**
  53376. * Gets the perf counter used for draw calls
  53377. */
  53378. get drawCallsCounter(): PerfCounter;
  53379. /**
  53380. * Instantiates a new scene instrumentation.
  53381. * This class can be used to get instrumentation data from a Babylon engine
  53382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53383. * @param scene Defines the scene to instrument
  53384. */
  53385. constructor(
  53386. /**
  53387. * Defines the scene to instrument
  53388. */
  53389. scene: Scene);
  53390. /**
  53391. * Dispose and release associated resources.
  53392. */
  53393. dispose(): void;
  53394. }
  53395. }
  53396. declare module BABYLON {
  53397. /** @hidden */
  53398. export var glowMapGenerationPixelShader: {
  53399. name: string;
  53400. shader: string;
  53401. };
  53402. }
  53403. declare module BABYLON {
  53404. /** @hidden */
  53405. export var glowMapGenerationVertexShader: {
  53406. name: string;
  53407. shader: string;
  53408. };
  53409. }
  53410. declare module BABYLON {
  53411. /**
  53412. * Effect layer options. This helps customizing the behaviour
  53413. * of the effect layer.
  53414. */
  53415. export interface IEffectLayerOptions {
  53416. /**
  53417. * Multiplication factor apply to the canvas size to compute the render target size
  53418. * used to generated the objects (the smaller the faster).
  53419. */
  53420. mainTextureRatio: number;
  53421. /**
  53422. * Enforces a fixed size texture to ensure effect stability across devices.
  53423. */
  53424. mainTextureFixedSize?: number;
  53425. /**
  53426. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53427. */
  53428. alphaBlendingMode: number;
  53429. /**
  53430. * The camera attached to the layer.
  53431. */
  53432. camera: Nullable<Camera>;
  53433. /**
  53434. * The rendering group to draw the layer in.
  53435. */
  53436. renderingGroupId: number;
  53437. }
  53438. /**
  53439. * The effect layer Helps adding post process effect blended with the main pass.
  53440. *
  53441. * This can be for instance use to generate glow or higlight effects on the scene.
  53442. *
  53443. * The effect layer class can not be used directly and is intented to inherited from to be
  53444. * customized per effects.
  53445. */
  53446. export abstract class EffectLayer {
  53447. private _vertexBuffers;
  53448. private _indexBuffer;
  53449. private _cachedDefines;
  53450. private _effectLayerMapGenerationEffect;
  53451. private _effectLayerOptions;
  53452. private _mergeEffect;
  53453. protected _scene: Scene;
  53454. protected _engine: Engine;
  53455. protected _maxSize: number;
  53456. protected _mainTextureDesiredSize: ISize;
  53457. protected _mainTexture: RenderTargetTexture;
  53458. protected _shouldRender: boolean;
  53459. protected _postProcesses: PostProcess[];
  53460. protected _textures: BaseTexture[];
  53461. protected _emissiveTextureAndColor: {
  53462. texture: Nullable<BaseTexture>;
  53463. color: Color4;
  53464. };
  53465. /**
  53466. * The name of the layer
  53467. */
  53468. name: string;
  53469. /**
  53470. * The clear color of the texture used to generate the glow map.
  53471. */
  53472. neutralColor: Color4;
  53473. /**
  53474. * Specifies whether the highlight layer is enabled or not.
  53475. */
  53476. isEnabled: boolean;
  53477. /**
  53478. * Gets the camera attached to the layer.
  53479. */
  53480. get camera(): Nullable<Camera>;
  53481. /**
  53482. * Gets the rendering group id the layer should render in.
  53483. */
  53484. get renderingGroupId(): number;
  53485. set renderingGroupId(renderingGroupId: number);
  53486. /**
  53487. * An event triggered when the effect layer has been disposed.
  53488. */
  53489. onDisposeObservable: Observable<EffectLayer>;
  53490. /**
  53491. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53492. */
  53493. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53494. /**
  53495. * An event triggered when the generated texture is being merged in the scene.
  53496. */
  53497. onBeforeComposeObservable: Observable<EffectLayer>;
  53498. /**
  53499. * An event triggered when the mesh is rendered into the effect render target.
  53500. */
  53501. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53502. /**
  53503. * An event triggered after the mesh has been rendered into the effect render target.
  53504. */
  53505. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53506. /**
  53507. * An event triggered when the generated texture has been merged in the scene.
  53508. */
  53509. onAfterComposeObservable: Observable<EffectLayer>;
  53510. /**
  53511. * An event triggered when the efffect layer changes its size.
  53512. */
  53513. onSizeChangedObservable: Observable<EffectLayer>;
  53514. /** @hidden */
  53515. static _SceneComponentInitialization: (scene: Scene) => void;
  53516. /**
  53517. * Instantiates a new effect Layer and references it in the scene.
  53518. * @param name The name of the layer
  53519. * @param scene The scene to use the layer in
  53520. */
  53521. constructor(
  53522. /** The Friendly of the effect in the scene */
  53523. name: string, scene: Scene);
  53524. /**
  53525. * Get the effect name of the layer.
  53526. * @return The effect name
  53527. */
  53528. abstract getEffectName(): string;
  53529. /**
  53530. * Checks for the readiness of the element composing the layer.
  53531. * @param subMesh the mesh to check for
  53532. * @param useInstances specify whether or not to use instances to render the mesh
  53533. * @return true if ready otherwise, false
  53534. */
  53535. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53536. /**
  53537. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53538. * @returns true if the effect requires stencil during the main canvas render pass.
  53539. */
  53540. abstract needStencil(): boolean;
  53541. /**
  53542. * Create the merge effect. This is the shader use to blit the information back
  53543. * to the main canvas at the end of the scene rendering.
  53544. * @returns The effect containing the shader used to merge the effect on the main canvas
  53545. */
  53546. protected abstract _createMergeEffect(): Effect;
  53547. /**
  53548. * Creates the render target textures and post processes used in the effect layer.
  53549. */
  53550. protected abstract _createTextureAndPostProcesses(): void;
  53551. /**
  53552. * Implementation specific of rendering the generating effect on the main canvas.
  53553. * @param effect The effect used to render through
  53554. */
  53555. protected abstract _internalRender(effect: Effect): void;
  53556. /**
  53557. * Sets the required values for both the emissive texture and and the main color.
  53558. */
  53559. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53560. /**
  53561. * Free any resources and references associated to a mesh.
  53562. * Internal use
  53563. * @param mesh The mesh to free.
  53564. */
  53565. abstract _disposeMesh(mesh: Mesh): void;
  53566. /**
  53567. * Serializes this layer (Glow or Highlight for example)
  53568. * @returns a serialized layer object
  53569. */
  53570. abstract serialize?(): any;
  53571. /**
  53572. * Initializes the effect layer with the required options.
  53573. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53574. */
  53575. protected _init(options: Partial<IEffectLayerOptions>): void;
  53576. /**
  53577. * Generates the index buffer of the full screen quad blending to the main canvas.
  53578. */
  53579. private _generateIndexBuffer;
  53580. /**
  53581. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53582. */
  53583. private _generateVertexBuffer;
  53584. /**
  53585. * Sets the main texture desired size which is the closest power of two
  53586. * of the engine canvas size.
  53587. */
  53588. private _setMainTextureSize;
  53589. /**
  53590. * Creates the main texture for the effect layer.
  53591. */
  53592. protected _createMainTexture(): void;
  53593. /**
  53594. * Adds specific effects defines.
  53595. * @param defines The defines to add specifics to.
  53596. */
  53597. protected _addCustomEffectDefines(defines: string[]): void;
  53598. /**
  53599. * Checks for the readiness of the element composing the layer.
  53600. * @param subMesh the mesh to check for
  53601. * @param useInstances specify whether or not to use instances to render the mesh
  53602. * @param emissiveTexture the associated emissive texture used to generate the glow
  53603. * @return true if ready otherwise, false
  53604. */
  53605. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53606. /**
  53607. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53608. */
  53609. render(): void;
  53610. /**
  53611. * Determine if a given mesh will be used in the current effect.
  53612. * @param mesh mesh to test
  53613. * @returns true if the mesh will be used
  53614. */
  53615. hasMesh(mesh: AbstractMesh): boolean;
  53616. /**
  53617. * Returns true if the layer contains information to display, otherwise false.
  53618. * @returns true if the glow layer should be rendered
  53619. */
  53620. shouldRender(): boolean;
  53621. /**
  53622. * Returns true if the mesh should render, otherwise false.
  53623. * @param mesh The mesh to render
  53624. * @returns true if it should render otherwise false
  53625. */
  53626. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53627. /**
  53628. * Returns true if the mesh can be rendered, otherwise false.
  53629. * @param mesh The mesh to render
  53630. * @param material The material used on the mesh
  53631. * @returns true if it can be rendered otherwise false
  53632. */
  53633. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53634. /**
  53635. * Returns true if the mesh should render, otherwise false.
  53636. * @param mesh The mesh to render
  53637. * @returns true if it should render otherwise false
  53638. */
  53639. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53640. /**
  53641. * Renders the submesh passed in parameter to the generation map.
  53642. */
  53643. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53644. /**
  53645. * Defines whether the current material of the mesh should be use to render the effect.
  53646. * @param mesh defines the current mesh to render
  53647. */
  53648. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53649. /**
  53650. * Rebuild the required buffers.
  53651. * @hidden Internal use only.
  53652. */
  53653. _rebuild(): void;
  53654. /**
  53655. * Dispose only the render target textures and post process.
  53656. */
  53657. private _disposeTextureAndPostProcesses;
  53658. /**
  53659. * Dispose the highlight layer and free resources.
  53660. */
  53661. dispose(): void;
  53662. /**
  53663. * Gets the class name of the effect layer
  53664. * @returns the string with the class name of the effect layer
  53665. */
  53666. getClassName(): string;
  53667. /**
  53668. * Creates an effect layer from parsed effect layer data
  53669. * @param parsedEffectLayer defines effect layer data
  53670. * @param scene defines the current scene
  53671. * @param rootUrl defines the root URL containing the effect layer information
  53672. * @returns a parsed effect Layer
  53673. */
  53674. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53675. }
  53676. }
  53677. declare module BABYLON {
  53678. interface AbstractScene {
  53679. /**
  53680. * The list of effect layers (highlights/glow) added to the scene
  53681. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53682. * @see http://doc.babylonjs.com/how_to/glow_layer
  53683. */
  53684. effectLayers: Array<EffectLayer>;
  53685. /**
  53686. * Removes the given effect layer from this scene.
  53687. * @param toRemove defines the effect layer to remove
  53688. * @returns the index of the removed effect layer
  53689. */
  53690. removeEffectLayer(toRemove: EffectLayer): number;
  53691. /**
  53692. * Adds the given effect layer to this scene
  53693. * @param newEffectLayer defines the effect layer to add
  53694. */
  53695. addEffectLayer(newEffectLayer: EffectLayer): void;
  53696. }
  53697. /**
  53698. * Defines the layer scene component responsible to manage any effect layers
  53699. * in a given scene.
  53700. */
  53701. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  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. private _renderEffects;
  53712. private _needStencil;
  53713. private _previousStencilState;
  53714. /**
  53715. * Creates a new instance of the component for the given scene
  53716. * @param scene Defines the scene to register the component in
  53717. */
  53718. constructor(scene: Scene);
  53719. /**
  53720. * Registers the component in a given scene
  53721. */
  53722. register(): void;
  53723. /**
  53724. * Rebuilds the elements related to this component in case of
  53725. * context lost for instance.
  53726. */
  53727. rebuild(): void;
  53728. /**
  53729. * Serializes the component data to the specified json object
  53730. * @param serializationObject The object to serialize to
  53731. */
  53732. serialize(serializationObject: any): void;
  53733. /**
  53734. * Adds all the elements from the container to the scene
  53735. * @param container the container holding the elements
  53736. */
  53737. addFromContainer(container: AbstractScene): void;
  53738. /**
  53739. * Removes all the elements in the container from the scene
  53740. * @param container contains the elements to remove
  53741. * @param dispose if the removed element should be disposed (default: false)
  53742. */
  53743. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53744. /**
  53745. * Disposes the component and the associated ressources.
  53746. */
  53747. dispose(): void;
  53748. private _isReadyForMesh;
  53749. private _renderMainTexture;
  53750. private _setStencil;
  53751. private _setStencilBack;
  53752. private _draw;
  53753. private _drawCamera;
  53754. private _drawRenderingGroup;
  53755. }
  53756. }
  53757. declare module BABYLON {
  53758. /** @hidden */
  53759. export var glowMapMergePixelShader: {
  53760. name: string;
  53761. shader: string;
  53762. };
  53763. }
  53764. declare module BABYLON {
  53765. /** @hidden */
  53766. export var glowMapMergeVertexShader: {
  53767. name: string;
  53768. shader: string;
  53769. };
  53770. }
  53771. declare module BABYLON {
  53772. interface AbstractScene {
  53773. /**
  53774. * Return a the first highlight layer of the scene with a given name.
  53775. * @param name The name of the highlight layer to look for.
  53776. * @return The highlight layer if found otherwise null.
  53777. */
  53778. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53779. }
  53780. /**
  53781. * Glow layer options. This helps customizing the behaviour
  53782. * of the glow layer.
  53783. */
  53784. export interface IGlowLayerOptions {
  53785. /**
  53786. * Multiplication factor apply to the canvas size to compute the render target size
  53787. * used to generated the glowing objects (the smaller the faster).
  53788. */
  53789. mainTextureRatio: number;
  53790. /**
  53791. * Enforces a fixed size texture to ensure resize independant blur.
  53792. */
  53793. mainTextureFixedSize?: number;
  53794. /**
  53795. * How big is the kernel of the blur texture.
  53796. */
  53797. blurKernelSize: number;
  53798. /**
  53799. * The camera attached to the layer.
  53800. */
  53801. camera: Nullable<Camera>;
  53802. /**
  53803. * Enable MSAA by chosing the number of samples.
  53804. */
  53805. mainTextureSamples?: number;
  53806. /**
  53807. * The rendering group to draw the layer in.
  53808. */
  53809. renderingGroupId: number;
  53810. }
  53811. /**
  53812. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53813. *
  53814. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53815. *
  53816. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53817. */
  53818. export class GlowLayer extends EffectLayer {
  53819. /**
  53820. * Effect Name of the layer.
  53821. */
  53822. static readonly EffectName: string;
  53823. /**
  53824. * The default blur kernel size used for the glow.
  53825. */
  53826. static DefaultBlurKernelSize: number;
  53827. /**
  53828. * The default texture size ratio used for the glow.
  53829. */
  53830. static DefaultTextureRatio: number;
  53831. /**
  53832. * Sets the kernel size of the blur.
  53833. */
  53834. set blurKernelSize(value: number);
  53835. /**
  53836. * Gets the kernel size of the blur.
  53837. */
  53838. get blurKernelSize(): number;
  53839. /**
  53840. * Sets the glow intensity.
  53841. */
  53842. set intensity(value: number);
  53843. /**
  53844. * Gets the glow intensity.
  53845. */
  53846. get intensity(): number;
  53847. private _options;
  53848. private _intensity;
  53849. private _horizontalBlurPostprocess1;
  53850. private _verticalBlurPostprocess1;
  53851. private _horizontalBlurPostprocess2;
  53852. private _verticalBlurPostprocess2;
  53853. private _blurTexture1;
  53854. private _blurTexture2;
  53855. private _postProcesses1;
  53856. private _postProcesses2;
  53857. private _includedOnlyMeshes;
  53858. private _excludedMeshes;
  53859. private _meshesUsingTheirOwnMaterials;
  53860. /**
  53861. * Callback used to let the user override the color selection on a per mesh basis
  53862. */
  53863. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53864. /**
  53865. * Callback used to let the user override the texture selection on a per mesh basis
  53866. */
  53867. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53868. /**
  53869. * Instantiates a new glow Layer and references it to the scene.
  53870. * @param name The name of the layer
  53871. * @param scene The scene to use the layer in
  53872. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53873. */
  53874. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53875. /**
  53876. * Get the effect name of the layer.
  53877. * @return The effect name
  53878. */
  53879. getEffectName(): string;
  53880. /**
  53881. * Create the merge effect. This is the shader use to blit the information back
  53882. * to the main canvas at the end of the scene rendering.
  53883. */
  53884. protected _createMergeEffect(): Effect;
  53885. /**
  53886. * Creates the render target textures and post processes used in the glow layer.
  53887. */
  53888. protected _createTextureAndPostProcesses(): void;
  53889. /**
  53890. * Checks for the readiness of the element composing the layer.
  53891. * @param subMesh the mesh to check for
  53892. * @param useInstances specify wether or not to use instances to render the mesh
  53893. * @param emissiveTexture the associated emissive texture used to generate the glow
  53894. * @return true if ready otherwise, false
  53895. */
  53896. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53897. /**
  53898. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53899. */
  53900. needStencil(): boolean;
  53901. /**
  53902. * Returns true if the mesh can be rendered, otherwise false.
  53903. * @param mesh The mesh to render
  53904. * @param material The material used on the mesh
  53905. * @returns true if it can be rendered otherwise false
  53906. */
  53907. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53908. /**
  53909. * Implementation specific of rendering the generating effect on the main canvas.
  53910. * @param effect The effect used to render through
  53911. */
  53912. protected _internalRender(effect: Effect): void;
  53913. /**
  53914. * Sets the required values for both the emissive texture and and the main color.
  53915. */
  53916. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53917. /**
  53918. * Returns true if the mesh should render, otherwise false.
  53919. * @param mesh The mesh to render
  53920. * @returns true if it should render otherwise false
  53921. */
  53922. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53923. /**
  53924. * Adds specific effects defines.
  53925. * @param defines The defines to add specifics to.
  53926. */
  53927. protected _addCustomEffectDefines(defines: string[]): void;
  53928. /**
  53929. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53930. * @param mesh The mesh to exclude from the glow layer
  53931. */
  53932. addExcludedMesh(mesh: Mesh): void;
  53933. /**
  53934. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53935. * @param mesh The mesh to remove
  53936. */
  53937. removeExcludedMesh(mesh: Mesh): void;
  53938. /**
  53939. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53940. * @param mesh The mesh to include in the glow layer
  53941. */
  53942. addIncludedOnlyMesh(mesh: Mesh): void;
  53943. /**
  53944. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53945. * @param mesh The mesh to remove
  53946. */
  53947. removeIncludedOnlyMesh(mesh: Mesh): void;
  53948. /**
  53949. * Determine if a given mesh will be used in the glow layer
  53950. * @param mesh The mesh to test
  53951. * @returns true if the mesh will be highlighted by the current glow layer
  53952. */
  53953. hasMesh(mesh: AbstractMesh): boolean;
  53954. /**
  53955. * Defines whether the current material of the mesh should be use to render the effect.
  53956. * @param mesh defines the current mesh to render
  53957. */
  53958. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53959. /**
  53960. * Add a mesh to be rendered through its own material and not with emissive only.
  53961. * @param mesh The mesh for which we need to use its material
  53962. */
  53963. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53964. /**
  53965. * Remove a mesh from being rendered through its own material and not with emissive only.
  53966. * @param mesh The mesh for which we need to not use its material
  53967. */
  53968. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53969. /**
  53970. * Free any resources and references associated to a mesh.
  53971. * Internal use
  53972. * @param mesh The mesh to free.
  53973. * @hidden
  53974. */
  53975. _disposeMesh(mesh: Mesh): void;
  53976. /**
  53977. * Gets the class name of the effect layer
  53978. * @returns the string with the class name of the effect layer
  53979. */
  53980. getClassName(): string;
  53981. /**
  53982. * Serializes this glow layer
  53983. * @returns a serialized glow layer object
  53984. */
  53985. serialize(): any;
  53986. /**
  53987. * Creates a Glow Layer from parsed glow layer data
  53988. * @param parsedGlowLayer defines glow layer data
  53989. * @param scene defines the current scene
  53990. * @param rootUrl defines the root URL containing the glow layer information
  53991. * @returns a parsed Glow Layer
  53992. */
  53993. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53994. }
  53995. }
  53996. declare module BABYLON {
  53997. /** @hidden */
  53998. export var glowBlurPostProcessPixelShader: {
  53999. name: string;
  54000. shader: string;
  54001. };
  54002. }
  54003. declare module BABYLON {
  54004. interface AbstractScene {
  54005. /**
  54006. * Return a the first highlight layer of the scene with a given name.
  54007. * @param name The name of the highlight layer to look for.
  54008. * @return The highlight layer if found otherwise null.
  54009. */
  54010. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54011. }
  54012. /**
  54013. * Highlight layer options. This helps customizing the behaviour
  54014. * of the highlight layer.
  54015. */
  54016. export interface IHighlightLayerOptions {
  54017. /**
  54018. * Multiplication factor apply to the canvas size to compute the render target size
  54019. * used to generated the glowing objects (the smaller the faster).
  54020. */
  54021. mainTextureRatio: number;
  54022. /**
  54023. * Enforces a fixed size texture to ensure resize independant blur.
  54024. */
  54025. mainTextureFixedSize?: number;
  54026. /**
  54027. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54028. * of the picture to blur (the smaller the faster).
  54029. */
  54030. blurTextureSizeRatio: number;
  54031. /**
  54032. * How big in texel of the blur texture is the vertical blur.
  54033. */
  54034. blurVerticalSize: number;
  54035. /**
  54036. * How big in texel of the blur texture is the horizontal blur.
  54037. */
  54038. blurHorizontalSize: number;
  54039. /**
  54040. * Alpha blending mode used to apply the blur. Default is combine.
  54041. */
  54042. alphaBlendingMode: number;
  54043. /**
  54044. * The camera attached to the layer.
  54045. */
  54046. camera: Nullable<Camera>;
  54047. /**
  54048. * Should we display highlight as a solid stroke?
  54049. */
  54050. isStroke?: boolean;
  54051. /**
  54052. * The rendering group to draw the layer in.
  54053. */
  54054. renderingGroupId: number;
  54055. }
  54056. /**
  54057. * The highlight layer Helps adding a glow effect around a mesh.
  54058. *
  54059. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54060. * glowy meshes to your scene.
  54061. *
  54062. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54063. */
  54064. export class HighlightLayer extends EffectLayer {
  54065. name: string;
  54066. /**
  54067. * Effect Name of the highlight layer.
  54068. */
  54069. static readonly EffectName: string;
  54070. /**
  54071. * The neutral color used during the preparation of the glow effect.
  54072. * This is black by default as the blend operation is a blend operation.
  54073. */
  54074. static NeutralColor: Color4;
  54075. /**
  54076. * Stencil value used for glowing meshes.
  54077. */
  54078. static GlowingMeshStencilReference: number;
  54079. /**
  54080. * Stencil value used for the other meshes in the scene.
  54081. */
  54082. static NormalMeshStencilReference: number;
  54083. /**
  54084. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54085. */
  54086. innerGlow: boolean;
  54087. /**
  54088. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54089. */
  54090. outerGlow: boolean;
  54091. /**
  54092. * Specifies the horizontal size of the blur.
  54093. */
  54094. set blurHorizontalSize(value: number);
  54095. /**
  54096. * Specifies the vertical size of the blur.
  54097. */
  54098. set blurVerticalSize(value: number);
  54099. /**
  54100. * Gets the horizontal size of the blur.
  54101. */
  54102. get blurHorizontalSize(): number;
  54103. /**
  54104. * Gets the vertical size of the blur.
  54105. */
  54106. get blurVerticalSize(): number;
  54107. /**
  54108. * An event triggered when the highlight layer is being blurred.
  54109. */
  54110. onBeforeBlurObservable: Observable<HighlightLayer>;
  54111. /**
  54112. * An event triggered when the highlight layer has been blurred.
  54113. */
  54114. onAfterBlurObservable: Observable<HighlightLayer>;
  54115. private _instanceGlowingMeshStencilReference;
  54116. private _options;
  54117. private _downSamplePostprocess;
  54118. private _horizontalBlurPostprocess;
  54119. private _verticalBlurPostprocess;
  54120. private _blurTexture;
  54121. private _meshes;
  54122. private _excludedMeshes;
  54123. /**
  54124. * Instantiates a new highlight Layer and references it to the scene..
  54125. * @param name The name of the layer
  54126. * @param scene The scene to use the layer in
  54127. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54128. */
  54129. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54130. /**
  54131. * Get the effect name of the layer.
  54132. * @return The effect name
  54133. */
  54134. getEffectName(): string;
  54135. /**
  54136. * Create the merge effect. This is the shader use to blit the information back
  54137. * to the main canvas at the end of the scene rendering.
  54138. */
  54139. protected _createMergeEffect(): Effect;
  54140. /**
  54141. * Creates the render target textures and post processes used in the highlight layer.
  54142. */
  54143. protected _createTextureAndPostProcesses(): void;
  54144. /**
  54145. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54146. */
  54147. needStencil(): boolean;
  54148. /**
  54149. * Checks for the readiness of the element composing the layer.
  54150. * @param subMesh the mesh to check for
  54151. * @param useInstances specify wether or not to use instances to render the mesh
  54152. * @param emissiveTexture the associated emissive texture used to generate the glow
  54153. * @return true if ready otherwise, false
  54154. */
  54155. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54156. /**
  54157. * Implementation specific of rendering the generating effect on the main canvas.
  54158. * @param effect The effect used to render through
  54159. */
  54160. protected _internalRender(effect: Effect): void;
  54161. /**
  54162. * Returns true if the layer contains information to display, otherwise false.
  54163. */
  54164. shouldRender(): boolean;
  54165. /**
  54166. * Returns true if the mesh should render, otherwise false.
  54167. * @param mesh The mesh to render
  54168. * @returns true if it should render otherwise false
  54169. */
  54170. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54171. /**
  54172. * Adds specific effects defines.
  54173. * @param defines The defines to add specifics to.
  54174. */
  54175. protected _addCustomEffectDefines(defines: string[]): void;
  54176. /**
  54177. * Sets the required values for both the emissive texture and and the main color.
  54178. */
  54179. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54180. /**
  54181. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54182. * @param mesh The mesh to exclude from the highlight layer
  54183. */
  54184. addExcludedMesh(mesh: Mesh): void;
  54185. /**
  54186. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54187. * @param mesh The mesh to highlight
  54188. */
  54189. removeExcludedMesh(mesh: Mesh): void;
  54190. /**
  54191. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54192. * @param mesh mesh to test
  54193. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54194. */
  54195. hasMesh(mesh: AbstractMesh): boolean;
  54196. /**
  54197. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54198. * @param mesh The mesh to highlight
  54199. * @param color The color of the highlight
  54200. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54201. */
  54202. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54203. /**
  54204. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54205. * @param mesh The mesh to highlight
  54206. */
  54207. removeMesh(mesh: Mesh): void;
  54208. /**
  54209. * Remove all the meshes currently referenced in the highlight layer
  54210. */
  54211. removeAllMeshes(): void;
  54212. /**
  54213. * Force the stencil to the normal expected value for none glowing parts
  54214. */
  54215. private _defaultStencilReference;
  54216. /**
  54217. * Free any resources and references associated to a mesh.
  54218. * Internal use
  54219. * @param mesh The mesh to free.
  54220. * @hidden
  54221. */
  54222. _disposeMesh(mesh: Mesh): void;
  54223. /**
  54224. * Dispose the highlight layer and free resources.
  54225. */
  54226. dispose(): void;
  54227. /**
  54228. * Gets the class name of the effect layer
  54229. * @returns the string with the class name of the effect layer
  54230. */
  54231. getClassName(): string;
  54232. /**
  54233. * Serializes this Highlight layer
  54234. * @returns a serialized Highlight layer object
  54235. */
  54236. serialize(): any;
  54237. /**
  54238. * Creates a Highlight layer from parsed Highlight layer data
  54239. * @param parsedHightlightLayer defines the Highlight layer data
  54240. * @param scene defines the current scene
  54241. * @param rootUrl defines the root URL containing the Highlight layer information
  54242. * @returns a parsed Highlight layer
  54243. */
  54244. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54245. }
  54246. }
  54247. declare module BABYLON {
  54248. interface AbstractScene {
  54249. /**
  54250. * The list of layers (background and foreground) of the scene
  54251. */
  54252. layers: Array<Layer>;
  54253. }
  54254. /**
  54255. * Defines the layer scene component responsible to manage any layers
  54256. * in a given scene.
  54257. */
  54258. export class LayerSceneComponent implements ISceneComponent {
  54259. /**
  54260. * The component name helpfull to identify the component in the list of scene components.
  54261. */
  54262. readonly name: string;
  54263. /**
  54264. * The scene the component belongs to.
  54265. */
  54266. scene: Scene;
  54267. private _engine;
  54268. /**
  54269. * Creates a new instance of the component for the given scene
  54270. * @param scene Defines the scene to register the component in
  54271. */
  54272. constructor(scene: Scene);
  54273. /**
  54274. * Registers the component in a given scene
  54275. */
  54276. register(): void;
  54277. /**
  54278. * Rebuilds the elements related to this component in case of
  54279. * context lost for instance.
  54280. */
  54281. rebuild(): void;
  54282. /**
  54283. * Disposes the component and the associated ressources.
  54284. */
  54285. dispose(): void;
  54286. private _draw;
  54287. private _drawCameraPredicate;
  54288. private _drawCameraBackground;
  54289. private _drawCameraForeground;
  54290. private _drawRenderTargetPredicate;
  54291. private _drawRenderTargetBackground;
  54292. private _drawRenderTargetForeground;
  54293. /**
  54294. * Adds all the elements from the container to the scene
  54295. * @param container the container holding the elements
  54296. */
  54297. addFromContainer(container: AbstractScene): void;
  54298. /**
  54299. * Removes all the elements in the container from the scene
  54300. * @param container contains the elements to remove
  54301. * @param dispose if the removed element should be disposed (default: false)
  54302. */
  54303. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54304. }
  54305. }
  54306. declare module BABYLON {
  54307. /** @hidden */
  54308. export var layerPixelShader: {
  54309. name: string;
  54310. shader: string;
  54311. };
  54312. }
  54313. declare module BABYLON {
  54314. /** @hidden */
  54315. export var layerVertexShader: {
  54316. name: string;
  54317. shader: string;
  54318. };
  54319. }
  54320. declare module BABYLON {
  54321. /**
  54322. * This represents a full screen 2d layer.
  54323. * This can be useful to display a picture in the background of your scene for instance.
  54324. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54325. */
  54326. export class Layer {
  54327. /**
  54328. * Define the name of the layer.
  54329. */
  54330. name: string;
  54331. /**
  54332. * Define the texture the layer should display.
  54333. */
  54334. texture: Nullable<Texture>;
  54335. /**
  54336. * Is the layer in background or foreground.
  54337. */
  54338. isBackground: boolean;
  54339. /**
  54340. * Define the color of the layer (instead of texture).
  54341. */
  54342. color: Color4;
  54343. /**
  54344. * Define the scale of the layer in order to zoom in out of the texture.
  54345. */
  54346. scale: Vector2;
  54347. /**
  54348. * Define an offset for the layer in order to shift the texture.
  54349. */
  54350. offset: Vector2;
  54351. /**
  54352. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54353. */
  54354. alphaBlendingMode: number;
  54355. /**
  54356. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54357. * Alpha test will not mix with the background color in case of transparency.
  54358. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54359. */
  54360. alphaTest: boolean;
  54361. /**
  54362. * Define a mask to restrict the layer to only some of the scene cameras.
  54363. */
  54364. layerMask: number;
  54365. /**
  54366. * Define the list of render target the layer is visible into.
  54367. */
  54368. renderTargetTextures: RenderTargetTexture[];
  54369. /**
  54370. * Define if the layer is only used in renderTarget or if it also
  54371. * renders in the main frame buffer of the canvas.
  54372. */
  54373. renderOnlyInRenderTargetTextures: boolean;
  54374. private _scene;
  54375. private _vertexBuffers;
  54376. private _indexBuffer;
  54377. private _effect;
  54378. private _previousDefines;
  54379. /**
  54380. * An event triggered when the layer is disposed.
  54381. */
  54382. onDisposeObservable: Observable<Layer>;
  54383. private _onDisposeObserver;
  54384. /**
  54385. * Back compatibility with callback before the onDisposeObservable existed.
  54386. * The set callback will be triggered when the layer has been disposed.
  54387. */
  54388. set onDispose(callback: () => void);
  54389. /**
  54390. * An event triggered before rendering the scene
  54391. */
  54392. onBeforeRenderObservable: Observable<Layer>;
  54393. private _onBeforeRenderObserver;
  54394. /**
  54395. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54396. * The set callback will be triggered just before rendering the layer.
  54397. */
  54398. set onBeforeRender(callback: () => void);
  54399. /**
  54400. * An event triggered after rendering the scene
  54401. */
  54402. onAfterRenderObservable: Observable<Layer>;
  54403. private _onAfterRenderObserver;
  54404. /**
  54405. * Back compatibility with callback before the onAfterRenderObservable existed.
  54406. * The set callback will be triggered just after rendering the layer.
  54407. */
  54408. set onAfterRender(callback: () => void);
  54409. /**
  54410. * Instantiates a new layer.
  54411. * This represents a full screen 2d layer.
  54412. * This can be useful to display a picture in the background of your scene for instance.
  54413. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54414. * @param name Define the name of the layer in the scene
  54415. * @param imgUrl Define the url of the texture to display in the layer
  54416. * @param scene Define the scene the layer belongs to
  54417. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54418. * @param color Defines a color for the layer
  54419. */
  54420. constructor(
  54421. /**
  54422. * Define the name of the layer.
  54423. */
  54424. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54425. private _createIndexBuffer;
  54426. /** @hidden */
  54427. _rebuild(): void;
  54428. /**
  54429. * Renders the layer in the scene.
  54430. */
  54431. render(): void;
  54432. /**
  54433. * Disposes and releases the associated ressources.
  54434. */
  54435. dispose(): void;
  54436. }
  54437. }
  54438. declare module BABYLON {
  54439. /** @hidden */
  54440. export var lensFlarePixelShader: {
  54441. name: string;
  54442. shader: string;
  54443. };
  54444. }
  54445. declare module BABYLON {
  54446. /** @hidden */
  54447. export var lensFlareVertexShader: {
  54448. name: string;
  54449. shader: string;
  54450. };
  54451. }
  54452. declare module BABYLON {
  54453. /**
  54454. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54455. * It is usually composed of several `lensFlare`.
  54456. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54457. */
  54458. export class LensFlareSystem {
  54459. /**
  54460. * Define the name of the lens flare system
  54461. */
  54462. name: string;
  54463. /**
  54464. * List of lens flares used in this system.
  54465. */
  54466. lensFlares: LensFlare[];
  54467. /**
  54468. * Define a limit from the border the lens flare can be visible.
  54469. */
  54470. borderLimit: number;
  54471. /**
  54472. * Define a viewport border we do not want to see the lens flare in.
  54473. */
  54474. viewportBorder: number;
  54475. /**
  54476. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54477. */
  54478. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54479. /**
  54480. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54481. */
  54482. layerMask: number;
  54483. /**
  54484. * Define the id of the lens flare system in the scene.
  54485. * (equal to name by default)
  54486. */
  54487. id: string;
  54488. private _scene;
  54489. private _emitter;
  54490. private _vertexBuffers;
  54491. private _indexBuffer;
  54492. private _effect;
  54493. private _positionX;
  54494. private _positionY;
  54495. private _isEnabled;
  54496. /** @hidden */
  54497. static _SceneComponentInitialization: (scene: Scene) => void;
  54498. /**
  54499. * Instantiates a lens flare system.
  54500. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54501. * It is usually composed of several `lensFlare`.
  54502. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54503. * @param name Define the name of the lens flare system in the scene
  54504. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54505. * @param scene Define the scene the lens flare system belongs to
  54506. */
  54507. constructor(
  54508. /**
  54509. * Define the name of the lens flare system
  54510. */
  54511. name: string, emitter: any, scene: Scene);
  54512. /**
  54513. * Define if the lens flare system is enabled.
  54514. */
  54515. get isEnabled(): boolean;
  54516. set isEnabled(value: boolean);
  54517. /**
  54518. * Get the scene the effects belongs to.
  54519. * @returns the scene holding the lens flare system
  54520. */
  54521. getScene(): Scene;
  54522. /**
  54523. * Get the emitter of the lens flare system.
  54524. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54525. * @returns the emitter of the lens flare system
  54526. */
  54527. getEmitter(): any;
  54528. /**
  54529. * Set the emitter of the lens flare system.
  54530. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54531. * @param newEmitter Define the new emitter of the system
  54532. */
  54533. setEmitter(newEmitter: any): void;
  54534. /**
  54535. * Get the lens flare system emitter position.
  54536. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54537. * @returns the position
  54538. */
  54539. getEmitterPosition(): Vector3;
  54540. /**
  54541. * @hidden
  54542. */
  54543. computeEffectivePosition(globalViewport: Viewport): boolean;
  54544. /** @hidden */
  54545. _isVisible(): boolean;
  54546. /**
  54547. * @hidden
  54548. */
  54549. render(): boolean;
  54550. /**
  54551. * Dispose and release the lens flare with its associated resources.
  54552. */
  54553. dispose(): void;
  54554. /**
  54555. * Parse a lens flare system from a JSON repressentation
  54556. * @param parsedLensFlareSystem Define the JSON to parse
  54557. * @param scene Define the scene the parsed system should be instantiated in
  54558. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54559. * @returns the parsed system
  54560. */
  54561. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54562. /**
  54563. * Serialize the current Lens Flare System into a JSON representation.
  54564. * @returns the serialized JSON
  54565. */
  54566. serialize(): any;
  54567. }
  54568. }
  54569. declare module BABYLON {
  54570. /**
  54571. * This represents one of the lens effect in a `lensFlareSystem`.
  54572. * It controls one of the indiviual texture used in the effect.
  54573. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54574. */
  54575. export class LensFlare {
  54576. /**
  54577. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54578. */
  54579. size: number;
  54580. /**
  54581. * 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.
  54582. */
  54583. position: number;
  54584. /**
  54585. * Define the lens color.
  54586. */
  54587. color: Color3;
  54588. /**
  54589. * Define the lens texture.
  54590. */
  54591. texture: Nullable<Texture>;
  54592. /**
  54593. * Define the alpha mode to render this particular lens.
  54594. */
  54595. alphaMode: number;
  54596. private _system;
  54597. /**
  54598. * Creates a new Lens Flare.
  54599. * This represents one of the lens effect in a `lensFlareSystem`.
  54600. * It controls one of the indiviual texture used in the effect.
  54601. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54602. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54603. * @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.
  54604. * @param color Define the lens color
  54605. * @param imgUrl Define the lens texture url
  54606. * @param system Define the `lensFlareSystem` this flare is part of
  54607. * @returns The newly created Lens Flare
  54608. */
  54609. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54610. /**
  54611. * Instantiates a new Lens Flare.
  54612. * This represents one of the lens effect in a `lensFlareSystem`.
  54613. * It controls one of the indiviual texture used in the effect.
  54614. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54615. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54616. * @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.
  54617. * @param color Define the lens color
  54618. * @param imgUrl Define the lens texture url
  54619. * @param system Define the `lensFlareSystem` this flare is part of
  54620. */
  54621. constructor(
  54622. /**
  54623. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54624. */
  54625. size: number,
  54626. /**
  54627. * 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.
  54628. */
  54629. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54630. /**
  54631. * Dispose and release the lens flare with its associated resources.
  54632. */
  54633. dispose(): void;
  54634. }
  54635. }
  54636. declare module BABYLON {
  54637. interface AbstractScene {
  54638. /**
  54639. * The list of lens flare system added to the scene
  54640. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54641. */
  54642. lensFlareSystems: Array<LensFlareSystem>;
  54643. /**
  54644. * Removes the given lens flare system from this scene.
  54645. * @param toRemove The lens flare system to remove
  54646. * @returns The index of the removed lens flare system
  54647. */
  54648. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54649. /**
  54650. * Adds the given lens flare system to this scene
  54651. * @param newLensFlareSystem The lens flare system to add
  54652. */
  54653. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54654. /**
  54655. * Gets a lens flare system using its name
  54656. * @param name defines the name to look for
  54657. * @returns the lens flare system or null if not found
  54658. */
  54659. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54660. /**
  54661. * Gets a lens flare system using its id
  54662. * @param id defines the id to look for
  54663. * @returns the lens flare system or null if not found
  54664. */
  54665. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54666. }
  54667. /**
  54668. * Defines the lens flare scene component responsible to manage any lens flares
  54669. * in a given scene.
  54670. */
  54671. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54672. /**
  54673. * The component name helpfull to identify the component in the list of scene components.
  54674. */
  54675. readonly name: string;
  54676. /**
  54677. * The scene the component belongs to.
  54678. */
  54679. scene: Scene;
  54680. /**
  54681. * Creates a new instance of the component for the given scene
  54682. * @param scene Defines the scene to register the component in
  54683. */
  54684. constructor(scene: Scene);
  54685. /**
  54686. * Registers the component in a given scene
  54687. */
  54688. register(): void;
  54689. /**
  54690. * Rebuilds the elements related to this component in case of
  54691. * context lost for instance.
  54692. */
  54693. rebuild(): void;
  54694. /**
  54695. * Adds all the elements from the container to the scene
  54696. * @param container the container holding the elements
  54697. */
  54698. addFromContainer(container: AbstractScene): void;
  54699. /**
  54700. * Removes all the elements in the container from the scene
  54701. * @param container contains the elements to remove
  54702. * @param dispose if the removed element should be disposed (default: false)
  54703. */
  54704. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54705. /**
  54706. * Serializes the component data to the specified json object
  54707. * @param serializationObject The object to serialize to
  54708. */
  54709. serialize(serializationObject: any): void;
  54710. /**
  54711. * Disposes the component and the associated ressources.
  54712. */
  54713. dispose(): void;
  54714. private _draw;
  54715. }
  54716. }
  54717. declare module BABYLON {
  54718. /** @hidden */
  54719. export var depthPixelShader: {
  54720. name: string;
  54721. shader: string;
  54722. };
  54723. }
  54724. declare module BABYLON {
  54725. /** @hidden */
  54726. export var depthVertexShader: {
  54727. name: string;
  54728. shader: string;
  54729. };
  54730. }
  54731. declare module BABYLON {
  54732. /**
  54733. * This represents a depth renderer in Babylon.
  54734. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54735. */
  54736. export class DepthRenderer {
  54737. private _scene;
  54738. private _depthMap;
  54739. private _effect;
  54740. private readonly _storeNonLinearDepth;
  54741. private readonly _clearColor;
  54742. /** Get if the depth renderer is using packed depth or not */
  54743. readonly isPacked: boolean;
  54744. private _cachedDefines;
  54745. private _camera;
  54746. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54747. enabled: boolean;
  54748. /**
  54749. * Specifiess that the depth renderer will only be used within
  54750. * the camera it is created for.
  54751. * This can help forcing its rendering during the camera processing.
  54752. */
  54753. useOnlyInActiveCamera: boolean;
  54754. /** @hidden */
  54755. static _SceneComponentInitialization: (scene: Scene) => void;
  54756. /**
  54757. * Instantiates a depth renderer
  54758. * @param scene The scene the renderer belongs to
  54759. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54760. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54761. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54762. */
  54763. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54764. /**
  54765. * Creates the depth rendering effect and checks if the effect is ready.
  54766. * @param subMesh The submesh to be used to render the depth map of
  54767. * @param useInstances If multiple world instances should be used
  54768. * @returns if the depth renderer is ready to render the depth map
  54769. */
  54770. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54771. /**
  54772. * Gets the texture which the depth map will be written to.
  54773. * @returns The depth map texture
  54774. */
  54775. getDepthMap(): RenderTargetTexture;
  54776. /**
  54777. * Disposes of the depth renderer.
  54778. */
  54779. dispose(): void;
  54780. }
  54781. }
  54782. declare module BABYLON {
  54783. /** @hidden */
  54784. export var minmaxReduxPixelShader: {
  54785. name: string;
  54786. shader: string;
  54787. };
  54788. }
  54789. declare module BABYLON {
  54790. /**
  54791. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54792. * and maximum values from all values of the texture.
  54793. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54794. * The source values are read from the red channel of the texture.
  54795. */
  54796. export class MinMaxReducer {
  54797. /**
  54798. * Observable triggered when the computation has been performed
  54799. */
  54800. onAfterReductionPerformed: Observable<{
  54801. min: number;
  54802. max: number;
  54803. }>;
  54804. protected _camera: Camera;
  54805. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54806. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54807. protected _postProcessManager: PostProcessManager;
  54808. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54809. protected _forceFullscreenViewport: boolean;
  54810. /**
  54811. * Creates a min/max reducer
  54812. * @param camera The camera to use for the post processes
  54813. */
  54814. constructor(camera: Camera);
  54815. /**
  54816. * Gets the texture used to read the values from.
  54817. */
  54818. get sourceTexture(): Nullable<RenderTargetTexture>;
  54819. /**
  54820. * Sets the source texture to read the values from.
  54821. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54822. * because in such textures '1' value must not be taken into account to compute the maximum
  54823. * as this value is used to clear the texture.
  54824. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54825. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54826. * @param depthRedux Indicates if the texture is a depth texture or not
  54827. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54828. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54829. */
  54830. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54831. /**
  54832. * Defines the refresh rate of the computation.
  54833. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54834. */
  54835. get refreshRate(): number;
  54836. set refreshRate(value: number);
  54837. protected _activated: boolean;
  54838. /**
  54839. * Gets the activation status of the reducer
  54840. */
  54841. get activated(): boolean;
  54842. /**
  54843. * Activates the reduction computation.
  54844. * When activated, the observers registered in onAfterReductionPerformed are
  54845. * called after the compuation is performed
  54846. */
  54847. activate(): void;
  54848. /**
  54849. * Deactivates the reduction computation.
  54850. */
  54851. deactivate(): void;
  54852. /**
  54853. * Disposes the min/max reducer
  54854. * @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.
  54855. */
  54856. dispose(disposeAll?: boolean): void;
  54857. }
  54858. }
  54859. declare module BABYLON {
  54860. /**
  54861. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54862. */
  54863. export class DepthReducer extends MinMaxReducer {
  54864. private _depthRenderer;
  54865. private _depthRendererId;
  54866. /**
  54867. * Gets the depth renderer used for the computation.
  54868. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54869. */
  54870. get depthRenderer(): Nullable<DepthRenderer>;
  54871. /**
  54872. * Creates a depth reducer
  54873. * @param camera The camera used to render the depth texture
  54874. */
  54875. constructor(camera: Camera);
  54876. /**
  54877. * Sets the depth renderer to use to generate the depth map
  54878. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54879. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54880. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54881. */
  54882. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54883. /** @hidden */
  54884. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54885. /**
  54886. * Activates the reduction computation.
  54887. * When activated, the observers registered in onAfterReductionPerformed are
  54888. * called after the compuation is performed
  54889. */
  54890. activate(): void;
  54891. /**
  54892. * Deactivates the reduction computation.
  54893. */
  54894. deactivate(): void;
  54895. /**
  54896. * Disposes the depth reducer
  54897. * @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.
  54898. */
  54899. dispose(disposeAll?: boolean): void;
  54900. }
  54901. }
  54902. declare module BABYLON {
  54903. /**
  54904. * A CSM implementation allowing casting shadows on large scenes.
  54905. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54906. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54907. */
  54908. export class CascadedShadowGenerator extends ShadowGenerator {
  54909. private static readonly frustumCornersNDCSpace;
  54910. /**
  54911. * Name of the CSM class
  54912. */
  54913. static CLASSNAME: string;
  54914. /**
  54915. * Defines the default number of cascades used by the CSM.
  54916. */
  54917. static readonly DEFAULT_CASCADES_COUNT: number;
  54918. /**
  54919. * Defines the minimum number of cascades used by the CSM.
  54920. */
  54921. static readonly MIN_CASCADES_COUNT: number;
  54922. /**
  54923. * Defines the maximum number of cascades used by the CSM.
  54924. */
  54925. static readonly MAX_CASCADES_COUNT: number;
  54926. protected _validateFilter(filter: number): number;
  54927. /**
  54928. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54929. */
  54930. penumbraDarkness: number;
  54931. private _numCascades;
  54932. /**
  54933. * Gets or set the number of cascades used by the CSM.
  54934. */
  54935. get numCascades(): number;
  54936. set numCascades(value: number);
  54937. /**
  54938. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54939. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54940. */
  54941. stabilizeCascades: boolean;
  54942. private _freezeShadowCastersBoundingInfo;
  54943. private _freezeShadowCastersBoundingInfoObservable;
  54944. /**
  54945. * Enables or disables the shadow casters bounding info computation.
  54946. * If your shadow casters don't move, you can disable this feature.
  54947. * If it is enabled, the bounding box computation is done every frame.
  54948. */
  54949. get freezeShadowCastersBoundingInfo(): boolean;
  54950. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54951. private _scbiMin;
  54952. private _scbiMax;
  54953. protected _computeShadowCastersBoundingInfo(): void;
  54954. protected _shadowCastersBoundingInfo: BoundingInfo;
  54955. /**
  54956. * Gets or sets the shadow casters bounding info.
  54957. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54958. * so that the system won't overwrite the bounds you provide
  54959. */
  54960. get shadowCastersBoundingInfo(): BoundingInfo;
  54961. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54962. protected _breaksAreDirty: boolean;
  54963. protected _minDistance: number;
  54964. protected _maxDistance: number;
  54965. /**
  54966. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54967. *
  54968. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54969. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54970. * @param min minimal distance for the breaks (default to 0.)
  54971. * @param max maximal distance for the breaks (default to 1.)
  54972. */
  54973. setMinMaxDistance(min: number, max: number): void;
  54974. /** Gets the minimal distance used in the cascade break computation */
  54975. get minDistance(): number;
  54976. /** Gets the maximal distance used in the cascade break computation */
  54977. get maxDistance(): number;
  54978. /**
  54979. * Gets the class name of that object
  54980. * @returns "CascadedShadowGenerator"
  54981. */
  54982. getClassName(): string;
  54983. private _cascadeMinExtents;
  54984. private _cascadeMaxExtents;
  54985. /**
  54986. * Gets a cascade minimum extents
  54987. * @param cascadeIndex index of the cascade
  54988. * @returns the minimum cascade extents
  54989. */
  54990. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54991. /**
  54992. * Gets a cascade maximum extents
  54993. * @param cascadeIndex index of the cascade
  54994. * @returns the maximum cascade extents
  54995. */
  54996. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54997. private _cascades;
  54998. private _currentLayer;
  54999. private _viewSpaceFrustumsZ;
  55000. private _viewMatrices;
  55001. private _projectionMatrices;
  55002. private _transformMatrices;
  55003. private _transformMatricesAsArray;
  55004. private _frustumLengths;
  55005. private _lightSizeUVCorrection;
  55006. private _depthCorrection;
  55007. private _frustumCornersWorldSpace;
  55008. private _frustumCenter;
  55009. private _shadowCameraPos;
  55010. private _shadowMaxZ;
  55011. /**
  55012. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55013. * It defaults to camera.maxZ
  55014. */
  55015. get shadowMaxZ(): number;
  55016. /**
  55017. * Sets the shadow max z distance.
  55018. */
  55019. set shadowMaxZ(value: number);
  55020. protected _debug: boolean;
  55021. /**
  55022. * Gets or sets the debug flag.
  55023. * When enabled, the cascades are materialized by different colors on the screen.
  55024. */
  55025. get debug(): boolean;
  55026. set debug(dbg: boolean);
  55027. private _depthClamp;
  55028. /**
  55029. * Gets or sets the depth clamping value.
  55030. *
  55031. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55032. * to account for the shadow casters far away.
  55033. *
  55034. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55035. */
  55036. get depthClamp(): boolean;
  55037. set depthClamp(value: boolean);
  55038. private _cascadeBlendPercentage;
  55039. /**
  55040. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55041. * It defaults to 0.1 (10% blending).
  55042. */
  55043. get cascadeBlendPercentage(): number;
  55044. set cascadeBlendPercentage(value: number);
  55045. private _lambda;
  55046. /**
  55047. * Gets or set the lambda parameter.
  55048. * This parameter is used to split the camera frustum and create the cascades.
  55049. * 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.
  55050. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55051. */
  55052. get lambda(): number;
  55053. set lambda(value: number);
  55054. /**
  55055. * Gets the view matrix corresponding to a given cascade
  55056. * @param cascadeNum cascade to retrieve the view matrix from
  55057. * @returns the cascade view matrix
  55058. */
  55059. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55060. /**
  55061. * Gets the projection matrix corresponding to a given cascade
  55062. * @param cascadeNum cascade to retrieve the projection matrix from
  55063. * @returns the cascade projection matrix
  55064. */
  55065. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55066. /**
  55067. * Gets the transformation matrix corresponding to a given cascade
  55068. * @param cascadeNum cascade to retrieve the transformation matrix from
  55069. * @returns the cascade transformation matrix
  55070. */
  55071. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55072. private _depthRenderer;
  55073. /**
  55074. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55075. *
  55076. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55077. *
  55078. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55079. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55080. * @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
  55081. */
  55082. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55083. private _depthReducer;
  55084. private _autoCalcDepthBounds;
  55085. /**
  55086. * Gets or sets the autoCalcDepthBounds property.
  55087. *
  55088. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55089. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55090. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55091. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55092. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55093. */
  55094. get autoCalcDepthBounds(): boolean;
  55095. set autoCalcDepthBounds(value: boolean);
  55096. /**
  55097. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55098. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55099. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55100. * for setting the refresh rate on the renderer yourself!
  55101. */
  55102. get autoCalcDepthBoundsRefreshRate(): number;
  55103. set autoCalcDepthBoundsRefreshRate(value: number);
  55104. /**
  55105. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55106. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55107. * you change the camera near/far planes!
  55108. */
  55109. splitFrustum(): void;
  55110. private _splitFrustum;
  55111. private _computeMatrices;
  55112. private _computeFrustumInWorldSpace;
  55113. private _computeCascadeFrustum;
  55114. /**
  55115. * Support test.
  55116. */
  55117. static get IsSupported(): boolean;
  55118. /** @hidden */
  55119. static _SceneComponentInitialization: (scene: Scene) => void;
  55120. /**
  55121. * Creates a Cascaded Shadow Generator object.
  55122. * A ShadowGenerator is the required tool to use the shadows.
  55123. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55124. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55125. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55126. * @param light The directional light object generating the shadows.
  55127. * @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.
  55128. */
  55129. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55130. protected _initializeGenerator(): void;
  55131. protected _createTargetRenderTexture(): void;
  55132. protected _initializeShadowMap(): void;
  55133. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55134. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55135. /**
  55136. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55137. * @param defines Defines of the material we want to update
  55138. * @param lightIndex Index of the light in the enabled light list of the material
  55139. */
  55140. prepareDefines(defines: any, lightIndex: number): void;
  55141. /**
  55142. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55143. * defined in the generator but impacting the effect).
  55144. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55145. * @param effect The effect we are binfing the information for
  55146. */
  55147. bindShadowLight(lightIndex: string, effect: Effect): void;
  55148. /**
  55149. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55150. * (eq to view projection * shadow projection matrices)
  55151. * @returns The transform matrix used to create the shadow map
  55152. */
  55153. getTransformMatrix(): Matrix;
  55154. /**
  55155. * Disposes the ShadowGenerator.
  55156. * Returns nothing.
  55157. */
  55158. dispose(): void;
  55159. /**
  55160. * Serializes the shadow generator setup to a json object.
  55161. * @returns The serialized JSON object
  55162. */
  55163. serialize(): any;
  55164. /**
  55165. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55166. * @param parsedShadowGenerator The JSON object to parse
  55167. * @param scene The scene to create the shadow map for
  55168. * @returns The parsed shadow generator
  55169. */
  55170. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55171. }
  55172. }
  55173. declare module BABYLON {
  55174. /**
  55175. * Defines the shadow generator component responsible to manage any shadow generators
  55176. * in a given scene.
  55177. */
  55178. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55179. /**
  55180. * The component name helpfull to identify the component in the list of scene components.
  55181. */
  55182. readonly name: string;
  55183. /**
  55184. * The scene the component belongs to.
  55185. */
  55186. scene: Scene;
  55187. /**
  55188. * Creates a new instance of the component for the given scene
  55189. * @param scene Defines the scene to register the component in
  55190. */
  55191. constructor(scene: Scene);
  55192. /**
  55193. * Registers the component in a given scene
  55194. */
  55195. register(): void;
  55196. /**
  55197. * Rebuilds the elements related to this component in case of
  55198. * context lost for instance.
  55199. */
  55200. rebuild(): void;
  55201. /**
  55202. * Serializes the component data to the specified json object
  55203. * @param serializationObject The object to serialize to
  55204. */
  55205. serialize(serializationObject: any): void;
  55206. /**
  55207. * Adds all the elements from the container to the scene
  55208. * @param container the container holding the elements
  55209. */
  55210. addFromContainer(container: AbstractScene): void;
  55211. /**
  55212. * Removes all the elements in the container from the scene
  55213. * @param container contains the elements to remove
  55214. * @param dispose if the removed element should be disposed (default: false)
  55215. */
  55216. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55217. /**
  55218. * Rebuilds the elements related to this component in case of
  55219. * context lost for instance.
  55220. */
  55221. dispose(): void;
  55222. private _gatherRenderTargets;
  55223. }
  55224. }
  55225. declare module BABYLON {
  55226. /**
  55227. * A point light is a light defined by an unique point in world space.
  55228. * The light is emitted in every direction from this point.
  55229. * A good example of a point light is a standard light bulb.
  55230. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55231. */
  55232. export class PointLight extends ShadowLight {
  55233. private _shadowAngle;
  55234. /**
  55235. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55236. * This specifies what angle the shadow will use to be created.
  55237. *
  55238. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55239. */
  55240. get shadowAngle(): number;
  55241. /**
  55242. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55243. * This specifies what angle the shadow will use to be created.
  55244. *
  55245. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55246. */
  55247. set shadowAngle(value: number);
  55248. /**
  55249. * Gets the direction if it has been set.
  55250. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55251. */
  55252. get direction(): Vector3;
  55253. /**
  55254. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55255. */
  55256. set direction(value: Vector3);
  55257. /**
  55258. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55259. * A PointLight emits the light in every direction.
  55260. * It can cast shadows.
  55261. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55262. * ```javascript
  55263. * var pointLight = new PointLight("pl", camera.position, scene);
  55264. * ```
  55265. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55266. * @param name The light friendly name
  55267. * @param position The position of the point light in the scene
  55268. * @param scene The scene the lights belongs to
  55269. */
  55270. constructor(name: string, position: Vector3, scene: Scene);
  55271. /**
  55272. * Returns the string "PointLight"
  55273. * @returns the class name
  55274. */
  55275. getClassName(): string;
  55276. /**
  55277. * Returns the integer 0.
  55278. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55279. */
  55280. getTypeID(): number;
  55281. /**
  55282. * Specifies wether or not the shadowmap should be a cube texture.
  55283. * @returns true if the shadowmap needs to be a cube texture.
  55284. */
  55285. needCube(): boolean;
  55286. /**
  55287. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55288. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55289. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55290. */
  55291. getShadowDirection(faceIndex?: number): Vector3;
  55292. /**
  55293. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55294. * - fov = PI / 2
  55295. * - aspect ratio : 1.0
  55296. * - z-near and far equal to the active camera minZ and maxZ.
  55297. * Returns the PointLight.
  55298. */
  55299. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55300. protected _buildUniformLayout(): void;
  55301. /**
  55302. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55303. * @param effect The effect to update
  55304. * @param lightIndex The index of the light in the effect to update
  55305. * @returns The point light
  55306. */
  55307. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55308. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55309. /**
  55310. * Prepares the list of defines specific to the light type.
  55311. * @param defines the list of defines
  55312. * @param lightIndex defines the index of the light for the effect
  55313. */
  55314. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55315. }
  55316. }
  55317. declare module BABYLON {
  55318. /**
  55319. * Header information of HDR texture files.
  55320. */
  55321. export interface HDRInfo {
  55322. /**
  55323. * The height of the texture in pixels.
  55324. */
  55325. height: number;
  55326. /**
  55327. * The width of the texture in pixels.
  55328. */
  55329. width: number;
  55330. /**
  55331. * The index of the beginning of the data in the binary file.
  55332. */
  55333. dataPosition: number;
  55334. }
  55335. /**
  55336. * This groups tools to convert HDR texture to native colors array.
  55337. */
  55338. export class HDRTools {
  55339. private static Ldexp;
  55340. private static Rgbe2float;
  55341. private static readStringLine;
  55342. /**
  55343. * Reads header information from an RGBE texture stored in a native array.
  55344. * More information on this format are available here:
  55345. * https://en.wikipedia.org/wiki/RGBE_image_format
  55346. *
  55347. * @param uint8array The binary file stored in native array.
  55348. * @return The header information.
  55349. */
  55350. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55351. /**
  55352. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55353. * This RGBE texture needs to store the information as a panorama.
  55354. *
  55355. * More information on this format are available here:
  55356. * https://en.wikipedia.org/wiki/RGBE_image_format
  55357. *
  55358. * @param buffer The binary file stored in an array buffer.
  55359. * @param size The expected size of the extracted cubemap.
  55360. * @return The Cube Map information.
  55361. */
  55362. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55363. /**
  55364. * Returns the pixels data extracted from an RGBE texture.
  55365. * This pixels will be stored left to right up to down in the R G B order in one array.
  55366. *
  55367. * More information on this format are available here:
  55368. * https://en.wikipedia.org/wiki/RGBE_image_format
  55369. *
  55370. * @param uint8array The binary file stored in an array buffer.
  55371. * @param hdrInfo The header information of the file.
  55372. * @return The pixels data in RGB right to left up to down order.
  55373. */
  55374. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55375. private static RGBE_ReadPixels_RLE;
  55376. }
  55377. }
  55378. declare module BABYLON {
  55379. /**
  55380. * This represents a texture coming from an HDR input.
  55381. *
  55382. * The only supported format is currently panorama picture stored in RGBE format.
  55383. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55384. */
  55385. export class HDRCubeTexture extends BaseTexture {
  55386. private static _facesMapping;
  55387. private _generateHarmonics;
  55388. private _noMipmap;
  55389. private _textureMatrix;
  55390. private _size;
  55391. private _onLoad;
  55392. private _onError;
  55393. /**
  55394. * The texture URL.
  55395. */
  55396. url: string;
  55397. /**
  55398. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55399. */
  55400. coordinatesMode: number;
  55401. protected _isBlocking: boolean;
  55402. /**
  55403. * Sets wether or not the texture is blocking during loading.
  55404. */
  55405. set isBlocking(value: boolean);
  55406. /**
  55407. * Gets wether or not the texture is blocking during loading.
  55408. */
  55409. get isBlocking(): boolean;
  55410. protected _rotationY: number;
  55411. /**
  55412. * Sets texture matrix rotation angle around Y axis in radians.
  55413. */
  55414. set rotationY(value: number);
  55415. /**
  55416. * Gets texture matrix rotation angle around Y axis radians.
  55417. */
  55418. get rotationY(): number;
  55419. /**
  55420. * Gets or sets the center of the bounding box associated with the cube texture
  55421. * It must define where the camera used to render the texture was set
  55422. */
  55423. boundingBoxPosition: Vector3;
  55424. private _boundingBoxSize;
  55425. /**
  55426. * Gets or sets the size of the bounding box associated with the cube texture
  55427. * When defined, the cubemap will switch to local mode
  55428. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55429. * @example https://www.babylonjs-playground.com/#RNASML
  55430. */
  55431. set boundingBoxSize(value: Vector3);
  55432. get boundingBoxSize(): Vector3;
  55433. /**
  55434. * Instantiates an HDRTexture from the following parameters.
  55435. *
  55436. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55437. * @param scene The scene the texture will be used in
  55438. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55439. * @param noMipmap Forces to not generate the mipmap if true
  55440. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55441. * @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)
  55442. * @param reserved Reserved flag for internal use.
  55443. */
  55444. 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>);
  55445. /**
  55446. * Get the current class name of the texture useful for serialization or dynamic coding.
  55447. * @returns "HDRCubeTexture"
  55448. */
  55449. getClassName(): string;
  55450. /**
  55451. * Occurs when the file is raw .hdr file.
  55452. */
  55453. private loadTexture;
  55454. clone(): HDRCubeTexture;
  55455. delayLoad(): void;
  55456. /**
  55457. * Get the texture reflection matrix used to rotate/transform the reflection.
  55458. * @returns the reflection matrix
  55459. */
  55460. getReflectionTextureMatrix(): Matrix;
  55461. /**
  55462. * Set the texture reflection matrix used to rotate/transform the reflection.
  55463. * @param value Define the reflection matrix to set
  55464. */
  55465. setReflectionTextureMatrix(value: Matrix): void;
  55466. /**
  55467. * Parses a JSON representation of an HDR Texture in order to create the texture
  55468. * @param parsedTexture Define the JSON representation
  55469. * @param scene Define the scene the texture should be created in
  55470. * @param rootUrl Define the root url in case we need to load relative dependencies
  55471. * @returns the newly created texture after parsing
  55472. */
  55473. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55474. serialize(): any;
  55475. }
  55476. }
  55477. declare module BABYLON {
  55478. /**
  55479. * Class used to control physics engine
  55480. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55481. */
  55482. export class PhysicsEngine implements IPhysicsEngine {
  55483. private _physicsPlugin;
  55484. /**
  55485. * Global value used to control the smallest number supported by the simulation
  55486. */
  55487. static Epsilon: number;
  55488. private _impostors;
  55489. private _joints;
  55490. private _subTimeStep;
  55491. /**
  55492. * Gets the gravity vector used by the simulation
  55493. */
  55494. gravity: Vector3;
  55495. /**
  55496. * Factory used to create the default physics plugin.
  55497. * @returns The default physics plugin
  55498. */
  55499. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55500. /**
  55501. * Creates a new Physics Engine
  55502. * @param gravity defines the gravity vector used by the simulation
  55503. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55504. */
  55505. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55506. /**
  55507. * Sets the gravity vector used by the simulation
  55508. * @param gravity defines the gravity vector to use
  55509. */
  55510. setGravity(gravity: Vector3): void;
  55511. /**
  55512. * Set the time step of the physics engine.
  55513. * Default is 1/60.
  55514. * To slow it down, enter 1/600 for example.
  55515. * To speed it up, 1/30
  55516. * @param newTimeStep defines the new timestep to apply to this world.
  55517. */
  55518. setTimeStep(newTimeStep?: number): void;
  55519. /**
  55520. * Get the time step of the physics engine.
  55521. * @returns the current time step
  55522. */
  55523. getTimeStep(): number;
  55524. /**
  55525. * Set the sub time step of the physics engine.
  55526. * Default is 0 meaning there is no sub steps
  55527. * To increase physics resolution precision, set a small value (like 1 ms)
  55528. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55529. */
  55530. setSubTimeStep(subTimeStep?: number): void;
  55531. /**
  55532. * Get the sub time step of the physics engine.
  55533. * @returns the current sub time step
  55534. */
  55535. getSubTimeStep(): number;
  55536. /**
  55537. * Release all resources
  55538. */
  55539. dispose(): void;
  55540. /**
  55541. * Gets the name of the current physics plugin
  55542. * @returns the name of the plugin
  55543. */
  55544. getPhysicsPluginName(): string;
  55545. /**
  55546. * Adding a new impostor for the impostor tracking.
  55547. * This will be done by the impostor itself.
  55548. * @param impostor the impostor to add
  55549. */
  55550. addImpostor(impostor: PhysicsImpostor): void;
  55551. /**
  55552. * Remove an impostor from the engine.
  55553. * This impostor and its mesh will not longer be updated by the physics engine.
  55554. * @param impostor the impostor to remove
  55555. */
  55556. removeImpostor(impostor: PhysicsImpostor): void;
  55557. /**
  55558. * Add a joint to the physics engine
  55559. * @param mainImpostor defines the main impostor to which the joint is added.
  55560. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55561. * @param joint defines the joint that will connect both impostors.
  55562. */
  55563. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55564. /**
  55565. * Removes a joint from the simulation
  55566. * @param mainImpostor defines the impostor used with the joint
  55567. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55568. * @param joint defines the joint to remove
  55569. */
  55570. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55571. /**
  55572. * Called by the scene. No need to call it.
  55573. * @param delta defines the timespam between frames
  55574. */
  55575. _step(delta: number): void;
  55576. /**
  55577. * Gets the current plugin used to run the simulation
  55578. * @returns current plugin
  55579. */
  55580. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55581. /**
  55582. * Gets the list of physic impostors
  55583. * @returns an array of PhysicsImpostor
  55584. */
  55585. getImpostors(): Array<PhysicsImpostor>;
  55586. /**
  55587. * Gets the impostor for a physics enabled object
  55588. * @param object defines the object impersonated by the impostor
  55589. * @returns the PhysicsImpostor or null if not found
  55590. */
  55591. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55592. /**
  55593. * Gets the impostor for a physics body object
  55594. * @param body defines physics body used by the impostor
  55595. * @returns the PhysicsImpostor or null if not found
  55596. */
  55597. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55598. /**
  55599. * Does a raycast in the physics world
  55600. * @param from when should the ray start?
  55601. * @param to when should the ray end?
  55602. * @returns PhysicsRaycastResult
  55603. */
  55604. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55605. }
  55606. }
  55607. declare module BABYLON {
  55608. /** @hidden */
  55609. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55610. private _useDeltaForWorldStep;
  55611. world: any;
  55612. name: string;
  55613. private _physicsMaterials;
  55614. private _fixedTimeStep;
  55615. private _cannonRaycastResult;
  55616. private _raycastResult;
  55617. private _physicsBodysToRemoveAfterStep;
  55618. BJSCANNON: any;
  55619. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55620. setGravity(gravity: Vector3): void;
  55621. setTimeStep(timeStep: number): void;
  55622. getTimeStep(): number;
  55623. executeStep(delta: number): void;
  55624. private _removeMarkedPhysicsBodiesFromWorld;
  55625. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55626. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55627. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55628. private _processChildMeshes;
  55629. removePhysicsBody(impostor: PhysicsImpostor): void;
  55630. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55631. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55632. private _addMaterial;
  55633. private _checkWithEpsilon;
  55634. private _createShape;
  55635. private _createHeightmap;
  55636. private _minus90X;
  55637. private _plus90X;
  55638. private _tmpPosition;
  55639. private _tmpDeltaPosition;
  55640. private _tmpUnityRotation;
  55641. private _updatePhysicsBodyTransformation;
  55642. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55643. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55644. isSupported(): boolean;
  55645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55648. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55649. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55650. getBodyMass(impostor: PhysicsImpostor): number;
  55651. getBodyFriction(impostor: PhysicsImpostor): number;
  55652. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55653. getBodyRestitution(impostor: PhysicsImpostor): number;
  55654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55655. sleepBody(impostor: PhysicsImpostor): void;
  55656. wakeUpBody(impostor: PhysicsImpostor): void;
  55657. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55658. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55659. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55660. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55661. getRadius(impostor: PhysicsImpostor): number;
  55662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55663. dispose(): void;
  55664. private _extendNamespace;
  55665. /**
  55666. * Does a raycast in the physics world
  55667. * @param from when should the ray start?
  55668. * @param to when should the ray end?
  55669. * @returns PhysicsRaycastResult
  55670. */
  55671. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55672. }
  55673. }
  55674. declare module BABYLON {
  55675. /** @hidden */
  55676. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55677. private _useDeltaForWorldStep;
  55678. world: any;
  55679. name: string;
  55680. BJSOIMO: any;
  55681. private _raycastResult;
  55682. private _fixedTimeStep;
  55683. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55684. setGravity(gravity: Vector3): void;
  55685. setTimeStep(timeStep: number): void;
  55686. getTimeStep(): number;
  55687. private _tmpImpostorsArray;
  55688. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55689. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55690. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55691. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55692. private _tmpPositionVector;
  55693. removePhysicsBody(impostor: PhysicsImpostor): void;
  55694. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55695. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55696. isSupported(): boolean;
  55697. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55698. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55699. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55700. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55701. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55702. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55703. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55704. getBodyMass(impostor: PhysicsImpostor): number;
  55705. getBodyFriction(impostor: PhysicsImpostor): number;
  55706. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55707. getBodyRestitution(impostor: PhysicsImpostor): number;
  55708. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55709. sleepBody(impostor: PhysicsImpostor): void;
  55710. wakeUpBody(impostor: PhysicsImpostor): void;
  55711. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55712. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55713. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55714. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55715. getRadius(impostor: PhysicsImpostor): number;
  55716. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55717. dispose(): void;
  55718. /**
  55719. * Does a raycast in the physics world
  55720. * @param from when should the ray start?
  55721. * @param to when should the ray end?
  55722. * @returns PhysicsRaycastResult
  55723. */
  55724. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55725. }
  55726. }
  55727. declare module BABYLON {
  55728. /**
  55729. * Class containing static functions to help procedurally build meshes
  55730. */
  55731. export class RibbonBuilder {
  55732. /**
  55733. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55734. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55735. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55736. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55737. * * 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
  55738. * * 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
  55739. * * 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
  55740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55741. * * 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
  55742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55743. * * 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
  55744. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55745. * * 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
  55746. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55748. * @param name defines the name of the mesh
  55749. * @param options defines the options used to create the mesh
  55750. * @param scene defines the hosting scene
  55751. * @returns the ribbon mesh
  55752. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55753. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55754. */
  55755. static CreateRibbon(name: string, options: {
  55756. pathArray: Vector3[][];
  55757. closeArray?: boolean;
  55758. closePath?: boolean;
  55759. offset?: number;
  55760. updatable?: boolean;
  55761. sideOrientation?: number;
  55762. frontUVs?: Vector4;
  55763. backUVs?: Vector4;
  55764. instance?: Mesh;
  55765. invertUV?: boolean;
  55766. uvs?: Vector2[];
  55767. colors?: Color4[];
  55768. }, scene?: Nullable<Scene>): Mesh;
  55769. }
  55770. }
  55771. declare module BABYLON {
  55772. /**
  55773. * Class containing static functions to help procedurally build meshes
  55774. */
  55775. export class ShapeBuilder {
  55776. /**
  55777. * 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.
  55778. * * 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.
  55779. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55780. * * 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.
  55781. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55782. * * 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
  55783. * * 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
  55784. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55786. * * 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
  55787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55789. * @param name defines the name of the mesh
  55790. * @param options defines the options used to create the mesh
  55791. * @param scene defines the hosting scene
  55792. * @returns the extruded shape mesh
  55793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55795. */
  55796. static ExtrudeShape(name: string, options: {
  55797. shape: Vector3[];
  55798. path: Vector3[];
  55799. scale?: number;
  55800. rotation?: number;
  55801. cap?: number;
  55802. updatable?: boolean;
  55803. sideOrientation?: number;
  55804. frontUVs?: Vector4;
  55805. backUVs?: Vector4;
  55806. instance?: Mesh;
  55807. invertUV?: boolean;
  55808. }, scene?: Nullable<Scene>): Mesh;
  55809. /**
  55810. * Creates an custom extruded shape mesh.
  55811. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55812. * * 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.
  55813. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55814. * * 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
  55815. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55816. * * 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
  55817. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55818. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55819. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55820. * * 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
  55821. * * 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
  55822. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55824. * * 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
  55825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55827. * @param name defines the name of the mesh
  55828. * @param options defines the options used to create the mesh
  55829. * @param scene defines the hosting scene
  55830. * @returns the custom extruded shape mesh
  55831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55834. */
  55835. static ExtrudeShapeCustom(name: string, options: {
  55836. shape: Vector3[];
  55837. path: Vector3[];
  55838. scaleFunction?: any;
  55839. rotationFunction?: any;
  55840. ribbonCloseArray?: boolean;
  55841. ribbonClosePath?: boolean;
  55842. cap?: number;
  55843. updatable?: boolean;
  55844. sideOrientation?: number;
  55845. frontUVs?: Vector4;
  55846. backUVs?: Vector4;
  55847. instance?: Mesh;
  55848. invertUV?: boolean;
  55849. }, scene?: Nullable<Scene>): Mesh;
  55850. private static _ExtrudeShapeGeneric;
  55851. }
  55852. }
  55853. declare module BABYLON {
  55854. /**
  55855. * AmmoJS Physics plugin
  55856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55857. * @see https://github.com/kripken/ammo.js/
  55858. */
  55859. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55860. private _useDeltaForWorldStep;
  55861. /**
  55862. * Reference to the Ammo library
  55863. */
  55864. bjsAMMO: any;
  55865. /**
  55866. * Created ammoJS world which physics bodies are added to
  55867. */
  55868. world: any;
  55869. /**
  55870. * Name of the plugin
  55871. */
  55872. name: string;
  55873. private _timeStep;
  55874. private _fixedTimeStep;
  55875. private _maxSteps;
  55876. private _tmpQuaternion;
  55877. private _tmpAmmoTransform;
  55878. private _tmpAmmoQuaternion;
  55879. private _tmpAmmoConcreteContactResultCallback;
  55880. private _collisionConfiguration;
  55881. private _dispatcher;
  55882. private _overlappingPairCache;
  55883. private _solver;
  55884. private _softBodySolver;
  55885. private _tmpAmmoVectorA;
  55886. private _tmpAmmoVectorB;
  55887. private _tmpAmmoVectorC;
  55888. private _tmpAmmoVectorD;
  55889. private _tmpContactCallbackResult;
  55890. private _tmpAmmoVectorRCA;
  55891. private _tmpAmmoVectorRCB;
  55892. private _raycastResult;
  55893. private static readonly DISABLE_COLLISION_FLAG;
  55894. private static readonly KINEMATIC_FLAG;
  55895. private static readonly DISABLE_DEACTIVATION_FLAG;
  55896. /**
  55897. * Initializes the ammoJS plugin
  55898. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55899. * @param ammoInjection can be used to inject your own ammo reference
  55900. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55901. */
  55902. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55903. /**
  55904. * Sets the gravity of the physics world (m/(s^2))
  55905. * @param gravity Gravity to set
  55906. */
  55907. setGravity(gravity: Vector3): void;
  55908. /**
  55909. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55910. * @param timeStep timestep to use in seconds
  55911. */
  55912. setTimeStep(timeStep: number): void;
  55913. /**
  55914. * 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)
  55915. * @param fixedTimeStep fixedTimeStep to use in seconds
  55916. */
  55917. setFixedTimeStep(fixedTimeStep: number): void;
  55918. /**
  55919. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55920. * @param maxSteps the maximum number of steps by the physics engine per frame
  55921. */
  55922. setMaxSteps(maxSteps: number): void;
  55923. /**
  55924. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55925. * @returns the current timestep in seconds
  55926. */
  55927. getTimeStep(): number;
  55928. /**
  55929. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55930. */
  55931. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55932. private _isImpostorInContact;
  55933. private _isImpostorPairInContact;
  55934. private _stepSimulation;
  55935. /**
  55936. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55937. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55938. * After the step the babylon meshes are set to the position of the physics imposters
  55939. * @param delta amount of time to step forward
  55940. * @param impostors array of imposters to update before/after the step
  55941. */
  55942. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55943. /**
  55944. * Update babylon mesh to match physics world object
  55945. * @param impostor imposter to match
  55946. */
  55947. private _afterSoftStep;
  55948. /**
  55949. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55950. * @param impostor imposter to match
  55951. */
  55952. private _ropeStep;
  55953. /**
  55954. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55955. * @param impostor imposter to match
  55956. */
  55957. private _softbodyOrClothStep;
  55958. private _tmpMatrix;
  55959. /**
  55960. * Applies an impulse on the imposter
  55961. * @param impostor imposter to apply impulse to
  55962. * @param force amount of force to be applied to the imposter
  55963. * @param contactPoint the location to apply the impulse on the imposter
  55964. */
  55965. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55966. /**
  55967. * Applies a force on the imposter
  55968. * @param impostor imposter to apply force
  55969. * @param force amount of force to be applied to the imposter
  55970. * @param contactPoint the location to apply the force on the imposter
  55971. */
  55972. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55973. /**
  55974. * Creates a physics body using the plugin
  55975. * @param impostor the imposter to create the physics body on
  55976. */
  55977. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55978. /**
  55979. * Removes the physics body from the imposter and disposes of the body's memory
  55980. * @param impostor imposter to remove the physics body from
  55981. */
  55982. removePhysicsBody(impostor: PhysicsImpostor): void;
  55983. /**
  55984. * Generates a joint
  55985. * @param impostorJoint the imposter joint to create the joint with
  55986. */
  55987. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55988. /**
  55989. * Removes a joint
  55990. * @param impostorJoint the imposter joint to remove the joint from
  55991. */
  55992. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55993. private _addMeshVerts;
  55994. /**
  55995. * Initialise the soft body vertices to match its object's (mesh) vertices
  55996. * Softbody vertices (nodes) are in world space and to match this
  55997. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55998. * @param impostor to create the softbody for
  55999. */
  56000. private _softVertexData;
  56001. /**
  56002. * Create an impostor's soft body
  56003. * @param impostor to create the softbody for
  56004. */
  56005. private _createSoftbody;
  56006. /**
  56007. * Create cloth for an impostor
  56008. * @param impostor to create the softbody for
  56009. */
  56010. private _createCloth;
  56011. /**
  56012. * Create rope for an impostor
  56013. * @param impostor to create the softbody for
  56014. */
  56015. private _createRope;
  56016. /**
  56017. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56018. * @param impostor to create the custom physics shape for
  56019. */
  56020. private _createCustom;
  56021. private _addHullVerts;
  56022. private _createShape;
  56023. /**
  56024. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56025. * @param impostor imposter containing the physics body and babylon object
  56026. */
  56027. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56028. /**
  56029. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56030. * @param impostor imposter containing the physics body and babylon object
  56031. * @param newPosition new position
  56032. * @param newRotation new rotation
  56033. */
  56034. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56035. /**
  56036. * If this plugin is supported
  56037. * @returns true if its supported
  56038. */
  56039. isSupported(): boolean;
  56040. /**
  56041. * Sets the linear velocity of the physics body
  56042. * @param impostor imposter to set the velocity on
  56043. * @param velocity velocity to set
  56044. */
  56045. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56046. /**
  56047. * Sets the angular velocity of the physics body
  56048. * @param impostor imposter to set the velocity on
  56049. * @param velocity velocity to set
  56050. */
  56051. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56052. /**
  56053. * gets the linear velocity
  56054. * @param impostor imposter to get linear velocity from
  56055. * @returns linear velocity
  56056. */
  56057. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56058. /**
  56059. * gets the angular velocity
  56060. * @param impostor imposter to get angular velocity from
  56061. * @returns angular velocity
  56062. */
  56063. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56064. /**
  56065. * Sets the mass of physics body
  56066. * @param impostor imposter to set the mass on
  56067. * @param mass mass to set
  56068. */
  56069. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56070. /**
  56071. * Gets the mass of the physics body
  56072. * @param impostor imposter to get the mass from
  56073. * @returns mass
  56074. */
  56075. getBodyMass(impostor: PhysicsImpostor): number;
  56076. /**
  56077. * Gets friction of the impostor
  56078. * @param impostor impostor to get friction from
  56079. * @returns friction value
  56080. */
  56081. getBodyFriction(impostor: PhysicsImpostor): number;
  56082. /**
  56083. * Sets friction of the impostor
  56084. * @param impostor impostor to set friction on
  56085. * @param friction friction value
  56086. */
  56087. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56088. /**
  56089. * Gets restitution of the impostor
  56090. * @param impostor impostor to get restitution from
  56091. * @returns restitution value
  56092. */
  56093. getBodyRestitution(impostor: PhysicsImpostor): number;
  56094. /**
  56095. * Sets resitution of the impostor
  56096. * @param impostor impostor to set resitution on
  56097. * @param restitution resitution value
  56098. */
  56099. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56100. /**
  56101. * Gets pressure inside the impostor
  56102. * @param impostor impostor to get pressure from
  56103. * @returns pressure value
  56104. */
  56105. getBodyPressure(impostor: PhysicsImpostor): number;
  56106. /**
  56107. * Sets pressure inside a soft body impostor
  56108. * Cloth and rope must remain 0 pressure
  56109. * @param impostor impostor to set pressure on
  56110. * @param pressure pressure value
  56111. */
  56112. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56113. /**
  56114. * Gets stiffness of the impostor
  56115. * @param impostor impostor to get stiffness from
  56116. * @returns pressure value
  56117. */
  56118. getBodyStiffness(impostor: PhysicsImpostor): number;
  56119. /**
  56120. * Sets stiffness of the impostor
  56121. * @param impostor impostor to set stiffness on
  56122. * @param stiffness stiffness value from 0 to 1
  56123. */
  56124. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56125. /**
  56126. * Gets velocityIterations of the impostor
  56127. * @param impostor impostor to get velocity iterations from
  56128. * @returns velocityIterations value
  56129. */
  56130. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56131. /**
  56132. * Sets velocityIterations of the impostor
  56133. * @param impostor impostor to set velocity iterations on
  56134. * @param velocityIterations velocityIterations value
  56135. */
  56136. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56137. /**
  56138. * Gets positionIterations of the impostor
  56139. * @param impostor impostor to get position iterations from
  56140. * @returns positionIterations value
  56141. */
  56142. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56143. /**
  56144. * Sets positionIterations of the impostor
  56145. * @param impostor impostor to set position on
  56146. * @param positionIterations positionIterations value
  56147. */
  56148. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56149. /**
  56150. * Append an anchor to a cloth object
  56151. * @param impostor is the cloth impostor to add anchor to
  56152. * @param otherImpostor is the rigid impostor to anchor to
  56153. * @param width ratio across width from 0 to 1
  56154. * @param height ratio up height from 0 to 1
  56155. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56156. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56157. */
  56158. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56159. /**
  56160. * Append an hook to a rope object
  56161. * @param impostor is the rope impostor to add hook to
  56162. * @param otherImpostor is the rigid impostor to hook to
  56163. * @param length ratio along the rope from 0 to 1
  56164. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56165. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56166. */
  56167. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56168. /**
  56169. * Sleeps the physics body and stops it from being active
  56170. * @param impostor impostor to sleep
  56171. */
  56172. sleepBody(impostor: PhysicsImpostor): void;
  56173. /**
  56174. * Activates the physics body
  56175. * @param impostor impostor to activate
  56176. */
  56177. wakeUpBody(impostor: PhysicsImpostor): void;
  56178. /**
  56179. * Updates the distance parameters of the joint
  56180. * @param joint joint to update
  56181. * @param maxDistance maximum distance of the joint
  56182. * @param minDistance minimum distance of the joint
  56183. */
  56184. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56185. /**
  56186. * Sets a motor on the joint
  56187. * @param joint joint to set motor on
  56188. * @param speed speed of the motor
  56189. * @param maxForce maximum force of the motor
  56190. * @param motorIndex index of the motor
  56191. */
  56192. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56193. /**
  56194. * Sets the motors limit
  56195. * @param joint joint to set limit on
  56196. * @param upperLimit upper limit
  56197. * @param lowerLimit lower limit
  56198. */
  56199. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56200. /**
  56201. * Syncs the position and rotation of a mesh with the impostor
  56202. * @param mesh mesh to sync
  56203. * @param impostor impostor to update the mesh with
  56204. */
  56205. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56206. /**
  56207. * Gets the radius of the impostor
  56208. * @param impostor impostor to get radius from
  56209. * @returns the radius
  56210. */
  56211. getRadius(impostor: PhysicsImpostor): number;
  56212. /**
  56213. * Gets the box size of the impostor
  56214. * @param impostor impostor to get box size from
  56215. * @param result the resulting box size
  56216. */
  56217. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56218. /**
  56219. * Disposes of the impostor
  56220. */
  56221. dispose(): void;
  56222. /**
  56223. * Does a raycast in the physics world
  56224. * @param from when should the ray start?
  56225. * @param to when should the ray end?
  56226. * @returns PhysicsRaycastResult
  56227. */
  56228. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56229. }
  56230. }
  56231. declare module BABYLON {
  56232. interface AbstractScene {
  56233. /**
  56234. * The list of reflection probes added to the scene
  56235. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56236. */
  56237. reflectionProbes: Array<ReflectionProbe>;
  56238. /**
  56239. * Removes the given reflection probe from this scene.
  56240. * @param toRemove The reflection probe to remove
  56241. * @returns The index of the removed reflection probe
  56242. */
  56243. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56244. /**
  56245. * Adds the given reflection probe to this scene.
  56246. * @param newReflectionProbe The reflection probe to add
  56247. */
  56248. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56249. }
  56250. /**
  56251. * Class used to generate realtime reflection / refraction cube textures
  56252. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56253. */
  56254. export class ReflectionProbe {
  56255. /** defines the name of the probe */
  56256. name: string;
  56257. private _scene;
  56258. private _renderTargetTexture;
  56259. private _projectionMatrix;
  56260. private _viewMatrix;
  56261. private _target;
  56262. private _add;
  56263. private _attachedMesh;
  56264. private _invertYAxis;
  56265. /** Gets or sets probe position (center of the cube map) */
  56266. position: Vector3;
  56267. /**
  56268. * Creates a new reflection probe
  56269. * @param name defines the name of the probe
  56270. * @param size defines the texture resolution (for each face)
  56271. * @param scene defines the hosting scene
  56272. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56273. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56274. */
  56275. constructor(
  56276. /** defines the name of the probe */
  56277. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56278. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56279. get samples(): number;
  56280. set samples(value: number);
  56281. /** Gets or sets the refresh rate to use (on every frame by default) */
  56282. get refreshRate(): number;
  56283. set refreshRate(value: number);
  56284. /**
  56285. * Gets the hosting scene
  56286. * @returns a Scene
  56287. */
  56288. getScene(): Scene;
  56289. /** Gets the internal CubeTexture used to render to */
  56290. get cubeTexture(): RenderTargetTexture;
  56291. /** Gets the list of meshes to render */
  56292. get renderList(): Nullable<AbstractMesh[]>;
  56293. /**
  56294. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56295. * @param mesh defines the mesh to attach to
  56296. */
  56297. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56298. /**
  56299. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56300. * @param renderingGroupId The rendering group id corresponding to its index
  56301. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56302. */
  56303. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56304. /**
  56305. * Clean all associated resources
  56306. */
  56307. dispose(): void;
  56308. /**
  56309. * Converts the reflection probe information to a readable string for debug purpose.
  56310. * @param fullDetails Supports for multiple levels of logging within scene loading
  56311. * @returns the human readable reflection probe info
  56312. */
  56313. toString(fullDetails?: boolean): string;
  56314. /**
  56315. * Get the class name of the relfection probe.
  56316. * @returns "ReflectionProbe"
  56317. */
  56318. getClassName(): string;
  56319. /**
  56320. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56321. * @returns The JSON representation of the texture
  56322. */
  56323. serialize(): any;
  56324. /**
  56325. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56326. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56327. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56328. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56329. * @returns The parsed reflection probe if successful
  56330. */
  56331. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56332. }
  56333. }
  56334. declare module BABYLON {
  56335. /** @hidden */
  56336. export var _BabylonLoaderRegistered: boolean;
  56337. /**
  56338. * Helps setting up some configuration for the babylon file loader.
  56339. */
  56340. export class BabylonFileLoaderConfiguration {
  56341. /**
  56342. * The loader does not allow injecting custom physix engine into the plugins.
  56343. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56344. * So you could set this variable to your engine import to make it work.
  56345. */
  56346. static LoaderInjectedPhysicsEngine: any;
  56347. }
  56348. }
  56349. declare module BABYLON {
  56350. /**
  56351. * The Physically based simple base material of BJS.
  56352. *
  56353. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56354. * It is used as the base class for both the specGloss and metalRough conventions.
  56355. */
  56356. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56357. /**
  56358. * Number of Simultaneous lights allowed on the material.
  56359. */
  56360. maxSimultaneousLights: number;
  56361. /**
  56362. * If sets to true, disables all the lights affecting the material.
  56363. */
  56364. disableLighting: boolean;
  56365. /**
  56366. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56367. */
  56368. environmentTexture: BaseTexture;
  56369. /**
  56370. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56371. */
  56372. invertNormalMapX: boolean;
  56373. /**
  56374. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56375. */
  56376. invertNormalMapY: boolean;
  56377. /**
  56378. * Normal map used in the model.
  56379. */
  56380. normalTexture: BaseTexture;
  56381. /**
  56382. * Emissivie color used to self-illuminate the model.
  56383. */
  56384. emissiveColor: Color3;
  56385. /**
  56386. * Emissivie texture used to self-illuminate the model.
  56387. */
  56388. emissiveTexture: BaseTexture;
  56389. /**
  56390. * Occlusion Channel Strenght.
  56391. */
  56392. occlusionStrength: number;
  56393. /**
  56394. * Occlusion Texture of the material (adding extra occlusion effects).
  56395. */
  56396. occlusionTexture: BaseTexture;
  56397. /**
  56398. * Defines the alpha limits in alpha test mode.
  56399. */
  56400. alphaCutOff: number;
  56401. /**
  56402. * Gets the current double sided mode.
  56403. */
  56404. get doubleSided(): boolean;
  56405. /**
  56406. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56407. */
  56408. set doubleSided(value: boolean);
  56409. /**
  56410. * Stores the pre-calculated light information of a mesh in a texture.
  56411. */
  56412. lightmapTexture: BaseTexture;
  56413. /**
  56414. * If true, the light map contains occlusion information instead of lighting info.
  56415. */
  56416. useLightmapAsShadowmap: boolean;
  56417. /**
  56418. * Instantiates a new PBRMaterial instance.
  56419. *
  56420. * @param name The material name
  56421. * @param scene The scene the material will be use in.
  56422. */
  56423. constructor(name: string, scene: Scene);
  56424. getClassName(): string;
  56425. }
  56426. }
  56427. declare module BABYLON {
  56428. /**
  56429. * The PBR material of BJS following the metal roughness convention.
  56430. *
  56431. * This fits to the PBR convention in the GLTF definition:
  56432. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56433. */
  56434. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56435. /**
  56436. * The base color has two different interpretations depending on the value of metalness.
  56437. * When the material is a metal, the base color is the specific measured reflectance value
  56438. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56439. * of the material.
  56440. */
  56441. baseColor: Color3;
  56442. /**
  56443. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56444. * well as opacity information in the alpha channel.
  56445. */
  56446. baseTexture: BaseTexture;
  56447. /**
  56448. * Specifies the metallic scalar value of the material.
  56449. * Can also be used to scale the metalness values of the metallic texture.
  56450. */
  56451. metallic: number;
  56452. /**
  56453. * Specifies the roughness scalar value of the material.
  56454. * Can also be used to scale the roughness values of the metallic texture.
  56455. */
  56456. roughness: number;
  56457. /**
  56458. * Texture containing both the metallic value in the B channel and the
  56459. * roughness value in the G channel to keep better precision.
  56460. */
  56461. metallicRoughnessTexture: BaseTexture;
  56462. /**
  56463. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56464. *
  56465. * @param name The material name
  56466. * @param scene The scene the material will be use in.
  56467. */
  56468. constructor(name: string, scene: Scene);
  56469. /**
  56470. * Return the currrent class name of the material.
  56471. */
  56472. getClassName(): string;
  56473. /**
  56474. * Makes a duplicate of the current material.
  56475. * @param name - name to use for the new material.
  56476. */
  56477. clone(name: string): PBRMetallicRoughnessMaterial;
  56478. /**
  56479. * Serialize the material to a parsable JSON object.
  56480. */
  56481. serialize(): any;
  56482. /**
  56483. * Parses a JSON object correponding to the serialize function.
  56484. */
  56485. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56486. }
  56487. }
  56488. declare module BABYLON {
  56489. /**
  56490. * The PBR material of BJS following the specular glossiness convention.
  56491. *
  56492. * This fits to the PBR convention in the GLTF definition:
  56493. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56494. */
  56495. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56496. /**
  56497. * Specifies the diffuse color of the material.
  56498. */
  56499. diffuseColor: Color3;
  56500. /**
  56501. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56502. * channel.
  56503. */
  56504. diffuseTexture: BaseTexture;
  56505. /**
  56506. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56507. */
  56508. specularColor: Color3;
  56509. /**
  56510. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56511. */
  56512. glossiness: number;
  56513. /**
  56514. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56515. */
  56516. specularGlossinessTexture: BaseTexture;
  56517. /**
  56518. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56519. *
  56520. * @param name The material name
  56521. * @param scene The scene the material will be use in.
  56522. */
  56523. constructor(name: string, scene: Scene);
  56524. /**
  56525. * Return the currrent class name of the material.
  56526. */
  56527. getClassName(): string;
  56528. /**
  56529. * Makes a duplicate of the current material.
  56530. * @param name - name to use for the new material.
  56531. */
  56532. clone(name: string): PBRSpecularGlossinessMaterial;
  56533. /**
  56534. * Serialize the material to a parsable JSON object.
  56535. */
  56536. serialize(): any;
  56537. /**
  56538. * Parses a JSON object correponding to the serialize function.
  56539. */
  56540. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56541. }
  56542. }
  56543. declare module BABYLON {
  56544. /**
  56545. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56546. * It can help converting any input color in a desired output one. This can then be used to create effects
  56547. * from sepia, black and white to sixties or futuristic rendering...
  56548. *
  56549. * The only supported format is currently 3dl.
  56550. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56551. */
  56552. export class ColorGradingTexture extends BaseTexture {
  56553. /**
  56554. * The texture URL.
  56555. */
  56556. url: string;
  56557. /**
  56558. * Empty line regex stored for GC.
  56559. */
  56560. private static _noneEmptyLineRegex;
  56561. private _textureMatrix;
  56562. private _engine;
  56563. private _onLoad;
  56564. /**
  56565. * Instantiates a ColorGradingTexture from the following parameters.
  56566. *
  56567. * @param url The location of the color gradind data (currently only supporting 3dl)
  56568. * @param sceneOrEngine The scene or engine the texture will be used in
  56569. * @param onLoad defines a callback triggered when the texture has been loaded
  56570. */
  56571. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56572. /**
  56573. * Fires the onload event from the constructor if requested.
  56574. */
  56575. private _triggerOnLoad;
  56576. /**
  56577. * Returns the texture matrix used in most of the material.
  56578. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56579. */
  56580. getTextureMatrix(): Matrix;
  56581. /**
  56582. * Occurs when the file being loaded is a .3dl LUT file.
  56583. */
  56584. private load3dlTexture;
  56585. /**
  56586. * Starts the loading process of the texture.
  56587. */
  56588. private loadTexture;
  56589. /**
  56590. * Clones the color gradind texture.
  56591. */
  56592. clone(): ColorGradingTexture;
  56593. /**
  56594. * Called during delayed load for textures.
  56595. */
  56596. delayLoad(): void;
  56597. /**
  56598. * Parses a color grading texture serialized by Babylon.
  56599. * @param parsedTexture The texture information being parsedTexture
  56600. * @param scene The scene to load the texture in
  56601. * @param rootUrl The root url of the data assets to load
  56602. * @return A color gradind texture
  56603. */
  56604. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56605. /**
  56606. * Serializes the LUT texture to json format.
  56607. */
  56608. serialize(): any;
  56609. /**
  56610. * Returns true if the passed parameter is a scene object (can be use for typings)
  56611. * @param sceneOrEngine The object to test.
  56612. */
  56613. private static _isScene;
  56614. }
  56615. }
  56616. declare module BABYLON {
  56617. /**
  56618. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56619. */
  56620. export class EquiRectangularCubeTexture extends BaseTexture {
  56621. /** The six faces of the cube. */
  56622. private static _FacesMapping;
  56623. private _noMipmap;
  56624. private _onLoad;
  56625. private _onError;
  56626. /** The size of the cubemap. */
  56627. private _size;
  56628. /** The buffer of the image. */
  56629. private _buffer;
  56630. /** The width of the input image. */
  56631. private _width;
  56632. /** The height of the input image. */
  56633. private _height;
  56634. /** The URL to the image. */
  56635. url: string;
  56636. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56637. coordinatesMode: number;
  56638. /**
  56639. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56640. * @param url The location of the image
  56641. * @param scene The scene the texture will be used in
  56642. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56643. * @param noMipmap Forces to not generate the mipmap if true
  56644. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56645. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56646. * @param onLoad — defines a callback called when texture is loaded
  56647. * @param onError — defines a callback called if there is an error
  56648. */
  56649. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56650. /**
  56651. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56652. */
  56653. private loadImage;
  56654. /**
  56655. * Convert the image buffer into a cubemap and create a CubeTexture.
  56656. */
  56657. private loadTexture;
  56658. /**
  56659. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56660. * @param buffer The ArrayBuffer that should be converted.
  56661. * @returns The buffer as Float32Array.
  56662. */
  56663. private getFloat32ArrayFromArrayBuffer;
  56664. /**
  56665. * Get the current class name of the texture useful for serialization or dynamic coding.
  56666. * @returns "EquiRectangularCubeTexture"
  56667. */
  56668. getClassName(): string;
  56669. /**
  56670. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56671. * @returns A clone of the current EquiRectangularCubeTexture.
  56672. */
  56673. clone(): EquiRectangularCubeTexture;
  56674. }
  56675. }
  56676. declare module BABYLON {
  56677. /**
  56678. * Based on jsTGALoader - Javascript loader for TGA file
  56679. * By Vincent Thibault
  56680. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56681. */
  56682. export class TGATools {
  56683. private static _TYPE_INDEXED;
  56684. private static _TYPE_RGB;
  56685. private static _TYPE_GREY;
  56686. private static _TYPE_RLE_INDEXED;
  56687. private static _TYPE_RLE_RGB;
  56688. private static _TYPE_RLE_GREY;
  56689. private static _ORIGIN_MASK;
  56690. private static _ORIGIN_SHIFT;
  56691. private static _ORIGIN_BL;
  56692. private static _ORIGIN_BR;
  56693. private static _ORIGIN_UL;
  56694. private static _ORIGIN_UR;
  56695. /**
  56696. * Gets the header of a TGA file
  56697. * @param data defines the TGA data
  56698. * @returns the header
  56699. */
  56700. static GetTGAHeader(data: Uint8Array): any;
  56701. /**
  56702. * Uploads TGA content to a Babylon Texture
  56703. * @hidden
  56704. */
  56705. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56706. /** @hidden */
  56707. 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;
  56708. /** @hidden */
  56709. 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;
  56710. /** @hidden */
  56711. 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;
  56712. /** @hidden */
  56713. 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;
  56714. /** @hidden */
  56715. 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;
  56716. /** @hidden */
  56717. 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;
  56718. }
  56719. }
  56720. declare module BABYLON {
  56721. /**
  56722. * Implementation of the TGA Texture Loader.
  56723. * @hidden
  56724. */
  56725. export class _TGATextureLoader implements IInternalTextureLoader {
  56726. /**
  56727. * Defines wether the loader supports cascade loading the different faces.
  56728. */
  56729. readonly supportCascades: boolean;
  56730. /**
  56731. * This returns if the loader support the current file information.
  56732. * @param extension defines the file extension of the file being loaded
  56733. * @returns true if the loader can load the specified file
  56734. */
  56735. canLoad(extension: string): boolean;
  56736. /**
  56737. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56738. * @param data contains the texture data
  56739. * @param texture defines the BabylonJS internal texture
  56740. * @param createPolynomials will be true if polynomials have been requested
  56741. * @param onLoad defines the callback to trigger once the texture is ready
  56742. * @param onError defines the callback to trigger in case of error
  56743. */
  56744. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56745. /**
  56746. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56747. * @param data contains the texture data
  56748. * @param texture defines the BabylonJS internal texture
  56749. * @param callback defines the method to call once ready to upload
  56750. */
  56751. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56752. }
  56753. }
  56754. declare module BABYLON {
  56755. /**
  56756. * Info about the .basis files
  56757. */
  56758. class BasisFileInfo {
  56759. /**
  56760. * If the file has alpha
  56761. */
  56762. hasAlpha: boolean;
  56763. /**
  56764. * Info about each image of the basis file
  56765. */
  56766. images: Array<{
  56767. levels: Array<{
  56768. width: number;
  56769. height: number;
  56770. transcodedPixels: ArrayBufferView;
  56771. }>;
  56772. }>;
  56773. }
  56774. /**
  56775. * Result of transcoding a basis file
  56776. */
  56777. class TranscodeResult {
  56778. /**
  56779. * Info about the .basis file
  56780. */
  56781. fileInfo: BasisFileInfo;
  56782. /**
  56783. * Format to use when loading the file
  56784. */
  56785. format: number;
  56786. }
  56787. /**
  56788. * Configuration options for the Basis transcoder
  56789. */
  56790. export class BasisTranscodeConfiguration {
  56791. /**
  56792. * Supported compression formats used to determine the supported output format of the transcoder
  56793. */
  56794. supportedCompressionFormats?: {
  56795. /**
  56796. * etc1 compression format
  56797. */
  56798. etc1?: boolean;
  56799. /**
  56800. * s3tc compression format
  56801. */
  56802. s3tc?: boolean;
  56803. /**
  56804. * pvrtc compression format
  56805. */
  56806. pvrtc?: boolean;
  56807. /**
  56808. * etc2 compression format
  56809. */
  56810. etc2?: boolean;
  56811. };
  56812. /**
  56813. * If mipmap levels should be loaded for transcoded images (Default: true)
  56814. */
  56815. loadMipmapLevels?: boolean;
  56816. /**
  56817. * Index of a single image to load (Default: all images)
  56818. */
  56819. loadSingleImage?: number;
  56820. }
  56821. /**
  56822. * Used to load .Basis files
  56823. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56824. */
  56825. export class BasisTools {
  56826. private static _IgnoreSupportedFormats;
  56827. /**
  56828. * URL to use when loading the basis transcoder
  56829. */
  56830. static JSModuleURL: string;
  56831. /**
  56832. * URL to use when loading the wasm module for the transcoder
  56833. */
  56834. static WasmModuleURL: string;
  56835. /**
  56836. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56837. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56838. * @returns internal format corresponding to the Basis format
  56839. */
  56840. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56841. private static _WorkerPromise;
  56842. private static _Worker;
  56843. private static _actionId;
  56844. private static _CreateWorkerAsync;
  56845. /**
  56846. * Transcodes a loaded image file to compressed pixel data
  56847. * @param data image data to transcode
  56848. * @param config configuration options for the transcoding
  56849. * @returns a promise resulting in the transcoded image
  56850. */
  56851. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56852. /**
  56853. * Loads a texture from the transcode result
  56854. * @param texture texture load to
  56855. * @param transcodeResult the result of transcoding the basis file to load from
  56856. */
  56857. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56858. }
  56859. }
  56860. declare module BABYLON {
  56861. /**
  56862. * Loader for .basis file format
  56863. */
  56864. export class _BasisTextureLoader implements IInternalTextureLoader {
  56865. /**
  56866. * Defines whether the loader supports cascade loading the different faces.
  56867. */
  56868. readonly supportCascades: boolean;
  56869. /**
  56870. * This returns if the loader support the current file information.
  56871. * @param extension defines the file extension of the file being loaded
  56872. * @returns true if the loader can load the specified file
  56873. */
  56874. canLoad(extension: string): boolean;
  56875. /**
  56876. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56877. * @param data contains the texture data
  56878. * @param texture defines the BabylonJS internal texture
  56879. * @param createPolynomials will be true if polynomials have been requested
  56880. * @param onLoad defines the callback to trigger once the texture is ready
  56881. * @param onError defines the callback to trigger in case of error
  56882. */
  56883. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56884. /**
  56885. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56886. * @param data contains the texture data
  56887. * @param texture defines the BabylonJS internal texture
  56888. * @param callback defines the method to call once ready to upload
  56889. */
  56890. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56891. }
  56892. }
  56893. declare module BABYLON {
  56894. /**
  56895. * 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.
  56896. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56897. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56898. */
  56899. export class CustomProceduralTexture extends ProceduralTexture {
  56900. private _animate;
  56901. private _time;
  56902. private _config;
  56903. private _texturePath;
  56904. /**
  56905. * Instantiates a new Custom Procedural Texture.
  56906. * 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.
  56907. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56908. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56909. * @param name Define the name of the texture
  56910. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56911. * @param size Define the size of the texture to create
  56912. * @param scene Define the scene the texture belongs to
  56913. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56914. * @param generateMipMaps Define if the texture should creates mip maps or not
  56915. */
  56916. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56917. private _loadJson;
  56918. /**
  56919. * Is the texture ready to be used ? (rendered at least once)
  56920. * @returns true if ready, otherwise, false.
  56921. */
  56922. isReady(): boolean;
  56923. /**
  56924. * Render the texture to its associated render target.
  56925. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56926. */
  56927. render(useCameraPostProcess?: boolean): void;
  56928. /**
  56929. * Update the list of dependant textures samplers in the shader.
  56930. */
  56931. updateTextures(): void;
  56932. /**
  56933. * Update the uniform values of the procedural texture in the shader.
  56934. */
  56935. updateShaderUniforms(): void;
  56936. /**
  56937. * Define if the texture animates or not.
  56938. */
  56939. get animate(): boolean;
  56940. set animate(value: boolean);
  56941. }
  56942. }
  56943. declare module BABYLON {
  56944. /** @hidden */
  56945. export var noisePixelShader: {
  56946. name: string;
  56947. shader: string;
  56948. };
  56949. }
  56950. declare module BABYLON {
  56951. /**
  56952. * Class used to generate noise procedural textures
  56953. */
  56954. export class NoiseProceduralTexture extends ProceduralTexture {
  56955. private _time;
  56956. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56957. brightness: number;
  56958. /** Defines the number of octaves to process */
  56959. octaves: number;
  56960. /** Defines the level of persistence (0.8 by default) */
  56961. persistence: number;
  56962. /** Gets or sets animation speed factor (default is 1) */
  56963. animationSpeedFactor: number;
  56964. /**
  56965. * Creates a new NoiseProceduralTexture
  56966. * @param name defines the name fo the texture
  56967. * @param size defines the size of the texture (default is 256)
  56968. * @param scene defines the hosting scene
  56969. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56970. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56971. */
  56972. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56973. private _updateShaderUniforms;
  56974. protected _getDefines(): string;
  56975. /** Generate the current state of the procedural texture */
  56976. render(useCameraPostProcess?: boolean): void;
  56977. /**
  56978. * Serializes this noise procedural texture
  56979. * @returns a serialized noise procedural texture object
  56980. */
  56981. serialize(): any;
  56982. /**
  56983. * Clone the texture.
  56984. * @returns the cloned texture
  56985. */
  56986. clone(): NoiseProceduralTexture;
  56987. /**
  56988. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56989. * @param parsedTexture defines parsed texture data
  56990. * @param scene defines the current scene
  56991. * @param rootUrl defines the root URL containing noise procedural texture information
  56992. * @returns a parsed NoiseProceduralTexture
  56993. */
  56994. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56995. }
  56996. }
  56997. declare module BABYLON {
  56998. /**
  56999. * Raw cube texture where the raw buffers are passed in
  57000. */
  57001. export class RawCubeTexture extends CubeTexture {
  57002. /**
  57003. * Creates a cube texture where the raw buffers are passed in.
  57004. * @param scene defines the scene the texture is attached to
  57005. * @param data defines the array of data to use to create each face
  57006. * @param size defines the size of the textures
  57007. * @param format defines the format of the data
  57008. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57009. * @param generateMipMaps defines if the engine should generate the mip levels
  57010. * @param invertY defines if data must be stored with Y axis inverted
  57011. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57012. * @param compression defines the compression used (null by default)
  57013. */
  57014. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57015. /**
  57016. * Updates the raw cube texture.
  57017. * @param data defines the data to store
  57018. * @param format defines the data format
  57019. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57020. * @param invertY defines if data must be stored with Y axis inverted
  57021. * @param compression defines the compression used (null by default)
  57022. * @param level defines which level of the texture to update
  57023. */
  57024. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57025. /**
  57026. * Updates a raw cube texture with RGBD encoded data.
  57027. * @param data defines the array of data [mipmap][face] to use to create each face
  57028. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57029. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57030. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57031. * @returns a promsie that resolves when the operation is complete
  57032. */
  57033. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57034. /**
  57035. * Clones the raw cube texture.
  57036. * @return a new cube texture
  57037. */
  57038. clone(): CubeTexture;
  57039. /** @hidden */
  57040. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57041. }
  57042. }
  57043. declare module BABYLON {
  57044. /**
  57045. * Class used to store 3D textures containing user data
  57046. */
  57047. export class RawTexture3D extends Texture {
  57048. /** Gets or sets the texture format to use */
  57049. format: number;
  57050. private _engine;
  57051. /**
  57052. * Create a new RawTexture3D
  57053. * @param data defines the data of the texture
  57054. * @param width defines the width of the texture
  57055. * @param height defines the height of the texture
  57056. * @param depth defines the depth of the texture
  57057. * @param format defines the texture format to use
  57058. * @param scene defines the hosting scene
  57059. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57060. * @param invertY defines if texture must be stored with Y axis inverted
  57061. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57062. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57063. */
  57064. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57065. /** Gets or sets the texture format to use */
  57066. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57067. /**
  57068. * Update the texture with new data
  57069. * @param data defines the data to store in the texture
  57070. */
  57071. update(data: ArrayBufferView): void;
  57072. }
  57073. }
  57074. declare module BABYLON {
  57075. /**
  57076. * Class used to store 2D array textures containing user data
  57077. */
  57078. export class RawTexture2DArray extends Texture {
  57079. /** Gets or sets the texture format to use */
  57080. format: number;
  57081. private _engine;
  57082. /**
  57083. * Create a new RawTexture2DArray
  57084. * @param data defines the data of the texture
  57085. * @param width defines the width of the texture
  57086. * @param height defines the height of the texture
  57087. * @param depth defines the number of layers of the texture
  57088. * @param format defines the texture format to use
  57089. * @param scene defines the hosting scene
  57090. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57091. * @param invertY defines if texture must be stored with Y axis inverted
  57092. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57093. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57094. */
  57095. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57096. /** Gets or sets the texture format to use */
  57097. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57098. /**
  57099. * Update the texture with new data
  57100. * @param data defines the data to store in the texture
  57101. */
  57102. update(data: ArrayBufferView): void;
  57103. }
  57104. }
  57105. declare module BABYLON {
  57106. /**
  57107. * Creates a refraction texture used by refraction channel of the standard material.
  57108. * It is like a mirror but to see through a material.
  57109. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57110. */
  57111. export class RefractionTexture extends RenderTargetTexture {
  57112. /**
  57113. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57114. * 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.
  57115. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57116. */
  57117. refractionPlane: Plane;
  57118. /**
  57119. * Define how deep under the surface we should see.
  57120. */
  57121. depth: number;
  57122. /**
  57123. * Creates a refraction texture used by refraction channel of the standard material.
  57124. * It is like a mirror but to see through a material.
  57125. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57126. * @param name Define the texture name
  57127. * @param size Define the size of the underlying texture
  57128. * @param scene Define the scene the refraction belongs to
  57129. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57130. */
  57131. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57132. /**
  57133. * Clone the refraction texture.
  57134. * @returns the cloned texture
  57135. */
  57136. clone(): RefractionTexture;
  57137. /**
  57138. * Serialize the texture to a JSON representation you could use in Parse later on
  57139. * @returns the serialized JSON representation
  57140. */
  57141. serialize(): any;
  57142. }
  57143. }
  57144. declare module BABYLON {
  57145. /**
  57146. * Defines the options related to the creation of an HtmlElementTexture
  57147. */
  57148. export interface IHtmlElementTextureOptions {
  57149. /**
  57150. * Defines wether mip maps should be created or not.
  57151. */
  57152. generateMipMaps?: boolean;
  57153. /**
  57154. * Defines the sampling mode of the texture.
  57155. */
  57156. samplingMode?: number;
  57157. /**
  57158. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57159. */
  57160. engine: Nullable<ThinEngine>;
  57161. /**
  57162. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57163. */
  57164. scene: Nullable<Scene>;
  57165. }
  57166. /**
  57167. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57168. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57169. * is automatically managed.
  57170. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57171. * in your application.
  57172. *
  57173. * As the update is not automatic, you need to call them manually.
  57174. */
  57175. export class HtmlElementTexture extends BaseTexture {
  57176. /**
  57177. * The texture URL.
  57178. */
  57179. element: HTMLVideoElement | HTMLCanvasElement;
  57180. private static readonly DefaultOptions;
  57181. private _textureMatrix;
  57182. private _engine;
  57183. private _isVideo;
  57184. private _generateMipMaps;
  57185. private _samplingMode;
  57186. /**
  57187. * Instantiates a HtmlElementTexture from the following parameters.
  57188. *
  57189. * @param name Defines the name of the texture
  57190. * @param element Defines the video or canvas the texture is filled with
  57191. * @param options Defines the other none mandatory texture creation options
  57192. */
  57193. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57194. private _createInternalTexture;
  57195. /**
  57196. * Returns the texture matrix used in most of the material.
  57197. */
  57198. getTextureMatrix(): Matrix;
  57199. /**
  57200. * Updates the content of the texture.
  57201. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57202. */
  57203. update(invertY?: Nullable<boolean>): void;
  57204. }
  57205. }
  57206. declare module BABYLON {
  57207. /**
  57208. * Defines the basic options interface of a TexturePacker Frame
  57209. */
  57210. export interface ITexturePackerFrame {
  57211. /**
  57212. * The frame ID
  57213. */
  57214. id: number;
  57215. /**
  57216. * The frames Scale
  57217. */
  57218. scale: Vector2;
  57219. /**
  57220. * The Frames offset
  57221. */
  57222. offset: Vector2;
  57223. }
  57224. /**
  57225. * This is a support class for frame Data on texture packer sets.
  57226. */
  57227. export class TexturePackerFrame implements ITexturePackerFrame {
  57228. /**
  57229. * The frame ID
  57230. */
  57231. id: number;
  57232. /**
  57233. * The frames Scale
  57234. */
  57235. scale: Vector2;
  57236. /**
  57237. * The Frames offset
  57238. */
  57239. offset: Vector2;
  57240. /**
  57241. * Initializes a texture package frame.
  57242. * @param id The numerical frame identifier
  57243. * @param scale Scalar Vector2 for UV frame
  57244. * @param offset Vector2 for the frame position in UV units.
  57245. * @returns TexturePackerFrame
  57246. */
  57247. constructor(id: number, scale: Vector2, offset: Vector2);
  57248. }
  57249. }
  57250. declare module BABYLON {
  57251. /**
  57252. * Defines the basic options interface of a TexturePacker
  57253. */
  57254. export interface ITexturePackerOptions {
  57255. /**
  57256. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57257. */
  57258. map?: string[];
  57259. /**
  57260. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57261. */
  57262. uvsIn?: string;
  57263. /**
  57264. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57265. */
  57266. uvsOut?: string;
  57267. /**
  57268. * number representing the layout style. Defaults to LAYOUT_STRIP
  57269. */
  57270. layout?: number;
  57271. /**
  57272. * number of columns if using custom column count layout(2). This defaults to 4.
  57273. */
  57274. colnum?: number;
  57275. /**
  57276. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57277. */
  57278. updateInputMeshes?: boolean;
  57279. /**
  57280. * boolean flag to dispose all the source textures. Defaults to true.
  57281. */
  57282. disposeSources?: boolean;
  57283. /**
  57284. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57285. */
  57286. fillBlanks?: boolean;
  57287. /**
  57288. * string value representing the context fill style color. Defaults to 'black'.
  57289. */
  57290. customFillColor?: string;
  57291. /**
  57292. * Width and Height Value of each Frame in the TexturePacker Sets
  57293. */
  57294. frameSize?: number;
  57295. /**
  57296. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57297. */
  57298. paddingRatio?: number;
  57299. /**
  57300. * Number that declares the fill method for the padding gutter.
  57301. */
  57302. paddingMode?: number;
  57303. /**
  57304. * If in SUBUV_COLOR padding mode what color to use.
  57305. */
  57306. paddingColor?: Color3 | Color4;
  57307. }
  57308. /**
  57309. * Defines the basic interface of a TexturePacker JSON File
  57310. */
  57311. export interface ITexturePackerJSON {
  57312. /**
  57313. * The frame ID
  57314. */
  57315. name: string;
  57316. /**
  57317. * The base64 channel data
  57318. */
  57319. sets: any;
  57320. /**
  57321. * The options of the Packer
  57322. */
  57323. options: ITexturePackerOptions;
  57324. /**
  57325. * The frame data of the Packer
  57326. */
  57327. frames: Array<number>;
  57328. }
  57329. /**
  57330. * This is a support class that generates a series of packed texture sets.
  57331. * @see https://doc.babylonjs.com/babylon101/materials
  57332. */
  57333. export class TexturePacker {
  57334. /** Packer Layout Constant 0 */
  57335. static readonly LAYOUT_STRIP: number;
  57336. /** Packer Layout Constant 1 */
  57337. static readonly LAYOUT_POWER2: number;
  57338. /** Packer Layout Constant 2 */
  57339. static readonly LAYOUT_COLNUM: number;
  57340. /** Packer Layout Constant 0 */
  57341. static readonly SUBUV_WRAP: number;
  57342. /** Packer Layout Constant 1 */
  57343. static readonly SUBUV_EXTEND: number;
  57344. /** Packer Layout Constant 2 */
  57345. static readonly SUBUV_COLOR: number;
  57346. /** The Name of the Texture Package */
  57347. name: string;
  57348. /** The scene scope of the TexturePacker */
  57349. scene: Scene;
  57350. /** The Meshes to target */
  57351. meshes: AbstractMesh[];
  57352. /** Arguments passed with the Constructor */
  57353. options: ITexturePackerOptions;
  57354. /** The promise that is started upon initialization */
  57355. promise: Nullable<Promise<TexturePacker | string>>;
  57356. /** The Container object for the channel sets that are generated */
  57357. sets: object;
  57358. /** The Container array for the frames that are generated */
  57359. frames: TexturePackerFrame[];
  57360. /** The expected number of textures the system is parsing. */
  57361. private _expecting;
  57362. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57363. private _paddingValue;
  57364. /**
  57365. * Initializes a texture package series from an array of meshes or a single mesh.
  57366. * @param name The name of the package
  57367. * @param meshes The target meshes to compose the package from
  57368. * @param options The arguments that texture packer should follow while building.
  57369. * @param scene The scene which the textures are scoped to.
  57370. * @returns TexturePacker
  57371. */
  57372. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57373. /**
  57374. * Starts the package process
  57375. * @param resolve The promises resolution function
  57376. * @returns TexturePacker
  57377. */
  57378. private _createFrames;
  57379. /**
  57380. * Calculates the Size of the Channel Sets
  57381. * @returns Vector2
  57382. */
  57383. private _calculateSize;
  57384. /**
  57385. * Calculates the UV data for the frames.
  57386. * @param baseSize the base frameSize
  57387. * @param padding the base frame padding
  57388. * @param dtSize size of the Dynamic Texture for that channel
  57389. * @param dtUnits is 1/dtSize
  57390. * @param update flag to update the input meshes
  57391. */
  57392. private _calculateMeshUVFrames;
  57393. /**
  57394. * Calculates the frames Offset.
  57395. * @param index of the frame
  57396. * @returns Vector2
  57397. */
  57398. private _getFrameOffset;
  57399. /**
  57400. * Updates a Mesh to the frame data
  57401. * @param mesh that is the target
  57402. * @param frameID or the frame index
  57403. */
  57404. private _updateMeshUV;
  57405. /**
  57406. * Updates a Meshes materials to use the texture packer channels
  57407. * @param m is the mesh to target
  57408. * @param force all channels on the packer to be set.
  57409. */
  57410. private _updateTextureReferences;
  57411. /**
  57412. * Public method to set a Mesh to a frame
  57413. * @param m that is the target
  57414. * @param frameID or the frame index
  57415. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57416. */
  57417. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57418. /**
  57419. * Starts the async promise to compile the texture packer.
  57420. * @returns Promise<void>
  57421. */
  57422. processAsync(): Promise<void>;
  57423. /**
  57424. * Disposes all textures associated with this packer
  57425. */
  57426. dispose(): void;
  57427. /**
  57428. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57429. * @param imageType is the image type to use.
  57430. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57431. */
  57432. download(imageType?: string, quality?: number): void;
  57433. /**
  57434. * Public method to load a texturePacker JSON file.
  57435. * @param data of the JSON file in string format.
  57436. */
  57437. updateFromJSON(data: string): void;
  57438. }
  57439. }
  57440. declare module BABYLON {
  57441. /**
  57442. * Enum used to define the target of a block
  57443. */
  57444. export enum NodeMaterialBlockTargets {
  57445. /** Vertex shader */
  57446. Vertex = 1,
  57447. /** Fragment shader */
  57448. Fragment = 2,
  57449. /** Neutral */
  57450. Neutral = 4,
  57451. /** Vertex and Fragment */
  57452. VertexAndFragment = 3
  57453. }
  57454. }
  57455. declare module BABYLON {
  57456. /**
  57457. * Defines the kind of connection point for node based material
  57458. */
  57459. export enum NodeMaterialBlockConnectionPointTypes {
  57460. /** Float */
  57461. Float = 1,
  57462. /** Int */
  57463. Int = 2,
  57464. /** Vector2 */
  57465. Vector2 = 4,
  57466. /** Vector3 */
  57467. Vector3 = 8,
  57468. /** Vector4 */
  57469. Vector4 = 16,
  57470. /** Color3 */
  57471. Color3 = 32,
  57472. /** Color4 */
  57473. Color4 = 64,
  57474. /** Matrix */
  57475. Matrix = 128,
  57476. /** Detect type based on connection */
  57477. AutoDetect = 1024,
  57478. /** Output type that will be defined by input type */
  57479. BasedOnInput = 2048
  57480. }
  57481. }
  57482. declare module BABYLON {
  57483. /**
  57484. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57485. */
  57486. export enum NodeMaterialBlockConnectionPointMode {
  57487. /** Value is an uniform */
  57488. Uniform = 0,
  57489. /** Value is a mesh attribute */
  57490. Attribute = 1,
  57491. /** Value is a varying between vertex and fragment shaders */
  57492. Varying = 2,
  57493. /** Mode is undefined */
  57494. Undefined = 3
  57495. }
  57496. }
  57497. declare module BABYLON {
  57498. /**
  57499. * Enum used to define system values e.g. values automatically provided by the system
  57500. */
  57501. export enum NodeMaterialSystemValues {
  57502. /** World */
  57503. World = 1,
  57504. /** View */
  57505. View = 2,
  57506. /** Projection */
  57507. Projection = 3,
  57508. /** ViewProjection */
  57509. ViewProjection = 4,
  57510. /** WorldView */
  57511. WorldView = 5,
  57512. /** WorldViewProjection */
  57513. WorldViewProjection = 6,
  57514. /** CameraPosition */
  57515. CameraPosition = 7,
  57516. /** Fog Color */
  57517. FogColor = 8,
  57518. /** Delta time */
  57519. DeltaTime = 9
  57520. }
  57521. }
  57522. declare module BABYLON {
  57523. /**
  57524. * Root class for all node material optimizers
  57525. */
  57526. export class NodeMaterialOptimizer {
  57527. /**
  57528. * Function used to optimize a NodeMaterial graph
  57529. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57530. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57531. */
  57532. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57533. }
  57534. }
  57535. declare module BABYLON {
  57536. /**
  57537. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57538. */
  57539. export class TransformBlock extends NodeMaterialBlock {
  57540. /**
  57541. * Defines the value to use to complement W value to transform it to a Vector4
  57542. */
  57543. complementW: number;
  57544. /**
  57545. * Defines the value to use to complement z value to transform it to a Vector4
  57546. */
  57547. complementZ: number;
  57548. /**
  57549. * Creates a new TransformBlock
  57550. * @param name defines the block name
  57551. */
  57552. constructor(name: string);
  57553. /**
  57554. * Gets the current class name
  57555. * @returns the class name
  57556. */
  57557. getClassName(): string;
  57558. /**
  57559. * Gets the vector input
  57560. */
  57561. get vector(): NodeMaterialConnectionPoint;
  57562. /**
  57563. * Gets the output component
  57564. */
  57565. get output(): NodeMaterialConnectionPoint;
  57566. /**
  57567. * Gets the xyz output component
  57568. */
  57569. get xyz(): NodeMaterialConnectionPoint;
  57570. /**
  57571. * Gets the matrix transform input
  57572. */
  57573. get transform(): NodeMaterialConnectionPoint;
  57574. protected _buildBlock(state: NodeMaterialBuildState): this;
  57575. serialize(): any;
  57576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57577. protected _dumpPropertiesCode(): string;
  57578. }
  57579. }
  57580. declare module BABYLON {
  57581. /**
  57582. * Block used to output the vertex position
  57583. */
  57584. export class VertexOutputBlock extends NodeMaterialBlock {
  57585. /**
  57586. * Creates a new VertexOutputBlock
  57587. * @param name defines the block name
  57588. */
  57589. constructor(name: string);
  57590. /**
  57591. * Gets the current class name
  57592. * @returns the class name
  57593. */
  57594. getClassName(): string;
  57595. /**
  57596. * Gets the vector input component
  57597. */
  57598. get vector(): NodeMaterialConnectionPoint;
  57599. protected _buildBlock(state: NodeMaterialBuildState): this;
  57600. }
  57601. }
  57602. declare module BABYLON {
  57603. /**
  57604. * Block used to output the final color
  57605. */
  57606. export class FragmentOutputBlock extends NodeMaterialBlock {
  57607. /**
  57608. * Create a new FragmentOutputBlock
  57609. * @param name defines the block name
  57610. */
  57611. constructor(name: string);
  57612. /**
  57613. * Gets the current class name
  57614. * @returns the class name
  57615. */
  57616. getClassName(): string;
  57617. /**
  57618. * Gets the rgba input component
  57619. */
  57620. get rgba(): NodeMaterialConnectionPoint;
  57621. /**
  57622. * Gets the rgb input component
  57623. */
  57624. get rgb(): NodeMaterialConnectionPoint;
  57625. /**
  57626. * Gets the a input component
  57627. */
  57628. get a(): NodeMaterialConnectionPoint;
  57629. protected _buildBlock(state: NodeMaterialBuildState): this;
  57630. }
  57631. }
  57632. declare module BABYLON {
  57633. /**
  57634. * Block used to read a reflection texture from a sampler
  57635. */
  57636. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57637. private _define3DName;
  57638. private _defineCubicName;
  57639. private _defineExplicitName;
  57640. private _defineProjectionName;
  57641. private _defineLocalCubicName;
  57642. private _defineSphericalName;
  57643. private _definePlanarName;
  57644. private _defineEquirectangularName;
  57645. private _defineMirroredEquirectangularFixedName;
  57646. private _defineEquirectangularFixedName;
  57647. private _defineSkyboxName;
  57648. private _cubeSamplerName;
  57649. private _2DSamplerName;
  57650. private _positionUVWName;
  57651. private _directionWName;
  57652. private _reflectionCoordsName;
  57653. private _reflection2DCoordsName;
  57654. private _reflectionColorName;
  57655. private _reflectionMatrixName;
  57656. /**
  57657. * Gets or sets the texture associated with the node
  57658. */
  57659. texture: Nullable<BaseTexture>;
  57660. /**
  57661. * Create a new TextureBlock
  57662. * @param name defines the block name
  57663. */
  57664. constructor(name: string);
  57665. /**
  57666. * Gets the current class name
  57667. * @returns the class name
  57668. */
  57669. getClassName(): string;
  57670. /**
  57671. * Gets the world position input component
  57672. */
  57673. get position(): NodeMaterialConnectionPoint;
  57674. /**
  57675. * Gets the world position input component
  57676. */
  57677. get worldPosition(): NodeMaterialConnectionPoint;
  57678. /**
  57679. * Gets the world normal input component
  57680. */
  57681. get worldNormal(): NodeMaterialConnectionPoint;
  57682. /**
  57683. * Gets the world input component
  57684. */
  57685. get world(): NodeMaterialConnectionPoint;
  57686. /**
  57687. * Gets the camera (or eye) position component
  57688. */
  57689. get cameraPosition(): NodeMaterialConnectionPoint;
  57690. /**
  57691. * Gets the view input component
  57692. */
  57693. get view(): NodeMaterialConnectionPoint;
  57694. /**
  57695. * Gets the rgb output component
  57696. */
  57697. get rgb(): NodeMaterialConnectionPoint;
  57698. /**
  57699. * Gets the r output component
  57700. */
  57701. get r(): NodeMaterialConnectionPoint;
  57702. /**
  57703. * Gets the g output component
  57704. */
  57705. get g(): NodeMaterialConnectionPoint;
  57706. /**
  57707. * Gets the b output component
  57708. */
  57709. get b(): NodeMaterialConnectionPoint;
  57710. autoConfigure(material: NodeMaterial): void;
  57711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57712. isReady(): boolean;
  57713. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57714. private _injectVertexCode;
  57715. private _writeOutput;
  57716. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57717. protected _dumpPropertiesCode(): string;
  57718. serialize(): any;
  57719. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57720. }
  57721. }
  57722. declare module BABYLON {
  57723. /**
  57724. * Interface used to configure the node material editor
  57725. */
  57726. export interface INodeMaterialEditorOptions {
  57727. /** Define the URl to load node editor script */
  57728. editorURL?: string;
  57729. }
  57730. /** @hidden */
  57731. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57732. NORMAL: boolean;
  57733. TANGENT: boolean;
  57734. UV1: boolean;
  57735. /** BONES */
  57736. NUM_BONE_INFLUENCERS: number;
  57737. BonesPerMesh: number;
  57738. BONETEXTURE: boolean;
  57739. /** MORPH TARGETS */
  57740. MORPHTARGETS: boolean;
  57741. MORPHTARGETS_NORMAL: boolean;
  57742. MORPHTARGETS_TANGENT: boolean;
  57743. MORPHTARGETS_UV: boolean;
  57744. NUM_MORPH_INFLUENCERS: number;
  57745. /** IMAGE PROCESSING */
  57746. IMAGEPROCESSING: boolean;
  57747. VIGNETTE: boolean;
  57748. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57749. VIGNETTEBLENDMODEOPAQUE: boolean;
  57750. TONEMAPPING: boolean;
  57751. TONEMAPPING_ACES: boolean;
  57752. CONTRAST: boolean;
  57753. EXPOSURE: boolean;
  57754. COLORCURVES: boolean;
  57755. COLORGRADING: boolean;
  57756. COLORGRADING3D: boolean;
  57757. SAMPLER3DGREENDEPTH: boolean;
  57758. SAMPLER3DBGRMAP: boolean;
  57759. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57760. /** MISC. */
  57761. BUMPDIRECTUV: number;
  57762. constructor();
  57763. setValue(name: string, value: boolean): void;
  57764. }
  57765. /**
  57766. * Class used to configure NodeMaterial
  57767. */
  57768. export interface INodeMaterialOptions {
  57769. /**
  57770. * Defines if blocks should emit comments
  57771. */
  57772. emitComments: boolean;
  57773. }
  57774. /**
  57775. * Class used to create a node based material built by assembling shader blocks
  57776. */
  57777. export class NodeMaterial extends PushMaterial {
  57778. private static _BuildIdGenerator;
  57779. private _options;
  57780. private _vertexCompilationState;
  57781. private _fragmentCompilationState;
  57782. private _sharedData;
  57783. private _buildId;
  57784. private _buildWasSuccessful;
  57785. private _cachedWorldViewMatrix;
  57786. private _cachedWorldViewProjectionMatrix;
  57787. private _optimizers;
  57788. private _animationFrame;
  57789. /** Define the Url to load node editor script */
  57790. static EditorURL: string;
  57791. /** Define the Url to load snippets */
  57792. static SnippetUrl: string;
  57793. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57794. static IgnoreTexturesAtLoadTime: boolean;
  57795. private BJSNODEMATERIALEDITOR;
  57796. /** Get the inspector from bundle or global */
  57797. private _getGlobalNodeMaterialEditor;
  57798. /**
  57799. * Snippet ID if the material was created from the snippet server
  57800. */
  57801. snippetId: string;
  57802. /**
  57803. * Gets or sets data used by visual editor
  57804. * @see https://nme.babylonjs.com
  57805. */
  57806. editorData: any;
  57807. /**
  57808. * 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)
  57809. */
  57810. ignoreAlpha: boolean;
  57811. /**
  57812. * Defines the maximum number of lights that can be used in the material
  57813. */
  57814. maxSimultaneousLights: number;
  57815. /**
  57816. * Observable raised when the material is built
  57817. */
  57818. onBuildObservable: Observable<NodeMaterial>;
  57819. /**
  57820. * Gets or sets the root nodes of the material vertex shader
  57821. */
  57822. _vertexOutputNodes: NodeMaterialBlock[];
  57823. /**
  57824. * Gets or sets the root nodes of the material fragment (pixel) shader
  57825. */
  57826. _fragmentOutputNodes: NodeMaterialBlock[];
  57827. /** Gets or sets options to control the node material overall behavior */
  57828. get options(): INodeMaterialOptions;
  57829. set options(options: INodeMaterialOptions);
  57830. /**
  57831. * Default configuration related to image processing available in the standard Material.
  57832. */
  57833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57834. /**
  57835. * Gets the image processing configuration used either in this material.
  57836. */
  57837. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57838. /**
  57839. * Sets the Default image processing configuration used either in the this material.
  57840. *
  57841. * If sets to null, the scene one is in use.
  57842. */
  57843. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57844. /**
  57845. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57846. */
  57847. attachedBlocks: NodeMaterialBlock[];
  57848. /**
  57849. * Create a new node based material
  57850. * @param name defines the material name
  57851. * @param scene defines the hosting scene
  57852. * @param options defines creation option
  57853. */
  57854. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57855. /**
  57856. * Gets the current class name of the material e.g. "NodeMaterial"
  57857. * @returns the class name
  57858. */
  57859. getClassName(): string;
  57860. /**
  57861. * Keep track of the image processing observer to allow dispose and replace.
  57862. */
  57863. private _imageProcessingObserver;
  57864. /**
  57865. * Attaches a new image processing configuration to the Standard Material.
  57866. * @param configuration
  57867. */
  57868. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57869. /**
  57870. * Get a block by its name
  57871. * @param name defines the name of the block to retrieve
  57872. * @returns the required block or null if not found
  57873. */
  57874. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57875. /**
  57876. * Get a block by its name
  57877. * @param predicate defines the predicate used to find the good candidate
  57878. * @returns the required block or null if not found
  57879. */
  57880. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57881. /**
  57882. * Get an input block by its name
  57883. * @param predicate defines the predicate used to find the good candidate
  57884. * @returns the required input block or null if not found
  57885. */
  57886. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57887. /**
  57888. * Gets the list of input blocks attached to this material
  57889. * @returns an array of InputBlocks
  57890. */
  57891. getInputBlocks(): InputBlock[];
  57892. /**
  57893. * Adds a new optimizer to the list of optimizers
  57894. * @param optimizer defines the optimizers to add
  57895. * @returns the current material
  57896. */
  57897. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57898. /**
  57899. * Remove an optimizer from the list of optimizers
  57900. * @param optimizer defines the optimizers to remove
  57901. * @returns the current material
  57902. */
  57903. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57904. /**
  57905. * Add a new block to the list of output nodes
  57906. * @param node defines the node to add
  57907. * @returns the current material
  57908. */
  57909. addOutputNode(node: NodeMaterialBlock): this;
  57910. /**
  57911. * Remove a block from the list of root nodes
  57912. * @param node defines the node to remove
  57913. * @returns the current material
  57914. */
  57915. removeOutputNode(node: NodeMaterialBlock): this;
  57916. private _addVertexOutputNode;
  57917. private _removeVertexOutputNode;
  57918. private _addFragmentOutputNode;
  57919. private _removeFragmentOutputNode;
  57920. /**
  57921. * Specifies if the material will require alpha blending
  57922. * @returns a boolean specifying if alpha blending is needed
  57923. */
  57924. needAlphaBlending(): boolean;
  57925. /**
  57926. * Specifies if this material should be rendered in alpha test mode
  57927. * @returns a boolean specifying if an alpha test is needed.
  57928. */
  57929. needAlphaTesting(): boolean;
  57930. private _initializeBlock;
  57931. private _resetDualBlocks;
  57932. /**
  57933. * Remove a block from the current node material
  57934. * @param block defines the block to remove
  57935. */
  57936. removeBlock(block: NodeMaterialBlock): void;
  57937. /**
  57938. * Build the material and generates the inner effect
  57939. * @param verbose defines if the build should log activity
  57940. */
  57941. build(verbose?: boolean): void;
  57942. /**
  57943. * Runs an otpimization phase to try to improve the shader code
  57944. */
  57945. optimize(): void;
  57946. private _prepareDefinesForAttributes;
  57947. /**
  57948. * Get if the submesh is ready to be used and all its information available.
  57949. * Child classes can use it to update shaders
  57950. * @param mesh defines the mesh to check
  57951. * @param subMesh defines which submesh to check
  57952. * @param useInstances specifies that instances should be used
  57953. * @returns a boolean indicating that the submesh is ready or not
  57954. */
  57955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57956. /**
  57957. * Get a string representing the shaders built by the current node graph
  57958. */
  57959. get compiledShaders(): string;
  57960. /**
  57961. * Binds the world matrix to the material
  57962. * @param world defines the world transformation matrix
  57963. */
  57964. bindOnlyWorldMatrix(world: Matrix): void;
  57965. /**
  57966. * Binds the submesh to this material by preparing the effect and shader to draw
  57967. * @param world defines the world transformation matrix
  57968. * @param mesh defines the mesh containing the submesh
  57969. * @param subMesh defines the submesh to bind the material to
  57970. */
  57971. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57972. /**
  57973. * Gets the active textures from the material
  57974. * @returns an array of textures
  57975. */
  57976. getActiveTextures(): BaseTexture[];
  57977. /**
  57978. * Gets the list of texture blocks
  57979. * @returns an array of texture blocks
  57980. */
  57981. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57982. /**
  57983. * Specifies if the material uses a texture
  57984. * @param texture defines the texture to check against the material
  57985. * @returns a boolean specifying if the material uses the texture
  57986. */
  57987. hasTexture(texture: BaseTexture): boolean;
  57988. /**
  57989. * Disposes the material
  57990. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57991. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57992. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57993. */
  57994. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57995. /** Creates the node editor window. */
  57996. private _createNodeEditor;
  57997. /**
  57998. * Launch the node material editor
  57999. * @param config Define the configuration of the editor
  58000. * @return a promise fulfilled when the node editor is visible
  58001. */
  58002. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58003. /**
  58004. * Clear the current material
  58005. */
  58006. clear(): void;
  58007. /**
  58008. * Clear the current material and set it to a default state
  58009. */
  58010. setToDefault(): void;
  58011. /**
  58012. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58013. * @param url defines the url to load from
  58014. * @returns a promise that will fullfil when the material is fully loaded
  58015. */
  58016. loadAsync(url: string): Promise<void>;
  58017. private _gatherBlocks;
  58018. /**
  58019. * Generate a string containing the code declaration required to create an equivalent of this material
  58020. * @returns a string
  58021. */
  58022. generateCode(): string;
  58023. /**
  58024. * Serializes this material in a JSON representation
  58025. * @returns the serialized material object
  58026. */
  58027. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58028. private _restoreConnections;
  58029. /**
  58030. * Clear the current graph and load a new one from a serialization object
  58031. * @param source defines the JSON representation of the material
  58032. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58033. */
  58034. loadFromSerialization(source: any, rootUrl?: string): void;
  58035. /**
  58036. * Makes a duplicate of the current material.
  58037. * @param name - name to use for the new material.
  58038. */
  58039. clone(name: string): NodeMaterial;
  58040. /**
  58041. * Creates a node material from parsed material data
  58042. * @param source defines the JSON representation of the material
  58043. * @param scene defines the hosting scene
  58044. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58045. * @returns a new node material
  58046. */
  58047. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58048. /**
  58049. * Creates a node material from a snippet saved in a remote file
  58050. * @param name defines the name of the material to create
  58051. * @param url defines the url to load from
  58052. * @param scene defines the hosting scene
  58053. * @returns a promise that will resolve to the new node material
  58054. */
  58055. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58056. /**
  58057. * Creates a node material from a snippet saved by the node material editor
  58058. * @param snippetId defines the snippet to load
  58059. * @param scene defines the hosting scene
  58060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58061. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58062. * @returns a promise that will resolve to the new node material
  58063. */
  58064. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58065. /**
  58066. * Creates a new node material set to default basic configuration
  58067. * @param name defines the name of the material
  58068. * @param scene defines the hosting scene
  58069. * @returns a new NodeMaterial
  58070. */
  58071. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58072. }
  58073. }
  58074. declare module BABYLON {
  58075. /**
  58076. * Block used to read a texture from a sampler
  58077. */
  58078. export class TextureBlock extends NodeMaterialBlock {
  58079. private _defineName;
  58080. private _linearDefineName;
  58081. private _tempTextureRead;
  58082. private _samplerName;
  58083. private _transformedUVName;
  58084. private _textureTransformName;
  58085. private _textureInfoName;
  58086. private _mainUVName;
  58087. private _mainUVDefineName;
  58088. /**
  58089. * Gets or sets the texture associated with the node
  58090. */
  58091. texture: Nullable<Texture>;
  58092. /**
  58093. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58094. */
  58095. convertToGammaSpace: boolean;
  58096. /**
  58097. * Create a new TextureBlock
  58098. * @param name defines the block name
  58099. */
  58100. constructor(name: string);
  58101. /**
  58102. * Gets the current class name
  58103. * @returns the class name
  58104. */
  58105. getClassName(): string;
  58106. /**
  58107. * Gets the uv input component
  58108. */
  58109. get uv(): NodeMaterialConnectionPoint;
  58110. /**
  58111. * Gets the rgba output component
  58112. */
  58113. get rgba(): NodeMaterialConnectionPoint;
  58114. /**
  58115. * Gets the rgb output component
  58116. */
  58117. get rgb(): NodeMaterialConnectionPoint;
  58118. /**
  58119. * Gets the r output component
  58120. */
  58121. get r(): NodeMaterialConnectionPoint;
  58122. /**
  58123. * Gets the g output component
  58124. */
  58125. get g(): NodeMaterialConnectionPoint;
  58126. /**
  58127. * Gets the b output component
  58128. */
  58129. get b(): NodeMaterialConnectionPoint;
  58130. /**
  58131. * Gets the a output component
  58132. */
  58133. get a(): NodeMaterialConnectionPoint;
  58134. get target(): NodeMaterialBlockTargets;
  58135. autoConfigure(material: NodeMaterial): void;
  58136. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58138. isReady(): boolean;
  58139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58140. private get _isMixed();
  58141. private _injectVertexCode;
  58142. private _writeTextureRead;
  58143. private _writeOutput;
  58144. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58145. protected _dumpPropertiesCode(): string;
  58146. serialize(): any;
  58147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58148. }
  58149. }
  58150. declare module BABYLON {
  58151. /**
  58152. * Class used to store shared data between 2 NodeMaterialBuildState
  58153. */
  58154. export class NodeMaterialBuildStateSharedData {
  58155. /**
  58156. * Gets the list of emitted varyings
  58157. */
  58158. temps: string[];
  58159. /**
  58160. * Gets the list of emitted varyings
  58161. */
  58162. varyings: string[];
  58163. /**
  58164. * Gets the varying declaration string
  58165. */
  58166. varyingDeclaration: string;
  58167. /**
  58168. * Input blocks
  58169. */
  58170. inputBlocks: InputBlock[];
  58171. /**
  58172. * Input blocks
  58173. */
  58174. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58175. /**
  58176. * Bindable blocks (Blocks that need to set data to the effect)
  58177. */
  58178. bindableBlocks: NodeMaterialBlock[];
  58179. /**
  58180. * List of blocks that can provide a compilation fallback
  58181. */
  58182. blocksWithFallbacks: NodeMaterialBlock[];
  58183. /**
  58184. * List of blocks that can provide a define update
  58185. */
  58186. blocksWithDefines: NodeMaterialBlock[];
  58187. /**
  58188. * List of blocks that can provide a repeatable content
  58189. */
  58190. repeatableContentBlocks: NodeMaterialBlock[];
  58191. /**
  58192. * List of blocks that can provide a dynamic list of uniforms
  58193. */
  58194. dynamicUniformBlocks: NodeMaterialBlock[];
  58195. /**
  58196. * List of blocks that can block the isReady function for the material
  58197. */
  58198. blockingBlocks: NodeMaterialBlock[];
  58199. /**
  58200. * Gets the list of animated inputs
  58201. */
  58202. animatedInputs: InputBlock[];
  58203. /**
  58204. * Build Id used to avoid multiple recompilations
  58205. */
  58206. buildId: number;
  58207. /** List of emitted variables */
  58208. variableNames: {
  58209. [key: string]: number;
  58210. };
  58211. /** List of emitted defines */
  58212. defineNames: {
  58213. [key: string]: number;
  58214. };
  58215. /** Should emit comments? */
  58216. emitComments: boolean;
  58217. /** Emit build activity */
  58218. verbose: boolean;
  58219. /** Gets or sets the hosting scene */
  58220. scene: Scene;
  58221. /**
  58222. * Gets the compilation hints emitted at compilation time
  58223. */
  58224. hints: {
  58225. needWorldViewMatrix: boolean;
  58226. needWorldViewProjectionMatrix: boolean;
  58227. needAlphaBlending: boolean;
  58228. needAlphaTesting: boolean;
  58229. };
  58230. /**
  58231. * List of compilation checks
  58232. */
  58233. checks: {
  58234. emitVertex: boolean;
  58235. emitFragment: boolean;
  58236. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58237. };
  58238. /** Creates a new shared data */
  58239. constructor();
  58240. /**
  58241. * Emits console errors and exceptions if there is a failing check
  58242. */
  58243. emitErrors(): void;
  58244. }
  58245. }
  58246. declare module BABYLON {
  58247. /**
  58248. * Class used to store node based material build state
  58249. */
  58250. export class NodeMaterialBuildState {
  58251. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58252. supportUniformBuffers: boolean;
  58253. /**
  58254. * Gets the list of emitted attributes
  58255. */
  58256. attributes: string[];
  58257. /**
  58258. * Gets the list of emitted uniforms
  58259. */
  58260. uniforms: string[];
  58261. /**
  58262. * Gets the list of emitted constants
  58263. */
  58264. constants: string[];
  58265. /**
  58266. * Gets the list of emitted samplers
  58267. */
  58268. samplers: string[];
  58269. /**
  58270. * Gets the list of emitted functions
  58271. */
  58272. functions: {
  58273. [key: string]: string;
  58274. };
  58275. /**
  58276. * Gets the list of emitted extensions
  58277. */
  58278. extensions: {
  58279. [key: string]: string;
  58280. };
  58281. /**
  58282. * Gets the target of the compilation state
  58283. */
  58284. target: NodeMaterialBlockTargets;
  58285. /**
  58286. * Gets the list of emitted counters
  58287. */
  58288. counters: {
  58289. [key: string]: number;
  58290. };
  58291. /**
  58292. * Shared data between multiple NodeMaterialBuildState instances
  58293. */
  58294. sharedData: NodeMaterialBuildStateSharedData;
  58295. /** @hidden */
  58296. _vertexState: NodeMaterialBuildState;
  58297. /** @hidden */
  58298. _attributeDeclaration: string;
  58299. /** @hidden */
  58300. _uniformDeclaration: string;
  58301. /** @hidden */
  58302. _constantDeclaration: string;
  58303. /** @hidden */
  58304. _samplerDeclaration: string;
  58305. /** @hidden */
  58306. _varyingTransfer: string;
  58307. private _repeatableContentAnchorIndex;
  58308. /** @hidden */
  58309. _builtCompilationString: string;
  58310. /**
  58311. * Gets the emitted compilation strings
  58312. */
  58313. compilationString: string;
  58314. /**
  58315. * Finalize the compilation strings
  58316. * @param state defines the current compilation state
  58317. */
  58318. finalize(state: NodeMaterialBuildState): void;
  58319. /** @hidden */
  58320. get _repeatableContentAnchor(): string;
  58321. /** @hidden */
  58322. _getFreeVariableName(prefix: string): string;
  58323. /** @hidden */
  58324. _getFreeDefineName(prefix: string): string;
  58325. /** @hidden */
  58326. _excludeVariableName(name: string): void;
  58327. /** @hidden */
  58328. _emit2DSampler(name: string): void;
  58329. /** @hidden */
  58330. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58331. /** @hidden */
  58332. _emitExtension(name: string, extension: string): void;
  58333. /** @hidden */
  58334. _emitFunction(name: string, code: string, comments: string): void;
  58335. /** @hidden */
  58336. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58337. replaceStrings?: {
  58338. search: RegExp;
  58339. replace: string;
  58340. }[];
  58341. repeatKey?: string;
  58342. }): string;
  58343. /** @hidden */
  58344. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58345. repeatKey?: string;
  58346. removeAttributes?: boolean;
  58347. removeUniforms?: boolean;
  58348. removeVaryings?: boolean;
  58349. removeIfDef?: boolean;
  58350. replaceStrings?: {
  58351. search: RegExp;
  58352. replace: string;
  58353. }[];
  58354. }, storeKey?: string): void;
  58355. /** @hidden */
  58356. _registerTempVariable(name: string): boolean;
  58357. /** @hidden */
  58358. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58359. /** @hidden */
  58360. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58361. /** @hidden */
  58362. _emitFloat(value: number): string;
  58363. }
  58364. }
  58365. declare module BABYLON {
  58366. /**
  58367. * Defines a block that can be used inside a node based material
  58368. */
  58369. export class NodeMaterialBlock {
  58370. private _buildId;
  58371. private _buildTarget;
  58372. private _target;
  58373. private _isFinalMerger;
  58374. private _isInput;
  58375. protected _isUnique: boolean;
  58376. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58377. inputsAreExclusive: boolean;
  58378. /** @hidden */
  58379. _codeVariableName: string;
  58380. /** @hidden */
  58381. _inputs: NodeMaterialConnectionPoint[];
  58382. /** @hidden */
  58383. _outputs: NodeMaterialConnectionPoint[];
  58384. /** @hidden */
  58385. _preparationId: number;
  58386. /**
  58387. * Gets or sets the name of the block
  58388. */
  58389. name: string;
  58390. /**
  58391. * Gets or sets the unique id of the node
  58392. */
  58393. uniqueId: number;
  58394. /**
  58395. * Gets or sets the comments associated with this block
  58396. */
  58397. comments: string;
  58398. /**
  58399. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58400. */
  58401. get isUnique(): boolean;
  58402. /**
  58403. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58404. */
  58405. get isFinalMerger(): boolean;
  58406. /**
  58407. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58408. */
  58409. get isInput(): boolean;
  58410. /**
  58411. * Gets or sets the build Id
  58412. */
  58413. get buildId(): number;
  58414. set buildId(value: number);
  58415. /**
  58416. * Gets or sets the target of the block
  58417. */
  58418. get target(): NodeMaterialBlockTargets;
  58419. set target(value: NodeMaterialBlockTargets);
  58420. /**
  58421. * Gets the list of input points
  58422. */
  58423. get inputs(): NodeMaterialConnectionPoint[];
  58424. /** Gets the list of output points */
  58425. get outputs(): NodeMaterialConnectionPoint[];
  58426. /**
  58427. * Find an input by its name
  58428. * @param name defines the name of the input to look for
  58429. * @returns the input or null if not found
  58430. */
  58431. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58432. /**
  58433. * Find an output by its name
  58434. * @param name defines the name of the outputto look for
  58435. * @returns the output or null if not found
  58436. */
  58437. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58438. /**
  58439. * Creates a new NodeMaterialBlock
  58440. * @param name defines the block name
  58441. * @param target defines the target of that block (Vertex by default)
  58442. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58443. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58444. */
  58445. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58446. /**
  58447. * Initialize the block and prepare the context for build
  58448. * @param state defines the state that will be used for the build
  58449. */
  58450. initialize(state: NodeMaterialBuildState): void;
  58451. /**
  58452. * Bind data to effect. Will only be called for blocks with isBindable === true
  58453. * @param effect defines the effect to bind data to
  58454. * @param nodeMaterial defines the hosting NodeMaterial
  58455. * @param mesh defines the mesh that will be rendered
  58456. */
  58457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58458. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58459. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58460. protected _writeFloat(value: number): string;
  58461. /**
  58462. * Gets the current class name e.g. "NodeMaterialBlock"
  58463. * @returns the class name
  58464. */
  58465. getClassName(): string;
  58466. /**
  58467. * Register a new input. Must be called inside a block constructor
  58468. * @param name defines the connection point name
  58469. * @param type defines the connection point type
  58470. * @param isOptional defines a boolean indicating that this input can be omitted
  58471. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58472. * @returns the current block
  58473. */
  58474. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58475. /**
  58476. * Register a new output. Must be called inside a block constructor
  58477. * @param name defines the connection point name
  58478. * @param type defines the connection point type
  58479. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58480. * @returns the current block
  58481. */
  58482. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58483. /**
  58484. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58485. * @param forOutput defines an optional connection point to check compatibility with
  58486. * @returns the first available input or null
  58487. */
  58488. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58489. /**
  58490. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58491. * @param forBlock defines an optional block to check compatibility with
  58492. * @returns the first available input or null
  58493. */
  58494. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58495. /**
  58496. * Gets the sibling of the given output
  58497. * @param current defines the current output
  58498. * @returns the next output in the list or null
  58499. */
  58500. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58501. /**
  58502. * Connect current block with another block
  58503. * @param other defines the block to connect with
  58504. * @param options define the various options to help pick the right connections
  58505. * @returns the current block
  58506. */
  58507. connectTo(other: NodeMaterialBlock, options?: {
  58508. input?: string;
  58509. output?: string;
  58510. outputSwizzle?: string;
  58511. }): this | undefined;
  58512. protected _buildBlock(state: NodeMaterialBuildState): void;
  58513. /**
  58514. * Add uniforms, samplers and uniform buffers at compilation time
  58515. * @param state defines the state to update
  58516. * @param nodeMaterial defines the node material requesting the update
  58517. * @param defines defines the material defines to update
  58518. * @param uniformBuffers defines the list of uniform buffer names
  58519. */
  58520. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58521. /**
  58522. * Add potential fallbacks if shader compilation fails
  58523. * @param mesh defines the mesh to be rendered
  58524. * @param fallbacks defines the current prioritized list of fallbacks
  58525. */
  58526. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58527. /**
  58528. * Initialize defines for shader compilation
  58529. * @param mesh defines the mesh to be rendered
  58530. * @param nodeMaterial defines the node material requesting the update
  58531. * @param defines defines the material defines to update
  58532. * @param useInstances specifies that instances should be used
  58533. */
  58534. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58535. /**
  58536. * Update defines for shader compilation
  58537. * @param mesh defines the mesh to be rendered
  58538. * @param nodeMaterial defines the node material requesting the update
  58539. * @param defines defines the material defines to update
  58540. * @param useInstances specifies that instances should be used
  58541. */
  58542. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58543. /**
  58544. * Lets the block try to connect some inputs automatically
  58545. * @param material defines the hosting NodeMaterial
  58546. */
  58547. autoConfigure(material: NodeMaterial): void;
  58548. /**
  58549. * Function called when a block is declared as repeatable content generator
  58550. * @param vertexShaderState defines the current compilation state for the vertex shader
  58551. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58552. * @param mesh defines the mesh to be rendered
  58553. * @param defines defines the material defines to update
  58554. */
  58555. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58556. /**
  58557. * Checks if the block is ready
  58558. * @param mesh defines the mesh to be rendered
  58559. * @param nodeMaterial defines the node material requesting the update
  58560. * @param defines defines the material defines to update
  58561. * @param useInstances specifies that instances should be used
  58562. * @returns true if the block is ready
  58563. */
  58564. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58565. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58566. private _processBuild;
  58567. /**
  58568. * Compile the current node and generate the shader code
  58569. * @param state defines the current compilation state (uniforms, samplers, current string)
  58570. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58571. * @returns true if already built
  58572. */
  58573. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58574. protected _inputRename(name: string): string;
  58575. protected _outputRename(name: string): string;
  58576. protected _dumpPropertiesCode(): string;
  58577. /** @hidden */
  58578. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58579. /** @hidden */
  58580. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58581. /**
  58582. * Clone the current block to a new identical block
  58583. * @param scene defines the hosting scene
  58584. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58585. * @returns a copy of the current block
  58586. */
  58587. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58588. /**
  58589. * Serializes this block in a JSON representation
  58590. * @returns the serialized block object
  58591. */
  58592. serialize(): any;
  58593. /** @hidden */
  58594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58595. /**
  58596. * Release resources
  58597. */
  58598. dispose(): void;
  58599. }
  58600. }
  58601. declare module BABYLON {
  58602. /**
  58603. * Enum defining the type of animations supported by InputBlock
  58604. */
  58605. export enum AnimatedInputBlockTypes {
  58606. /** No animation */
  58607. None = 0,
  58608. /** Time based animation. Will only work for floats */
  58609. Time = 1
  58610. }
  58611. }
  58612. declare module BABYLON {
  58613. /**
  58614. * Block used to expose an input value
  58615. */
  58616. export class InputBlock extends NodeMaterialBlock {
  58617. private _mode;
  58618. private _associatedVariableName;
  58619. private _storedValue;
  58620. private _valueCallback;
  58621. private _type;
  58622. private _animationType;
  58623. /** Gets or set a value used to limit the range of float values */
  58624. min: number;
  58625. /** Gets or set a value used to limit the range of float values */
  58626. max: number;
  58627. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58628. isBoolean: boolean;
  58629. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58630. matrixMode: number;
  58631. /** @hidden */
  58632. _systemValue: Nullable<NodeMaterialSystemValues>;
  58633. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58634. visibleInInspector: boolean;
  58635. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58636. isConstant: boolean;
  58637. /** Gets or sets the group to use to display this block in the Inspector */
  58638. groupInInspector: string;
  58639. /** Gets an observable raised when the value is changed */
  58640. onValueChangedObservable: Observable<InputBlock>;
  58641. /**
  58642. * Gets or sets the connection point type (default is float)
  58643. */
  58644. get type(): NodeMaterialBlockConnectionPointTypes;
  58645. /**
  58646. * Creates a new InputBlock
  58647. * @param name defines the block name
  58648. * @param target defines the target of that block (Vertex by default)
  58649. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58650. */
  58651. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58652. /**
  58653. * Gets the output component
  58654. */
  58655. get output(): NodeMaterialConnectionPoint;
  58656. /**
  58657. * Set the source of this connection point to a vertex attribute
  58658. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58659. * @returns the current connection point
  58660. */
  58661. setAsAttribute(attributeName?: string): InputBlock;
  58662. /**
  58663. * Set the source of this connection point to a system value
  58664. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58665. * @returns the current connection point
  58666. */
  58667. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58668. /**
  58669. * Gets or sets the value of that point.
  58670. * Please note that this value will be ignored if valueCallback is defined
  58671. */
  58672. get value(): any;
  58673. set value(value: any);
  58674. /**
  58675. * Gets or sets a callback used to get the value of that point.
  58676. * Please note that setting this value will force the connection point to ignore the value property
  58677. */
  58678. get valueCallback(): () => any;
  58679. set valueCallback(value: () => any);
  58680. /**
  58681. * Gets or sets the associated variable name in the shader
  58682. */
  58683. get associatedVariableName(): string;
  58684. set associatedVariableName(value: string);
  58685. /** Gets or sets the type of animation applied to the input */
  58686. get animationType(): AnimatedInputBlockTypes;
  58687. set animationType(value: AnimatedInputBlockTypes);
  58688. /**
  58689. * Gets a boolean indicating that this connection point not defined yet
  58690. */
  58691. get isUndefined(): boolean;
  58692. /**
  58693. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58694. * In this case the connection point name must be the name of the uniform to use.
  58695. * Can only be set on inputs
  58696. */
  58697. get isUniform(): boolean;
  58698. set isUniform(value: boolean);
  58699. /**
  58700. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58701. * In this case the connection point name must be the name of the attribute to use
  58702. * Can only be set on inputs
  58703. */
  58704. get isAttribute(): boolean;
  58705. set isAttribute(value: boolean);
  58706. /**
  58707. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58708. * Can only be set on exit points
  58709. */
  58710. get isVarying(): boolean;
  58711. set isVarying(value: boolean);
  58712. /**
  58713. * Gets a boolean indicating that the current connection point is a system value
  58714. */
  58715. get isSystemValue(): boolean;
  58716. /**
  58717. * Gets or sets the current well known value or null if not defined as a system value
  58718. */
  58719. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58720. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58721. /**
  58722. * Gets the current class name
  58723. * @returns the class name
  58724. */
  58725. getClassName(): string;
  58726. /**
  58727. * Animate the input if animationType !== None
  58728. * @param scene defines the rendering scene
  58729. */
  58730. animate(scene: Scene): void;
  58731. private _emitDefine;
  58732. initialize(state: NodeMaterialBuildState): void;
  58733. /**
  58734. * Set the input block to its default value (based on its type)
  58735. */
  58736. setDefaultValue(): void;
  58737. private _emitConstant;
  58738. private _emit;
  58739. /** @hidden */
  58740. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58741. /** @hidden */
  58742. _transmit(effect: Effect, scene: Scene): void;
  58743. protected _buildBlock(state: NodeMaterialBuildState): void;
  58744. protected _dumpPropertiesCode(): string;
  58745. dispose(): void;
  58746. serialize(): any;
  58747. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58748. }
  58749. }
  58750. declare module BABYLON {
  58751. /**
  58752. * Enum used to define the compatibility state between two connection points
  58753. */
  58754. export enum NodeMaterialConnectionPointCompatibilityStates {
  58755. /** Points are compatibles */
  58756. Compatible = 0,
  58757. /** Points are incompatible because of their types */
  58758. TypeIncompatible = 1,
  58759. /** Points are incompatible because of their targets (vertex vs fragment) */
  58760. TargetIncompatible = 2
  58761. }
  58762. /**
  58763. * Defines the direction of a connection point
  58764. */
  58765. export enum NodeMaterialConnectionPointDirection {
  58766. /** Input */
  58767. Input = 0,
  58768. /** Output */
  58769. Output = 1
  58770. }
  58771. /**
  58772. * Defines a connection point for a block
  58773. */
  58774. export class NodeMaterialConnectionPoint {
  58775. /** @hidden */
  58776. _ownerBlock: NodeMaterialBlock;
  58777. /** @hidden */
  58778. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58779. private _endpoints;
  58780. private _associatedVariableName;
  58781. private _direction;
  58782. /** @hidden */
  58783. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58784. /** @hidden */
  58785. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58786. private _type;
  58787. /** @hidden */
  58788. _enforceAssociatedVariableName: boolean;
  58789. /** Gets the direction of the point */
  58790. get direction(): NodeMaterialConnectionPointDirection;
  58791. /**
  58792. * Gets or sets the additional types supported by this connection point
  58793. */
  58794. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58795. /**
  58796. * Gets or sets the additional types excluded by this connection point
  58797. */
  58798. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58799. /**
  58800. * Observable triggered when this point is connected
  58801. */
  58802. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58803. /**
  58804. * Gets or sets the associated variable name in the shader
  58805. */
  58806. get associatedVariableName(): string;
  58807. set associatedVariableName(value: string);
  58808. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58809. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58810. /**
  58811. * Gets or sets the connection point type (default is float)
  58812. */
  58813. get type(): NodeMaterialBlockConnectionPointTypes;
  58814. set type(value: NodeMaterialBlockConnectionPointTypes);
  58815. /**
  58816. * Gets or sets the connection point name
  58817. */
  58818. name: string;
  58819. /**
  58820. * Gets or sets a boolean indicating that this connection point can be omitted
  58821. */
  58822. isOptional: boolean;
  58823. /**
  58824. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58825. */
  58826. define: string;
  58827. /** @hidden */
  58828. _prioritizeVertex: boolean;
  58829. private _target;
  58830. /** Gets or sets the target of that connection point */
  58831. get target(): NodeMaterialBlockTargets;
  58832. set target(value: NodeMaterialBlockTargets);
  58833. /**
  58834. * Gets a boolean indicating that the current point is connected
  58835. */
  58836. get isConnected(): boolean;
  58837. /**
  58838. * Gets a boolean indicating that the current point is connected to an input block
  58839. */
  58840. get isConnectedToInputBlock(): boolean;
  58841. /**
  58842. * Gets a the connected input block (if any)
  58843. */
  58844. get connectInputBlock(): Nullable<InputBlock>;
  58845. /** Get the other side of the connection (if any) */
  58846. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58847. /** Get the block that owns this connection point */
  58848. get ownerBlock(): NodeMaterialBlock;
  58849. /** Get the block connected on the other side of this connection (if any) */
  58850. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58851. /** Get the block connected on the endpoints of this connection (if any) */
  58852. get connectedBlocks(): Array<NodeMaterialBlock>;
  58853. /** Gets the list of connected endpoints */
  58854. get endpoints(): NodeMaterialConnectionPoint[];
  58855. /** Gets a boolean indicating if that output point is connected to at least one input */
  58856. get hasEndpoints(): boolean;
  58857. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58858. get isConnectedInVertexShader(): boolean;
  58859. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58860. get isConnectedInFragmentShader(): boolean;
  58861. /**
  58862. * Creates a new connection point
  58863. * @param name defines the connection point name
  58864. * @param ownerBlock defines the block hosting this connection point
  58865. * @param direction defines the direction of the connection point
  58866. */
  58867. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58868. /**
  58869. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58870. * @returns the class name
  58871. */
  58872. getClassName(): string;
  58873. /**
  58874. * Gets a boolean indicating if the current point can be connected to another point
  58875. * @param connectionPoint defines the other connection point
  58876. * @returns a boolean
  58877. */
  58878. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58879. /**
  58880. * Gets a number indicating if the current point can be connected to another point
  58881. * @param connectionPoint defines the other connection point
  58882. * @returns a number defining the compatibility state
  58883. */
  58884. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58885. /**
  58886. * Connect this point to another connection point
  58887. * @param connectionPoint defines the other connection point
  58888. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58889. * @returns the current connection point
  58890. */
  58891. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58892. /**
  58893. * Disconnect this point from one of his endpoint
  58894. * @param endpoint defines the other connection point
  58895. * @returns the current connection point
  58896. */
  58897. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58898. /**
  58899. * Serializes this point in a JSON representation
  58900. * @returns the serialized point object
  58901. */
  58902. serialize(): any;
  58903. /**
  58904. * Release resources
  58905. */
  58906. dispose(): void;
  58907. }
  58908. }
  58909. declare module BABYLON {
  58910. /**
  58911. * Block used to add support for vertex skinning (bones)
  58912. */
  58913. export class BonesBlock extends NodeMaterialBlock {
  58914. /**
  58915. * Creates a new BonesBlock
  58916. * @param name defines the block name
  58917. */
  58918. constructor(name: string);
  58919. /**
  58920. * Initialize the block and prepare the context for build
  58921. * @param state defines the state that will be used for the build
  58922. */
  58923. initialize(state: NodeMaterialBuildState): void;
  58924. /**
  58925. * Gets the current class name
  58926. * @returns the class name
  58927. */
  58928. getClassName(): string;
  58929. /**
  58930. * Gets the matrix indices input component
  58931. */
  58932. get matricesIndices(): NodeMaterialConnectionPoint;
  58933. /**
  58934. * Gets the matrix weights input component
  58935. */
  58936. get matricesWeights(): NodeMaterialConnectionPoint;
  58937. /**
  58938. * Gets the extra matrix indices input component
  58939. */
  58940. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58941. /**
  58942. * Gets the extra matrix weights input component
  58943. */
  58944. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58945. /**
  58946. * Gets the world input component
  58947. */
  58948. get world(): NodeMaterialConnectionPoint;
  58949. /**
  58950. * Gets the output component
  58951. */
  58952. get output(): NodeMaterialConnectionPoint;
  58953. autoConfigure(material: NodeMaterial): void;
  58954. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58957. protected _buildBlock(state: NodeMaterialBuildState): this;
  58958. }
  58959. }
  58960. declare module BABYLON {
  58961. /**
  58962. * Block used to add support for instances
  58963. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58964. */
  58965. export class InstancesBlock extends NodeMaterialBlock {
  58966. /**
  58967. * Creates a new InstancesBlock
  58968. * @param name defines the block name
  58969. */
  58970. constructor(name: string);
  58971. /**
  58972. * Gets the current class name
  58973. * @returns the class name
  58974. */
  58975. getClassName(): string;
  58976. /**
  58977. * Gets the first world row input component
  58978. */
  58979. get world0(): NodeMaterialConnectionPoint;
  58980. /**
  58981. * Gets the second world row input component
  58982. */
  58983. get world1(): NodeMaterialConnectionPoint;
  58984. /**
  58985. * Gets the third world row input component
  58986. */
  58987. get world2(): NodeMaterialConnectionPoint;
  58988. /**
  58989. * Gets the forth world row input component
  58990. */
  58991. get world3(): NodeMaterialConnectionPoint;
  58992. /**
  58993. * Gets the world input component
  58994. */
  58995. get world(): NodeMaterialConnectionPoint;
  58996. /**
  58997. * Gets the output component
  58998. */
  58999. get output(): NodeMaterialConnectionPoint;
  59000. /**
  59001. * Gets the isntanceID component
  59002. */
  59003. get instanceID(): NodeMaterialConnectionPoint;
  59004. autoConfigure(material: NodeMaterial): void;
  59005. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59006. protected _buildBlock(state: NodeMaterialBuildState): this;
  59007. }
  59008. }
  59009. declare module BABYLON {
  59010. /**
  59011. * Block used to add morph targets support to vertex shader
  59012. */
  59013. export class MorphTargetsBlock extends NodeMaterialBlock {
  59014. private _repeatableContentAnchor;
  59015. /**
  59016. * Create a new MorphTargetsBlock
  59017. * @param name defines the block name
  59018. */
  59019. constructor(name: string);
  59020. /**
  59021. * Gets the current class name
  59022. * @returns the class name
  59023. */
  59024. getClassName(): string;
  59025. /**
  59026. * Gets the position input component
  59027. */
  59028. get position(): NodeMaterialConnectionPoint;
  59029. /**
  59030. * Gets the normal input component
  59031. */
  59032. get normal(): NodeMaterialConnectionPoint;
  59033. /**
  59034. * Gets the tangent input component
  59035. */
  59036. get tangent(): NodeMaterialConnectionPoint;
  59037. /**
  59038. * Gets the tangent input component
  59039. */
  59040. get uv(): NodeMaterialConnectionPoint;
  59041. /**
  59042. * Gets the position output component
  59043. */
  59044. get positionOutput(): NodeMaterialConnectionPoint;
  59045. /**
  59046. * Gets the normal output component
  59047. */
  59048. get normalOutput(): NodeMaterialConnectionPoint;
  59049. /**
  59050. * Gets the tangent output component
  59051. */
  59052. get tangentOutput(): NodeMaterialConnectionPoint;
  59053. /**
  59054. * Gets the tangent output component
  59055. */
  59056. get uvOutput(): NodeMaterialConnectionPoint;
  59057. initialize(state: NodeMaterialBuildState): void;
  59058. autoConfigure(material: NodeMaterial): void;
  59059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59061. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59062. protected _buildBlock(state: NodeMaterialBuildState): this;
  59063. }
  59064. }
  59065. declare module BABYLON {
  59066. /**
  59067. * Block used to get data information from a light
  59068. */
  59069. export class LightInformationBlock extends NodeMaterialBlock {
  59070. private _lightDataUniformName;
  59071. private _lightColorUniformName;
  59072. private _lightTypeDefineName;
  59073. /**
  59074. * Gets or sets the light associated with this block
  59075. */
  59076. light: Nullable<Light>;
  59077. /**
  59078. * Creates a new LightInformationBlock
  59079. * @param name defines the block name
  59080. */
  59081. constructor(name: string);
  59082. /**
  59083. * Gets the current class name
  59084. * @returns the class name
  59085. */
  59086. getClassName(): string;
  59087. /**
  59088. * Gets the world position input component
  59089. */
  59090. get worldPosition(): NodeMaterialConnectionPoint;
  59091. /**
  59092. * Gets the direction output component
  59093. */
  59094. get direction(): NodeMaterialConnectionPoint;
  59095. /**
  59096. * Gets the direction output component
  59097. */
  59098. get color(): NodeMaterialConnectionPoint;
  59099. /**
  59100. * Gets the direction output component
  59101. */
  59102. get intensity(): NodeMaterialConnectionPoint;
  59103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59105. protected _buildBlock(state: NodeMaterialBuildState): this;
  59106. serialize(): any;
  59107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59108. }
  59109. }
  59110. declare module BABYLON {
  59111. /**
  59112. * Block used to add image processing support to fragment shader
  59113. */
  59114. export class ImageProcessingBlock extends NodeMaterialBlock {
  59115. /**
  59116. * Create a new ImageProcessingBlock
  59117. * @param name defines the block name
  59118. */
  59119. constructor(name: string);
  59120. /**
  59121. * Gets the current class name
  59122. * @returns the class name
  59123. */
  59124. getClassName(): string;
  59125. /**
  59126. * Gets the color input component
  59127. */
  59128. get color(): NodeMaterialConnectionPoint;
  59129. /**
  59130. * Gets the output component
  59131. */
  59132. get output(): NodeMaterialConnectionPoint;
  59133. /**
  59134. * Initialize the block and prepare the context for build
  59135. * @param state defines the state that will be used for the build
  59136. */
  59137. initialize(state: NodeMaterialBuildState): void;
  59138. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59141. protected _buildBlock(state: NodeMaterialBuildState): this;
  59142. }
  59143. }
  59144. declare module BABYLON {
  59145. /**
  59146. * Block used to pertub normals based on a normal map
  59147. */
  59148. export class PerturbNormalBlock extends NodeMaterialBlock {
  59149. private _tangentSpaceParameterName;
  59150. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59151. invertX: boolean;
  59152. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59153. invertY: boolean;
  59154. /**
  59155. * Create a new PerturbNormalBlock
  59156. * @param name defines the block name
  59157. */
  59158. constructor(name: string);
  59159. /**
  59160. * Gets the current class name
  59161. * @returns the class name
  59162. */
  59163. getClassName(): string;
  59164. /**
  59165. * Gets the world position input component
  59166. */
  59167. get worldPosition(): NodeMaterialConnectionPoint;
  59168. /**
  59169. * Gets the world normal input component
  59170. */
  59171. get worldNormal(): NodeMaterialConnectionPoint;
  59172. /**
  59173. * Gets the world tangent input component
  59174. */
  59175. get worldTangent(): NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the uv input component
  59178. */
  59179. get uv(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the normal map color input component
  59182. */
  59183. get normalMapColor(): NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the strength input component
  59186. */
  59187. get strength(): NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the output component
  59190. */
  59191. get output(): NodeMaterialConnectionPoint;
  59192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59194. autoConfigure(material: NodeMaterial): void;
  59195. protected _buildBlock(state: NodeMaterialBuildState): this;
  59196. protected _dumpPropertiesCode(): string;
  59197. serialize(): any;
  59198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59199. }
  59200. }
  59201. declare module BABYLON {
  59202. /**
  59203. * Block used to discard a pixel if a value is smaller than a cutoff
  59204. */
  59205. export class DiscardBlock extends NodeMaterialBlock {
  59206. /**
  59207. * Create a new DiscardBlock
  59208. * @param name defines the block name
  59209. */
  59210. constructor(name: string);
  59211. /**
  59212. * Gets the current class name
  59213. * @returns the class name
  59214. */
  59215. getClassName(): string;
  59216. /**
  59217. * Gets the color input component
  59218. */
  59219. get value(): NodeMaterialConnectionPoint;
  59220. /**
  59221. * Gets the cutoff input component
  59222. */
  59223. get cutoff(): NodeMaterialConnectionPoint;
  59224. protected _buildBlock(state: NodeMaterialBuildState): this;
  59225. }
  59226. }
  59227. declare module BABYLON {
  59228. /**
  59229. * Block used to test if the fragment shader is front facing
  59230. */
  59231. export class FrontFacingBlock extends NodeMaterialBlock {
  59232. /**
  59233. * Creates a new FrontFacingBlock
  59234. * @param name defines the block name
  59235. */
  59236. constructor(name: string);
  59237. /**
  59238. * Gets the current class name
  59239. * @returns the class name
  59240. */
  59241. getClassName(): string;
  59242. /**
  59243. * Gets the output component
  59244. */
  59245. get output(): NodeMaterialConnectionPoint;
  59246. protected _buildBlock(state: NodeMaterialBuildState): this;
  59247. }
  59248. }
  59249. declare module BABYLON {
  59250. /**
  59251. * Block used to get the derivative value on x and y of a given input
  59252. */
  59253. export class DerivativeBlock extends NodeMaterialBlock {
  59254. /**
  59255. * Create a new DerivativeBlock
  59256. * @param name defines the block name
  59257. */
  59258. constructor(name: string);
  59259. /**
  59260. * Gets the current class name
  59261. * @returns the class name
  59262. */
  59263. getClassName(): string;
  59264. /**
  59265. * Gets the input component
  59266. */
  59267. get input(): NodeMaterialConnectionPoint;
  59268. /**
  59269. * Gets the derivative output on x
  59270. */
  59271. get dx(): NodeMaterialConnectionPoint;
  59272. /**
  59273. * Gets the derivative output on y
  59274. */
  59275. get dy(): NodeMaterialConnectionPoint;
  59276. protected _buildBlock(state: NodeMaterialBuildState): this;
  59277. }
  59278. }
  59279. declare module BABYLON {
  59280. /**
  59281. * Block used to add support for scene fog
  59282. */
  59283. export class FogBlock extends NodeMaterialBlock {
  59284. private _fogDistanceName;
  59285. private _fogParameters;
  59286. /**
  59287. * Create a new FogBlock
  59288. * @param name defines the block name
  59289. */
  59290. constructor(name: string);
  59291. /**
  59292. * Gets the current class name
  59293. * @returns the class name
  59294. */
  59295. getClassName(): string;
  59296. /**
  59297. * Gets the world position input component
  59298. */
  59299. get worldPosition(): NodeMaterialConnectionPoint;
  59300. /**
  59301. * Gets the view input component
  59302. */
  59303. get view(): NodeMaterialConnectionPoint;
  59304. /**
  59305. * Gets the color input component
  59306. */
  59307. get input(): NodeMaterialConnectionPoint;
  59308. /**
  59309. * Gets the fog color input component
  59310. */
  59311. get fogColor(): NodeMaterialConnectionPoint;
  59312. /**
  59313. * Gets the output component
  59314. */
  59315. get output(): NodeMaterialConnectionPoint;
  59316. autoConfigure(material: NodeMaterial): void;
  59317. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59318. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59319. protected _buildBlock(state: NodeMaterialBuildState): this;
  59320. }
  59321. }
  59322. declare module BABYLON {
  59323. /**
  59324. * Block used to add light in the fragment shader
  59325. */
  59326. export class LightBlock extends NodeMaterialBlock {
  59327. private _lightId;
  59328. /**
  59329. * Gets or sets the light associated with this block
  59330. */
  59331. light: Nullable<Light>;
  59332. /**
  59333. * Create a new LightBlock
  59334. * @param name defines the block name
  59335. */
  59336. constructor(name: string);
  59337. /**
  59338. * Gets the current class name
  59339. * @returns the class name
  59340. */
  59341. getClassName(): string;
  59342. /**
  59343. * Gets the world position input component
  59344. */
  59345. get worldPosition(): NodeMaterialConnectionPoint;
  59346. /**
  59347. * Gets the world normal input component
  59348. */
  59349. get worldNormal(): NodeMaterialConnectionPoint;
  59350. /**
  59351. * Gets the camera (or eye) position component
  59352. */
  59353. get cameraPosition(): NodeMaterialConnectionPoint;
  59354. /**
  59355. * Gets the glossiness component
  59356. */
  59357. get glossiness(): NodeMaterialConnectionPoint;
  59358. /**
  59359. * Gets the glossinness power component
  59360. */
  59361. get glossPower(): NodeMaterialConnectionPoint;
  59362. /**
  59363. * Gets the diffuse color component
  59364. */
  59365. get diffuseColor(): NodeMaterialConnectionPoint;
  59366. /**
  59367. * Gets the specular color component
  59368. */
  59369. get specularColor(): NodeMaterialConnectionPoint;
  59370. /**
  59371. * Gets the diffuse output component
  59372. */
  59373. get diffuseOutput(): NodeMaterialConnectionPoint;
  59374. /**
  59375. * Gets the specular output component
  59376. */
  59377. get specularOutput(): NodeMaterialConnectionPoint;
  59378. /**
  59379. * Gets the shadow output component
  59380. */
  59381. get shadow(): NodeMaterialConnectionPoint;
  59382. autoConfigure(material: NodeMaterial): void;
  59383. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59384. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59385. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59386. private _injectVertexCode;
  59387. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59388. serialize(): any;
  59389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59390. }
  59391. }
  59392. declare module BABYLON {
  59393. /**
  59394. * Block used to multiply 2 values
  59395. */
  59396. export class MultiplyBlock extends NodeMaterialBlock {
  59397. /**
  59398. * Creates a new MultiplyBlock
  59399. * @param name defines the block name
  59400. */
  59401. constructor(name: string);
  59402. /**
  59403. * Gets the current class name
  59404. * @returns the class name
  59405. */
  59406. getClassName(): string;
  59407. /**
  59408. * Gets the left operand input component
  59409. */
  59410. get left(): NodeMaterialConnectionPoint;
  59411. /**
  59412. * Gets the right operand input component
  59413. */
  59414. get right(): NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the output component
  59417. */
  59418. get output(): NodeMaterialConnectionPoint;
  59419. protected _buildBlock(state: NodeMaterialBuildState): this;
  59420. }
  59421. }
  59422. declare module BABYLON {
  59423. /**
  59424. * Block used to add 2 vectors
  59425. */
  59426. export class AddBlock extends NodeMaterialBlock {
  59427. /**
  59428. * Creates a new AddBlock
  59429. * @param name defines the block name
  59430. */
  59431. constructor(name: string);
  59432. /**
  59433. * Gets the current class name
  59434. * @returns the class name
  59435. */
  59436. getClassName(): string;
  59437. /**
  59438. * Gets the left operand input component
  59439. */
  59440. get left(): NodeMaterialConnectionPoint;
  59441. /**
  59442. * Gets the right operand input component
  59443. */
  59444. get right(): NodeMaterialConnectionPoint;
  59445. /**
  59446. * Gets the output component
  59447. */
  59448. get output(): NodeMaterialConnectionPoint;
  59449. protected _buildBlock(state: NodeMaterialBuildState): this;
  59450. }
  59451. }
  59452. declare module BABYLON {
  59453. /**
  59454. * Block used to scale a vector by a float
  59455. */
  59456. export class ScaleBlock extends NodeMaterialBlock {
  59457. /**
  59458. * Creates a new ScaleBlock
  59459. * @param name defines the block name
  59460. */
  59461. constructor(name: string);
  59462. /**
  59463. * Gets the current class name
  59464. * @returns the class name
  59465. */
  59466. getClassName(): string;
  59467. /**
  59468. * Gets the input component
  59469. */
  59470. get input(): NodeMaterialConnectionPoint;
  59471. /**
  59472. * Gets the factor input component
  59473. */
  59474. get factor(): NodeMaterialConnectionPoint;
  59475. /**
  59476. * Gets the output component
  59477. */
  59478. get output(): NodeMaterialConnectionPoint;
  59479. protected _buildBlock(state: NodeMaterialBuildState): this;
  59480. }
  59481. }
  59482. declare module BABYLON {
  59483. /**
  59484. * Block used to clamp a float
  59485. */
  59486. export class ClampBlock extends NodeMaterialBlock {
  59487. /** Gets or sets the minimum range */
  59488. minimum: number;
  59489. /** Gets or sets the maximum range */
  59490. maximum: number;
  59491. /**
  59492. * Creates a new ClampBlock
  59493. * @param name defines the block name
  59494. */
  59495. constructor(name: string);
  59496. /**
  59497. * Gets the current class name
  59498. * @returns the class name
  59499. */
  59500. getClassName(): string;
  59501. /**
  59502. * Gets the value input component
  59503. */
  59504. get value(): NodeMaterialConnectionPoint;
  59505. /**
  59506. * Gets the output component
  59507. */
  59508. get output(): NodeMaterialConnectionPoint;
  59509. protected _buildBlock(state: NodeMaterialBuildState): this;
  59510. protected _dumpPropertiesCode(): string;
  59511. serialize(): any;
  59512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59513. }
  59514. }
  59515. declare module BABYLON {
  59516. /**
  59517. * Block used to apply a cross product between 2 vectors
  59518. */
  59519. export class CrossBlock extends NodeMaterialBlock {
  59520. /**
  59521. * Creates a new CrossBlock
  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 left operand input component
  59532. */
  59533. get left(): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Gets the right operand input component
  59536. */
  59537. get right(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the output component
  59540. */
  59541. get output(): NodeMaterialConnectionPoint;
  59542. protected _buildBlock(state: NodeMaterialBuildState): this;
  59543. }
  59544. }
  59545. declare module BABYLON {
  59546. /**
  59547. * Block used to apply a dot product between 2 vectors
  59548. */
  59549. export class DotBlock extends NodeMaterialBlock {
  59550. /**
  59551. * Creates a new DotBlock
  59552. * @param name defines the block name
  59553. */
  59554. constructor(name: string);
  59555. /**
  59556. * Gets the current class name
  59557. * @returns the class name
  59558. */
  59559. getClassName(): string;
  59560. /**
  59561. * Gets the left operand input component
  59562. */
  59563. get left(): NodeMaterialConnectionPoint;
  59564. /**
  59565. * Gets the right operand input component
  59566. */
  59567. get right(): NodeMaterialConnectionPoint;
  59568. /**
  59569. * Gets the output component
  59570. */
  59571. get output(): NodeMaterialConnectionPoint;
  59572. protected _buildBlock(state: NodeMaterialBuildState): this;
  59573. }
  59574. }
  59575. declare module BABYLON {
  59576. /**
  59577. * Block used to remap a float from a range to a new one
  59578. */
  59579. export class RemapBlock extends NodeMaterialBlock {
  59580. /**
  59581. * Gets or sets the source range
  59582. */
  59583. sourceRange: Vector2;
  59584. /**
  59585. * Gets or sets the target range
  59586. */
  59587. targetRange: Vector2;
  59588. /**
  59589. * Creates a new RemapBlock
  59590. * @param name defines the block name
  59591. */
  59592. constructor(name: string);
  59593. /**
  59594. * Gets the current class name
  59595. * @returns the class name
  59596. */
  59597. getClassName(): string;
  59598. /**
  59599. * Gets the input component
  59600. */
  59601. get input(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the source min input component
  59604. */
  59605. get sourceMin(): NodeMaterialConnectionPoint;
  59606. /**
  59607. * Gets the source max input component
  59608. */
  59609. get sourceMax(): NodeMaterialConnectionPoint;
  59610. /**
  59611. * Gets the target min input component
  59612. */
  59613. get targetMin(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the target max input component
  59616. */
  59617. get targetMax(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the output component
  59620. */
  59621. get output(): NodeMaterialConnectionPoint;
  59622. protected _buildBlock(state: NodeMaterialBuildState): this;
  59623. protected _dumpPropertiesCode(): string;
  59624. serialize(): any;
  59625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59626. }
  59627. }
  59628. declare module BABYLON {
  59629. /**
  59630. * Block used to normalize a vector
  59631. */
  59632. export class NormalizeBlock extends NodeMaterialBlock {
  59633. /**
  59634. * Creates a new NormalizeBlock
  59635. * @param name defines the block name
  59636. */
  59637. constructor(name: string);
  59638. /**
  59639. * Gets the current class name
  59640. * @returns the class name
  59641. */
  59642. getClassName(): string;
  59643. /**
  59644. * Gets the input component
  59645. */
  59646. get input(): NodeMaterialConnectionPoint;
  59647. /**
  59648. * Gets the output component
  59649. */
  59650. get output(): NodeMaterialConnectionPoint;
  59651. protected _buildBlock(state: NodeMaterialBuildState): this;
  59652. }
  59653. }
  59654. declare module BABYLON {
  59655. /**
  59656. * Operations supported by the Trigonometry block
  59657. */
  59658. export enum TrigonometryBlockOperations {
  59659. /** Cos */
  59660. Cos = 0,
  59661. /** Sin */
  59662. Sin = 1,
  59663. /** Abs */
  59664. Abs = 2,
  59665. /** Exp */
  59666. Exp = 3,
  59667. /** Exp2 */
  59668. Exp2 = 4,
  59669. /** Round */
  59670. Round = 5,
  59671. /** Floor */
  59672. Floor = 6,
  59673. /** Ceiling */
  59674. Ceiling = 7,
  59675. /** Square root */
  59676. Sqrt = 8,
  59677. /** Log */
  59678. Log = 9,
  59679. /** Tangent */
  59680. Tan = 10,
  59681. /** Arc tangent */
  59682. ArcTan = 11,
  59683. /** Arc cosinus */
  59684. ArcCos = 12,
  59685. /** Arc sinus */
  59686. ArcSin = 13,
  59687. /** Fraction */
  59688. Fract = 14,
  59689. /** Sign */
  59690. Sign = 15,
  59691. /** To radians (from degrees) */
  59692. Radians = 16,
  59693. /** To degrees (from radians) */
  59694. Degrees = 17
  59695. }
  59696. /**
  59697. * Block used to apply trigonometry operation to floats
  59698. */
  59699. export class TrigonometryBlock extends NodeMaterialBlock {
  59700. /**
  59701. * Gets or sets the operation applied by the block
  59702. */
  59703. operation: TrigonometryBlockOperations;
  59704. /**
  59705. * Creates a new TrigonometryBlock
  59706. * @param name defines the block name
  59707. */
  59708. constructor(name: string);
  59709. /**
  59710. * Gets the current class name
  59711. * @returns the class name
  59712. */
  59713. getClassName(): string;
  59714. /**
  59715. * Gets the input component
  59716. */
  59717. get input(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the output component
  59720. */
  59721. get output(): NodeMaterialConnectionPoint;
  59722. protected _buildBlock(state: NodeMaterialBuildState): this;
  59723. serialize(): any;
  59724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59725. protected _dumpPropertiesCode(): string;
  59726. }
  59727. }
  59728. declare module BABYLON {
  59729. /**
  59730. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59731. */
  59732. export class ColorMergerBlock extends NodeMaterialBlock {
  59733. /**
  59734. * Create a new ColorMergerBlock
  59735. * @param name defines the block name
  59736. */
  59737. constructor(name: string);
  59738. /**
  59739. * Gets the current class name
  59740. * @returns the class name
  59741. */
  59742. getClassName(): string;
  59743. /**
  59744. * Gets the rgb component (input)
  59745. */
  59746. get rgbIn(): NodeMaterialConnectionPoint;
  59747. /**
  59748. * Gets the r component (input)
  59749. */
  59750. get r(): NodeMaterialConnectionPoint;
  59751. /**
  59752. * Gets the g component (input)
  59753. */
  59754. get g(): NodeMaterialConnectionPoint;
  59755. /**
  59756. * Gets the b component (input)
  59757. */
  59758. get b(): NodeMaterialConnectionPoint;
  59759. /**
  59760. * Gets the a component (input)
  59761. */
  59762. get a(): NodeMaterialConnectionPoint;
  59763. /**
  59764. * Gets the rgba component (output)
  59765. */
  59766. get rgba(): NodeMaterialConnectionPoint;
  59767. /**
  59768. * Gets the rgb component (output)
  59769. */
  59770. get rgbOut(): NodeMaterialConnectionPoint;
  59771. /**
  59772. * Gets the rgb component (output)
  59773. * @deprecated Please use rgbOut instead.
  59774. */
  59775. get rgb(): NodeMaterialConnectionPoint;
  59776. protected _buildBlock(state: NodeMaterialBuildState): this;
  59777. }
  59778. }
  59779. declare module BABYLON {
  59780. /**
  59781. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59782. */
  59783. export class VectorMergerBlock extends NodeMaterialBlock {
  59784. /**
  59785. * Create a new VectorMergerBlock
  59786. * @param name defines the block name
  59787. */
  59788. constructor(name: string);
  59789. /**
  59790. * Gets the current class name
  59791. * @returns the class name
  59792. */
  59793. getClassName(): string;
  59794. /**
  59795. * Gets the xyz component (input)
  59796. */
  59797. get xyzIn(): NodeMaterialConnectionPoint;
  59798. /**
  59799. * Gets the xy component (input)
  59800. */
  59801. get xyIn(): NodeMaterialConnectionPoint;
  59802. /**
  59803. * Gets the x component (input)
  59804. */
  59805. get x(): NodeMaterialConnectionPoint;
  59806. /**
  59807. * Gets the y component (input)
  59808. */
  59809. get y(): NodeMaterialConnectionPoint;
  59810. /**
  59811. * Gets the z component (input)
  59812. */
  59813. get z(): NodeMaterialConnectionPoint;
  59814. /**
  59815. * Gets the w component (input)
  59816. */
  59817. get w(): NodeMaterialConnectionPoint;
  59818. /**
  59819. * Gets the xyzw component (output)
  59820. */
  59821. get xyzw(): NodeMaterialConnectionPoint;
  59822. /**
  59823. * Gets the xyz component (output)
  59824. */
  59825. get xyzOut(): NodeMaterialConnectionPoint;
  59826. /**
  59827. * Gets the xy component (output)
  59828. */
  59829. get xyOut(): NodeMaterialConnectionPoint;
  59830. /**
  59831. * Gets the xy component (output)
  59832. * @deprecated Please use xyOut instead.
  59833. */
  59834. get xy(): NodeMaterialConnectionPoint;
  59835. /**
  59836. * Gets the xyz component (output)
  59837. * @deprecated Please use xyzOut instead.
  59838. */
  59839. get xyz(): NodeMaterialConnectionPoint;
  59840. protected _buildBlock(state: NodeMaterialBuildState): this;
  59841. }
  59842. }
  59843. declare module BABYLON {
  59844. /**
  59845. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59846. */
  59847. export class ColorSplitterBlock extends NodeMaterialBlock {
  59848. /**
  59849. * Create a new ColorSplitterBlock
  59850. * @param name defines the block name
  59851. */
  59852. constructor(name: string);
  59853. /**
  59854. * Gets the current class name
  59855. * @returns the class name
  59856. */
  59857. getClassName(): string;
  59858. /**
  59859. * Gets the rgba component (input)
  59860. */
  59861. get rgba(): NodeMaterialConnectionPoint;
  59862. /**
  59863. * Gets the rgb component (input)
  59864. */
  59865. get rgbIn(): NodeMaterialConnectionPoint;
  59866. /**
  59867. * Gets the rgb component (output)
  59868. */
  59869. get rgbOut(): NodeMaterialConnectionPoint;
  59870. /**
  59871. * Gets the r component (output)
  59872. */
  59873. get r(): NodeMaterialConnectionPoint;
  59874. /**
  59875. * Gets the g component (output)
  59876. */
  59877. get g(): NodeMaterialConnectionPoint;
  59878. /**
  59879. * Gets the b component (output)
  59880. */
  59881. get b(): NodeMaterialConnectionPoint;
  59882. /**
  59883. * Gets the a component (output)
  59884. */
  59885. get a(): NodeMaterialConnectionPoint;
  59886. protected _inputRename(name: string): string;
  59887. protected _outputRename(name: string): string;
  59888. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59889. }
  59890. }
  59891. declare module BABYLON {
  59892. /**
  59893. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59894. */
  59895. export class VectorSplitterBlock extends NodeMaterialBlock {
  59896. /**
  59897. * Create a new VectorSplitterBlock
  59898. * @param name defines the block name
  59899. */
  59900. constructor(name: string);
  59901. /**
  59902. * Gets the current class name
  59903. * @returns the class name
  59904. */
  59905. getClassName(): string;
  59906. /**
  59907. * Gets the xyzw component (input)
  59908. */
  59909. get xyzw(): NodeMaterialConnectionPoint;
  59910. /**
  59911. * Gets the xyz component (input)
  59912. */
  59913. get xyzIn(): NodeMaterialConnectionPoint;
  59914. /**
  59915. * Gets the xy component (input)
  59916. */
  59917. get xyIn(): NodeMaterialConnectionPoint;
  59918. /**
  59919. * Gets the xyz component (output)
  59920. */
  59921. get xyzOut(): NodeMaterialConnectionPoint;
  59922. /**
  59923. * Gets the xy component (output)
  59924. */
  59925. get xyOut(): NodeMaterialConnectionPoint;
  59926. /**
  59927. * Gets the x component (output)
  59928. */
  59929. get x(): NodeMaterialConnectionPoint;
  59930. /**
  59931. * Gets the y component (output)
  59932. */
  59933. get y(): NodeMaterialConnectionPoint;
  59934. /**
  59935. * Gets the z component (output)
  59936. */
  59937. get z(): NodeMaterialConnectionPoint;
  59938. /**
  59939. * Gets the w component (output)
  59940. */
  59941. get w(): NodeMaterialConnectionPoint;
  59942. protected _inputRename(name: string): string;
  59943. protected _outputRename(name: string): string;
  59944. protected _buildBlock(state: NodeMaterialBuildState): this;
  59945. }
  59946. }
  59947. declare module BABYLON {
  59948. /**
  59949. * Block used to lerp between 2 values
  59950. */
  59951. export class LerpBlock extends NodeMaterialBlock {
  59952. /**
  59953. * Creates a new LerpBlock
  59954. * @param name defines the block name
  59955. */
  59956. constructor(name: string);
  59957. /**
  59958. * Gets the current class name
  59959. * @returns the class name
  59960. */
  59961. getClassName(): string;
  59962. /**
  59963. * Gets the left operand input component
  59964. */
  59965. get left(): NodeMaterialConnectionPoint;
  59966. /**
  59967. * Gets the right operand input component
  59968. */
  59969. get right(): NodeMaterialConnectionPoint;
  59970. /**
  59971. * Gets the gradient operand input component
  59972. */
  59973. get gradient(): NodeMaterialConnectionPoint;
  59974. /**
  59975. * Gets the output component
  59976. */
  59977. get output(): NodeMaterialConnectionPoint;
  59978. protected _buildBlock(state: NodeMaterialBuildState): this;
  59979. }
  59980. }
  59981. declare module BABYLON {
  59982. /**
  59983. * Block used to divide 2 vectors
  59984. */
  59985. export class DivideBlock extends NodeMaterialBlock {
  59986. /**
  59987. * Creates a new DivideBlock
  59988. * @param name defines the block name
  59989. */
  59990. constructor(name: string);
  59991. /**
  59992. * Gets the current class name
  59993. * @returns the class name
  59994. */
  59995. getClassName(): string;
  59996. /**
  59997. * Gets the left operand input component
  59998. */
  59999. get left(): NodeMaterialConnectionPoint;
  60000. /**
  60001. * Gets the right operand input component
  60002. */
  60003. get right(): NodeMaterialConnectionPoint;
  60004. /**
  60005. * Gets the output component
  60006. */
  60007. get output(): NodeMaterialConnectionPoint;
  60008. protected _buildBlock(state: NodeMaterialBuildState): this;
  60009. }
  60010. }
  60011. declare module BABYLON {
  60012. /**
  60013. * Block used to subtract 2 vectors
  60014. */
  60015. export class SubtractBlock extends NodeMaterialBlock {
  60016. /**
  60017. * Creates a new SubtractBlock
  60018. * @param name defines the block name
  60019. */
  60020. constructor(name: string);
  60021. /**
  60022. * Gets the current class name
  60023. * @returns the class name
  60024. */
  60025. getClassName(): string;
  60026. /**
  60027. * Gets the left operand input component
  60028. */
  60029. get left(): NodeMaterialConnectionPoint;
  60030. /**
  60031. * Gets the right operand input component
  60032. */
  60033. get right(): NodeMaterialConnectionPoint;
  60034. /**
  60035. * Gets the output component
  60036. */
  60037. get output(): NodeMaterialConnectionPoint;
  60038. protected _buildBlock(state: NodeMaterialBuildState): this;
  60039. }
  60040. }
  60041. declare module BABYLON {
  60042. /**
  60043. * Block used to step a value
  60044. */
  60045. export class StepBlock extends NodeMaterialBlock {
  60046. /**
  60047. * Creates a new StepBlock
  60048. * @param name defines the block name
  60049. */
  60050. constructor(name: string);
  60051. /**
  60052. * Gets the current class name
  60053. * @returns the class name
  60054. */
  60055. getClassName(): string;
  60056. /**
  60057. * Gets the value operand input component
  60058. */
  60059. get value(): NodeMaterialConnectionPoint;
  60060. /**
  60061. * Gets the edge operand input component
  60062. */
  60063. get edge(): NodeMaterialConnectionPoint;
  60064. /**
  60065. * Gets the output component
  60066. */
  60067. get output(): NodeMaterialConnectionPoint;
  60068. protected _buildBlock(state: NodeMaterialBuildState): this;
  60069. }
  60070. }
  60071. declare module BABYLON {
  60072. /**
  60073. * Block used to get the opposite (1 - x) of a value
  60074. */
  60075. export class OneMinusBlock extends NodeMaterialBlock {
  60076. /**
  60077. * Creates a new OneMinusBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the input component
  60088. */
  60089. get input(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the output component
  60092. */
  60093. get output(): NodeMaterialConnectionPoint;
  60094. protected _buildBlock(state: NodeMaterialBuildState): this;
  60095. }
  60096. }
  60097. declare module BABYLON {
  60098. /**
  60099. * Block used to get the view direction
  60100. */
  60101. export class ViewDirectionBlock extends NodeMaterialBlock {
  60102. /**
  60103. * Creates a new ViewDirectionBlock
  60104. * @param name defines the block name
  60105. */
  60106. constructor(name: string);
  60107. /**
  60108. * Gets the current class name
  60109. * @returns the class name
  60110. */
  60111. getClassName(): string;
  60112. /**
  60113. * Gets the world position component
  60114. */
  60115. get worldPosition(): NodeMaterialConnectionPoint;
  60116. /**
  60117. * Gets the camera position component
  60118. */
  60119. get cameraPosition(): NodeMaterialConnectionPoint;
  60120. /**
  60121. * Gets the output component
  60122. */
  60123. get output(): NodeMaterialConnectionPoint;
  60124. autoConfigure(material: NodeMaterial): void;
  60125. protected _buildBlock(state: NodeMaterialBuildState): this;
  60126. }
  60127. }
  60128. declare module BABYLON {
  60129. /**
  60130. * Block used to compute fresnel value
  60131. */
  60132. export class FresnelBlock extends NodeMaterialBlock {
  60133. /**
  60134. * Create a new FresnelBlock
  60135. * @param name defines the block name
  60136. */
  60137. constructor(name: string);
  60138. /**
  60139. * Gets the current class name
  60140. * @returns the class name
  60141. */
  60142. getClassName(): string;
  60143. /**
  60144. * Gets the world normal input component
  60145. */
  60146. get worldNormal(): NodeMaterialConnectionPoint;
  60147. /**
  60148. * Gets the view direction input component
  60149. */
  60150. get viewDirection(): NodeMaterialConnectionPoint;
  60151. /**
  60152. * Gets the bias input component
  60153. */
  60154. get bias(): NodeMaterialConnectionPoint;
  60155. /**
  60156. * Gets the camera (or eye) position component
  60157. */
  60158. get power(): NodeMaterialConnectionPoint;
  60159. /**
  60160. * Gets the fresnel output component
  60161. */
  60162. get fresnel(): NodeMaterialConnectionPoint;
  60163. autoConfigure(material: NodeMaterial): void;
  60164. protected _buildBlock(state: NodeMaterialBuildState): this;
  60165. }
  60166. }
  60167. declare module BABYLON {
  60168. /**
  60169. * Block used to get the max of 2 values
  60170. */
  60171. export class MaxBlock extends NodeMaterialBlock {
  60172. /**
  60173. * Creates a new MaxBlock
  60174. * @param name defines the block name
  60175. */
  60176. constructor(name: string);
  60177. /**
  60178. * Gets the current class name
  60179. * @returns the class name
  60180. */
  60181. getClassName(): string;
  60182. /**
  60183. * Gets the left operand input component
  60184. */
  60185. get left(): NodeMaterialConnectionPoint;
  60186. /**
  60187. * Gets the right operand input component
  60188. */
  60189. get right(): NodeMaterialConnectionPoint;
  60190. /**
  60191. * Gets the output component
  60192. */
  60193. get output(): NodeMaterialConnectionPoint;
  60194. protected _buildBlock(state: NodeMaterialBuildState): this;
  60195. }
  60196. }
  60197. declare module BABYLON {
  60198. /**
  60199. * Block used to get the min of 2 values
  60200. */
  60201. export class MinBlock extends NodeMaterialBlock {
  60202. /**
  60203. * Creates a new MinBlock
  60204. * @param name defines the block name
  60205. */
  60206. constructor(name: string);
  60207. /**
  60208. * Gets the current class name
  60209. * @returns the class name
  60210. */
  60211. getClassName(): string;
  60212. /**
  60213. * Gets the left operand input component
  60214. */
  60215. get left(): NodeMaterialConnectionPoint;
  60216. /**
  60217. * Gets the right operand input component
  60218. */
  60219. get right(): NodeMaterialConnectionPoint;
  60220. /**
  60221. * Gets the output component
  60222. */
  60223. get output(): NodeMaterialConnectionPoint;
  60224. protected _buildBlock(state: NodeMaterialBuildState): this;
  60225. }
  60226. }
  60227. declare module BABYLON {
  60228. /**
  60229. * Block used to get the distance between 2 values
  60230. */
  60231. export class DistanceBlock extends NodeMaterialBlock {
  60232. /**
  60233. * Creates a new DistanceBlock
  60234. * @param name defines the block name
  60235. */
  60236. constructor(name: string);
  60237. /**
  60238. * Gets the current class name
  60239. * @returns the class name
  60240. */
  60241. getClassName(): string;
  60242. /**
  60243. * Gets the left operand input component
  60244. */
  60245. get left(): NodeMaterialConnectionPoint;
  60246. /**
  60247. * Gets the right operand input component
  60248. */
  60249. get right(): NodeMaterialConnectionPoint;
  60250. /**
  60251. * Gets the output component
  60252. */
  60253. get output(): NodeMaterialConnectionPoint;
  60254. protected _buildBlock(state: NodeMaterialBuildState): this;
  60255. }
  60256. }
  60257. declare module BABYLON {
  60258. /**
  60259. * Block used to get the length of a vector
  60260. */
  60261. export class LengthBlock extends NodeMaterialBlock {
  60262. /**
  60263. * Creates a new LengthBlock
  60264. * @param name defines the block name
  60265. */
  60266. constructor(name: string);
  60267. /**
  60268. * Gets the current class name
  60269. * @returns the class name
  60270. */
  60271. getClassName(): string;
  60272. /**
  60273. * Gets the value input component
  60274. */
  60275. get value(): NodeMaterialConnectionPoint;
  60276. /**
  60277. * Gets the output component
  60278. */
  60279. get output(): NodeMaterialConnectionPoint;
  60280. protected _buildBlock(state: NodeMaterialBuildState): this;
  60281. }
  60282. }
  60283. declare module BABYLON {
  60284. /**
  60285. * Block used to get negative version of a value (i.e. x * -1)
  60286. */
  60287. export class NegateBlock extends NodeMaterialBlock {
  60288. /**
  60289. * Creates a new NegateBlock
  60290. * @param name defines the block name
  60291. */
  60292. constructor(name: string);
  60293. /**
  60294. * Gets the current class name
  60295. * @returns the class name
  60296. */
  60297. getClassName(): string;
  60298. /**
  60299. * Gets the value input component
  60300. */
  60301. get value(): NodeMaterialConnectionPoint;
  60302. /**
  60303. * Gets the output component
  60304. */
  60305. get output(): NodeMaterialConnectionPoint;
  60306. protected _buildBlock(state: NodeMaterialBuildState): this;
  60307. }
  60308. }
  60309. declare module BABYLON {
  60310. /**
  60311. * Block used to get the value of the first parameter raised to the power of the second
  60312. */
  60313. export class PowBlock extends NodeMaterialBlock {
  60314. /**
  60315. * Creates a new PowBlock
  60316. * @param name defines the block name
  60317. */
  60318. constructor(name: string);
  60319. /**
  60320. * Gets the current class name
  60321. * @returns the class name
  60322. */
  60323. getClassName(): string;
  60324. /**
  60325. * Gets the value operand input component
  60326. */
  60327. get value(): NodeMaterialConnectionPoint;
  60328. /**
  60329. * Gets the power operand input component
  60330. */
  60331. get power(): NodeMaterialConnectionPoint;
  60332. /**
  60333. * Gets the output component
  60334. */
  60335. get output(): NodeMaterialConnectionPoint;
  60336. protected _buildBlock(state: NodeMaterialBuildState): this;
  60337. }
  60338. }
  60339. declare module BABYLON {
  60340. /**
  60341. * Block used to get a random number
  60342. */
  60343. export class RandomNumberBlock extends NodeMaterialBlock {
  60344. /**
  60345. * Creates a new RandomNumberBlock
  60346. * @param name defines the block name
  60347. */
  60348. constructor(name: string);
  60349. /**
  60350. * Gets the current class name
  60351. * @returns the class name
  60352. */
  60353. getClassName(): string;
  60354. /**
  60355. * Gets the seed input component
  60356. */
  60357. get seed(): NodeMaterialConnectionPoint;
  60358. /**
  60359. * Gets the output component
  60360. */
  60361. get output(): NodeMaterialConnectionPoint;
  60362. protected _buildBlock(state: NodeMaterialBuildState): this;
  60363. }
  60364. }
  60365. declare module BABYLON {
  60366. /**
  60367. * Block used to compute arc tangent of 2 values
  60368. */
  60369. export class ArcTan2Block extends NodeMaterialBlock {
  60370. /**
  60371. * Creates a new ArcTan2Block
  60372. * @param name defines the block name
  60373. */
  60374. constructor(name: string);
  60375. /**
  60376. * Gets the current class name
  60377. * @returns the class name
  60378. */
  60379. getClassName(): string;
  60380. /**
  60381. * Gets the x operand input component
  60382. */
  60383. get x(): NodeMaterialConnectionPoint;
  60384. /**
  60385. * Gets the y operand input component
  60386. */
  60387. get y(): NodeMaterialConnectionPoint;
  60388. /**
  60389. * Gets the output component
  60390. */
  60391. get output(): NodeMaterialConnectionPoint;
  60392. protected _buildBlock(state: NodeMaterialBuildState): this;
  60393. }
  60394. }
  60395. declare module BABYLON {
  60396. /**
  60397. * Block used to smooth step a value
  60398. */
  60399. export class SmoothStepBlock extends NodeMaterialBlock {
  60400. /**
  60401. * Creates a new SmoothStepBlock
  60402. * @param name defines the block name
  60403. */
  60404. constructor(name: string);
  60405. /**
  60406. * Gets the current class name
  60407. * @returns the class name
  60408. */
  60409. getClassName(): string;
  60410. /**
  60411. * Gets the value operand input component
  60412. */
  60413. get value(): NodeMaterialConnectionPoint;
  60414. /**
  60415. * Gets the first edge operand input component
  60416. */
  60417. get edge0(): NodeMaterialConnectionPoint;
  60418. /**
  60419. * Gets the second edge operand input component
  60420. */
  60421. get edge1(): NodeMaterialConnectionPoint;
  60422. /**
  60423. * Gets the output component
  60424. */
  60425. get output(): NodeMaterialConnectionPoint;
  60426. protected _buildBlock(state: NodeMaterialBuildState): this;
  60427. }
  60428. }
  60429. declare module BABYLON {
  60430. /**
  60431. * Block used to get the reciprocal (1 / x) of a value
  60432. */
  60433. export class ReciprocalBlock extends NodeMaterialBlock {
  60434. /**
  60435. * Creates a new ReciprocalBlock
  60436. * @param name defines the block name
  60437. */
  60438. constructor(name: string);
  60439. /**
  60440. * Gets the current class name
  60441. * @returns the class name
  60442. */
  60443. getClassName(): string;
  60444. /**
  60445. * Gets the input component
  60446. */
  60447. get input(): NodeMaterialConnectionPoint;
  60448. /**
  60449. * Gets the output component
  60450. */
  60451. get output(): NodeMaterialConnectionPoint;
  60452. protected _buildBlock(state: NodeMaterialBuildState): this;
  60453. }
  60454. }
  60455. declare module BABYLON {
  60456. /**
  60457. * Block used to replace a color by another one
  60458. */
  60459. export class ReplaceColorBlock extends NodeMaterialBlock {
  60460. /**
  60461. * Creates a new ReplaceColorBlock
  60462. * @param name defines the block name
  60463. */
  60464. constructor(name: string);
  60465. /**
  60466. * Gets the current class name
  60467. * @returns the class name
  60468. */
  60469. getClassName(): string;
  60470. /**
  60471. * Gets the value input component
  60472. */
  60473. get value(): NodeMaterialConnectionPoint;
  60474. /**
  60475. * Gets the reference input component
  60476. */
  60477. get reference(): NodeMaterialConnectionPoint;
  60478. /**
  60479. * Gets the distance input component
  60480. */
  60481. get distance(): NodeMaterialConnectionPoint;
  60482. /**
  60483. * Gets the replacement input component
  60484. */
  60485. get replacement(): NodeMaterialConnectionPoint;
  60486. /**
  60487. * Gets the output component
  60488. */
  60489. get output(): NodeMaterialConnectionPoint;
  60490. protected _buildBlock(state: NodeMaterialBuildState): this;
  60491. }
  60492. }
  60493. declare module BABYLON {
  60494. /**
  60495. * Block used to posterize a value
  60496. * @see https://en.wikipedia.org/wiki/Posterization
  60497. */
  60498. export class PosterizeBlock extends NodeMaterialBlock {
  60499. /**
  60500. * Creates a new PosterizeBlock
  60501. * @param name defines the block name
  60502. */
  60503. constructor(name: string);
  60504. /**
  60505. * Gets the current class name
  60506. * @returns the class name
  60507. */
  60508. getClassName(): string;
  60509. /**
  60510. * Gets the value input component
  60511. */
  60512. get value(): NodeMaterialConnectionPoint;
  60513. /**
  60514. * Gets the steps input component
  60515. */
  60516. get steps(): NodeMaterialConnectionPoint;
  60517. /**
  60518. * Gets the output component
  60519. */
  60520. get output(): NodeMaterialConnectionPoint;
  60521. protected _buildBlock(state: NodeMaterialBuildState): this;
  60522. }
  60523. }
  60524. declare module BABYLON {
  60525. /**
  60526. * Operations supported by the Wave block
  60527. */
  60528. export enum WaveBlockKind {
  60529. /** SawTooth */
  60530. SawTooth = 0,
  60531. /** Square */
  60532. Square = 1,
  60533. /** Triangle */
  60534. Triangle = 2
  60535. }
  60536. /**
  60537. * Block used to apply wave operation to floats
  60538. */
  60539. export class WaveBlock extends NodeMaterialBlock {
  60540. /**
  60541. * Gets or sets the kibnd of wave to be applied by the block
  60542. */
  60543. kind: WaveBlockKind;
  60544. /**
  60545. * Creates a new WaveBlock
  60546. * @param name defines the block name
  60547. */
  60548. constructor(name: string);
  60549. /**
  60550. * Gets the current class name
  60551. * @returns the class name
  60552. */
  60553. getClassName(): string;
  60554. /**
  60555. * Gets the input component
  60556. */
  60557. get input(): NodeMaterialConnectionPoint;
  60558. /**
  60559. * Gets the output component
  60560. */
  60561. get output(): NodeMaterialConnectionPoint;
  60562. protected _buildBlock(state: NodeMaterialBuildState): this;
  60563. serialize(): any;
  60564. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60565. }
  60566. }
  60567. declare module BABYLON {
  60568. /**
  60569. * Class used to store a color step for the GradientBlock
  60570. */
  60571. export class GradientBlockColorStep {
  60572. /**
  60573. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60574. */
  60575. step: number;
  60576. /**
  60577. * Gets or sets the color associated with this step
  60578. */
  60579. color: Color3;
  60580. /**
  60581. * Creates a new GradientBlockColorStep
  60582. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60583. * @param color defines the color associated with this step
  60584. */
  60585. constructor(
  60586. /**
  60587. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60588. */
  60589. step: number,
  60590. /**
  60591. * Gets or sets the color associated with this step
  60592. */
  60593. color: Color3);
  60594. }
  60595. /**
  60596. * Block used to return a color from a gradient based on an input value between 0 and 1
  60597. */
  60598. export class GradientBlock extends NodeMaterialBlock {
  60599. /**
  60600. * Gets or sets the list of color steps
  60601. */
  60602. colorSteps: GradientBlockColorStep[];
  60603. /**
  60604. * Creates a new GradientBlock
  60605. * @param name defines the block name
  60606. */
  60607. constructor(name: string);
  60608. /**
  60609. * Gets the current class name
  60610. * @returns the class name
  60611. */
  60612. getClassName(): string;
  60613. /**
  60614. * Gets the gradient input component
  60615. */
  60616. get gradient(): NodeMaterialConnectionPoint;
  60617. /**
  60618. * Gets the output component
  60619. */
  60620. get output(): NodeMaterialConnectionPoint;
  60621. private _writeColorConstant;
  60622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60623. serialize(): any;
  60624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60625. protected _dumpPropertiesCode(): string;
  60626. }
  60627. }
  60628. declare module BABYLON {
  60629. /**
  60630. * Block used to normalize lerp between 2 values
  60631. */
  60632. export class NLerpBlock extends NodeMaterialBlock {
  60633. /**
  60634. * Creates a new NLerpBlock
  60635. * @param name defines the block name
  60636. */
  60637. constructor(name: string);
  60638. /**
  60639. * Gets the current class name
  60640. * @returns the class name
  60641. */
  60642. getClassName(): string;
  60643. /**
  60644. * Gets the left operand input component
  60645. */
  60646. get left(): NodeMaterialConnectionPoint;
  60647. /**
  60648. * Gets the right operand input component
  60649. */
  60650. get right(): NodeMaterialConnectionPoint;
  60651. /**
  60652. * Gets the gradient operand input component
  60653. */
  60654. get gradient(): NodeMaterialConnectionPoint;
  60655. /**
  60656. * Gets the output component
  60657. */
  60658. get output(): NodeMaterialConnectionPoint;
  60659. protected _buildBlock(state: NodeMaterialBuildState): this;
  60660. }
  60661. }
  60662. declare module BABYLON {
  60663. /**
  60664. * block used to Generate a Worley Noise 3D Noise Pattern
  60665. */
  60666. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60667. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60668. manhattanDistance: boolean;
  60669. /**
  60670. * Creates a new WorleyNoise3DBlock
  60671. * @param name defines the block name
  60672. */
  60673. constructor(name: string);
  60674. /**
  60675. * Gets the current class name
  60676. * @returns the class name
  60677. */
  60678. getClassName(): string;
  60679. /**
  60680. * Gets the seed input component
  60681. */
  60682. get seed(): NodeMaterialConnectionPoint;
  60683. /**
  60684. * Gets the jitter input component
  60685. */
  60686. get jitter(): NodeMaterialConnectionPoint;
  60687. /**
  60688. * Gets the output component
  60689. */
  60690. get output(): NodeMaterialConnectionPoint;
  60691. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60692. /**
  60693. * Exposes the properties to the UI?
  60694. */
  60695. protected _dumpPropertiesCode(): string;
  60696. /**
  60697. * Exposes the properties to the Seralize?
  60698. */
  60699. serialize(): any;
  60700. /**
  60701. * Exposes the properties to the deseralize?
  60702. */
  60703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60704. }
  60705. }
  60706. declare module BABYLON {
  60707. /**
  60708. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60709. */
  60710. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60711. /**
  60712. * Creates a new SimplexPerlin3DBlock
  60713. * @param name defines the block name
  60714. */
  60715. constructor(name: string);
  60716. /**
  60717. * Gets the current class name
  60718. * @returns the class name
  60719. */
  60720. getClassName(): string;
  60721. /**
  60722. * Gets the seed operand input component
  60723. */
  60724. get seed(): NodeMaterialConnectionPoint;
  60725. /**
  60726. * Gets the output component
  60727. */
  60728. get output(): NodeMaterialConnectionPoint;
  60729. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60730. }
  60731. }
  60732. declare module BABYLON {
  60733. /**
  60734. * Block used to blend normals
  60735. */
  60736. export class NormalBlendBlock extends NodeMaterialBlock {
  60737. /**
  60738. * Creates a new NormalBlendBlock
  60739. * @param name defines the block name
  60740. */
  60741. constructor(name: string);
  60742. /**
  60743. * Gets the current class name
  60744. * @returns the class name
  60745. */
  60746. getClassName(): string;
  60747. /**
  60748. * Gets the first input component
  60749. */
  60750. get normalMap0(): NodeMaterialConnectionPoint;
  60751. /**
  60752. * Gets the second input component
  60753. */
  60754. get normalMap1(): NodeMaterialConnectionPoint;
  60755. /**
  60756. * Gets the output component
  60757. */
  60758. get output(): NodeMaterialConnectionPoint;
  60759. protected _buildBlock(state: NodeMaterialBuildState): this;
  60760. }
  60761. }
  60762. declare module BABYLON {
  60763. /**
  60764. * Block used to rotate a 2d vector by a given angle
  60765. */
  60766. export class Rotate2dBlock extends NodeMaterialBlock {
  60767. /**
  60768. * Creates a new Rotate2dBlock
  60769. * @param name defines the block name
  60770. */
  60771. constructor(name: string);
  60772. /**
  60773. * Gets the current class name
  60774. * @returns the class name
  60775. */
  60776. getClassName(): string;
  60777. /**
  60778. * Gets the input vector
  60779. */
  60780. get input(): NodeMaterialConnectionPoint;
  60781. /**
  60782. * Gets the input angle
  60783. */
  60784. get angle(): NodeMaterialConnectionPoint;
  60785. /**
  60786. * Gets the output component
  60787. */
  60788. get output(): NodeMaterialConnectionPoint;
  60789. autoConfigure(material: NodeMaterial): void;
  60790. protected _buildBlock(state: NodeMaterialBuildState): this;
  60791. }
  60792. }
  60793. declare module BABYLON {
  60794. /**
  60795. * Block used to get the reflected vector from a direction and a normal
  60796. */
  60797. export class ReflectBlock extends NodeMaterialBlock {
  60798. /**
  60799. * Creates a new ReflectBlock
  60800. * @param name defines the block name
  60801. */
  60802. constructor(name: string);
  60803. /**
  60804. * Gets the current class name
  60805. * @returns the class name
  60806. */
  60807. getClassName(): string;
  60808. /**
  60809. * Gets the incident component
  60810. */
  60811. get incident(): NodeMaterialConnectionPoint;
  60812. /**
  60813. * Gets the normal component
  60814. */
  60815. get normal(): NodeMaterialConnectionPoint;
  60816. /**
  60817. * Gets the output component
  60818. */
  60819. get output(): NodeMaterialConnectionPoint;
  60820. protected _buildBlock(state: NodeMaterialBuildState): this;
  60821. }
  60822. }
  60823. declare module BABYLON {
  60824. /**
  60825. * Block used to get the refracted vector from a direction and a normal
  60826. */
  60827. export class RefractBlock extends NodeMaterialBlock {
  60828. /**
  60829. * Creates a new RefractBlock
  60830. * @param name defines the block name
  60831. */
  60832. constructor(name: string);
  60833. /**
  60834. * Gets the current class name
  60835. * @returns the class name
  60836. */
  60837. getClassName(): string;
  60838. /**
  60839. * Gets the incident component
  60840. */
  60841. get incident(): NodeMaterialConnectionPoint;
  60842. /**
  60843. * Gets the normal component
  60844. */
  60845. get normal(): NodeMaterialConnectionPoint;
  60846. /**
  60847. * Gets the index of refraction component
  60848. */
  60849. get ior(): NodeMaterialConnectionPoint;
  60850. /**
  60851. * Gets the output component
  60852. */
  60853. get output(): NodeMaterialConnectionPoint;
  60854. protected _buildBlock(state: NodeMaterialBuildState): this;
  60855. }
  60856. }
  60857. declare module BABYLON {
  60858. /**
  60859. * Block used to desaturate a color
  60860. */
  60861. export class DesaturateBlock extends NodeMaterialBlock {
  60862. /**
  60863. * Creates a new DesaturateBlock
  60864. * @param name defines the block name
  60865. */
  60866. constructor(name: string);
  60867. /**
  60868. * Gets the current class name
  60869. * @returns the class name
  60870. */
  60871. getClassName(): string;
  60872. /**
  60873. * Gets the color operand input component
  60874. */
  60875. get color(): NodeMaterialConnectionPoint;
  60876. /**
  60877. * Gets the level operand input component
  60878. */
  60879. get level(): NodeMaterialConnectionPoint;
  60880. /**
  60881. * Gets the output component
  60882. */
  60883. get output(): NodeMaterialConnectionPoint;
  60884. protected _buildBlock(state: NodeMaterialBuildState): this;
  60885. }
  60886. }
  60887. declare module BABYLON {
  60888. /**
  60889. * Effect Render Options
  60890. */
  60891. export interface IEffectRendererOptions {
  60892. /**
  60893. * Defines the vertices positions.
  60894. */
  60895. positions?: number[];
  60896. /**
  60897. * Defines the indices.
  60898. */
  60899. indices?: number[];
  60900. }
  60901. /**
  60902. * Helper class to render one or more effects.
  60903. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60904. */
  60905. export class EffectRenderer {
  60906. private engine;
  60907. private static _DefaultOptions;
  60908. private _vertexBuffers;
  60909. private _indexBuffer;
  60910. private _fullscreenViewport;
  60911. /**
  60912. * Creates an effect renderer
  60913. * @param engine the engine to use for rendering
  60914. * @param options defines the options of the effect renderer
  60915. */
  60916. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60917. /**
  60918. * Sets the current viewport in normalized coordinates 0-1
  60919. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60920. */
  60921. setViewport(viewport?: Viewport): void;
  60922. /**
  60923. * Binds the embedded attributes buffer to the effect.
  60924. * @param effect Defines the effect to bind the attributes for
  60925. */
  60926. bindBuffers(effect: Effect): void;
  60927. /**
  60928. * Sets the current effect wrapper to use during draw.
  60929. * The effect needs to be ready before calling this api.
  60930. * This also sets the default full screen position attribute.
  60931. * @param effectWrapper Defines the effect to draw with
  60932. */
  60933. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60934. /**
  60935. * Draws a full screen quad.
  60936. */
  60937. draw(): void;
  60938. private isRenderTargetTexture;
  60939. /**
  60940. * renders one or more effects to a specified texture
  60941. * @param effectWrapper the effect to renderer
  60942. * @param outputTexture texture to draw to, if null it will render to the screen.
  60943. */
  60944. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60945. /**
  60946. * Disposes of the effect renderer
  60947. */
  60948. dispose(): void;
  60949. }
  60950. /**
  60951. * Options to create an EffectWrapper
  60952. */
  60953. interface EffectWrapperCreationOptions {
  60954. /**
  60955. * Engine to use to create the effect
  60956. */
  60957. engine: ThinEngine;
  60958. /**
  60959. * Fragment shader for the effect
  60960. */
  60961. fragmentShader: string;
  60962. /**
  60963. * Vertex shader for the effect
  60964. */
  60965. vertexShader?: string;
  60966. /**
  60967. * Attributes to use in the shader
  60968. */
  60969. attributeNames?: Array<string>;
  60970. /**
  60971. * Uniforms to use in the shader
  60972. */
  60973. uniformNames?: Array<string>;
  60974. /**
  60975. * Texture sampler names to use in the shader
  60976. */
  60977. samplerNames?: Array<string>;
  60978. /**
  60979. * The friendly name of the effect displayed in Spector.
  60980. */
  60981. name?: string;
  60982. }
  60983. /**
  60984. * Wraps an effect to be used for rendering
  60985. */
  60986. export class EffectWrapper {
  60987. /**
  60988. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60989. */
  60990. onApplyObservable: Observable<{}>;
  60991. /**
  60992. * The underlying effect
  60993. */
  60994. effect: Effect;
  60995. /**
  60996. * Creates an effect to be renderer
  60997. * @param creationOptions options to create the effect
  60998. */
  60999. constructor(creationOptions: EffectWrapperCreationOptions);
  61000. /**
  61001. * Disposes of the effect wrapper
  61002. */
  61003. dispose(): void;
  61004. }
  61005. }
  61006. declare module BABYLON {
  61007. /**
  61008. * Helper class to push actions to a pool of workers.
  61009. */
  61010. export class WorkerPool implements IDisposable {
  61011. private _workerInfos;
  61012. private _pendingActions;
  61013. /**
  61014. * Constructor
  61015. * @param workers Array of workers to use for actions
  61016. */
  61017. constructor(workers: Array<Worker>);
  61018. /**
  61019. * Terminates all workers and clears any pending actions.
  61020. */
  61021. dispose(): void;
  61022. /**
  61023. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61024. * pended until a worker has completed its action.
  61025. * @param action The action to perform. Call onComplete when the action is complete.
  61026. */
  61027. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61028. private _execute;
  61029. }
  61030. }
  61031. declare module BABYLON {
  61032. /**
  61033. * Configuration for Draco compression
  61034. */
  61035. export interface IDracoCompressionConfiguration {
  61036. /**
  61037. * Configuration for the decoder.
  61038. */
  61039. decoder: {
  61040. /**
  61041. * The url to the WebAssembly module.
  61042. */
  61043. wasmUrl?: string;
  61044. /**
  61045. * The url to the WebAssembly binary.
  61046. */
  61047. wasmBinaryUrl?: string;
  61048. /**
  61049. * The url to the fallback JavaScript module.
  61050. */
  61051. fallbackUrl?: string;
  61052. };
  61053. }
  61054. /**
  61055. * Draco compression (https://google.github.io/draco/)
  61056. *
  61057. * This class wraps the Draco module.
  61058. *
  61059. * **Encoder**
  61060. *
  61061. * The encoder is not currently implemented.
  61062. *
  61063. * **Decoder**
  61064. *
  61065. * 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.
  61066. *
  61067. * To update the configuration, use the following code:
  61068. * ```javascript
  61069. * DracoCompression.Configuration = {
  61070. * decoder: {
  61071. * wasmUrl: "<url to the WebAssembly library>",
  61072. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61073. * fallbackUrl: "<url to the fallback JavaScript library>",
  61074. * }
  61075. * };
  61076. * ```
  61077. *
  61078. * 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.
  61079. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61080. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61081. *
  61082. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61083. * ```javascript
  61084. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61085. * ```
  61086. *
  61087. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61088. */
  61089. export class DracoCompression implements IDisposable {
  61090. private _workerPoolPromise?;
  61091. private _decoderModulePromise?;
  61092. /**
  61093. * The configuration. Defaults to the following urls:
  61094. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61095. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61096. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61097. */
  61098. static Configuration: IDracoCompressionConfiguration;
  61099. /**
  61100. * Returns true if the decoder configuration is available.
  61101. */
  61102. static get DecoderAvailable(): boolean;
  61103. /**
  61104. * Default number of workers to create when creating the draco compression object.
  61105. */
  61106. static DefaultNumWorkers: number;
  61107. private static GetDefaultNumWorkers;
  61108. private static _Default;
  61109. /**
  61110. * Default instance for the draco compression object.
  61111. */
  61112. static get Default(): DracoCompression;
  61113. /**
  61114. * Constructor
  61115. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61116. */
  61117. constructor(numWorkers?: number);
  61118. /**
  61119. * Stop all async operations and release resources.
  61120. */
  61121. dispose(): void;
  61122. /**
  61123. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61124. * @returns a promise that resolves when ready
  61125. */
  61126. whenReadyAsync(): Promise<void>;
  61127. /**
  61128. * Decode Draco compressed mesh data to vertex data.
  61129. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61130. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61131. * @returns A promise that resolves with the decoded vertex data
  61132. */
  61133. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61134. [kind: string]: number;
  61135. }): Promise<VertexData>;
  61136. }
  61137. }
  61138. declare module BABYLON {
  61139. /**
  61140. * Class for building Constructive Solid Geometry
  61141. */
  61142. export class CSG {
  61143. private polygons;
  61144. /**
  61145. * The world matrix
  61146. */
  61147. matrix: Matrix;
  61148. /**
  61149. * Stores the position
  61150. */
  61151. position: Vector3;
  61152. /**
  61153. * Stores the rotation
  61154. */
  61155. rotation: Vector3;
  61156. /**
  61157. * Stores the rotation quaternion
  61158. */
  61159. rotationQuaternion: Nullable<Quaternion>;
  61160. /**
  61161. * Stores the scaling vector
  61162. */
  61163. scaling: Vector3;
  61164. /**
  61165. * Convert the Mesh to CSG
  61166. * @param mesh The Mesh to convert to CSG
  61167. * @returns A new CSG from the Mesh
  61168. */
  61169. static FromMesh(mesh: Mesh): CSG;
  61170. /**
  61171. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61172. * @param polygons Polygons used to construct a CSG solid
  61173. */
  61174. private static FromPolygons;
  61175. /**
  61176. * Clones, or makes a deep copy, of the CSG
  61177. * @returns A new CSG
  61178. */
  61179. clone(): CSG;
  61180. /**
  61181. * Unions this CSG with another CSG
  61182. * @param csg The CSG to union against this CSG
  61183. * @returns The unioned CSG
  61184. */
  61185. union(csg: CSG): CSG;
  61186. /**
  61187. * Unions this CSG with another CSG in place
  61188. * @param csg The CSG to union against this CSG
  61189. */
  61190. unionInPlace(csg: CSG): void;
  61191. /**
  61192. * Subtracts this CSG with another CSG
  61193. * @param csg The CSG to subtract against this CSG
  61194. * @returns A new CSG
  61195. */
  61196. subtract(csg: CSG): CSG;
  61197. /**
  61198. * Subtracts this CSG with another CSG in place
  61199. * @param csg The CSG to subtact against this CSG
  61200. */
  61201. subtractInPlace(csg: CSG): void;
  61202. /**
  61203. * Intersect this CSG with another CSG
  61204. * @param csg The CSG to intersect against this CSG
  61205. * @returns A new CSG
  61206. */
  61207. intersect(csg: CSG): CSG;
  61208. /**
  61209. * Intersects this CSG with another CSG in place
  61210. * @param csg The CSG to intersect against this CSG
  61211. */
  61212. intersectInPlace(csg: CSG): void;
  61213. /**
  61214. * Return a new CSG solid with solid and empty space switched. This solid is
  61215. * not modified.
  61216. * @returns A new CSG solid with solid and empty space switched
  61217. */
  61218. inverse(): CSG;
  61219. /**
  61220. * Inverses the CSG in place
  61221. */
  61222. inverseInPlace(): void;
  61223. /**
  61224. * This is used to keep meshes transformations so they can be restored
  61225. * when we build back a Babylon Mesh
  61226. * NB : All CSG operations are performed in world coordinates
  61227. * @param csg The CSG to copy the transform attributes from
  61228. * @returns This CSG
  61229. */
  61230. copyTransformAttributes(csg: CSG): CSG;
  61231. /**
  61232. * Build Raw mesh from CSG
  61233. * Coordinates here are in world space
  61234. * @param name The name of the mesh geometry
  61235. * @param scene The Scene
  61236. * @param keepSubMeshes Specifies if the submeshes should be kept
  61237. * @returns A new Mesh
  61238. */
  61239. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61240. /**
  61241. * Build Mesh from CSG taking material and transforms into account
  61242. * @param name The name of the Mesh
  61243. * @param material The material of the Mesh
  61244. * @param scene The Scene
  61245. * @param keepSubMeshes Specifies if submeshes should be kept
  61246. * @returns The new Mesh
  61247. */
  61248. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61249. }
  61250. }
  61251. declare module BABYLON {
  61252. /**
  61253. * Class used to create a trail following a mesh
  61254. */
  61255. export class TrailMesh extends Mesh {
  61256. private _generator;
  61257. private _autoStart;
  61258. private _running;
  61259. private _diameter;
  61260. private _length;
  61261. private _sectionPolygonPointsCount;
  61262. private _sectionVectors;
  61263. private _sectionNormalVectors;
  61264. private _beforeRenderObserver;
  61265. /**
  61266. * @constructor
  61267. * @param name The value used by scene.getMeshByName() to do a lookup.
  61268. * @param generator The mesh or transform node to generate a trail.
  61269. * @param scene The scene to add this mesh to.
  61270. * @param diameter Diameter of trailing mesh. Default is 1.
  61271. * @param length Length of trailing mesh. Default is 60.
  61272. * @param autoStart Automatically start trailing mesh. Default true.
  61273. */
  61274. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61275. /**
  61276. * "TrailMesh"
  61277. * @returns "TrailMesh"
  61278. */
  61279. getClassName(): string;
  61280. private _createMesh;
  61281. /**
  61282. * Start trailing mesh.
  61283. */
  61284. start(): void;
  61285. /**
  61286. * Stop trailing mesh.
  61287. */
  61288. stop(): void;
  61289. /**
  61290. * Update trailing mesh geometry.
  61291. */
  61292. update(): void;
  61293. /**
  61294. * Returns a new TrailMesh object.
  61295. * @param name is a string, the name given to the new mesh
  61296. * @param newGenerator use new generator object for cloned trail mesh
  61297. * @returns a new mesh
  61298. */
  61299. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61300. /**
  61301. * Serializes this trail mesh
  61302. * @param serializationObject object to write serialization to
  61303. */
  61304. serialize(serializationObject: any): void;
  61305. /**
  61306. * Parses a serialized trail mesh
  61307. * @param parsedMesh the serialized mesh
  61308. * @param scene the scene to create the trail mesh in
  61309. * @returns the created trail mesh
  61310. */
  61311. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61312. }
  61313. }
  61314. declare module BABYLON {
  61315. /**
  61316. * Class containing static functions to help procedurally build meshes
  61317. */
  61318. export class TiledBoxBuilder {
  61319. /**
  61320. * Creates a box mesh
  61321. * 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)
  61322. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61324. * * 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
  61325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61326. * @param name defines the name of the mesh
  61327. * @param options defines the options used to create the mesh
  61328. * @param scene defines the hosting scene
  61329. * @returns the box mesh
  61330. */
  61331. static CreateTiledBox(name: string, options: {
  61332. pattern?: number;
  61333. width?: number;
  61334. height?: number;
  61335. depth?: number;
  61336. tileSize?: number;
  61337. tileWidth?: number;
  61338. tileHeight?: number;
  61339. alignHorizontal?: number;
  61340. alignVertical?: number;
  61341. faceUV?: Vector4[];
  61342. faceColors?: Color4[];
  61343. sideOrientation?: number;
  61344. updatable?: boolean;
  61345. }, scene?: Nullable<Scene>): Mesh;
  61346. }
  61347. }
  61348. declare module BABYLON {
  61349. /**
  61350. * Class containing static functions to help procedurally build meshes
  61351. */
  61352. export class TorusKnotBuilder {
  61353. /**
  61354. * Creates a torus knot mesh
  61355. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61356. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61357. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61358. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61360. * * 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
  61361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61362. * @param name defines the name of the mesh
  61363. * @param options defines the options used to create the mesh
  61364. * @param scene defines the hosting scene
  61365. * @returns the torus knot mesh
  61366. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61367. */
  61368. static CreateTorusKnot(name: string, options: {
  61369. radius?: number;
  61370. tube?: number;
  61371. radialSegments?: number;
  61372. tubularSegments?: number;
  61373. p?: number;
  61374. q?: number;
  61375. updatable?: boolean;
  61376. sideOrientation?: number;
  61377. frontUVs?: Vector4;
  61378. backUVs?: Vector4;
  61379. }, scene: any): Mesh;
  61380. }
  61381. }
  61382. declare module BABYLON {
  61383. /**
  61384. * Polygon
  61385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61386. */
  61387. export class Polygon {
  61388. /**
  61389. * Creates a rectangle
  61390. * @param xmin bottom X coord
  61391. * @param ymin bottom Y coord
  61392. * @param xmax top X coord
  61393. * @param ymax top Y coord
  61394. * @returns points that make the resulting rectation
  61395. */
  61396. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61397. /**
  61398. * Creates a circle
  61399. * @param radius radius of circle
  61400. * @param cx scale in x
  61401. * @param cy scale in y
  61402. * @param numberOfSides number of sides that make up the circle
  61403. * @returns points that make the resulting circle
  61404. */
  61405. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61406. /**
  61407. * Creates a polygon from input string
  61408. * @param input Input polygon data
  61409. * @returns the parsed points
  61410. */
  61411. static Parse(input: string): Vector2[];
  61412. /**
  61413. * Starts building a polygon from x and y coordinates
  61414. * @param x x coordinate
  61415. * @param y y coordinate
  61416. * @returns the started path2
  61417. */
  61418. static StartingAt(x: number, y: number): Path2;
  61419. }
  61420. /**
  61421. * Builds a polygon
  61422. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61423. */
  61424. export class PolygonMeshBuilder {
  61425. private _points;
  61426. private _outlinepoints;
  61427. private _holes;
  61428. private _name;
  61429. private _scene;
  61430. private _epoints;
  61431. private _eholes;
  61432. private _addToepoint;
  61433. /**
  61434. * Babylon reference to the earcut plugin.
  61435. */
  61436. bjsEarcut: any;
  61437. /**
  61438. * Creates a PolygonMeshBuilder
  61439. * @param name name of the builder
  61440. * @param contours Path of the polygon
  61441. * @param scene scene to add to when creating the mesh
  61442. * @param earcutInjection can be used to inject your own earcut reference
  61443. */
  61444. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61445. /**
  61446. * Adds a whole within the polygon
  61447. * @param hole Array of points defining the hole
  61448. * @returns this
  61449. */
  61450. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61451. /**
  61452. * Creates the polygon
  61453. * @param updatable If the mesh should be updatable
  61454. * @param depth The depth of the mesh created
  61455. * @returns the created mesh
  61456. */
  61457. build(updatable?: boolean, depth?: number): Mesh;
  61458. /**
  61459. * Creates the polygon
  61460. * @param depth The depth of the mesh created
  61461. * @returns the created VertexData
  61462. */
  61463. buildVertexData(depth?: number): VertexData;
  61464. /**
  61465. * Adds a side to the polygon
  61466. * @param positions points that make the polygon
  61467. * @param normals normals of the polygon
  61468. * @param uvs uvs of the polygon
  61469. * @param indices indices of the polygon
  61470. * @param bounds bounds of the polygon
  61471. * @param points points of the polygon
  61472. * @param depth depth of the polygon
  61473. * @param flip flip of the polygon
  61474. */
  61475. private addSide;
  61476. }
  61477. }
  61478. declare module BABYLON {
  61479. /**
  61480. * Class containing static functions to help procedurally build meshes
  61481. */
  61482. export class PolygonBuilder {
  61483. /**
  61484. * Creates a polygon mesh
  61485. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61486. * * 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
  61487. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61489. * * 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)
  61490. * * Remember you can only change the shape positions, not their number when updating a polygon
  61491. * @param name defines the name of the mesh
  61492. * @param options defines the options used to create the mesh
  61493. * @param scene defines the hosting scene
  61494. * @param earcutInjection can be used to inject your own earcut reference
  61495. * @returns the polygon mesh
  61496. */
  61497. static CreatePolygon(name: string, options: {
  61498. shape: Vector3[];
  61499. holes?: Vector3[][];
  61500. depth?: number;
  61501. faceUV?: Vector4[];
  61502. faceColors?: Color4[];
  61503. updatable?: boolean;
  61504. sideOrientation?: number;
  61505. frontUVs?: Vector4;
  61506. backUVs?: Vector4;
  61507. wrap?: boolean;
  61508. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61509. /**
  61510. * Creates an extruded polygon mesh, with depth in the Y direction.
  61511. * * 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)
  61512. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61513. * @param name defines the name of the mesh
  61514. * @param options defines the options used to create the mesh
  61515. * @param scene defines the hosting scene
  61516. * @param earcutInjection can be used to inject your own earcut reference
  61517. * @returns the polygon mesh
  61518. */
  61519. static ExtrudePolygon(name: string, options: {
  61520. shape: Vector3[];
  61521. holes?: Vector3[][];
  61522. depth?: number;
  61523. faceUV?: Vector4[];
  61524. faceColors?: Color4[];
  61525. updatable?: boolean;
  61526. sideOrientation?: number;
  61527. frontUVs?: Vector4;
  61528. backUVs?: Vector4;
  61529. wrap?: boolean;
  61530. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61531. }
  61532. }
  61533. declare module BABYLON {
  61534. /**
  61535. * Class containing static functions to help procedurally build meshes
  61536. */
  61537. export class LatheBuilder {
  61538. /**
  61539. * Creates lathe mesh.
  61540. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61541. * * 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
  61542. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61543. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61544. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61545. * * 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
  61546. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61547. * * 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
  61548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61549. * * 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
  61550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61552. * @param name defines the name of the mesh
  61553. * @param options defines the options used to create the mesh
  61554. * @param scene defines the hosting scene
  61555. * @returns the lathe mesh
  61556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61557. */
  61558. static CreateLathe(name: string, options: {
  61559. shape: Vector3[];
  61560. radius?: number;
  61561. tessellation?: number;
  61562. clip?: number;
  61563. arc?: number;
  61564. closed?: boolean;
  61565. updatable?: boolean;
  61566. sideOrientation?: number;
  61567. frontUVs?: Vector4;
  61568. backUVs?: Vector4;
  61569. cap?: number;
  61570. invertUV?: boolean;
  61571. }, scene?: Nullable<Scene>): Mesh;
  61572. }
  61573. }
  61574. declare module BABYLON {
  61575. /**
  61576. * Class containing static functions to help procedurally build meshes
  61577. */
  61578. export class TiledPlaneBuilder {
  61579. /**
  61580. * Creates a tiled plane mesh
  61581. * * The parameter `pattern` will, depending on value, do nothing or
  61582. * * * flip (reflect about central vertical) alternate tiles across and up
  61583. * * * flip every tile on alternate rows
  61584. * * * rotate (180 degs) alternate tiles across and up
  61585. * * * rotate every tile on alternate rows
  61586. * * * flip and rotate alternate tiles across and up
  61587. * * * flip and rotate every tile on alternate rows
  61588. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61589. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61590. * * 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
  61591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61592. * * 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)
  61593. * * 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)
  61594. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61595. * @param name defines the name of the mesh
  61596. * @param options defines the options used to create the mesh
  61597. * @param scene defines the hosting scene
  61598. * @returns the box mesh
  61599. */
  61600. static CreateTiledPlane(name: string, options: {
  61601. pattern?: number;
  61602. tileSize?: number;
  61603. tileWidth?: number;
  61604. tileHeight?: number;
  61605. size?: number;
  61606. width?: number;
  61607. height?: number;
  61608. alignHorizontal?: number;
  61609. alignVertical?: number;
  61610. sideOrientation?: number;
  61611. frontUVs?: Vector4;
  61612. backUVs?: Vector4;
  61613. updatable?: boolean;
  61614. }, scene?: Nullable<Scene>): Mesh;
  61615. }
  61616. }
  61617. declare module BABYLON {
  61618. /**
  61619. * Class containing static functions to help procedurally build meshes
  61620. */
  61621. export class TubeBuilder {
  61622. /**
  61623. * Creates a tube mesh.
  61624. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61625. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61626. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61627. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61628. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61629. * * 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)
  61630. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61631. * * 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
  61632. * * 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
  61633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61634. * * 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
  61635. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61637. * @param name defines the name of the mesh
  61638. * @param options defines the options used to create the mesh
  61639. * @param scene defines the hosting scene
  61640. * @returns the tube mesh
  61641. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61642. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61643. */
  61644. static CreateTube(name: string, options: {
  61645. path: Vector3[];
  61646. radius?: number;
  61647. tessellation?: number;
  61648. radiusFunction?: {
  61649. (i: number, distance: number): number;
  61650. };
  61651. cap?: number;
  61652. arc?: number;
  61653. updatable?: boolean;
  61654. sideOrientation?: number;
  61655. frontUVs?: Vector4;
  61656. backUVs?: Vector4;
  61657. instance?: Mesh;
  61658. invertUV?: boolean;
  61659. }, scene?: Nullable<Scene>): Mesh;
  61660. }
  61661. }
  61662. declare module BABYLON {
  61663. /**
  61664. * Class containing static functions to help procedurally build meshes
  61665. */
  61666. export class IcoSphereBuilder {
  61667. /**
  61668. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61669. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61670. * * 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`)
  61671. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61672. * * 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
  61673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61674. * * 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
  61675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61676. * @param name defines the name of the mesh
  61677. * @param options defines the options used to create the mesh
  61678. * @param scene defines the hosting scene
  61679. * @returns the icosahedron mesh
  61680. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61681. */
  61682. static CreateIcoSphere(name: string, options: {
  61683. radius?: number;
  61684. radiusX?: number;
  61685. radiusY?: number;
  61686. radiusZ?: number;
  61687. flat?: boolean;
  61688. subdivisions?: number;
  61689. sideOrientation?: number;
  61690. frontUVs?: Vector4;
  61691. backUVs?: Vector4;
  61692. updatable?: boolean;
  61693. }, scene?: Nullable<Scene>): Mesh;
  61694. }
  61695. }
  61696. declare module BABYLON {
  61697. /**
  61698. * Class containing static functions to help procedurally build meshes
  61699. */
  61700. export class DecalBuilder {
  61701. /**
  61702. * Creates a decal mesh.
  61703. * 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
  61704. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61705. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61706. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61707. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61708. * @param name defines the name of the mesh
  61709. * @param sourceMesh defines the mesh where the decal must be applied
  61710. * @param options defines the options used to create the mesh
  61711. * @param scene defines the hosting scene
  61712. * @returns the decal mesh
  61713. * @see https://doc.babylonjs.com/how_to/decals
  61714. */
  61715. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61716. position?: Vector3;
  61717. normal?: Vector3;
  61718. size?: Vector3;
  61719. angle?: number;
  61720. }): Mesh;
  61721. }
  61722. }
  61723. declare module BABYLON {
  61724. /**
  61725. * Class containing static functions to help procedurally build meshes
  61726. */
  61727. export class MeshBuilder {
  61728. /**
  61729. * Creates a box mesh
  61730. * * The parameter `size` sets the size (float) of each box side (default 1)
  61731. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61732. * * 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)
  61733. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61735. * * 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
  61736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61737. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61738. * @param name defines the name of the mesh
  61739. * @param options defines the options used to create the mesh
  61740. * @param scene defines the hosting scene
  61741. * @returns the box mesh
  61742. */
  61743. static CreateBox(name: string, options: {
  61744. size?: number;
  61745. width?: number;
  61746. height?: number;
  61747. depth?: number;
  61748. faceUV?: Vector4[];
  61749. faceColors?: Color4[];
  61750. sideOrientation?: number;
  61751. frontUVs?: Vector4;
  61752. backUVs?: Vector4;
  61753. wrap?: boolean;
  61754. topBaseAt?: number;
  61755. bottomBaseAt?: number;
  61756. updatable?: boolean;
  61757. }, scene?: Nullable<Scene>): Mesh;
  61758. /**
  61759. * Creates a tiled box mesh
  61760. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61762. * @param name defines the name of the mesh
  61763. * @param options defines the options used to create the mesh
  61764. * @param scene defines the hosting scene
  61765. * @returns the tiled box mesh
  61766. */
  61767. static CreateTiledBox(name: string, options: {
  61768. pattern?: number;
  61769. size?: number;
  61770. width?: number;
  61771. height?: number;
  61772. depth: number;
  61773. tileSize?: number;
  61774. tileWidth?: number;
  61775. tileHeight?: number;
  61776. faceUV?: Vector4[];
  61777. faceColors?: Color4[];
  61778. alignHorizontal?: number;
  61779. alignVertical?: number;
  61780. sideOrientation?: number;
  61781. updatable?: boolean;
  61782. }, scene?: Nullable<Scene>): Mesh;
  61783. /**
  61784. * Creates a sphere mesh
  61785. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61786. * * 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`)
  61787. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61788. * * 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
  61789. * * 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)
  61790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61791. * * 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
  61792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61793. * @param name defines the name of the mesh
  61794. * @param options defines the options used to create the mesh
  61795. * @param scene defines the hosting scene
  61796. * @returns the sphere mesh
  61797. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61798. */
  61799. static CreateSphere(name: string, options: {
  61800. segments?: number;
  61801. diameter?: number;
  61802. diameterX?: number;
  61803. diameterY?: number;
  61804. diameterZ?: number;
  61805. arc?: number;
  61806. slice?: number;
  61807. sideOrientation?: number;
  61808. frontUVs?: Vector4;
  61809. backUVs?: Vector4;
  61810. updatable?: boolean;
  61811. }, scene?: Nullable<Scene>): Mesh;
  61812. /**
  61813. * Creates a plane polygonal mesh. By default, this is a disc
  61814. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61815. * * 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
  61816. * * 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
  61817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61818. * * 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
  61819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61820. * @param name defines the name of the mesh
  61821. * @param options defines the options used to create the mesh
  61822. * @param scene defines the hosting scene
  61823. * @returns the plane polygonal mesh
  61824. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61825. */
  61826. static CreateDisc(name: string, options: {
  61827. radius?: number;
  61828. tessellation?: number;
  61829. arc?: number;
  61830. updatable?: boolean;
  61831. sideOrientation?: number;
  61832. frontUVs?: Vector4;
  61833. backUVs?: Vector4;
  61834. }, scene?: Nullable<Scene>): Mesh;
  61835. /**
  61836. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61837. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61838. * * 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`)
  61839. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61840. * * 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
  61841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61842. * * 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
  61843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61844. * @param name defines the name of the mesh
  61845. * @param options defines the options used to create the mesh
  61846. * @param scene defines the hosting scene
  61847. * @returns the icosahedron mesh
  61848. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61849. */
  61850. static CreateIcoSphere(name: string, options: {
  61851. radius?: number;
  61852. radiusX?: number;
  61853. radiusY?: number;
  61854. radiusZ?: number;
  61855. flat?: boolean;
  61856. subdivisions?: number;
  61857. sideOrientation?: number;
  61858. frontUVs?: Vector4;
  61859. backUVs?: Vector4;
  61860. updatable?: boolean;
  61861. }, scene?: Nullable<Scene>): Mesh;
  61862. /**
  61863. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61864. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61865. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61866. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61867. * * 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
  61868. * * 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
  61869. * * 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
  61870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61871. * * 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
  61872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61873. * * 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
  61874. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61875. * * 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
  61876. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61878. * @param name defines the name of the mesh
  61879. * @param options defines the options used to create the mesh
  61880. * @param scene defines the hosting scene
  61881. * @returns the ribbon mesh
  61882. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61883. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61884. */
  61885. static CreateRibbon(name: string, options: {
  61886. pathArray: Vector3[][];
  61887. closeArray?: boolean;
  61888. closePath?: boolean;
  61889. offset?: number;
  61890. updatable?: boolean;
  61891. sideOrientation?: number;
  61892. frontUVs?: Vector4;
  61893. backUVs?: Vector4;
  61894. instance?: Mesh;
  61895. invertUV?: boolean;
  61896. uvs?: Vector2[];
  61897. colors?: Color4[];
  61898. }, scene?: Nullable<Scene>): Mesh;
  61899. /**
  61900. * Creates a cylinder or a cone mesh
  61901. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61902. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61903. * * 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.
  61904. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61905. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61906. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61907. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61908. * * 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).
  61909. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61910. * * 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).
  61911. * * 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
  61912. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61913. * * 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
  61914. * * 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.
  61915. * * If `enclose` is false, a ring surface is one element.
  61916. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61917. * * 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
  61918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61919. * * 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
  61920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61921. * @param name defines the name of the mesh
  61922. * @param options defines the options used to create the mesh
  61923. * @param scene defines the hosting scene
  61924. * @returns the cylinder mesh
  61925. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61926. */
  61927. static CreateCylinder(name: string, options: {
  61928. height?: number;
  61929. diameterTop?: number;
  61930. diameterBottom?: number;
  61931. diameter?: number;
  61932. tessellation?: number;
  61933. subdivisions?: number;
  61934. arc?: number;
  61935. faceColors?: Color4[];
  61936. faceUV?: Vector4[];
  61937. updatable?: boolean;
  61938. hasRings?: boolean;
  61939. enclose?: boolean;
  61940. cap?: number;
  61941. sideOrientation?: number;
  61942. frontUVs?: Vector4;
  61943. backUVs?: Vector4;
  61944. }, scene?: Nullable<Scene>): Mesh;
  61945. /**
  61946. * Creates a torus mesh
  61947. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61948. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61949. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61951. * * 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
  61952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61953. * @param name defines the name of the mesh
  61954. * @param options defines the options used to create the mesh
  61955. * @param scene defines the hosting scene
  61956. * @returns the torus mesh
  61957. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61958. */
  61959. static CreateTorus(name: string, options: {
  61960. diameter?: number;
  61961. thickness?: number;
  61962. tessellation?: number;
  61963. updatable?: boolean;
  61964. sideOrientation?: number;
  61965. frontUVs?: Vector4;
  61966. backUVs?: Vector4;
  61967. }, scene?: Nullable<Scene>): Mesh;
  61968. /**
  61969. * Creates a torus knot mesh
  61970. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61971. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61972. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61973. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61975. * * 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
  61976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61977. * @param name defines the name of the mesh
  61978. * @param options defines the options used to create the mesh
  61979. * @param scene defines the hosting scene
  61980. * @returns the torus knot mesh
  61981. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61982. */
  61983. static CreateTorusKnot(name: string, options: {
  61984. radius?: number;
  61985. tube?: number;
  61986. radialSegments?: number;
  61987. tubularSegments?: number;
  61988. p?: number;
  61989. q?: number;
  61990. updatable?: boolean;
  61991. sideOrientation?: number;
  61992. frontUVs?: Vector4;
  61993. backUVs?: Vector4;
  61994. }, scene?: Nullable<Scene>): Mesh;
  61995. /**
  61996. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61997. * * 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
  61998. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61999. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62000. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62001. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62002. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62003. * * 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
  62004. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62007. * @param name defines the name of the new line system
  62008. * @param options defines the options used to create the line system
  62009. * @param scene defines the hosting scene
  62010. * @returns a new line system mesh
  62011. */
  62012. static CreateLineSystem(name: string, options: {
  62013. lines: Vector3[][];
  62014. updatable?: boolean;
  62015. instance?: Nullable<LinesMesh>;
  62016. colors?: Nullable<Color4[][]>;
  62017. useVertexAlpha?: boolean;
  62018. }, scene: Nullable<Scene>): LinesMesh;
  62019. /**
  62020. * Creates a line mesh
  62021. * 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
  62022. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62023. * * The parameter `points` is an array successive Vector3
  62024. * * 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
  62025. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62026. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62027. * * When updating an instance, remember that only point positions can change, not the number of points
  62028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62030. * @param name defines the name of the new line system
  62031. * @param options defines the options used to create the line system
  62032. * @param scene defines the hosting scene
  62033. * @returns a new line mesh
  62034. */
  62035. static CreateLines(name: string, options: {
  62036. points: Vector3[];
  62037. updatable?: boolean;
  62038. instance?: Nullable<LinesMesh>;
  62039. colors?: Color4[];
  62040. useVertexAlpha?: boolean;
  62041. }, scene?: Nullable<Scene>): LinesMesh;
  62042. /**
  62043. * Creates a dashed line mesh
  62044. * * 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
  62045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62046. * * The parameter `points` is an array successive Vector3
  62047. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62048. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62049. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62050. * * 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
  62051. * * When updating an instance, remember that only point positions can change, not the number of points
  62052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62053. * @param name defines the name of the mesh
  62054. * @param options defines the options used to create the mesh
  62055. * @param scene defines the hosting scene
  62056. * @returns the dashed line mesh
  62057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62058. */
  62059. static CreateDashedLines(name: string, options: {
  62060. points: Vector3[];
  62061. dashSize?: number;
  62062. gapSize?: number;
  62063. dashNb?: number;
  62064. updatable?: boolean;
  62065. instance?: LinesMesh;
  62066. }, scene?: Nullable<Scene>): LinesMesh;
  62067. /**
  62068. * 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.
  62069. * * 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.
  62070. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62071. * * 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.
  62072. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62073. * * 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
  62074. * * 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
  62075. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62077. * * 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
  62078. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62080. * @param name defines the name of the mesh
  62081. * @param options defines the options used to create the mesh
  62082. * @param scene defines the hosting scene
  62083. * @returns the extruded shape mesh
  62084. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62086. */
  62087. static ExtrudeShape(name: string, options: {
  62088. shape: Vector3[];
  62089. path: Vector3[];
  62090. scale?: number;
  62091. rotation?: number;
  62092. cap?: number;
  62093. updatable?: boolean;
  62094. sideOrientation?: number;
  62095. frontUVs?: Vector4;
  62096. backUVs?: Vector4;
  62097. instance?: Mesh;
  62098. invertUV?: boolean;
  62099. }, scene?: Nullable<Scene>): Mesh;
  62100. /**
  62101. * Creates an custom extruded shape mesh.
  62102. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62103. * * 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.
  62104. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62105. * * 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
  62106. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62107. * * 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
  62108. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62109. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62110. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62111. * * 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
  62112. * * 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
  62113. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62115. * * 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
  62116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62118. * @param name defines the name of the mesh
  62119. * @param options defines the options used to create the mesh
  62120. * @param scene defines the hosting scene
  62121. * @returns the custom extruded shape mesh
  62122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62125. */
  62126. static ExtrudeShapeCustom(name: string, options: {
  62127. shape: Vector3[];
  62128. path: Vector3[];
  62129. scaleFunction?: any;
  62130. rotationFunction?: any;
  62131. ribbonCloseArray?: boolean;
  62132. ribbonClosePath?: boolean;
  62133. cap?: number;
  62134. updatable?: boolean;
  62135. sideOrientation?: number;
  62136. frontUVs?: Vector4;
  62137. backUVs?: Vector4;
  62138. instance?: Mesh;
  62139. invertUV?: boolean;
  62140. }, scene?: Nullable<Scene>): Mesh;
  62141. /**
  62142. * Creates lathe mesh.
  62143. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62144. * * 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
  62145. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62146. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62147. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62148. * * 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
  62149. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62150. * * 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
  62151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62152. * * 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
  62153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62155. * @param name defines the name of the mesh
  62156. * @param options defines the options used to create the mesh
  62157. * @param scene defines the hosting scene
  62158. * @returns the lathe mesh
  62159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62160. */
  62161. static CreateLathe(name: string, options: {
  62162. shape: Vector3[];
  62163. radius?: number;
  62164. tessellation?: number;
  62165. clip?: number;
  62166. arc?: number;
  62167. closed?: boolean;
  62168. updatable?: boolean;
  62169. sideOrientation?: number;
  62170. frontUVs?: Vector4;
  62171. backUVs?: Vector4;
  62172. cap?: number;
  62173. invertUV?: boolean;
  62174. }, scene?: Nullable<Scene>): Mesh;
  62175. /**
  62176. * Creates a tiled plane mesh
  62177. * * You can set a limited pattern arrangement with the tiles
  62178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62179. * * 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
  62180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62181. * @param name defines the name of the mesh
  62182. * @param options defines the options used to create the mesh
  62183. * @param scene defines the hosting scene
  62184. * @returns the plane mesh
  62185. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62186. */
  62187. static CreateTiledPlane(name: string, options: {
  62188. pattern?: number;
  62189. tileSize?: number;
  62190. tileWidth?: number;
  62191. tileHeight?: number;
  62192. size?: number;
  62193. width?: number;
  62194. height?: number;
  62195. alignHorizontal?: number;
  62196. alignVertical?: number;
  62197. sideOrientation?: number;
  62198. frontUVs?: Vector4;
  62199. backUVs?: Vector4;
  62200. updatable?: boolean;
  62201. }, scene?: Nullable<Scene>): Mesh;
  62202. /**
  62203. * Creates a plane mesh
  62204. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62205. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62206. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62208. * * 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
  62209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62210. * @param name defines the name of the mesh
  62211. * @param options defines the options used to create the mesh
  62212. * @param scene defines the hosting scene
  62213. * @returns the plane mesh
  62214. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62215. */
  62216. static CreatePlane(name: string, options: {
  62217. size?: number;
  62218. width?: number;
  62219. height?: number;
  62220. sideOrientation?: number;
  62221. frontUVs?: Vector4;
  62222. backUVs?: Vector4;
  62223. updatable?: boolean;
  62224. sourcePlane?: Plane;
  62225. }, scene?: Nullable<Scene>): Mesh;
  62226. /**
  62227. * Creates a ground mesh
  62228. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62229. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62231. * @param name defines the name of the mesh
  62232. * @param options defines the options used to create the mesh
  62233. * @param scene defines the hosting scene
  62234. * @returns the ground mesh
  62235. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62236. */
  62237. static CreateGround(name: string, options: {
  62238. width?: number;
  62239. height?: number;
  62240. subdivisions?: number;
  62241. subdivisionsX?: number;
  62242. subdivisionsY?: number;
  62243. updatable?: boolean;
  62244. }, scene?: Nullable<Scene>): Mesh;
  62245. /**
  62246. * Creates a tiled ground mesh
  62247. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62248. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62249. * * 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
  62250. * * 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
  62251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62252. * @param name defines the name of the mesh
  62253. * @param options defines the options used to create the mesh
  62254. * @param scene defines the hosting scene
  62255. * @returns the tiled ground mesh
  62256. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62257. */
  62258. static CreateTiledGround(name: string, options: {
  62259. xmin: number;
  62260. zmin: number;
  62261. xmax: number;
  62262. zmax: number;
  62263. subdivisions?: {
  62264. w: number;
  62265. h: number;
  62266. };
  62267. precision?: {
  62268. w: number;
  62269. h: number;
  62270. };
  62271. updatable?: boolean;
  62272. }, scene?: Nullable<Scene>): Mesh;
  62273. /**
  62274. * Creates a ground mesh from a height map
  62275. * * The parameter `url` sets the URL of the height map image resource.
  62276. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62277. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62278. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62279. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62280. * * 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.
  62281. * * 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).
  62282. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62284. * @param name defines the name of the mesh
  62285. * @param url defines the url to the height map
  62286. * @param options defines the options used to create the mesh
  62287. * @param scene defines the hosting scene
  62288. * @returns the ground mesh
  62289. * @see https://doc.babylonjs.com/babylon101/height_map
  62290. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62291. */
  62292. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62293. width?: number;
  62294. height?: number;
  62295. subdivisions?: number;
  62296. minHeight?: number;
  62297. maxHeight?: number;
  62298. colorFilter?: Color3;
  62299. alphaFilter?: number;
  62300. updatable?: boolean;
  62301. onReady?: (mesh: GroundMesh) => void;
  62302. }, scene?: Nullable<Scene>): GroundMesh;
  62303. /**
  62304. * Creates a polygon mesh
  62305. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62306. * * 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
  62307. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62309. * * 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)
  62310. * * Remember you can only change the shape positions, not their number when updating a polygon
  62311. * @param name defines the name of the mesh
  62312. * @param options defines the options used to create the mesh
  62313. * @param scene defines the hosting scene
  62314. * @param earcutInjection can be used to inject your own earcut reference
  62315. * @returns the polygon mesh
  62316. */
  62317. static CreatePolygon(name: string, options: {
  62318. shape: Vector3[];
  62319. holes?: Vector3[][];
  62320. depth?: number;
  62321. faceUV?: Vector4[];
  62322. faceColors?: Color4[];
  62323. updatable?: boolean;
  62324. sideOrientation?: number;
  62325. frontUVs?: Vector4;
  62326. backUVs?: Vector4;
  62327. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62328. /**
  62329. * Creates an extruded polygon mesh, with depth in the Y direction.
  62330. * * 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)
  62331. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62332. * @param name defines the name of the mesh
  62333. * @param options defines the options used to create the mesh
  62334. * @param scene defines the hosting scene
  62335. * @param earcutInjection can be used to inject your own earcut reference
  62336. * @returns the polygon mesh
  62337. */
  62338. static ExtrudePolygon(name: string, options: {
  62339. shape: Vector3[];
  62340. holes?: Vector3[][];
  62341. depth?: number;
  62342. faceUV?: Vector4[];
  62343. faceColors?: Color4[];
  62344. updatable?: boolean;
  62345. sideOrientation?: number;
  62346. frontUVs?: Vector4;
  62347. backUVs?: Vector4;
  62348. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62349. /**
  62350. * Creates a tube mesh.
  62351. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62352. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62353. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62354. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62355. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62356. * * 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)
  62357. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62358. * * 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
  62359. * * 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
  62360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62361. * * 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
  62362. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62364. * @param name defines the name of the mesh
  62365. * @param options defines the options used to create the mesh
  62366. * @param scene defines the hosting scene
  62367. * @returns the tube mesh
  62368. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62369. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62370. */
  62371. static CreateTube(name: string, options: {
  62372. path: Vector3[];
  62373. radius?: number;
  62374. tessellation?: number;
  62375. radiusFunction?: {
  62376. (i: number, distance: number): number;
  62377. };
  62378. cap?: number;
  62379. arc?: number;
  62380. updatable?: boolean;
  62381. sideOrientation?: number;
  62382. frontUVs?: Vector4;
  62383. backUVs?: Vector4;
  62384. instance?: Mesh;
  62385. invertUV?: boolean;
  62386. }, scene?: Nullable<Scene>): Mesh;
  62387. /**
  62388. * Creates a polyhedron mesh
  62389. * * 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
  62390. * * The parameter `size` (positive float, default 1) sets the polygon size
  62391. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62392. * * 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`
  62393. * * 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
  62394. * * 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)`)
  62395. * * 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
  62396. * * 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
  62397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62398. * * 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
  62399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62400. * @param name defines the name of the mesh
  62401. * @param options defines the options used to create the mesh
  62402. * @param scene defines the hosting scene
  62403. * @returns the polyhedron mesh
  62404. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62405. */
  62406. static CreatePolyhedron(name: string, options: {
  62407. type?: number;
  62408. size?: number;
  62409. sizeX?: number;
  62410. sizeY?: number;
  62411. sizeZ?: number;
  62412. custom?: any;
  62413. faceUV?: Vector4[];
  62414. faceColors?: Color4[];
  62415. flat?: boolean;
  62416. updatable?: boolean;
  62417. sideOrientation?: number;
  62418. frontUVs?: Vector4;
  62419. backUVs?: Vector4;
  62420. }, scene?: Nullable<Scene>): Mesh;
  62421. /**
  62422. * Creates a decal mesh.
  62423. * 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
  62424. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62425. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62426. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62427. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62428. * @param name defines the name of the mesh
  62429. * @param sourceMesh defines the mesh where the decal must be applied
  62430. * @param options defines the options used to create the mesh
  62431. * @param scene defines the hosting scene
  62432. * @returns the decal mesh
  62433. * @see https://doc.babylonjs.com/how_to/decals
  62434. */
  62435. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62436. position?: Vector3;
  62437. normal?: Vector3;
  62438. size?: Vector3;
  62439. angle?: number;
  62440. }): Mesh;
  62441. }
  62442. }
  62443. declare module BABYLON {
  62444. /**
  62445. * A simplifier interface for future simplification implementations
  62446. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62447. */
  62448. export interface ISimplifier {
  62449. /**
  62450. * Simplification of a given mesh according to the given settings.
  62451. * Since this requires computation, it is assumed that the function runs async.
  62452. * @param settings The settings of the simplification, including quality and distance
  62453. * @param successCallback A callback that will be called after the mesh was simplified.
  62454. * @param errorCallback in case of an error, this callback will be called. optional.
  62455. */
  62456. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62457. }
  62458. /**
  62459. * Expected simplification settings.
  62460. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62461. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62462. */
  62463. export interface ISimplificationSettings {
  62464. /**
  62465. * Gets or sets the expected quality
  62466. */
  62467. quality: number;
  62468. /**
  62469. * Gets or sets the distance when this optimized version should be used
  62470. */
  62471. distance: number;
  62472. /**
  62473. * Gets an already optimized mesh
  62474. */
  62475. optimizeMesh?: boolean;
  62476. }
  62477. /**
  62478. * Class used to specify simplification options
  62479. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62480. */
  62481. export class SimplificationSettings implements ISimplificationSettings {
  62482. /** expected quality */
  62483. quality: number;
  62484. /** distance when this optimized version should be used */
  62485. distance: number;
  62486. /** already optimized mesh */
  62487. optimizeMesh?: boolean | undefined;
  62488. /**
  62489. * Creates a SimplificationSettings
  62490. * @param quality expected quality
  62491. * @param distance distance when this optimized version should be used
  62492. * @param optimizeMesh already optimized mesh
  62493. */
  62494. constructor(
  62495. /** expected quality */
  62496. quality: number,
  62497. /** distance when this optimized version should be used */
  62498. distance: number,
  62499. /** already optimized mesh */
  62500. optimizeMesh?: boolean | undefined);
  62501. }
  62502. /**
  62503. * Interface used to define a simplification task
  62504. */
  62505. export interface ISimplificationTask {
  62506. /**
  62507. * Array of settings
  62508. */
  62509. settings: Array<ISimplificationSettings>;
  62510. /**
  62511. * Simplification type
  62512. */
  62513. simplificationType: SimplificationType;
  62514. /**
  62515. * Mesh to simplify
  62516. */
  62517. mesh: Mesh;
  62518. /**
  62519. * Callback called on success
  62520. */
  62521. successCallback?: () => void;
  62522. /**
  62523. * Defines if parallel processing can be used
  62524. */
  62525. parallelProcessing: boolean;
  62526. }
  62527. /**
  62528. * Queue used to order the simplification tasks
  62529. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62530. */
  62531. export class SimplificationQueue {
  62532. private _simplificationArray;
  62533. /**
  62534. * Gets a boolean indicating that the process is still running
  62535. */
  62536. running: boolean;
  62537. /**
  62538. * Creates a new queue
  62539. */
  62540. constructor();
  62541. /**
  62542. * Adds a new simplification task
  62543. * @param task defines a task to add
  62544. */
  62545. addTask(task: ISimplificationTask): void;
  62546. /**
  62547. * Execute next task
  62548. */
  62549. executeNext(): void;
  62550. /**
  62551. * Execute a simplification task
  62552. * @param task defines the task to run
  62553. */
  62554. runSimplification(task: ISimplificationTask): void;
  62555. private getSimplifier;
  62556. }
  62557. /**
  62558. * The implemented types of simplification
  62559. * At the moment only Quadratic Error Decimation is implemented
  62560. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62561. */
  62562. export enum SimplificationType {
  62563. /** Quadratic error decimation */
  62564. QUADRATIC = 0
  62565. }
  62566. /**
  62567. * An implementation of the Quadratic Error simplification algorithm.
  62568. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62569. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62570. * @author RaananW
  62571. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62572. */
  62573. export class QuadraticErrorSimplification implements ISimplifier {
  62574. private _mesh;
  62575. private triangles;
  62576. private vertices;
  62577. private references;
  62578. private _reconstructedMesh;
  62579. /** Gets or sets the number pf sync interations */
  62580. syncIterations: number;
  62581. /** Gets or sets the aggressiveness of the simplifier */
  62582. aggressiveness: number;
  62583. /** Gets or sets the number of allowed iterations for decimation */
  62584. decimationIterations: number;
  62585. /** Gets or sets the espilon to use for bounding box computation */
  62586. boundingBoxEpsilon: number;
  62587. /**
  62588. * Creates a new QuadraticErrorSimplification
  62589. * @param _mesh defines the target mesh
  62590. */
  62591. constructor(_mesh: Mesh);
  62592. /**
  62593. * Simplification of a given mesh according to the given settings.
  62594. * Since this requires computation, it is assumed that the function runs async.
  62595. * @param settings The settings of the simplification, including quality and distance
  62596. * @param successCallback A callback that will be called after the mesh was simplified.
  62597. */
  62598. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62599. private runDecimation;
  62600. private initWithMesh;
  62601. private init;
  62602. private reconstructMesh;
  62603. private initDecimatedMesh;
  62604. private isFlipped;
  62605. private updateTriangles;
  62606. private identifyBorder;
  62607. private updateMesh;
  62608. private vertexError;
  62609. private calculateError;
  62610. }
  62611. }
  62612. declare module BABYLON {
  62613. interface Scene {
  62614. /** @hidden (Backing field) */
  62615. _simplificationQueue: SimplificationQueue;
  62616. /**
  62617. * Gets or sets the simplification queue attached to the scene
  62618. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62619. */
  62620. simplificationQueue: SimplificationQueue;
  62621. }
  62622. interface Mesh {
  62623. /**
  62624. * Simplify the mesh according to the given array of settings.
  62625. * Function will return immediately and will simplify async
  62626. * @param settings a collection of simplification settings
  62627. * @param parallelProcessing should all levels calculate parallel or one after the other
  62628. * @param simplificationType the type of simplification to run
  62629. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62630. * @returns the current mesh
  62631. */
  62632. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62633. }
  62634. /**
  62635. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62636. * created in a scene
  62637. */
  62638. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62639. /**
  62640. * The component name helpfull to identify the component in the list of scene components.
  62641. */
  62642. readonly name: string;
  62643. /**
  62644. * The scene the component belongs to.
  62645. */
  62646. scene: Scene;
  62647. /**
  62648. * Creates a new instance of the component for the given scene
  62649. * @param scene Defines the scene to register the component in
  62650. */
  62651. constructor(scene: Scene);
  62652. /**
  62653. * Registers the component in a given scene
  62654. */
  62655. register(): void;
  62656. /**
  62657. * Rebuilds the elements related to this component in case of
  62658. * context lost for instance.
  62659. */
  62660. rebuild(): void;
  62661. /**
  62662. * Disposes the component and the associated ressources
  62663. */
  62664. dispose(): void;
  62665. private _beforeCameraUpdate;
  62666. }
  62667. }
  62668. declare module BABYLON {
  62669. /**
  62670. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62671. */
  62672. export interface INavigationEnginePlugin {
  62673. /**
  62674. * plugin name
  62675. */
  62676. name: string;
  62677. /**
  62678. * Creates a navigation mesh
  62679. * @param meshes array of all the geometry used to compute the navigatio mesh
  62680. * @param parameters bunch of parameters used to filter geometry
  62681. */
  62682. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62683. /**
  62684. * Create a navigation mesh debug mesh
  62685. * @param scene is where the mesh will be added
  62686. * @returns debug display mesh
  62687. */
  62688. createDebugNavMesh(scene: Scene): Mesh;
  62689. /**
  62690. * Get a navigation mesh constrained position, closest to the parameter position
  62691. * @param position world position
  62692. * @returns the closest point to position constrained by the navigation mesh
  62693. */
  62694. getClosestPoint(position: Vector3): Vector3;
  62695. /**
  62696. * Get a navigation mesh constrained position, closest to the parameter position
  62697. * @param position world position
  62698. * @param result output the closest point to position constrained by the navigation mesh
  62699. */
  62700. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62701. /**
  62702. * Get a navigation mesh constrained position, within a particular radius
  62703. * @param position world position
  62704. * @param maxRadius the maximum distance to the constrained world position
  62705. * @returns the closest point to position constrained by the navigation mesh
  62706. */
  62707. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62708. /**
  62709. * Get a navigation mesh constrained position, within a particular radius
  62710. * @param position world position
  62711. * @param maxRadius the maximum distance to the constrained world position
  62712. * @param result output the closest point to position constrained by the navigation mesh
  62713. */
  62714. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62715. /**
  62716. * Compute the final position from a segment made of destination-position
  62717. * @param position world position
  62718. * @param destination world position
  62719. * @returns the resulting point along the navmesh
  62720. */
  62721. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62722. /**
  62723. * Compute the final position from a segment made of destination-position
  62724. * @param position world position
  62725. * @param destination world position
  62726. * @param result output the resulting point along the navmesh
  62727. */
  62728. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62729. /**
  62730. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62731. * @param start world position
  62732. * @param end world position
  62733. * @returns array containing world position composing the path
  62734. */
  62735. computePath(start: Vector3, end: Vector3): Vector3[];
  62736. /**
  62737. * If this plugin is supported
  62738. * @returns true if plugin is supported
  62739. */
  62740. isSupported(): boolean;
  62741. /**
  62742. * Create a new Crowd so you can add agents
  62743. * @param maxAgents the maximum agent count in the crowd
  62744. * @param maxAgentRadius the maximum radius an agent can have
  62745. * @param scene to attach the crowd to
  62746. * @returns the crowd you can add agents to
  62747. */
  62748. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62749. /**
  62750. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62751. * The queries will try to find a solution within those bounds
  62752. * default is (1,1,1)
  62753. * @param extent x,y,z value that define the extent around the queries point of reference
  62754. */
  62755. setDefaultQueryExtent(extent: Vector3): void;
  62756. /**
  62757. * Get the Bounding box extent specified by setDefaultQueryExtent
  62758. * @returns the box extent values
  62759. */
  62760. getDefaultQueryExtent(): Vector3;
  62761. /**
  62762. * build the navmesh from a previously saved state using getNavmeshData
  62763. * @param data the Uint8Array returned by getNavmeshData
  62764. */
  62765. buildFromNavmeshData(data: Uint8Array): void;
  62766. /**
  62767. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62768. * @returns data the Uint8Array that can be saved and reused
  62769. */
  62770. getNavmeshData(): Uint8Array;
  62771. /**
  62772. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62773. * @param result output the box extent values
  62774. */
  62775. getDefaultQueryExtentToRef(result: Vector3): void;
  62776. /**
  62777. * Release all resources
  62778. */
  62779. dispose(): void;
  62780. }
  62781. /**
  62782. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62783. */
  62784. export interface ICrowd {
  62785. /**
  62786. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62787. * You can attach anything to that node. The node position is updated in the scene update tick.
  62788. * @param pos world position that will be constrained by the navigation mesh
  62789. * @param parameters agent parameters
  62790. * @param transform hooked to the agent that will be update by the scene
  62791. * @returns agent index
  62792. */
  62793. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62794. /**
  62795. * Returns the agent position in world space
  62796. * @param index agent index returned by addAgent
  62797. * @returns world space position
  62798. */
  62799. getAgentPosition(index: number): Vector3;
  62800. /**
  62801. * Gets the agent position result in world space
  62802. * @param index agent index returned by addAgent
  62803. * @param result output world space position
  62804. */
  62805. getAgentPositionToRef(index: number, result: Vector3): void;
  62806. /**
  62807. * Gets the agent velocity in world space
  62808. * @param index agent index returned by addAgent
  62809. * @returns world space velocity
  62810. */
  62811. getAgentVelocity(index: number): Vector3;
  62812. /**
  62813. * Gets the agent velocity result in world space
  62814. * @param index agent index returned by addAgent
  62815. * @param result output world space velocity
  62816. */
  62817. getAgentVelocityToRef(index: number, result: Vector3): void;
  62818. /**
  62819. * remove a particular agent previously created
  62820. * @param index agent index returned by addAgent
  62821. */
  62822. removeAgent(index: number): void;
  62823. /**
  62824. * get the list of all agents attached to this crowd
  62825. * @returns list of agent indices
  62826. */
  62827. getAgents(): number[];
  62828. /**
  62829. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62830. * @param deltaTime in seconds
  62831. */
  62832. update(deltaTime: number): void;
  62833. /**
  62834. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62835. * @param index agent index returned by addAgent
  62836. * @param destination targeted world position
  62837. */
  62838. agentGoto(index: number, destination: Vector3): void;
  62839. /**
  62840. * Teleport the agent to a new position
  62841. * @param index agent index returned by addAgent
  62842. * @param destination targeted world position
  62843. */
  62844. agentTeleport(index: number, destination: Vector3): void;
  62845. /**
  62846. * Update agent parameters
  62847. * @param index agent index returned by addAgent
  62848. * @param parameters agent parameters
  62849. */
  62850. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62851. /**
  62852. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62853. * The queries will try to find a solution within those bounds
  62854. * default is (1,1,1)
  62855. * @param extent x,y,z value that define the extent around the queries point of reference
  62856. */
  62857. setDefaultQueryExtent(extent: Vector3): void;
  62858. /**
  62859. * Get the Bounding box extent specified by setDefaultQueryExtent
  62860. * @returns the box extent values
  62861. */
  62862. getDefaultQueryExtent(): Vector3;
  62863. /**
  62864. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62865. * @param result output the box extent values
  62866. */
  62867. getDefaultQueryExtentToRef(result: Vector3): void;
  62868. /**
  62869. * Release all resources
  62870. */
  62871. dispose(): void;
  62872. }
  62873. /**
  62874. * Configures an agent
  62875. */
  62876. export interface IAgentParameters {
  62877. /**
  62878. * Agent radius. [Limit: >= 0]
  62879. */
  62880. radius: number;
  62881. /**
  62882. * Agent height. [Limit: > 0]
  62883. */
  62884. height: number;
  62885. /**
  62886. * Maximum allowed acceleration. [Limit: >= 0]
  62887. */
  62888. maxAcceleration: number;
  62889. /**
  62890. * Maximum allowed speed. [Limit: >= 0]
  62891. */
  62892. maxSpeed: number;
  62893. /**
  62894. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62895. */
  62896. collisionQueryRange: number;
  62897. /**
  62898. * The path visibility optimization range. [Limit: > 0]
  62899. */
  62900. pathOptimizationRange: number;
  62901. /**
  62902. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62903. */
  62904. separationWeight: number;
  62905. }
  62906. /**
  62907. * Configures the navigation mesh creation
  62908. */
  62909. export interface INavMeshParameters {
  62910. /**
  62911. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62912. */
  62913. cs: number;
  62914. /**
  62915. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62916. */
  62917. ch: number;
  62918. /**
  62919. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62920. */
  62921. walkableSlopeAngle: number;
  62922. /**
  62923. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62924. * be considered walkable. [Limit: >= 3] [Units: vx]
  62925. */
  62926. walkableHeight: number;
  62927. /**
  62928. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62929. */
  62930. walkableClimb: number;
  62931. /**
  62932. * The distance to erode/shrink the walkable area of the heightfield away from
  62933. * obstructions. [Limit: >=0] [Units: vx]
  62934. */
  62935. walkableRadius: number;
  62936. /**
  62937. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62938. */
  62939. maxEdgeLen: number;
  62940. /**
  62941. * The maximum distance a simplfied contour's border edges should deviate
  62942. * the original raw contour. [Limit: >=0] [Units: vx]
  62943. */
  62944. maxSimplificationError: number;
  62945. /**
  62946. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62947. */
  62948. minRegionArea: number;
  62949. /**
  62950. * Any regions with a span count smaller than this value will, if possible,
  62951. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62952. */
  62953. mergeRegionArea: number;
  62954. /**
  62955. * The maximum number of vertices allowed for polygons generated during the
  62956. * contour to polygon conversion process. [Limit: >= 3]
  62957. */
  62958. maxVertsPerPoly: number;
  62959. /**
  62960. * Sets the sampling distance to use when generating the detail mesh.
  62961. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62962. */
  62963. detailSampleDist: number;
  62964. /**
  62965. * The maximum distance the detail mesh surface should deviate from heightfield
  62966. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62967. */
  62968. detailSampleMaxError: number;
  62969. }
  62970. }
  62971. declare module BABYLON {
  62972. /**
  62973. * RecastJS navigation plugin
  62974. */
  62975. export class RecastJSPlugin implements INavigationEnginePlugin {
  62976. /**
  62977. * Reference to the Recast library
  62978. */
  62979. bjsRECAST: any;
  62980. /**
  62981. * plugin name
  62982. */
  62983. name: string;
  62984. /**
  62985. * the first navmesh created. We might extend this to support multiple navmeshes
  62986. */
  62987. navMesh: any;
  62988. /**
  62989. * Initializes the recastJS plugin
  62990. * @param recastInjection can be used to inject your own recast reference
  62991. */
  62992. constructor(recastInjection?: any);
  62993. /**
  62994. * Creates a navigation mesh
  62995. * @param meshes array of all the geometry used to compute the navigatio mesh
  62996. * @param parameters bunch of parameters used to filter geometry
  62997. */
  62998. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62999. /**
  63000. * Create a navigation mesh debug mesh
  63001. * @param scene is where the mesh will be added
  63002. * @returns debug display mesh
  63003. */
  63004. createDebugNavMesh(scene: Scene): Mesh;
  63005. /**
  63006. * Get a navigation mesh constrained position, closest to the parameter position
  63007. * @param position world position
  63008. * @returns the closest point to position constrained by the navigation mesh
  63009. */
  63010. getClosestPoint(position: Vector3): Vector3;
  63011. /**
  63012. * Get a navigation mesh constrained position, closest to the parameter position
  63013. * @param position world position
  63014. * @param result output the closest point to position constrained by the navigation mesh
  63015. */
  63016. getClosestPointToRef(position: Vector3, result: Vector3): void;
  63017. /**
  63018. * Get a navigation mesh constrained position, within a particular radius
  63019. * @param position world position
  63020. * @param maxRadius the maximum distance to the constrained world position
  63021. * @returns the closest point to position constrained by the navigation mesh
  63022. */
  63023. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63024. /**
  63025. * Get a navigation mesh constrained position, within a particular radius
  63026. * @param position world position
  63027. * @param maxRadius the maximum distance to the constrained world position
  63028. * @param result output the closest point to position constrained by the navigation mesh
  63029. */
  63030. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  63031. /**
  63032. * Compute the final position from a segment made of destination-position
  63033. * @param position world position
  63034. * @param destination world position
  63035. * @returns the resulting point along the navmesh
  63036. */
  63037. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63038. /**
  63039. * Compute the final position from a segment made of destination-position
  63040. * @param position world position
  63041. * @param destination world position
  63042. * @param result output the resulting point along the navmesh
  63043. */
  63044. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  63045. /**
  63046. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63047. * @param start world position
  63048. * @param end world position
  63049. * @returns array containing world position composing the path
  63050. */
  63051. computePath(start: Vector3, end: Vector3): Vector3[];
  63052. /**
  63053. * Create a new Crowd so you can add agents
  63054. * @param maxAgents the maximum agent count in the crowd
  63055. * @param maxAgentRadius the maximum radius an agent can have
  63056. * @param scene to attach the crowd to
  63057. * @returns the crowd you can add agents to
  63058. */
  63059. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63060. /**
  63061. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63062. * The queries will try to find a solution within those bounds
  63063. * default is (1,1,1)
  63064. * @param extent x,y,z value that define the extent around the queries point of reference
  63065. */
  63066. setDefaultQueryExtent(extent: Vector3): void;
  63067. /**
  63068. * Get the Bounding box extent specified by setDefaultQueryExtent
  63069. * @returns the box extent values
  63070. */
  63071. getDefaultQueryExtent(): Vector3;
  63072. /**
  63073. * build the navmesh from a previously saved state using getNavmeshData
  63074. * @param data the Uint8Array returned by getNavmeshData
  63075. */
  63076. buildFromNavmeshData(data: Uint8Array): void;
  63077. /**
  63078. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63079. * @returns data the Uint8Array that can be saved and reused
  63080. */
  63081. getNavmeshData(): Uint8Array;
  63082. /**
  63083. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63084. * @param result output the box extent values
  63085. */
  63086. getDefaultQueryExtentToRef(result: Vector3): void;
  63087. /**
  63088. * Disposes
  63089. */
  63090. dispose(): void;
  63091. /**
  63092. * If this plugin is supported
  63093. * @returns true if plugin is supported
  63094. */
  63095. isSupported(): boolean;
  63096. }
  63097. /**
  63098. * Recast detour crowd implementation
  63099. */
  63100. export class RecastJSCrowd implements ICrowd {
  63101. /**
  63102. * Recast/detour plugin
  63103. */
  63104. bjsRECASTPlugin: RecastJSPlugin;
  63105. /**
  63106. * Link to the detour crowd
  63107. */
  63108. recastCrowd: any;
  63109. /**
  63110. * One transform per agent
  63111. */
  63112. transforms: TransformNode[];
  63113. /**
  63114. * All agents created
  63115. */
  63116. agents: number[];
  63117. /**
  63118. * Link to the scene is kept to unregister the crowd from the scene
  63119. */
  63120. private _scene;
  63121. /**
  63122. * Observer for crowd updates
  63123. */
  63124. private _onBeforeAnimationsObserver;
  63125. /**
  63126. * Constructor
  63127. * @param plugin recastJS plugin
  63128. * @param maxAgents the maximum agent count in the crowd
  63129. * @param maxAgentRadius the maximum radius an agent can have
  63130. * @param scene to attach the crowd to
  63131. * @returns the crowd you can add agents to
  63132. */
  63133. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63134. /**
  63135. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63136. * You can attach anything to that node. The node position is updated in the scene update tick.
  63137. * @param pos world position that will be constrained by the navigation mesh
  63138. * @param parameters agent parameters
  63139. * @param transform hooked to the agent that will be update by the scene
  63140. * @returns agent index
  63141. */
  63142. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63143. /**
  63144. * Returns the agent position in world space
  63145. * @param index agent index returned by addAgent
  63146. * @returns world space position
  63147. */
  63148. getAgentPosition(index: number): Vector3;
  63149. /**
  63150. * Returns the agent position result in world space
  63151. * @param index agent index returned by addAgent
  63152. * @param result output world space position
  63153. */
  63154. getAgentPositionToRef(index: number, result: Vector3): void;
  63155. /**
  63156. * Returns the agent velocity in world space
  63157. * @param index agent index returned by addAgent
  63158. * @returns world space velocity
  63159. */
  63160. getAgentVelocity(index: number): Vector3;
  63161. /**
  63162. * Returns the agent velocity result in world space
  63163. * @param index agent index returned by addAgent
  63164. * @param result output world space velocity
  63165. */
  63166. getAgentVelocityToRef(index: number, result: Vector3): void;
  63167. /**
  63168. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63169. * @param index agent index returned by addAgent
  63170. * @param destination targeted world position
  63171. */
  63172. agentGoto(index: number, destination: Vector3): void;
  63173. /**
  63174. * Teleport the agent to a new position
  63175. * @param index agent index returned by addAgent
  63176. * @param destination targeted world position
  63177. */
  63178. agentTeleport(index: number, destination: Vector3): void;
  63179. /**
  63180. * Update agent parameters
  63181. * @param index agent index returned by addAgent
  63182. * @param parameters agent parameters
  63183. */
  63184. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63185. /**
  63186. * remove a particular agent previously created
  63187. * @param index agent index returned by addAgent
  63188. */
  63189. removeAgent(index: number): void;
  63190. /**
  63191. * get the list of all agents attached to this crowd
  63192. * @returns list of agent indices
  63193. */
  63194. getAgents(): number[];
  63195. /**
  63196. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63197. * @param deltaTime in seconds
  63198. */
  63199. update(deltaTime: number): void;
  63200. /**
  63201. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63202. * The queries will try to find a solution within those bounds
  63203. * default is (1,1,1)
  63204. * @param extent x,y,z value that define the extent around the queries point of reference
  63205. */
  63206. setDefaultQueryExtent(extent: Vector3): void;
  63207. /**
  63208. * Get the Bounding box extent specified by setDefaultQueryExtent
  63209. * @returns the box extent values
  63210. */
  63211. getDefaultQueryExtent(): Vector3;
  63212. /**
  63213. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63214. * @param result output the box extent values
  63215. */
  63216. getDefaultQueryExtentToRef(result: Vector3): void;
  63217. /**
  63218. * Release all resources
  63219. */
  63220. dispose(): void;
  63221. }
  63222. }
  63223. declare module BABYLON {
  63224. /**
  63225. * Class used to enable access to IndexedDB
  63226. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63227. */
  63228. export class Database implements IOfflineProvider {
  63229. private _callbackManifestChecked;
  63230. private _currentSceneUrl;
  63231. private _db;
  63232. private _enableSceneOffline;
  63233. private _enableTexturesOffline;
  63234. private _manifestVersionFound;
  63235. private _mustUpdateRessources;
  63236. private _hasReachedQuota;
  63237. private _isSupported;
  63238. private _idbFactory;
  63239. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63240. private static IsUASupportingBlobStorage;
  63241. /**
  63242. * Gets a boolean indicating if Database storate is enabled (off by default)
  63243. */
  63244. static IDBStorageEnabled: boolean;
  63245. /**
  63246. * Gets a boolean indicating if scene must be saved in the database
  63247. */
  63248. get enableSceneOffline(): boolean;
  63249. /**
  63250. * Gets a boolean indicating if textures must be saved in the database
  63251. */
  63252. get enableTexturesOffline(): boolean;
  63253. /**
  63254. * Creates a new Database
  63255. * @param urlToScene defines the url to load the scene
  63256. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63257. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63258. */
  63259. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63260. private static _ParseURL;
  63261. private static _ReturnFullUrlLocation;
  63262. private _checkManifestFile;
  63263. /**
  63264. * Open the database and make it available
  63265. * @param successCallback defines the callback to call on success
  63266. * @param errorCallback defines the callback to call on error
  63267. */
  63268. open(successCallback: () => void, errorCallback: () => void): void;
  63269. /**
  63270. * Loads an image from the database
  63271. * @param url defines the url to load from
  63272. * @param image defines the target DOM image
  63273. */
  63274. loadImage(url: string, image: HTMLImageElement): void;
  63275. private _loadImageFromDBAsync;
  63276. private _saveImageIntoDBAsync;
  63277. private _checkVersionFromDB;
  63278. private _loadVersionFromDBAsync;
  63279. private _saveVersionIntoDBAsync;
  63280. /**
  63281. * Loads a file from database
  63282. * @param url defines the URL to load from
  63283. * @param sceneLoaded defines a callback to call on success
  63284. * @param progressCallBack defines a callback to call when progress changed
  63285. * @param errorCallback defines a callback to call on error
  63286. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63287. */
  63288. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63289. private _loadFileAsync;
  63290. private _saveFileAsync;
  63291. /**
  63292. * Validates if xhr data is correct
  63293. * @param xhr defines the request to validate
  63294. * @param dataType defines the expected data type
  63295. * @returns true if data is correct
  63296. */
  63297. private static _ValidateXHRData;
  63298. }
  63299. }
  63300. declare module BABYLON {
  63301. /** @hidden */
  63302. export var gpuUpdateParticlesPixelShader: {
  63303. name: string;
  63304. shader: string;
  63305. };
  63306. }
  63307. declare module BABYLON {
  63308. /** @hidden */
  63309. export var gpuUpdateParticlesVertexShader: {
  63310. name: string;
  63311. shader: string;
  63312. };
  63313. }
  63314. declare module BABYLON {
  63315. /** @hidden */
  63316. export var clipPlaneFragmentDeclaration2: {
  63317. name: string;
  63318. shader: string;
  63319. };
  63320. }
  63321. declare module BABYLON {
  63322. /** @hidden */
  63323. export var gpuRenderParticlesPixelShader: {
  63324. name: string;
  63325. shader: string;
  63326. };
  63327. }
  63328. declare module BABYLON {
  63329. /** @hidden */
  63330. export var clipPlaneVertexDeclaration2: {
  63331. name: string;
  63332. shader: string;
  63333. };
  63334. }
  63335. declare module BABYLON {
  63336. /** @hidden */
  63337. export var gpuRenderParticlesVertexShader: {
  63338. name: string;
  63339. shader: string;
  63340. };
  63341. }
  63342. declare module BABYLON {
  63343. /**
  63344. * This represents a GPU particle system in Babylon
  63345. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63346. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63347. */
  63348. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63349. /**
  63350. * The layer mask we are rendering the particles through.
  63351. */
  63352. layerMask: number;
  63353. private _capacity;
  63354. private _activeCount;
  63355. private _currentActiveCount;
  63356. private _accumulatedCount;
  63357. private _renderEffect;
  63358. private _updateEffect;
  63359. private _buffer0;
  63360. private _buffer1;
  63361. private _spriteBuffer;
  63362. private _updateVAO;
  63363. private _renderVAO;
  63364. private _targetIndex;
  63365. private _sourceBuffer;
  63366. private _targetBuffer;
  63367. private _engine;
  63368. private _currentRenderId;
  63369. private _started;
  63370. private _stopped;
  63371. private _timeDelta;
  63372. private _randomTexture;
  63373. private _randomTexture2;
  63374. private _attributesStrideSize;
  63375. private _updateEffectOptions;
  63376. private _randomTextureSize;
  63377. private _actualFrame;
  63378. private readonly _rawTextureWidth;
  63379. /**
  63380. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63381. */
  63382. static get IsSupported(): boolean;
  63383. /**
  63384. * An event triggered when the system is disposed.
  63385. */
  63386. onDisposeObservable: Observable<GPUParticleSystem>;
  63387. /**
  63388. * Gets the maximum number of particles active at the same time.
  63389. * @returns The max number of active particles.
  63390. */
  63391. getCapacity(): number;
  63392. /**
  63393. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63394. * to override the particles.
  63395. */
  63396. forceDepthWrite: boolean;
  63397. /**
  63398. * Gets or set the number of active particles
  63399. */
  63400. get activeParticleCount(): number;
  63401. set activeParticleCount(value: number);
  63402. private _preWarmDone;
  63403. /**
  63404. * Specifies if the particles are updated in emitter local space or world space.
  63405. */
  63406. isLocal: boolean;
  63407. /**
  63408. * Is this system ready to be used/rendered
  63409. * @return true if the system is ready
  63410. */
  63411. isReady(): boolean;
  63412. /**
  63413. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63414. * @returns True if it has been started, otherwise false.
  63415. */
  63416. isStarted(): boolean;
  63417. /**
  63418. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63419. * @returns True if it has been stopped, otherwise false.
  63420. */
  63421. isStopped(): boolean;
  63422. /**
  63423. * Gets a boolean indicating that the system is stopping
  63424. * @returns true if the system is currently stopping
  63425. */
  63426. isStopping(): boolean;
  63427. /**
  63428. * Gets the number of particles active at the same time.
  63429. * @returns The number of active particles.
  63430. */
  63431. getActiveCount(): number;
  63432. /**
  63433. * Starts the particle system and begins to emit
  63434. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63435. */
  63436. start(delay?: number): void;
  63437. /**
  63438. * Stops the particle system.
  63439. */
  63440. stop(): void;
  63441. /**
  63442. * Remove all active particles
  63443. */
  63444. reset(): void;
  63445. /**
  63446. * Returns the string "GPUParticleSystem"
  63447. * @returns a string containing the class name
  63448. */
  63449. getClassName(): string;
  63450. private _colorGradientsTexture;
  63451. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63452. /**
  63453. * Adds a new color gradient
  63454. * @param gradient defines the gradient to use (between 0 and 1)
  63455. * @param color1 defines the color to affect to the specified gradient
  63456. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63457. * @returns the current particle system
  63458. */
  63459. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63460. private _refreshColorGradient;
  63461. /** Force the system to rebuild all gradients that need to be resync */
  63462. forceRefreshGradients(): void;
  63463. /**
  63464. * Remove a specific color gradient
  63465. * @param gradient defines the gradient to remove
  63466. * @returns the current particle system
  63467. */
  63468. removeColorGradient(gradient: number): GPUParticleSystem;
  63469. private _angularSpeedGradientsTexture;
  63470. private _sizeGradientsTexture;
  63471. private _velocityGradientsTexture;
  63472. private _limitVelocityGradientsTexture;
  63473. private _dragGradientsTexture;
  63474. private _addFactorGradient;
  63475. /**
  63476. * Adds a new size gradient
  63477. * @param gradient defines the gradient to use (between 0 and 1)
  63478. * @param factor defines the size factor to affect to the specified gradient
  63479. * @returns the current particle system
  63480. */
  63481. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63482. /**
  63483. * Remove a specific size gradient
  63484. * @param gradient defines the gradient to remove
  63485. * @returns the current particle system
  63486. */
  63487. removeSizeGradient(gradient: number): GPUParticleSystem;
  63488. private _refreshFactorGradient;
  63489. /**
  63490. * Adds a new angular speed gradient
  63491. * @param gradient defines the gradient to use (between 0 and 1)
  63492. * @param factor defines the angular speed to affect to the specified gradient
  63493. * @returns the current particle system
  63494. */
  63495. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63496. /**
  63497. * Remove a specific angular speed gradient
  63498. * @param gradient defines the gradient to remove
  63499. * @returns the current particle system
  63500. */
  63501. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63502. /**
  63503. * Adds a new velocity gradient
  63504. * @param gradient defines the gradient to use (between 0 and 1)
  63505. * @param factor defines the velocity to affect to the specified gradient
  63506. * @returns the current particle system
  63507. */
  63508. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63509. /**
  63510. * Remove a specific velocity gradient
  63511. * @param gradient defines the gradient to remove
  63512. * @returns the current particle system
  63513. */
  63514. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63515. /**
  63516. * Adds a new limit velocity gradient
  63517. * @param gradient defines the gradient to use (between 0 and 1)
  63518. * @param factor defines the limit velocity value to affect to the specified gradient
  63519. * @returns the current particle system
  63520. */
  63521. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63522. /**
  63523. * Remove a specific limit velocity gradient
  63524. * @param gradient defines the gradient to remove
  63525. * @returns the current particle system
  63526. */
  63527. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63528. /**
  63529. * Adds a new drag gradient
  63530. * @param gradient defines the gradient to use (between 0 and 1)
  63531. * @param factor defines the drag value to affect to the specified gradient
  63532. * @returns the current particle system
  63533. */
  63534. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63535. /**
  63536. * Remove a specific drag gradient
  63537. * @param gradient defines the gradient to remove
  63538. * @returns the current particle system
  63539. */
  63540. removeDragGradient(gradient: number): GPUParticleSystem;
  63541. /**
  63542. * Not supported by GPUParticleSystem
  63543. * @param gradient defines the gradient to use (between 0 and 1)
  63544. * @param factor defines the emit rate value to affect to the specified gradient
  63545. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63546. * @returns the current particle system
  63547. */
  63548. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63549. /**
  63550. * Not supported by GPUParticleSystem
  63551. * @param gradient defines the gradient to remove
  63552. * @returns the current particle system
  63553. */
  63554. removeEmitRateGradient(gradient: number): IParticleSystem;
  63555. /**
  63556. * Not supported by GPUParticleSystem
  63557. * @param gradient defines the gradient to use (between 0 and 1)
  63558. * @param factor defines the start size value to affect to the specified gradient
  63559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63560. * @returns the current particle system
  63561. */
  63562. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63563. /**
  63564. * Not supported by GPUParticleSystem
  63565. * @param gradient defines the gradient to remove
  63566. * @returns the current particle system
  63567. */
  63568. removeStartSizeGradient(gradient: number): IParticleSystem;
  63569. /**
  63570. * Not supported by GPUParticleSystem
  63571. * @param gradient defines the gradient to use (between 0 and 1)
  63572. * @param min defines the color remap minimal range
  63573. * @param max defines the color remap maximal range
  63574. * @returns the current particle system
  63575. */
  63576. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63577. /**
  63578. * Not supported by GPUParticleSystem
  63579. * @param gradient defines the gradient to remove
  63580. * @returns the current particle system
  63581. */
  63582. removeColorRemapGradient(): IParticleSystem;
  63583. /**
  63584. * Not supported by GPUParticleSystem
  63585. * @param gradient defines the gradient to use (between 0 and 1)
  63586. * @param min defines the alpha remap minimal range
  63587. * @param max defines the alpha remap maximal range
  63588. * @returns the current particle system
  63589. */
  63590. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63591. /**
  63592. * Not supported by GPUParticleSystem
  63593. * @param gradient defines the gradient to remove
  63594. * @returns the current particle system
  63595. */
  63596. removeAlphaRemapGradient(): IParticleSystem;
  63597. /**
  63598. * Not supported by GPUParticleSystem
  63599. * @param gradient defines the gradient to use (between 0 and 1)
  63600. * @param color defines the color to affect to the specified gradient
  63601. * @returns the current particle system
  63602. */
  63603. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63604. /**
  63605. * Not supported by GPUParticleSystem
  63606. * @param gradient defines the gradient to remove
  63607. * @returns the current particle system
  63608. */
  63609. removeRampGradient(): IParticleSystem;
  63610. /**
  63611. * Not supported by GPUParticleSystem
  63612. * @returns the list of ramp gradients
  63613. */
  63614. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63615. /**
  63616. * Not supported by GPUParticleSystem
  63617. * Gets or sets a boolean indicating that ramp gradients must be used
  63618. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63619. */
  63620. get useRampGradients(): boolean;
  63621. set useRampGradients(value: boolean);
  63622. /**
  63623. * Not supported by GPUParticleSystem
  63624. * @param gradient defines the gradient to use (between 0 and 1)
  63625. * @param factor defines the life time factor to affect to the specified gradient
  63626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63627. * @returns the current particle system
  63628. */
  63629. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63630. /**
  63631. * Not supported by GPUParticleSystem
  63632. * @param gradient defines the gradient to remove
  63633. * @returns the current particle system
  63634. */
  63635. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63636. /**
  63637. * Instantiates a GPU particle system.
  63638. * 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.
  63639. * @param name The name of the particle system
  63640. * @param options The options used to create the system
  63641. * @param scene The scene the particle system belongs to
  63642. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63643. */
  63644. constructor(name: string, options: Partial<{
  63645. capacity: number;
  63646. randomTextureSize: number;
  63647. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63648. protected _reset(): void;
  63649. private _createUpdateVAO;
  63650. private _createRenderVAO;
  63651. private _initialize;
  63652. /** @hidden */
  63653. _recreateUpdateEffect(): void;
  63654. /** @hidden */
  63655. _recreateRenderEffect(): void;
  63656. /**
  63657. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63658. * @param preWarm defines if we are in the pre-warmimg phase
  63659. */
  63660. animate(preWarm?: boolean): void;
  63661. private _createFactorGradientTexture;
  63662. private _createSizeGradientTexture;
  63663. private _createAngularSpeedGradientTexture;
  63664. private _createVelocityGradientTexture;
  63665. private _createLimitVelocityGradientTexture;
  63666. private _createDragGradientTexture;
  63667. private _createColorGradientTexture;
  63668. /**
  63669. * Renders the particle system in its current state
  63670. * @param preWarm defines if the system should only update the particles but not render them
  63671. * @returns the current number of particles
  63672. */
  63673. render(preWarm?: boolean): number;
  63674. /**
  63675. * Rebuilds the particle system
  63676. */
  63677. rebuild(): void;
  63678. private _releaseBuffers;
  63679. private _releaseVAOs;
  63680. /**
  63681. * Disposes the particle system and free the associated resources
  63682. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63683. */
  63684. dispose(disposeTexture?: boolean): void;
  63685. /**
  63686. * Clones the particle system.
  63687. * @param name The name of the cloned object
  63688. * @param newEmitter The new emitter to use
  63689. * @returns the cloned particle system
  63690. */
  63691. clone(name: string, newEmitter: any): GPUParticleSystem;
  63692. /**
  63693. * Serializes the particle system to a JSON object
  63694. * @param serializeTexture defines if the texture must be serialized as well
  63695. * @returns the JSON object
  63696. */
  63697. serialize(serializeTexture?: boolean): any;
  63698. /**
  63699. * Parses a JSON object to create a GPU particle system.
  63700. * @param parsedParticleSystem The JSON object to parse
  63701. * @param scene The scene to create the particle system in
  63702. * @param rootUrl The root url to use to load external dependencies like texture
  63703. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63704. * @returns the parsed GPU particle system
  63705. */
  63706. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63707. }
  63708. }
  63709. declare module BABYLON {
  63710. /**
  63711. * Represents a set of particle systems working together to create a specific effect
  63712. */
  63713. export class ParticleSystemSet implements IDisposable {
  63714. /**
  63715. * Gets or sets base Assets URL
  63716. */
  63717. static BaseAssetsUrl: string;
  63718. private _emitterCreationOptions;
  63719. private _emitterNode;
  63720. /**
  63721. * Gets the particle system list
  63722. */
  63723. systems: IParticleSystem[];
  63724. /**
  63725. * Gets the emitter node used with this set
  63726. */
  63727. get emitterNode(): Nullable<TransformNode>;
  63728. /**
  63729. * Creates a new emitter mesh as a sphere
  63730. * @param options defines the options used to create the sphere
  63731. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63732. * @param scene defines the hosting scene
  63733. */
  63734. setEmitterAsSphere(options: {
  63735. diameter: number;
  63736. segments: number;
  63737. color: Color3;
  63738. }, renderingGroupId: number, scene: Scene): void;
  63739. /**
  63740. * Starts all particle systems of the set
  63741. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63742. */
  63743. start(emitter?: AbstractMesh): void;
  63744. /**
  63745. * Release all associated resources
  63746. */
  63747. dispose(): void;
  63748. /**
  63749. * Serialize the set into a JSON compatible object
  63750. * @param serializeTexture defines if the texture must be serialized as well
  63751. * @returns a JSON compatible representation of the set
  63752. */
  63753. serialize(serializeTexture?: boolean): any;
  63754. /**
  63755. * Parse a new ParticleSystemSet from a serialized source
  63756. * @param data defines a JSON compatible representation of the set
  63757. * @param scene defines the hosting scene
  63758. * @param gpu defines if we want GPU particles or CPU particles
  63759. * @returns a new ParticleSystemSet
  63760. */
  63761. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63762. }
  63763. }
  63764. declare module BABYLON {
  63765. /**
  63766. * This class is made for on one-liner static method to help creating particle system set.
  63767. */
  63768. export class ParticleHelper {
  63769. /**
  63770. * Gets or sets base Assets URL
  63771. */
  63772. static BaseAssetsUrl: string;
  63773. /** Define the Url to load snippets */
  63774. static SnippetUrl: string;
  63775. /**
  63776. * Create a default particle system that you can tweak
  63777. * @param emitter defines the emitter to use
  63778. * @param capacity defines the system capacity (default is 500 particles)
  63779. * @param scene defines the hosting scene
  63780. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63781. * @returns the new Particle system
  63782. */
  63783. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63784. /**
  63785. * This is the main static method (one-liner) of this helper to create different particle systems
  63786. * @param type This string represents the type to the particle system to create
  63787. * @param scene The scene where the particle system should live
  63788. * @param gpu If the system will use gpu
  63789. * @returns the ParticleSystemSet created
  63790. */
  63791. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63792. /**
  63793. * Static function used to export a particle system to a ParticleSystemSet variable.
  63794. * Please note that the emitter shape is not exported
  63795. * @param systems defines the particle systems to export
  63796. * @returns the created particle system set
  63797. */
  63798. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63799. /**
  63800. * Creates a particle system from a snippet saved in a remote file
  63801. * @param name defines the name of the particle system to create
  63802. * @param url defines the url to load from
  63803. * @param scene defines the hosting scene
  63804. * @param gpu If the system will use gpu
  63805. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63806. * @returns a promise that will resolve to the new particle system
  63807. */
  63808. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63809. /**
  63810. * Creates a particle system from a snippet saved by the particle system editor
  63811. * @param snippetId defines the snippet to load
  63812. * @param scene defines the hosting scene
  63813. * @param gpu If the system will use gpu
  63814. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63815. * @returns a promise that will resolve to the new particle system
  63816. */
  63817. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63818. }
  63819. }
  63820. declare module BABYLON {
  63821. interface Engine {
  63822. /**
  63823. * Create an effect to use with particle systems.
  63824. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63825. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63826. * @param uniformsNames defines a list of attribute names
  63827. * @param samplers defines an array of string used to represent textures
  63828. * @param defines defines the string containing the defines to use to compile the shaders
  63829. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63830. * @param onCompiled defines a function to call when the effect creation is successful
  63831. * @param onError defines a function to call when the effect creation has failed
  63832. * @returns the new Effect
  63833. */
  63834. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63835. }
  63836. interface Mesh {
  63837. /**
  63838. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63839. * @returns an array of IParticleSystem
  63840. */
  63841. getEmittedParticleSystems(): IParticleSystem[];
  63842. /**
  63843. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63844. * @returns an array of IParticleSystem
  63845. */
  63846. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63847. }
  63848. /**
  63849. * @hidden
  63850. */
  63851. export var _IDoNeedToBeInTheBuild: number;
  63852. }
  63853. declare module BABYLON {
  63854. /** Defines the 4 color options */
  63855. export enum PointColor {
  63856. /** color value */
  63857. Color = 2,
  63858. /** uv value */
  63859. UV = 1,
  63860. /** random value */
  63861. Random = 0,
  63862. /** stated value */
  63863. Stated = 3
  63864. }
  63865. /**
  63866. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63867. * 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.
  63868. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63869. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63870. *
  63871. * Full documentation here : TO BE ENTERED
  63872. */
  63873. export class PointsCloudSystem implements IDisposable {
  63874. /**
  63875. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63876. * Example : var p = SPS.particles[i];
  63877. */
  63878. particles: CloudPoint[];
  63879. /**
  63880. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63881. */
  63882. nbParticles: number;
  63883. /**
  63884. * This a counter for your own usage. It's not set by any SPS functions.
  63885. */
  63886. counter: number;
  63887. /**
  63888. * The PCS name. This name is also given to the underlying mesh.
  63889. */
  63890. name: string;
  63891. /**
  63892. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63893. */
  63894. mesh: Mesh;
  63895. /**
  63896. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63897. * Please read :
  63898. */
  63899. vars: any;
  63900. /**
  63901. * @hidden
  63902. */
  63903. _size: number;
  63904. private _scene;
  63905. private _promises;
  63906. private _positions;
  63907. private _indices;
  63908. private _normals;
  63909. private _colors;
  63910. private _uvs;
  63911. private _indices32;
  63912. private _positions32;
  63913. private _colors32;
  63914. private _uvs32;
  63915. private _updatable;
  63916. private _isVisibilityBoxLocked;
  63917. private _alwaysVisible;
  63918. private _groups;
  63919. private _groupCounter;
  63920. private _computeParticleColor;
  63921. private _computeParticleTexture;
  63922. private _computeParticleRotation;
  63923. private _computeBoundingBox;
  63924. private _isReady;
  63925. /**
  63926. * Creates a PCS (Points Cloud System) object
  63927. * @param name (String) is the PCS name, this will be the underlying mesh name
  63928. * @param pointSize (number) is the size for each point
  63929. * @param scene (Scene) is the scene in which the PCS is added
  63930. * @param options defines the options of the PCS e.g.
  63931. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63932. */
  63933. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63934. updatable?: boolean;
  63935. });
  63936. /**
  63937. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63938. * If no points were added to the PCS, the returned mesh is just a single point.
  63939. * @returns a promise for the created mesh
  63940. */
  63941. buildMeshAsync(): Promise<Mesh>;
  63942. /**
  63943. * @hidden
  63944. */
  63945. private _buildMesh;
  63946. private _addParticle;
  63947. private _randomUnitVector;
  63948. private _getColorIndicesForCoord;
  63949. private _setPointsColorOrUV;
  63950. private _colorFromTexture;
  63951. private _calculateDensity;
  63952. /**
  63953. * Adds points to the PCS in random positions within a unit sphere
  63954. * @param nb (positive integer) the number of particles to be created from this model
  63955. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63956. * @returns the number of groups in the system
  63957. */
  63958. addPoints(nb: number, pointFunction?: any): number;
  63959. /**
  63960. * Adds points to the PCS from the surface of the model shape
  63961. * @param mesh is any Mesh object that will be used as a surface model for the points
  63962. * @param nb (positive integer) the number of particles to be created from this model
  63963. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63964. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63965. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63966. * @returns the number of groups in the system
  63967. */
  63968. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63969. /**
  63970. * Adds points to the PCS inside the model shape
  63971. * @param mesh is any Mesh object that will be used as a surface model for the points
  63972. * @param nb (positive integer) the number of particles to be created from this model
  63973. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63974. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63975. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63976. * @returns the number of groups in the system
  63977. */
  63978. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63979. /**
  63980. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63981. * This method calls `updateParticle()` for each particle of the SPS.
  63982. * For an animated SPS, it is usually called within the render loop.
  63983. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63984. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63985. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63986. * @returns the PCS.
  63987. */
  63988. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63989. /**
  63990. * Disposes the PCS.
  63991. */
  63992. dispose(): void;
  63993. /**
  63994. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63995. * doc :
  63996. * @returns the PCS.
  63997. */
  63998. refreshVisibleSize(): PointsCloudSystem;
  63999. /**
  64000. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64001. * @param size the size (float) of the visibility box
  64002. * note : this doesn't lock the PCS mesh bounding box.
  64003. * doc :
  64004. */
  64005. setVisibilityBox(size: number): void;
  64006. /**
  64007. * Gets whether the PCS is always visible or not
  64008. * doc :
  64009. */
  64010. get isAlwaysVisible(): boolean;
  64011. /**
  64012. * Sets the PCS as always visible or not
  64013. * doc :
  64014. */
  64015. set isAlwaysVisible(val: boolean);
  64016. /**
  64017. * Tells to `setParticles()` to compute the particle rotations or not
  64018. * Default value : false. The PCS is faster when it's set to false
  64019. * Note : particle rotations are only applied to parent particles
  64020. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64021. */
  64022. set computeParticleRotation(val: boolean);
  64023. /**
  64024. * Tells to `setParticles()` to compute the particle colors or not.
  64025. * Default value : true. The PCS is faster when it's set to false.
  64026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64027. */
  64028. set computeParticleColor(val: boolean);
  64029. set computeParticleTexture(val: boolean);
  64030. /**
  64031. * Gets if `setParticles()` computes the particle colors or not.
  64032. * Default value : false. The PCS is faster when it's set to false.
  64033. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64034. */
  64035. get computeParticleColor(): boolean;
  64036. /**
  64037. * Gets if `setParticles()` computes the particle textures or not.
  64038. * Default value : false. The PCS is faster when it's set to false.
  64039. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64040. */
  64041. get computeParticleTexture(): boolean;
  64042. /**
  64043. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64044. */
  64045. set computeBoundingBox(val: boolean);
  64046. /**
  64047. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64048. */
  64049. get computeBoundingBox(): boolean;
  64050. /**
  64051. * This function does nothing. It may be overwritten to set all the particle first values.
  64052. * The PCS doesn't call this function, you may have to call it by your own.
  64053. * doc :
  64054. */
  64055. initParticles(): void;
  64056. /**
  64057. * This function does nothing. It may be overwritten to recycle a particle
  64058. * The PCS doesn't call this function, you can to call it
  64059. * doc :
  64060. * @param particle The particle to recycle
  64061. * @returns the recycled particle
  64062. */
  64063. recycleParticle(particle: CloudPoint): CloudPoint;
  64064. /**
  64065. * Updates a particle : this function should be overwritten by the user.
  64066. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64067. * doc :
  64068. * @example : just set a particle position or velocity and recycle conditions
  64069. * @param particle The particle to update
  64070. * @returns the updated particle
  64071. */
  64072. updateParticle(particle: CloudPoint): CloudPoint;
  64073. /**
  64074. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64075. * This does nothing and may be overwritten by the user.
  64076. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64077. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64078. * @param update the boolean update value actually passed to setParticles()
  64079. */
  64080. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64081. /**
  64082. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64083. * This will be passed three parameters.
  64084. * This does nothing and may be overwritten by the user.
  64085. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64086. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64087. * @param update the boolean update value actually passed to setParticles()
  64088. */
  64089. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64090. }
  64091. }
  64092. declare module BABYLON {
  64093. /**
  64094. * Represents one particle of a points cloud system.
  64095. */
  64096. export class CloudPoint {
  64097. /**
  64098. * particle global index
  64099. */
  64100. idx: number;
  64101. /**
  64102. * The color of the particle
  64103. */
  64104. color: Nullable<Color4>;
  64105. /**
  64106. * The world space position of the particle.
  64107. */
  64108. position: Vector3;
  64109. /**
  64110. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64111. */
  64112. rotation: Vector3;
  64113. /**
  64114. * The world space rotation quaternion of the particle.
  64115. */
  64116. rotationQuaternion: Nullable<Quaternion>;
  64117. /**
  64118. * The uv of the particle.
  64119. */
  64120. uv: Nullable<Vector2>;
  64121. /**
  64122. * The current speed of the particle.
  64123. */
  64124. velocity: Vector3;
  64125. /**
  64126. * The pivot point in the particle local space.
  64127. */
  64128. pivot: Vector3;
  64129. /**
  64130. * Must the particle be translated from its pivot point in its local space ?
  64131. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64132. * Default : false
  64133. */
  64134. translateFromPivot: boolean;
  64135. /**
  64136. * Index of this particle in the global "positions" array (Internal use)
  64137. * @hidden
  64138. */
  64139. _pos: number;
  64140. /**
  64141. * @hidden Index of this particle in the global "indices" array (Internal use)
  64142. */
  64143. _ind: number;
  64144. /**
  64145. * Group this particle belongs to
  64146. */
  64147. _group: PointsGroup;
  64148. /**
  64149. * Group id of this particle
  64150. */
  64151. groupId: number;
  64152. /**
  64153. * Index of the particle in its group id (Internal use)
  64154. */
  64155. idxInGroup: number;
  64156. /**
  64157. * @hidden Particle BoundingInfo object (Internal use)
  64158. */
  64159. _boundingInfo: BoundingInfo;
  64160. /**
  64161. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64162. */
  64163. _pcs: PointsCloudSystem;
  64164. /**
  64165. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64166. */
  64167. _stillInvisible: boolean;
  64168. /**
  64169. * @hidden Last computed particle rotation matrix
  64170. */
  64171. _rotationMatrix: number[];
  64172. /**
  64173. * Parent particle Id, if any.
  64174. * Default null.
  64175. */
  64176. parentId: Nullable<number>;
  64177. /**
  64178. * @hidden Internal global position in the PCS.
  64179. */
  64180. _globalPosition: Vector3;
  64181. /**
  64182. * Creates a Point Cloud object.
  64183. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64184. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64185. * @param group (PointsGroup) is the group the particle belongs to
  64186. * @param groupId (integer) is the group identifier in the PCS.
  64187. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64188. * @param pcs defines the PCS it is associated to
  64189. */
  64190. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64191. /**
  64192. * get point size
  64193. */
  64194. get size(): Vector3;
  64195. /**
  64196. * Set point size
  64197. */
  64198. set size(scale: Vector3);
  64199. /**
  64200. * Legacy support, changed quaternion to rotationQuaternion
  64201. */
  64202. get quaternion(): Nullable<Quaternion>;
  64203. /**
  64204. * Legacy support, changed quaternion to rotationQuaternion
  64205. */
  64206. set quaternion(q: Nullable<Quaternion>);
  64207. /**
  64208. * Returns a boolean. True if the particle intersects a mesh, else false
  64209. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64210. * @param target is the object (point or mesh) what the intersection is computed against
  64211. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64212. * @returns true if it intersects
  64213. */
  64214. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64215. /**
  64216. * get the rotation matrix of the particle
  64217. * @hidden
  64218. */
  64219. getRotationMatrix(m: Matrix): void;
  64220. }
  64221. /**
  64222. * Represents a group of points in a points cloud system
  64223. * * PCS internal tool, don't use it manually.
  64224. */
  64225. export class PointsGroup {
  64226. /**
  64227. * The group id
  64228. * @hidden
  64229. */
  64230. groupID: number;
  64231. /**
  64232. * image data for group (internal use)
  64233. * @hidden
  64234. */
  64235. _groupImageData: Nullable<ArrayBufferView>;
  64236. /**
  64237. * Image Width (internal use)
  64238. * @hidden
  64239. */
  64240. _groupImgWidth: number;
  64241. /**
  64242. * Image Height (internal use)
  64243. * @hidden
  64244. */
  64245. _groupImgHeight: number;
  64246. /**
  64247. * Custom position function (internal use)
  64248. * @hidden
  64249. */
  64250. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64251. /**
  64252. * density per facet for surface points
  64253. * @hidden
  64254. */
  64255. _groupDensity: number[];
  64256. /**
  64257. * Only when points are colored by texture carries pointer to texture list array
  64258. * @hidden
  64259. */
  64260. _textureNb: number;
  64261. /**
  64262. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64263. * PCS internal tool, don't use it manually.
  64264. * @hidden
  64265. */
  64266. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64267. }
  64268. }
  64269. declare module BABYLON {
  64270. interface Scene {
  64271. /** @hidden (Backing field) */
  64272. _physicsEngine: Nullable<IPhysicsEngine>;
  64273. /** @hidden */
  64274. _physicsTimeAccumulator: number;
  64275. /**
  64276. * Gets the current physics engine
  64277. * @returns a IPhysicsEngine or null if none attached
  64278. */
  64279. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64280. /**
  64281. * Enables physics to the current scene
  64282. * @param gravity defines the scene's gravity for the physics engine
  64283. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64284. * @return a boolean indicating if the physics engine was initialized
  64285. */
  64286. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64287. /**
  64288. * Disables and disposes the physics engine associated with the scene
  64289. */
  64290. disablePhysicsEngine(): void;
  64291. /**
  64292. * Gets a boolean indicating if there is an active physics engine
  64293. * @returns a boolean indicating if there is an active physics engine
  64294. */
  64295. isPhysicsEnabled(): boolean;
  64296. /**
  64297. * Deletes a physics compound impostor
  64298. * @param compound defines the compound to delete
  64299. */
  64300. deleteCompoundImpostor(compound: any): void;
  64301. /**
  64302. * An event triggered when physic simulation is about to be run
  64303. */
  64304. onBeforePhysicsObservable: Observable<Scene>;
  64305. /**
  64306. * An event triggered when physic simulation has been done
  64307. */
  64308. onAfterPhysicsObservable: Observable<Scene>;
  64309. }
  64310. interface AbstractMesh {
  64311. /** @hidden */
  64312. _physicsImpostor: Nullable<PhysicsImpostor>;
  64313. /**
  64314. * Gets or sets impostor used for physic simulation
  64315. * @see http://doc.babylonjs.com/features/physics_engine
  64316. */
  64317. physicsImpostor: Nullable<PhysicsImpostor>;
  64318. /**
  64319. * Gets the current physics impostor
  64320. * @see http://doc.babylonjs.com/features/physics_engine
  64321. * @returns a physics impostor or null
  64322. */
  64323. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64324. /** Apply a physic impulse to the mesh
  64325. * @param force defines the force to apply
  64326. * @param contactPoint defines where to apply the force
  64327. * @returns the current mesh
  64328. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64329. */
  64330. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64331. /**
  64332. * Creates a physic joint between two meshes
  64333. * @param otherMesh defines the other mesh to use
  64334. * @param pivot1 defines the pivot to use on this mesh
  64335. * @param pivot2 defines the pivot to use on the other mesh
  64336. * @param options defines additional options (can be plugin dependent)
  64337. * @returns the current mesh
  64338. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64339. */
  64340. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64341. /** @hidden */
  64342. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64343. }
  64344. /**
  64345. * Defines the physics engine scene component responsible to manage a physics engine
  64346. */
  64347. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64348. /**
  64349. * The component name helpful to identify the component in the list of scene components.
  64350. */
  64351. readonly name: string;
  64352. /**
  64353. * The scene the component belongs to.
  64354. */
  64355. scene: Scene;
  64356. /**
  64357. * Creates a new instance of the component for the given scene
  64358. * @param scene Defines the scene to register the component in
  64359. */
  64360. constructor(scene: Scene);
  64361. /**
  64362. * Registers the component in a given scene
  64363. */
  64364. register(): void;
  64365. /**
  64366. * Rebuilds the elements related to this component in case of
  64367. * context lost for instance.
  64368. */
  64369. rebuild(): void;
  64370. /**
  64371. * Disposes the component and the associated ressources
  64372. */
  64373. dispose(): void;
  64374. }
  64375. }
  64376. declare module BABYLON {
  64377. /**
  64378. * A helper for physics simulations
  64379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64380. */
  64381. export class PhysicsHelper {
  64382. private _scene;
  64383. private _physicsEngine;
  64384. /**
  64385. * Initializes the Physics helper
  64386. * @param scene Babylon.js scene
  64387. */
  64388. constructor(scene: Scene);
  64389. /**
  64390. * Applies a radial explosion impulse
  64391. * @param origin the origin of the explosion
  64392. * @param radiusOrEventOptions the radius or the options of radial explosion
  64393. * @param strength the explosion strength
  64394. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64395. * @returns A physics radial explosion event, or null
  64396. */
  64397. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64398. /**
  64399. * Applies a radial explosion force
  64400. * @param origin the origin of the explosion
  64401. * @param radiusOrEventOptions the radius or the options of radial explosion
  64402. * @param strength the explosion strength
  64403. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64404. * @returns A physics radial explosion event, or null
  64405. */
  64406. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64407. /**
  64408. * Creates a gravitational field
  64409. * @param origin the origin of the explosion
  64410. * @param radiusOrEventOptions the radius or the options of radial explosion
  64411. * @param strength the explosion strength
  64412. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64413. * @returns A physics gravitational field event, or null
  64414. */
  64415. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64416. /**
  64417. * Creates a physics updraft event
  64418. * @param origin the origin of the updraft
  64419. * @param radiusOrEventOptions the radius or the options of the updraft
  64420. * @param strength the strength of the updraft
  64421. * @param height the height of the updraft
  64422. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64423. * @returns A physics updraft event, or null
  64424. */
  64425. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64426. /**
  64427. * Creates a physics vortex event
  64428. * @param origin the of the vortex
  64429. * @param radiusOrEventOptions the radius or the options of the vortex
  64430. * @param strength the strength of the vortex
  64431. * @param height the height of the vortex
  64432. * @returns a Physics vortex event, or null
  64433. * A physics vortex event or null
  64434. */
  64435. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64436. }
  64437. /**
  64438. * Represents a physics radial explosion event
  64439. */
  64440. class PhysicsRadialExplosionEvent {
  64441. private _scene;
  64442. private _options;
  64443. private _sphere;
  64444. private _dataFetched;
  64445. /**
  64446. * Initializes a radial explosioin event
  64447. * @param _scene BabylonJS scene
  64448. * @param _options The options for the vortex event
  64449. */
  64450. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64451. /**
  64452. * Returns the data related to the radial explosion event (sphere).
  64453. * @returns The radial explosion event data
  64454. */
  64455. getData(): PhysicsRadialExplosionEventData;
  64456. /**
  64457. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64458. * @param impostor A physics imposter
  64459. * @param origin the origin of the explosion
  64460. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64461. */
  64462. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64463. /**
  64464. * Triggers affecterd impostors callbacks
  64465. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64466. */
  64467. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64468. /**
  64469. * Disposes the sphere.
  64470. * @param force Specifies if the sphere should be disposed by force
  64471. */
  64472. dispose(force?: boolean): void;
  64473. /*** Helpers ***/
  64474. private _prepareSphere;
  64475. private _intersectsWithSphere;
  64476. }
  64477. /**
  64478. * Represents a gravitational field event
  64479. */
  64480. class PhysicsGravitationalFieldEvent {
  64481. private _physicsHelper;
  64482. private _scene;
  64483. private _origin;
  64484. private _options;
  64485. private _tickCallback;
  64486. private _sphere;
  64487. private _dataFetched;
  64488. /**
  64489. * Initializes the physics gravitational field event
  64490. * @param _physicsHelper A physics helper
  64491. * @param _scene BabylonJS scene
  64492. * @param _origin The origin position of the gravitational field event
  64493. * @param _options The options for the vortex event
  64494. */
  64495. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64496. /**
  64497. * Returns the data related to the gravitational field event (sphere).
  64498. * @returns A gravitational field event
  64499. */
  64500. getData(): PhysicsGravitationalFieldEventData;
  64501. /**
  64502. * Enables the gravitational field.
  64503. */
  64504. enable(): void;
  64505. /**
  64506. * Disables the gravitational field.
  64507. */
  64508. disable(): void;
  64509. /**
  64510. * Disposes the sphere.
  64511. * @param force The force to dispose from the gravitational field event
  64512. */
  64513. dispose(force?: boolean): void;
  64514. private _tick;
  64515. }
  64516. /**
  64517. * Represents a physics updraft event
  64518. */
  64519. class PhysicsUpdraftEvent {
  64520. private _scene;
  64521. private _origin;
  64522. private _options;
  64523. private _physicsEngine;
  64524. private _originTop;
  64525. private _originDirection;
  64526. private _tickCallback;
  64527. private _cylinder;
  64528. private _cylinderPosition;
  64529. private _dataFetched;
  64530. /**
  64531. * Initializes the physics updraft event
  64532. * @param _scene BabylonJS scene
  64533. * @param _origin The origin position of the updraft
  64534. * @param _options The options for the updraft event
  64535. */
  64536. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64537. /**
  64538. * Returns the data related to the updraft event (cylinder).
  64539. * @returns A physics updraft event
  64540. */
  64541. getData(): PhysicsUpdraftEventData;
  64542. /**
  64543. * Enables the updraft.
  64544. */
  64545. enable(): void;
  64546. /**
  64547. * Disables the updraft.
  64548. */
  64549. disable(): void;
  64550. /**
  64551. * Disposes the cylinder.
  64552. * @param force Specifies if the updraft should be disposed by force
  64553. */
  64554. dispose(force?: boolean): void;
  64555. private getImpostorHitData;
  64556. private _tick;
  64557. /*** Helpers ***/
  64558. private _prepareCylinder;
  64559. private _intersectsWithCylinder;
  64560. }
  64561. /**
  64562. * Represents a physics vortex event
  64563. */
  64564. class PhysicsVortexEvent {
  64565. private _scene;
  64566. private _origin;
  64567. private _options;
  64568. private _physicsEngine;
  64569. private _originTop;
  64570. private _tickCallback;
  64571. private _cylinder;
  64572. private _cylinderPosition;
  64573. private _dataFetched;
  64574. /**
  64575. * Initializes the physics vortex event
  64576. * @param _scene The BabylonJS scene
  64577. * @param _origin The origin position of the vortex
  64578. * @param _options The options for the vortex event
  64579. */
  64580. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64581. /**
  64582. * Returns the data related to the vortex event (cylinder).
  64583. * @returns The physics vortex event data
  64584. */
  64585. getData(): PhysicsVortexEventData;
  64586. /**
  64587. * Enables the vortex.
  64588. */
  64589. enable(): void;
  64590. /**
  64591. * Disables the cortex.
  64592. */
  64593. disable(): void;
  64594. /**
  64595. * Disposes the sphere.
  64596. * @param force
  64597. */
  64598. dispose(force?: boolean): void;
  64599. private getImpostorHitData;
  64600. private _tick;
  64601. /*** Helpers ***/
  64602. private _prepareCylinder;
  64603. private _intersectsWithCylinder;
  64604. }
  64605. /**
  64606. * Options fot the radial explosion event
  64607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64608. */
  64609. export class PhysicsRadialExplosionEventOptions {
  64610. /**
  64611. * The radius of the sphere for the radial explosion.
  64612. */
  64613. radius: number;
  64614. /**
  64615. * The strenth of the explosion.
  64616. */
  64617. strength: number;
  64618. /**
  64619. * The strenght of the force in correspondence to the distance of the affected object
  64620. */
  64621. falloff: PhysicsRadialImpulseFalloff;
  64622. /**
  64623. * Sphere options for the radial explosion.
  64624. */
  64625. sphere: {
  64626. segments: number;
  64627. diameter: number;
  64628. };
  64629. /**
  64630. * Sphere options for the radial explosion.
  64631. */
  64632. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64633. }
  64634. /**
  64635. * Options fot the updraft event
  64636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64637. */
  64638. export class PhysicsUpdraftEventOptions {
  64639. /**
  64640. * The radius of the cylinder for the vortex
  64641. */
  64642. radius: number;
  64643. /**
  64644. * The strenth of the updraft.
  64645. */
  64646. strength: number;
  64647. /**
  64648. * The height of the cylinder for the updraft.
  64649. */
  64650. height: number;
  64651. /**
  64652. * The mode for the the updraft.
  64653. */
  64654. updraftMode: PhysicsUpdraftMode;
  64655. }
  64656. /**
  64657. * Options fot the vortex event
  64658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64659. */
  64660. export class PhysicsVortexEventOptions {
  64661. /**
  64662. * The radius of the cylinder for the vortex
  64663. */
  64664. radius: number;
  64665. /**
  64666. * The strenth of the vortex.
  64667. */
  64668. strength: number;
  64669. /**
  64670. * The height of the cylinder for the vortex.
  64671. */
  64672. height: number;
  64673. /**
  64674. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64675. */
  64676. centripetalForceThreshold: number;
  64677. /**
  64678. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64679. */
  64680. centripetalForceMultiplier: number;
  64681. /**
  64682. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64683. */
  64684. centrifugalForceMultiplier: number;
  64685. /**
  64686. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64687. */
  64688. updraftForceMultiplier: number;
  64689. }
  64690. /**
  64691. * The strenght of the force in correspondence to the distance of the affected object
  64692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64693. */
  64694. export enum PhysicsRadialImpulseFalloff {
  64695. /** Defines that impulse is constant in strength across it's whole radius */
  64696. Constant = 0,
  64697. /** Defines that impulse gets weaker if it's further from the origin */
  64698. Linear = 1
  64699. }
  64700. /**
  64701. * The strength of the force in correspondence to the distance of the affected object
  64702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64703. */
  64704. export enum PhysicsUpdraftMode {
  64705. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64706. Center = 0,
  64707. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64708. Perpendicular = 1
  64709. }
  64710. /**
  64711. * Interface for a physics hit data
  64712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64713. */
  64714. export interface PhysicsHitData {
  64715. /**
  64716. * The force applied at the contact point
  64717. */
  64718. force: Vector3;
  64719. /**
  64720. * The contact point
  64721. */
  64722. contactPoint: Vector3;
  64723. /**
  64724. * The distance from the origin to the contact point
  64725. */
  64726. distanceFromOrigin: number;
  64727. }
  64728. /**
  64729. * Interface for radial explosion event data
  64730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64731. */
  64732. export interface PhysicsRadialExplosionEventData {
  64733. /**
  64734. * A sphere used for the radial explosion event
  64735. */
  64736. sphere: Mesh;
  64737. }
  64738. /**
  64739. * Interface for gravitational field event data
  64740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64741. */
  64742. export interface PhysicsGravitationalFieldEventData {
  64743. /**
  64744. * A sphere mesh used for the gravitational field event
  64745. */
  64746. sphere: Mesh;
  64747. }
  64748. /**
  64749. * Interface for updraft event data
  64750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64751. */
  64752. export interface PhysicsUpdraftEventData {
  64753. /**
  64754. * A cylinder used for the updraft event
  64755. */
  64756. cylinder: Mesh;
  64757. }
  64758. /**
  64759. * Interface for vortex event data
  64760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64761. */
  64762. export interface PhysicsVortexEventData {
  64763. /**
  64764. * A cylinder used for the vortex event
  64765. */
  64766. cylinder: Mesh;
  64767. }
  64768. /**
  64769. * Interface for an affected physics impostor
  64770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64771. */
  64772. export interface PhysicsAffectedImpostorWithData {
  64773. /**
  64774. * The impostor affected by the effect
  64775. */
  64776. impostor: PhysicsImpostor;
  64777. /**
  64778. * The data about the hit/horce from the explosion
  64779. */
  64780. hitData: PhysicsHitData;
  64781. }
  64782. }
  64783. declare module BABYLON {
  64784. /** @hidden */
  64785. export var blackAndWhitePixelShader: {
  64786. name: string;
  64787. shader: string;
  64788. };
  64789. }
  64790. declare module BABYLON {
  64791. /**
  64792. * Post process used to render in black and white
  64793. */
  64794. export class BlackAndWhitePostProcess extends PostProcess {
  64795. /**
  64796. * Linear about to convert he result to black and white (default: 1)
  64797. */
  64798. degree: number;
  64799. /**
  64800. * Creates a black and white post process
  64801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64802. * @param name The name of the effect.
  64803. * @param options The required width/height ratio to downsize to before computing the render pass.
  64804. * @param camera The camera to apply the render pass to.
  64805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64806. * @param engine The engine which the post process will be applied. (default: current engine)
  64807. * @param reusable If the post process can be reused on the same frame. (default: false)
  64808. */
  64809. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64810. }
  64811. }
  64812. declare module BABYLON {
  64813. /**
  64814. * This represents a set of one or more post processes in Babylon.
  64815. * A post process can be used to apply a shader to a texture after it is rendered.
  64816. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64817. */
  64818. export class PostProcessRenderEffect {
  64819. private _postProcesses;
  64820. private _getPostProcesses;
  64821. private _singleInstance;
  64822. private _cameras;
  64823. private _indicesForCamera;
  64824. /**
  64825. * Name of the effect
  64826. * @hidden
  64827. */
  64828. _name: string;
  64829. /**
  64830. * Instantiates a post process render effect.
  64831. * A post process can be used to apply a shader to a texture after it is rendered.
  64832. * @param engine The engine the effect is tied to
  64833. * @param name The name of the effect
  64834. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64835. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64836. */
  64837. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64838. /**
  64839. * Checks if all the post processes in the effect are supported.
  64840. */
  64841. get isSupported(): boolean;
  64842. /**
  64843. * Updates the current state of the effect
  64844. * @hidden
  64845. */
  64846. _update(): void;
  64847. /**
  64848. * Attaches the effect on cameras
  64849. * @param cameras The camera to attach to.
  64850. * @hidden
  64851. */
  64852. _attachCameras(cameras: Camera): void;
  64853. /**
  64854. * Attaches the effect on cameras
  64855. * @param cameras The camera to attach to.
  64856. * @hidden
  64857. */
  64858. _attachCameras(cameras: Camera[]): void;
  64859. /**
  64860. * Detaches the effect on cameras
  64861. * @param cameras The camera to detatch from.
  64862. * @hidden
  64863. */
  64864. _detachCameras(cameras: Camera): void;
  64865. /**
  64866. * Detatches the effect on cameras
  64867. * @param cameras The camera to detatch from.
  64868. * @hidden
  64869. */
  64870. _detachCameras(cameras: Camera[]): void;
  64871. /**
  64872. * Enables the effect on given cameras
  64873. * @param cameras The camera to enable.
  64874. * @hidden
  64875. */
  64876. _enable(cameras: Camera): void;
  64877. /**
  64878. * Enables the effect on given cameras
  64879. * @param cameras The camera to enable.
  64880. * @hidden
  64881. */
  64882. _enable(cameras: Nullable<Camera[]>): void;
  64883. /**
  64884. * Disables the effect on the given cameras
  64885. * @param cameras The camera to disable.
  64886. * @hidden
  64887. */
  64888. _disable(cameras: Camera): void;
  64889. /**
  64890. * Disables the effect on the given cameras
  64891. * @param cameras The camera to disable.
  64892. * @hidden
  64893. */
  64894. _disable(cameras: Nullable<Camera[]>): void;
  64895. /**
  64896. * Gets a list of the post processes contained in the effect.
  64897. * @param camera The camera to get the post processes on.
  64898. * @returns The list of the post processes in the effect.
  64899. */
  64900. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64901. }
  64902. }
  64903. declare module BABYLON {
  64904. /** @hidden */
  64905. export var extractHighlightsPixelShader: {
  64906. name: string;
  64907. shader: string;
  64908. };
  64909. }
  64910. declare module BABYLON {
  64911. /**
  64912. * 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.
  64913. */
  64914. export class ExtractHighlightsPostProcess extends PostProcess {
  64915. /**
  64916. * The luminance threshold, pixels below this value will be set to black.
  64917. */
  64918. threshold: number;
  64919. /** @hidden */
  64920. _exposure: number;
  64921. /**
  64922. * Post process which has the input texture to be used when performing highlight extraction
  64923. * @hidden
  64924. */
  64925. _inputPostProcess: Nullable<PostProcess>;
  64926. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64927. }
  64928. }
  64929. declare module BABYLON {
  64930. /** @hidden */
  64931. export var bloomMergePixelShader: {
  64932. name: string;
  64933. shader: string;
  64934. };
  64935. }
  64936. declare module BABYLON {
  64937. /**
  64938. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64939. */
  64940. export class BloomMergePostProcess extends PostProcess {
  64941. /** Weight of the bloom to be added to the original input. */
  64942. weight: number;
  64943. /**
  64944. * Creates a new instance of @see BloomMergePostProcess
  64945. * @param name The name of the effect.
  64946. * @param originalFromInput Post process which's input will be used for the merge.
  64947. * @param blurred Blurred highlights post process which's output will be used.
  64948. * @param weight Weight of the bloom to be added to the original input.
  64949. * @param options The required width/height ratio to downsize to before computing the render pass.
  64950. * @param camera The camera to apply the render pass to.
  64951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64952. * @param engine The engine which the post process will be applied. (default: current engine)
  64953. * @param reusable If the post process can be reused on the same frame. (default: false)
  64954. * @param textureType Type of textures used when performing the post process. (default: 0)
  64955. * @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)
  64956. */
  64957. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64958. /** Weight of the bloom to be added to the original input. */
  64959. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64960. }
  64961. }
  64962. declare module BABYLON {
  64963. /**
  64964. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64965. */
  64966. export class BloomEffect extends PostProcessRenderEffect {
  64967. private bloomScale;
  64968. /**
  64969. * @hidden Internal
  64970. */
  64971. _effects: Array<PostProcess>;
  64972. /**
  64973. * @hidden Internal
  64974. */
  64975. _downscale: ExtractHighlightsPostProcess;
  64976. private _blurX;
  64977. private _blurY;
  64978. private _merge;
  64979. /**
  64980. * The luminance threshold to find bright areas of the image to bloom.
  64981. */
  64982. get threshold(): number;
  64983. set threshold(value: number);
  64984. /**
  64985. * The strength of the bloom.
  64986. */
  64987. get weight(): number;
  64988. set weight(value: number);
  64989. /**
  64990. * Specifies the size of the bloom blur kernel, relative to the final output size
  64991. */
  64992. get kernel(): number;
  64993. set kernel(value: number);
  64994. /**
  64995. * Creates a new instance of @see BloomEffect
  64996. * @param scene The scene the effect belongs to.
  64997. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64998. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64999. * @param bloomWeight The the strength of bloom.
  65000. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65001. * @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)
  65002. */
  65003. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65004. /**
  65005. * Disposes each of the internal effects for a given camera.
  65006. * @param camera The camera to dispose the effect on.
  65007. */
  65008. disposeEffects(camera: Camera): void;
  65009. /**
  65010. * @hidden Internal
  65011. */
  65012. _updateEffects(): void;
  65013. /**
  65014. * Internal
  65015. * @returns if all the contained post processes are ready.
  65016. * @hidden
  65017. */
  65018. _isReady(): boolean;
  65019. }
  65020. }
  65021. declare module BABYLON {
  65022. /** @hidden */
  65023. export var chromaticAberrationPixelShader: {
  65024. name: string;
  65025. shader: string;
  65026. };
  65027. }
  65028. declare module BABYLON {
  65029. /**
  65030. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65031. */
  65032. export class ChromaticAberrationPostProcess extends PostProcess {
  65033. /**
  65034. * The amount of seperation of rgb channels (default: 30)
  65035. */
  65036. aberrationAmount: number;
  65037. /**
  65038. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65039. */
  65040. radialIntensity: number;
  65041. /**
  65042. * 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))
  65043. */
  65044. direction: Vector2;
  65045. /**
  65046. * 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))
  65047. */
  65048. centerPosition: Vector2;
  65049. /**
  65050. * Creates a new instance ChromaticAberrationPostProcess
  65051. * @param name The name of the effect.
  65052. * @param screenWidth The width of the screen to apply the effect on.
  65053. * @param screenHeight The height of the screen to apply the effect on.
  65054. * @param options The required width/height ratio to downsize to before computing the render pass.
  65055. * @param camera The camera to apply the render pass to.
  65056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65057. * @param engine The engine which the post process will be applied. (default: current engine)
  65058. * @param reusable If the post process can be reused on the same frame. (default: false)
  65059. * @param textureType Type of textures used when performing the post process. (default: 0)
  65060. * @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)
  65061. */
  65062. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65063. }
  65064. }
  65065. declare module BABYLON {
  65066. /** @hidden */
  65067. export var circleOfConfusionPixelShader: {
  65068. name: string;
  65069. shader: string;
  65070. };
  65071. }
  65072. declare module BABYLON {
  65073. /**
  65074. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65075. */
  65076. export class CircleOfConfusionPostProcess extends PostProcess {
  65077. /**
  65078. * 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.
  65079. */
  65080. lensSize: number;
  65081. /**
  65082. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65083. */
  65084. fStop: number;
  65085. /**
  65086. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65087. */
  65088. focusDistance: number;
  65089. /**
  65090. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65091. */
  65092. focalLength: number;
  65093. private _depthTexture;
  65094. /**
  65095. * Creates a new instance CircleOfConfusionPostProcess
  65096. * @param name The name of the effect.
  65097. * @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.
  65098. * @param options The required width/height ratio to downsize to before computing the render pass.
  65099. * @param camera The camera to apply the render pass to.
  65100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65101. * @param engine The engine which the post process will be applied. (default: current engine)
  65102. * @param reusable If the post process can be reused on the same frame. (default: false)
  65103. * @param textureType Type of textures used when performing the post process. (default: 0)
  65104. * @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)
  65105. */
  65106. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65107. /**
  65108. * 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.
  65109. */
  65110. set depthTexture(value: RenderTargetTexture);
  65111. }
  65112. }
  65113. declare module BABYLON {
  65114. /** @hidden */
  65115. export var colorCorrectionPixelShader: {
  65116. name: string;
  65117. shader: string;
  65118. };
  65119. }
  65120. declare module BABYLON {
  65121. /**
  65122. *
  65123. * This post-process allows the modification of rendered colors by using
  65124. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65125. *
  65126. * The object needs to be provided an url to a texture containing the color
  65127. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65128. * Use an image editing software to tweak the LUT to match your needs.
  65129. *
  65130. * For an example of a color LUT, see here:
  65131. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65132. * For explanations on color grading, see here:
  65133. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65134. *
  65135. */
  65136. export class ColorCorrectionPostProcess extends PostProcess {
  65137. private _colorTableTexture;
  65138. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65139. }
  65140. }
  65141. declare module BABYLON {
  65142. /** @hidden */
  65143. export var convolutionPixelShader: {
  65144. name: string;
  65145. shader: string;
  65146. };
  65147. }
  65148. declare module BABYLON {
  65149. /**
  65150. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65151. * input texture to perform effects such as edge detection or sharpening
  65152. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65153. */
  65154. export class ConvolutionPostProcess extends PostProcess {
  65155. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65156. kernel: number[];
  65157. /**
  65158. * Creates a new instance ConvolutionPostProcess
  65159. * @param name The name of the effect.
  65160. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65161. * @param options The required width/height ratio to downsize to before computing the render pass.
  65162. * @param camera The camera to apply the render pass to.
  65163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65164. * @param engine The engine which the post process will be applied. (default: current engine)
  65165. * @param reusable If the post process can be reused on the same frame. (default: false)
  65166. * @param textureType Type of textures used when performing the post process. (default: 0)
  65167. */
  65168. constructor(name: string,
  65169. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65170. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65171. /**
  65172. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65173. */
  65174. static EdgeDetect0Kernel: number[];
  65175. /**
  65176. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65177. */
  65178. static EdgeDetect1Kernel: number[];
  65179. /**
  65180. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65181. */
  65182. static EdgeDetect2Kernel: number[];
  65183. /**
  65184. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65185. */
  65186. static SharpenKernel: number[];
  65187. /**
  65188. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65189. */
  65190. static EmbossKernel: number[];
  65191. /**
  65192. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65193. */
  65194. static GaussianKernel: number[];
  65195. }
  65196. }
  65197. declare module BABYLON {
  65198. /**
  65199. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65200. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65201. * based on samples that have a large difference in distance than the center pixel.
  65202. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65203. */
  65204. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65205. direction: Vector2;
  65206. /**
  65207. * Creates a new instance CircleOfConfusionPostProcess
  65208. * @param name The name of the effect.
  65209. * @param scene The scene the effect belongs to.
  65210. * @param direction The direction the blur should be applied.
  65211. * @param kernel The size of the kernel used to blur.
  65212. * @param options The required width/height ratio to downsize to before computing the render pass.
  65213. * @param camera The camera to apply the render pass to.
  65214. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65215. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65217. * @param engine The engine which the post process will be applied. (default: current engine)
  65218. * @param reusable If the post process can be reused on the same frame. (default: false)
  65219. * @param textureType Type of textures used when performing the post process. (default: 0)
  65220. * @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)
  65221. */
  65222. 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);
  65223. }
  65224. }
  65225. declare module BABYLON {
  65226. /** @hidden */
  65227. export var depthOfFieldMergePixelShader: {
  65228. name: string;
  65229. shader: string;
  65230. };
  65231. }
  65232. declare module BABYLON {
  65233. /**
  65234. * Options to be set when merging outputs from the default pipeline.
  65235. */
  65236. export class DepthOfFieldMergePostProcessOptions {
  65237. /**
  65238. * The original image to merge on top of
  65239. */
  65240. originalFromInput: PostProcess;
  65241. /**
  65242. * Parameters to perform the merge of the depth of field effect
  65243. */
  65244. depthOfField?: {
  65245. circleOfConfusion: PostProcess;
  65246. blurSteps: Array<PostProcess>;
  65247. };
  65248. /**
  65249. * Parameters to perform the merge of bloom effect
  65250. */
  65251. bloom?: {
  65252. blurred: PostProcess;
  65253. weight: number;
  65254. };
  65255. }
  65256. /**
  65257. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65258. */
  65259. export class DepthOfFieldMergePostProcess extends PostProcess {
  65260. private blurSteps;
  65261. /**
  65262. * Creates a new instance of DepthOfFieldMergePostProcess
  65263. * @param name The name of the effect.
  65264. * @param originalFromInput Post process which's input will be used for the merge.
  65265. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65266. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65267. * @param options The required width/height ratio to downsize to before computing the render pass.
  65268. * @param camera The camera to apply the render pass to.
  65269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65270. * @param engine The engine which the post process will be applied. (default: current engine)
  65271. * @param reusable If the post process can be reused on the same frame. (default: false)
  65272. * @param textureType Type of textures used when performing the post process. (default: 0)
  65273. * @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)
  65274. */
  65275. 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);
  65276. /**
  65277. * Updates the effect with the current post process compile time values and recompiles the shader.
  65278. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65279. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65280. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65281. * @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
  65282. * @param onCompiled Called when the shader has been compiled.
  65283. * @param onError Called if there is an error when compiling a shader.
  65284. */
  65285. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65286. }
  65287. }
  65288. declare module BABYLON {
  65289. /**
  65290. * Specifies the level of max blur that should be applied when using the depth of field effect
  65291. */
  65292. export enum DepthOfFieldEffectBlurLevel {
  65293. /**
  65294. * Subtle blur
  65295. */
  65296. Low = 0,
  65297. /**
  65298. * Medium blur
  65299. */
  65300. Medium = 1,
  65301. /**
  65302. * Large blur
  65303. */
  65304. High = 2
  65305. }
  65306. /**
  65307. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65308. */
  65309. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65310. private _circleOfConfusion;
  65311. /**
  65312. * @hidden Internal, blurs from high to low
  65313. */
  65314. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65315. private _depthOfFieldBlurY;
  65316. private _dofMerge;
  65317. /**
  65318. * @hidden Internal post processes in depth of field effect
  65319. */
  65320. _effects: Array<PostProcess>;
  65321. /**
  65322. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65323. */
  65324. set focalLength(value: number);
  65325. get focalLength(): number;
  65326. /**
  65327. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65328. */
  65329. set fStop(value: number);
  65330. get fStop(): number;
  65331. /**
  65332. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65333. */
  65334. set focusDistance(value: number);
  65335. get focusDistance(): number;
  65336. /**
  65337. * 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.
  65338. */
  65339. set lensSize(value: number);
  65340. get lensSize(): number;
  65341. /**
  65342. * Creates a new instance DepthOfFieldEffect
  65343. * @param scene The scene the effect belongs to.
  65344. * @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.
  65345. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65346. * @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)
  65347. */
  65348. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65349. /**
  65350. * Get the current class name of the current effet
  65351. * @returns "DepthOfFieldEffect"
  65352. */
  65353. getClassName(): string;
  65354. /**
  65355. * 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.
  65356. */
  65357. set depthTexture(value: RenderTargetTexture);
  65358. /**
  65359. * Disposes each of the internal effects for a given camera.
  65360. * @param camera The camera to dispose the effect on.
  65361. */
  65362. disposeEffects(camera: Camera): void;
  65363. /**
  65364. * @hidden Internal
  65365. */
  65366. _updateEffects(): void;
  65367. /**
  65368. * Internal
  65369. * @returns if all the contained post processes are ready.
  65370. * @hidden
  65371. */
  65372. _isReady(): boolean;
  65373. }
  65374. }
  65375. declare module BABYLON {
  65376. /** @hidden */
  65377. export var displayPassPixelShader: {
  65378. name: string;
  65379. shader: string;
  65380. };
  65381. }
  65382. declare module BABYLON {
  65383. /**
  65384. * DisplayPassPostProcess which produces an output the same as it's input
  65385. */
  65386. export class DisplayPassPostProcess extends PostProcess {
  65387. /**
  65388. * Creates the DisplayPassPostProcess
  65389. * @param name The name of the effect.
  65390. * @param options The required width/height ratio to downsize to before computing the render pass.
  65391. * @param camera The camera to apply the render pass to.
  65392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65393. * @param engine The engine which the post process will be applied. (default: current engine)
  65394. * @param reusable If the post process can be reused on the same frame. (default: false)
  65395. */
  65396. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65397. }
  65398. }
  65399. declare module BABYLON {
  65400. /** @hidden */
  65401. export var filterPixelShader: {
  65402. name: string;
  65403. shader: string;
  65404. };
  65405. }
  65406. declare module BABYLON {
  65407. /**
  65408. * Applies a kernel filter to the image
  65409. */
  65410. export class FilterPostProcess extends PostProcess {
  65411. /** The matrix to be applied to the image */
  65412. kernelMatrix: Matrix;
  65413. /**
  65414. *
  65415. * @param name The name of the effect.
  65416. * @param kernelMatrix The matrix to be applied to the image
  65417. * @param options The required width/height ratio to downsize to before computing the render pass.
  65418. * @param camera The camera to apply the render pass to.
  65419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65420. * @param engine The engine which the post process will be applied. (default: current engine)
  65421. * @param reusable If the post process can be reused on the same frame. (default: false)
  65422. */
  65423. constructor(name: string,
  65424. /** The matrix to be applied to the image */
  65425. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65426. }
  65427. }
  65428. declare module BABYLON {
  65429. /** @hidden */
  65430. export var fxaaPixelShader: {
  65431. name: string;
  65432. shader: string;
  65433. };
  65434. }
  65435. declare module BABYLON {
  65436. /** @hidden */
  65437. export var fxaaVertexShader: {
  65438. name: string;
  65439. shader: string;
  65440. };
  65441. }
  65442. declare module BABYLON {
  65443. /**
  65444. * Fxaa post process
  65445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65446. */
  65447. export class FxaaPostProcess extends PostProcess {
  65448. /** @hidden */
  65449. texelWidth: number;
  65450. /** @hidden */
  65451. texelHeight: number;
  65452. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65453. private _getDefines;
  65454. }
  65455. }
  65456. declare module BABYLON {
  65457. /** @hidden */
  65458. export var grainPixelShader: {
  65459. name: string;
  65460. shader: string;
  65461. };
  65462. }
  65463. declare module BABYLON {
  65464. /**
  65465. * The GrainPostProcess adds noise to the image at mid luminance levels
  65466. */
  65467. export class GrainPostProcess extends PostProcess {
  65468. /**
  65469. * The intensity of the grain added (default: 30)
  65470. */
  65471. intensity: number;
  65472. /**
  65473. * If the grain should be randomized on every frame
  65474. */
  65475. animated: boolean;
  65476. /**
  65477. * Creates a new instance of @see GrainPostProcess
  65478. * @param name The name of the effect.
  65479. * @param options The required width/height ratio to downsize to before computing the render pass.
  65480. * @param camera The camera to apply the render pass to.
  65481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65482. * @param engine The engine which the post process will be applied. (default: current engine)
  65483. * @param reusable If the post process can be reused on the same frame. (default: false)
  65484. * @param textureType Type of textures used when performing the post process. (default: 0)
  65485. * @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)
  65486. */
  65487. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65488. }
  65489. }
  65490. declare module BABYLON {
  65491. /** @hidden */
  65492. export var highlightsPixelShader: {
  65493. name: string;
  65494. shader: string;
  65495. };
  65496. }
  65497. declare module BABYLON {
  65498. /**
  65499. * Extracts highlights from the image
  65500. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65501. */
  65502. export class HighlightsPostProcess extends PostProcess {
  65503. /**
  65504. * Extracts highlights from the image
  65505. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65506. * @param name The name of the effect.
  65507. * @param options The required width/height ratio to downsize to before computing the render pass.
  65508. * @param camera The camera to apply the render pass to.
  65509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65510. * @param engine The engine which the post process will be applied. (default: current engine)
  65511. * @param reusable If the post process can be reused on the same frame. (default: false)
  65512. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65513. */
  65514. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65515. }
  65516. }
  65517. declare module BABYLON {
  65518. /** @hidden */
  65519. export var mrtFragmentDeclaration: {
  65520. name: string;
  65521. shader: string;
  65522. };
  65523. }
  65524. declare module BABYLON {
  65525. /** @hidden */
  65526. export var geometryPixelShader: {
  65527. name: string;
  65528. shader: string;
  65529. };
  65530. }
  65531. declare module BABYLON {
  65532. /** @hidden */
  65533. export var geometryVertexShader: {
  65534. name: string;
  65535. shader: string;
  65536. };
  65537. }
  65538. declare module BABYLON {
  65539. /** @hidden */
  65540. interface ISavedTransformationMatrix {
  65541. world: Matrix;
  65542. viewProjection: Matrix;
  65543. }
  65544. /**
  65545. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65546. */
  65547. export class GeometryBufferRenderer {
  65548. /**
  65549. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65550. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65551. */
  65552. static readonly POSITION_TEXTURE_TYPE: number;
  65553. /**
  65554. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65555. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65556. */
  65557. static readonly VELOCITY_TEXTURE_TYPE: number;
  65558. /**
  65559. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65560. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65561. */
  65562. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65563. /**
  65564. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65565. * in order to compute objects velocities when enableVelocity is set to "true"
  65566. * @hidden
  65567. */
  65568. _previousTransformationMatrices: {
  65569. [index: number]: ISavedTransformationMatrix;
  65570. };
  65571. /**
  65572. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65573. * in order to compute objects velocities when enableVelocity is set to "true"
  65574. * @hidden
  65575. */
  65576. _previousBonesTransformationMatrices: {
  65577. [index: number]: Float32Array;
  65578. };
  65579. /**
  65580. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65581. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65582. */
  65583. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65584. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65585. renderTransparentMeshes: boolean;
  65586. private _scene;
  65587. private _multiRenderTarget;
  65588. private _ratio;
  65589. private _enablePosition;
  65590. private _enableVelocity;
  65591. private _enableReflectivity;
  65592. private _positionIndex;
  65593. private _velocityIndex;
  65594. private _reflectivityIndex;
  65595. protected _effect: Effect;
  65596. protected _cachedDefines: string;
  65597. /**
  65598. * Set the render list (meshes to be rendered) used in the G buffer.
  65599. */
  65600. set renderList(meshes: Mesh[]);
  65601. /**
  65602. * Gets wether or not G buffer are supported by the running hardware.
  65603. * This requires draw buffer supports
  65604. */
  65605. get isSupported(): boolean;
  65606. /**
  65607. * Returns the index of the given texture type in the G-Buffer textures array
  65608. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65609. * @returns the index of the given texture type in the G-Buffer textures array
  65610. */
  65611. getTextureIndex(textureType: number): number;
  65612. /**
  65613. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65614. */
  65615. get enablePosition(): boolean;
  65616. /**
  65617. * Sets whether or not objects positions are enabled for the G buffer.
  65618. */
  65619. set enablePosition(enable: boolean);
  65620. /**
  65621. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65622. */
  65623. get enableVelocity(): boolean;
  65624. /**
  65625. * Sets wether or not objects velocities are enabled for the G buffer.
  65626. */
  65627. set enableVelocity(enable: boolean);
  65628. /**
  65629. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65630. */
  65631. get enableReflectivity(): boolean;
  65632. /**
  65633. * Sets wether or not objects roughness are enabled for the G buffer.
  65634. */
  65635. set enableReflectivity(enable: boolean);
  65636. /**
  65637. * Gets the scene associated with the buffer.
  65638. */
  65639. get scene(): Scene;
  65640. /**
  65641. * Gets the ratio used by the buffer during its creation.
  65642. * How big is the buffer related to the main canvas.
  65643. */
  65644. get ratio(): number;
  65645. /** @hidden */
  65646. static _SceneComponentInitialization: (scene: Scene) => void;
  65647. /**
  65648. * Creates a new G Buffer for the scene
  65649. * @param scene The scene the buffer belongs to
  65650. * @param ratio How big is the buffer related to the main canvas.
  65651. */
  65652. constructor(scene: Scene, ratio?: number);
  65653. /**
  65654. * Checks wether everything is ready to render a submesh to the G buffer.
  65655. * @param subMesh the submesh to check readiness for
  65656. * @param useInstances is the mesh drawn using instance or not
  65657. * @returns true if ready otherwise false
  65658. */
  65659. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65660. /**
  65661. * Gets the current underlying G Buffer.
  65662. * @returns the buffer
  65663. */
  65664. getGBuffer(): MultiRenderTarget;
  65665. /**
  65666. * Gets the number of samples used to render the buffer (anti aliasing).
  65667. */
  65668. get samples(): number;
  65669. /**
  65670. * Sets the number of samples used to render the buffer (anti aliasing).
  65671. */
  65672. set samples(value: number);
  65673. /**
  65674. * Disposes the renderer and frees up associated resources.
  65675. */
  65676. dispose(): void;
  65677. protected _createRenderTargets(): void;
  65678. private _copyBonesTransformationMatrices;
  65679. }
  65680. }
  65681. declare module BABYLON {
  65682. interface Scene {
  65683. /** @hidden (Backing field) */
  65684. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65685. /**
  65686. * Gets or Sets the current geometry buffer associated to the scene.
  65687. */
  65688. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65689. /**
  65690. * Enables a GeometryBufferRender and associates it with the scene
  65691. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65692. * @returns the GeometryBufferRenderer
  65693. */
  65694. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65695. /**
  65696. * Disables the GeometryBufferRender associated with the scene
  65697. */
  65698. disableGeometryBufferRenderer(): void;
  65699. }
  65700. /**
  65701. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65702. * in several rendering techniques.
  65703. */
  65704. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65705. /**
  65706. * The component name helpful to identify the component in the list of scene components.
  65707. */
  65708. readonly name: string;
  65709. /**
  65710. * The scene the component belongs to.
  65711. */
  65712. scene: Scene;
  65713. /**
  65714. * Creates a new instance of the component for the given scene
  65715. * @param scene Defines the scene to register the component in
  65716. */
  65717. constructor(scene: Scene);
  65718. /**
  65719. * Registers the component in a given scene
  65720. */
  65721. register(): void;
  65722. /**
  65723. * Rebuilds the elements related to this component in case of
  65724. * context lost for instance.
  65725. */
  65726. rebuild(): void;
  65727. /**
  65728. * Disposes the component and the associated ressources
  65729. */
  65730. dispose(): void;
  65731. private _gatherRenderTargets;
  65732. }
  65733. }
  65734. declare module BABYLON {
  65735. /** @hidden */
  65736. export var motionBlurPixelShader: {
  65737. name: string;
  65738. shader: string;
  65739. };
  65740. }
  65741. declare module BABYLON {
  65742. /**
  65743. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65744. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65745. * As an example, all you have to do is to create the post-process:
  65746. * var mb = new BABYLON.MotionBlurPostProcess(
  65747. * 'mb', // The name of the effect.
  65748. * scene, // The scene containing the objects to blur according to their velocity.
  65749. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65750. * camera // The camera to apply the render pass to.
  65751. * );
  65752. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65753. */
  65754. export class MotionBlurPostProcess extends PostProcess {
  65755. /**
  65756. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65757. */
  65758. motionStrength: number;
  65759. /**
  65760. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65761. */
  65762. get motionBlurSamples(): number;
  65763. /**
  65764. * Sets the number of iterations to be used for motion blur quality
  65765. */
  65766. set motionBlurSamples(samples: number);
  65767. private _motionBlurSamples;
  65768. private _geometryBufferRenderer;
  65769. /**
  65770. * Creates a new instance MotionBlurPostProcess
  65771. * @param name The name of the effect.
  65772. * @param scene The scene containing the objects to blur according to their velocity.
  65773. * @param options The required width/height ratio to downsize to before computing the render pass.
  65774. * @param camera The camera to apply the render pass to.
  65775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65776. * @param engine The engine which the post process will be applied. (default: current engine)
  65777. * @param reusable If the post process can be reused on the same frame. (default: false)
  65778. * @param textureType Type of textures used when performing the post process. (default: 0)
  65779. * @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)
  65780. */
  65781. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65782. /**
  65783. * Excludes the given skinned mesh from computing bones velocities.
  65784. * 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.
  65785. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65786. */
  65787. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65788. /**
  65789. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65790. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65791. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65792. */
  65793. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65794. /**
  65795. * Disposes the post process.
  65796. * @param camera The camera to dispose the post process on.
  65797. */
  65798. dispose(camera?: Camera): void;
  65799. }
  65800. }
  65801. declare module BABYLON {
  65802. /** @hidden */
  65803. export var refractionPixelShader: {
  65804. name: string;
  65805. shader: string;
  65806. };
  65807. }
  65808. declare module BABYLON {
  65809. /**
  65810. * Post process which applies a refractin texture
  65811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65812. */
  65813. export class RefractionPostProcess extends PostProcess {
  65814. /** the base color of the refraction (used to taint the rendering) */
  65815. color: Color3;
  65816. /** simulated refraction depth */
  65817. depth: number;
  65818. /** the coefficient of the base color (0 to remove base color tainting) */
  65819. colorLevel: number;
  65820. private _refTexture;
  65821. private _ownRefractionTexture;
  65822. /**
  65823. * Gets or sets the refraction texture
  65824. * Please note that you are responsible for disposing the texture if you set it manually
  65825. */
  65826. get refractionTexture(): Texture;
  65827. set refractionTexture(value: Texture);
  65828. /**
  65829. * Initializes the RefractionPostProcess
  65830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65831. * @param name The name of the effect.
  65832. * @param refractionTextureUrl Url of the refraction texture to use
  65833. * @param color the base color of the refraction (used to taint the rendering)
  65834. * @param depth simulated refraction depth
  65835. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65836. * @param camera The camera to apply the render pass to.
  65837. * @param options The required width/height ratio to downsize to before computing the render pass.
  65838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65839. * @param engine The engine which the post process will be applied. (default: current engine)
  65840. * @param reusable If the post process can be reused on the same frame. (default: false)
  65841. */
  65842. constructor(name: string, refractionTextureUrl: string,
  65843. /** the base color of the refraction (used to taint the rendering) */
  65844. color: Color3,
  65845. /** simulated refraction depth */
  65846. depth: number,
  65847. /** the coefficient of the base color (0 to remove base color tainting) */
  65848. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65849. /**
  65850. * Disposes of the post process
  65851. * @param camera Camera to dispose post process on
  65852. */
  65853. dispose(camera: Camera): void;
  65854. }
  65855. }
  65856. declare module BABYLON {
  65857. /** @hidden */
  65858. export var sharpenPixelShader: {
  65859. name: string;
  65860. shader: string;
  65861. };
  65862. }
  65863. declare module BABYLON {
  65864. /**
  65865. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65866. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65867. */
  65868. export class SharpenPostProcess extends PostProcess {
  65869. /**
  65870. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65871. */
  65872. colorAmount: number;
  65873. /**
  65874. * How much sharpness should be applied (default: 0.3)
  65875. */
  65876. edgeAmount: number;
  65877. /**
  65878. * Creates a new instance ConvolutionPostProcess
  65879. * @param name The name of the effect.
  65880. * @param options The required width/height ratio to downsize to before computing the render pass.
  65881. * @param camera The camera to apply the render pass to.
  65882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65883. * @param engine The engine which the post process will be applied. (default: current engine)
  65884. * @param reusable If the post process can be reused on the same frame. (default: false)
  65885. * @param textureType Type of textures used when performing the post process. (default: 0)
  65886. * @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)
  65887. */
  65888. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65889. }
  65890. }
  65891. declare module BABYLON {
  65892. /**
  65893. * PostProcessRenderPipeline
  65894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65895. */
  65896. export class PostProcessRenderPipeline {
  65897. private engine;
  65898. private _renderEffects;
  65899. private _renderEffectsForIsolatedPass;
  65900. /**
  65901. * List of inspectable custom properties (used by the Inspector)
  65902. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65903. */
  65904. inspectableCustomProperties: IInspectable[];
  65905. /**
  65906. * @hidden
  65907. */
  65908. protected _cameras: Camera[];
  65909. /** @hidden */
  65910. _name: string;
  65911. /**
  65912. * Gets pipeline name
  65913. */
  65914. get name(): string;
  65915. /** Gets the list of attached cameras */
  65916. get cameras(): Camera[];
  65917. /**
  65918. * Initializes a PostProcessRenderPipeline
  65919. * @param engine engine to add the pipeline to
  65920. * @param name name of the pipeline
  65921. */
  65922. constructor(engine: Engine, name: string);
  65923. /**
  65924. * Gets the class name
  65925. * @returns "PostProcessRenderPipeline"
  65926. */
  65927. getClassName(): string;
  65928. /**
  65929. * If all the render effects in the pipeline are supported
  65930. */
  65931. get isSupported(): boolean;
  65932. /**
  65933. * Adds an effect to the pipeline
  65934. * @param renderEffect the effect to add
  65935. */
  65936. addEffect(renderEffect: PostProcessRenderEffect): void;
  65937. /** @hidden */
  65938. _rebuild(): void;
  65939. /** @hidden */
  65940. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65941. /** @hidden */
  65942. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65943. /** @hidden */
  65944. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65945. /** @hidden */
  65946. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65947. /** @hidden */
  65948. _attachCameras(cameras: Camera, unique: boolean): void;
  65949. /** @hidden */
  65950. _attachCameras(cameras: Camera[], unique: boolean): void;
  65951. /** @hidden */
  65952. _detachCameras(cameras: Camera): void;
  65953. /** @hidden */
  65954. _detachCameras(cameras: Nullable<Camera[]>): void;
  65955. /** @hidden */
  65956. _update(): void;
  65957. /** @hidden */
  65958. _reset(): void;
  65959. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65960. /**
  65961. * Disposes of the pipeline
  65962. */
  65963. dispose(): void;
  65964. }
  65965. }
  65966. declare module BABYLON {
  65967. /**
  65968. * PostProcessRenderPipelineManager class
  65969. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65970. */
  65971. export class PostProcessRenderPipelineManager {
  65972. private _renderPipelines;
  65973. /**
  65974. * Initializes a PostProcessRenderPipelineManager
  65975. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65976. */
  65977. constructor();
  65978. /**
  65979. * Gets the list of supported render pipelines
  65980. */
  65981. get supportedPipelines(): PostProcessRenderPipeline[];
  65982. /**
  65983. * Adds a pipeline to the manager
  65984. * @param renderPipeline The pipeline to add
  65985. */
  65986. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65987. /**
  65988. * Attaches a camera to the pipeline
  65989. * @param renderPipelineName The name of the pipeline to attach to
  65990. * @param cameras the camera to attach
  65991. * @param unique if the camera can be attached multiple times to the pipeline
  65992. */
  65993. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65994. /**
  65995. * Detaches a camera from the pipeline
  65996. * @param renderPipelineName The name of the pipeline to detach from
  65997. * @param cameras the camera to detach
  65998. */
  65999. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66000. /**
  66001. * Enables an effect by name on a pipeline
  66002. * @param renderPipelineName the name of the pipeline to enable the effect in
  66003. * @param renderEffectName the name of the effect to enable
  66004. * @param cameras the cameras that the effect should be enabled on
  66005. */
  66006. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66007. /**
  66008. * Disables an effect by name on a pipeline
  66009. * @param renderPipelineName the name of the pipeline to disable the effect in
  66010. * @param renderEffectName the name of the effect to disable
  66011. * @param cameras the cameras that the effect should be disabled on
  66012. */
  66013. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66014. /**
  66015. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66016. */
  66017. update(): void;
  66018. /** @hidden */
  66019. _rebuild(): void;
  66020. /**
  66021. * Disposes of the manager and pipelines
  66022. */
  66023. dispose(): void;
  66024. }
  66025. }
  66026. declare module BABYLON {
  66027. interface Scene {
  66028. /** @hidden (Backing field) */
  66029. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66030. /**
  66031. * Gets the postprocess render pipeline manager
  66032. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66033. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66034. */
  66035. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66036. }
  66037. /**
  66038. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66039. */
  66040. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66041. /**
  66042. * The component name helpfull to identify the component in the list of scene components.
  66043. */
  66044. readonly name: string;
  66045. /**
  66046. * The scene the component belongs to.
  66047. */
  66048. scene: Scene;
  66049. /**
  66050. * Creates a new instance of the component for the given scene
  66051. * @param scene Defines the scene to register the component in
  66052. */
  66053. constructor(scene: Scene);
  66054. /**
  66055. * Registers the component in a given scene
  66056. */
  66057. register(): void;
  66058. /**
  66059. * Rebuilds the elements related to this component in case of
  66060. * context lost for instance.
  66061. */
  66062. rebuild(): void;
  66063. /**
  66064. * Disposes the component and the associated ressources
  66065. */
  66066. dispose(): void;
  66067. private _gatherRenderTargets;
  66068. }
  66069. }
  66070. declare module BABYLON {
  66071. /**
  66072. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66073. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66074. */
  66075. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66076. private _scene;
  66077. private _camerasToBeAttached;
  66078. /**
  66079. * ID of the sharpen post process,
  66080. */
  66081. private readonly SharpenPostProcessId;
  66082. /**
  66083. * @ignore
  66084. * ID of the image processing post process;
  66085. */
  66086. readonly ImageProcessingPostProcessId: string;
  66087. /**
  66088. * @ignore
  66089. * ID of the Fast Approximate Anti-Aliasing post process;
  66090. */
  66091. readonly FxaaPostProcessId: string;
  66092. /**
  66093. * ID of the chromatic aberration post process,
  66094. */
  66095. private readonly ChromaticAberrationPostProcessId;
  66096. /**
  66097. * ID of the grain post process
  66098. */
  66099. private readonly GrainPostProcessId;
  66100. /**
  66101. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66102. */
  66103. sharpen: SharpenPostProcess;
  66104. private _sharpenEffect;
  66105. private bloom;
  66106. /**
  66107. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66108. */
  66109. depthOfField: DepthOfFieldEffect;
  66110. /**
  66111. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66112. */
  66113. fxaa: FxaaPostProcess;
  66114. /**
  66115. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66116. */
  66117. imageProcessing: ImageProcessingPostProcess;
  66118. /**
  66119. * Chromatic aberration post process which will shift rgb colors in the image
  66120. */
  66121. chromaticAberration: ChromaticAberrationPostProcess;
  66122. private _chromaticAberrationEffect;
  66123. /**
  66124. * Grain post process which add noise to the image
  66125. */
  66126. grain: GrainPostProcess;
  66127. private _grainEffect;
  66128. /**
  66129. * Glow post process which adds a glow to emissive areas of the image
  66130. */
  66131. private _glowLayer;
  66132. /**
  66133. * Animations which can be used to tweak settings over a period of time
  66134. */
  66135. animations: Animation[];
  66136. private _imageProcessingConfigurationObserver;
  66137. private _sharpenEnabled;
  66138. private _bloomEnabled;
  66139. private _depthOfFieldEnabled;
  66140. private _depthOfFieldBlurLevel;
  66141. private _fxaaEnabled;
  66142. private _imageProcessingEnabled;
  66143. private _defaultPipelineTextureType;
  66144. private _bloomScale;
  66145. private _chromaticAberrationEnabled;
  66146. private _grainEnabled;
  66147. private _buildAllowed;
  66148. /**
  66149. * Gets active scene
  66150. */
  66151. get scene(): Scene;
  66152. /**
  66153. * Enable or disable the sharpen process from the pipeline
  66154. */
  66155. set sharpenEnabled(enabled: boolean);
  66156. get sharpenEnabled(): boolean;
  66157. private _resizeObserver;
  66158. private _hardwareScaleLevel;
  66159. private _bloomKernel;
  66160. /**
  66161. * Specifies the size of the bloom blur kernel, relative to the final output size
  66162. */
  66163. get bloomKernel(): number;
  66164. set bloomKernel(value: number);
  66165. /**
  66166. * Specifies the weight of the bloom in the final rendering
  66167. */
  66168. private _bloomWeight;
  66169. /**
  66170. * Specifies the luma threshold for the area that will be blurred by the bloom
  66171. */
  66172. private _bloomThreshold;
  66173. private _hdr;
  66174. /**
  66175. * The strength of the bloom.
  66176. */
  66177. set bloomWeight(value: number);
  66178. get bloomWeight(): number;
  66179. /**
  66180. * The strength of the bloom.
  66181. */
  66182. set bloomThreshold(value: number);
  66183. get bloomThreshold(): number;
  66184. /**
  66185. * The scale of the bloom, lower value will provide better performance.
  66186. */
  66187. set bloomScale(value: number);
  66188. get bloomScale(): number;
  66189. /**
  66190. * Enable or disable the bloom from the pipeline
  66191. */
  66192. set bloomEnabled(enabled: boolean);
  66193. get bloomEnabled(): boolean;
  66194. private _rebuildBloom;
  66195. /**
  66196. * If the depth of field is enabled.
  66197. */
  66198. get depthOfFieldEnabled(): boolean;
  66199. set depthOfFieldEnabled(enabled: boolean);
  66200. /**
  66201. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66202. */
  66203. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66204. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66205. /**
  66206. * If the anti aliasing is enabled.
  66207. */
  66208. set fxaaEnabled(enabled: boolean);
  66209. get fxaaEnabled(): boolean;
  66210. private _samples;
  66211. /**
  66212. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66213. */
  66214. set samples(sampleCount: number);
  66215. get samples(): number;
  66216. /**
  66217. * If image processing is enabled.
  66218. */
  66219. set imageProcessingEnabled(enabled: boolean);
  66220. get imageProcessingEnabled(): boolean;
  66221. /**
  66222. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66223. */
  66224. set glowLayerEnabled(enabled: boolean);
  66225. get glowLayerEnabled(): boolean;
  66226. /**
  66227. * Gets the glow layer (or null if not defined)
  66228. */
  66229. get glowLayer(): Nullable<GlowLayer>;
  66230. /**
  66231. * Enable or disable the chromaticAberration process from the pipeline
  66232. */
  66233. set chromaticAberrationEnabled(enabled: boolean);
  66234. get chromaticAberrationEnabled(): boolean;
  66235. /**
  66236. * Enable or disable the grain process from the pipeline
  66237. */
  66238. set grainEnabled(enabled: boolean);
  66239. get grainEnabled(): boolean;
  66240. /**
  66241. * @constructor
  66242. * @param name - The rendering pipeline name (default: "")
  66243. * @param hdr - If high dynamic range textures should be used (default: true)
  66244. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66245. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66246. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66247. */
  66248. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66249. /**
  66250. * Get the class name
  66251. * @returns "DefaultRenderingPipeline"
  66252. */
  66253. getClassName(): string;
  66254. /**
  66255. * Force the compilation of the entire pipeline.
  66256. */
  66257. prepare(): void;
  66258. private _hasCleared;
  66259. private _prevPostProcess;
  66260. private _prevPrevPostProcess;
  66261. private _setAutoClearAndTextureSharing;
  66262. private _depthOfFieldSceneObserver;
  66263. private _buildPipeline;
  66264. private _disposePostProcesses;
  66265. /**
  66266. * Adds a camera to the pipeline
  66267. * @param camera the camera to be added
  66268. */
  66269. addCamera(camera: Camera): void;
  66270. /**
  66271. * Removes a camera from the pipeline
  66272. * @param camera the camera to remove
  66273. */
  66274. removeCamera(camera: Camera): void;
  66275. /**
  66276. * Dispose of the pipeline and stop all post processes
  66277. */
  66278. dispose(): void;
  66279. /**
  66280. * Serialize the rendering pipeline (Used when exporting)
  66281. * @returns the serialized object
  66282. */
  66283. serialize(): any;
  66284. /**
  66285. * Parse the serialized pipeline
  66286. * @param source Source pipeline.
  66287. * @param scene The scene to load the pipeline to.
  66288. * @param rootUrl The URL of the serialized pipeline.
  66289. * @returns An instantiated pipeline from the serialized object.
  66290. */
  66291. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66292. }
  66293. }
  66294. declare module BABYLON {
  66295. /** @hidden */
  66296. export var lensHighlightsPixelShader: {
  66297. name: string;
  66298. shader: string;
  66299. };
  66300. }
  66301. declare module BABYLON {
  66302. /** @hidden */
  66303. export var depthOfFieldPixelShader: {
  66304. name: string;
  66305. shader: string;
  66306. };
  66307. }
  66308. declare module BABYLON {
  66309. /**
  66310. * BABYLON.JS Chromatic Aberration GLSL Shader
  66311. * Author: Olivier Guyot
  66312. * Separates very slightly R, G and B colors on the edges of the screen
  66313. * Inspired by Francois Tarlier & Martins Upitis
  66314. */
  66315. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66316. /**
  66317. * @ignore
  66318. * The chromatic aberration PostProcess id in the pipeline
  66319. */
  66320. LensChromaticAberrationEffect: string;
  66321. /**
  66322. * @ignore
  66323. * The highlights enhancing PostProcess id in the pipeline
  66324. */
  66325. HighlightsEnhancingEffect: string;
  66326. /**
  66327. * @ignore
  66328. * The depth-of-field PostProcess id in the pipeline
  66329. */
  66330. LensDepthOfFieldEffect: string;
  66331. private _scene;
  66332. private _depthTexture;
  66333. private _grainTexture;
  66334. private _chromaticAberrationPostProcess;
  66335. private _highlightsPostProcess;
  66336. private _depthOfFieldPostProcess;
  66337. private _edgeBlur;
  66338. private _grainAmount;
  66339. private _chromaticAberration;
  66340. private _distortion;
  66341. private _highlightsGain;
  66342. private _highlightsThreshold;
  66343. private _dofDistance;
  66344. private _dofAperture;
  66345. private _dofDarken;
  66346. private _dofPentagon;
  66347. private _blurNoise;
  66348. /**
  66349. * @constructor
  66350. *
  66351. * Effect parameters are as follow:
  66352. * {
  66353. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66354. * edge_blur: number; // from 0 to x (1 for realism)
  66355. * distortion: number; // from 0 to x (1 for realism)
  66356. * grain_amount: number; // from 0 to 1
  66357. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66358. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66359. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66360. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66361. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66362. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66363. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66364. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66365. * }
  66366. * Note: if an effect parameter is unset, effect is disabled
  66367. *
  66368. * @param name The rendering pipeline name
  66369. * @param parameters - An object containing all parameters (see above)
  66370. * @param scene The scene linked to this pipeline
  66371. * @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)
  66372. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66373. */
  66374. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66375. /**
  66376. * Get the class name
  66377. * @returns "LensRenderingPipeline"
  66378. */
  66379. getClassName(): string;
  66380. /**
  66381. * Gets associated scene
  66382. */
  66383. get scene(): Scene;
  66384. /**
  66385. * Gets or sets the edge blur
  66386. */
  66387. get edgeBlur(): number;
  66388. set edgeBlur(value: number);
  66389. /**
  66390. * Gets or sets the grain amount
  66391. */
  66392. get grainAmount(): number;
  66393. set grainAmount(value: number);
  66394. /**
  66395. * Gets or sets the chromatic aberration amount
  66396. */
  66397. get chromaticAberration(): number;
  66398. set chromaticAberration(value: number);
  66399. /**
  66400. * Gets or sets the depth of field aperture
  66401. */
  66402. get dofAperture(): number;
  66403. set dofAperture(value: number);
  66404. /**
  66405. * Gets or sets the edge distortion
  66406. */
  66407. get edgeDistortion(): number;
  66408. set edgeDistortion(value: number);
  66409. /**
  66410. * Gets or sets the depth of field distortion
  66411. */
  66412. get dofDistortion(): number;
  66413. set dofDistortion(value: number);
  66414. /**
  66415. * Gets or sets the darken out of focus amount
  66416. */
  66417. get darkenOutOfFocus(): number;
  66418. set darkenOutOfFocus(value: number);
  66419. /**
  66420. * Gets or sets a boolean indicating if blur noise is enabled
  66421. */
  66422. get blurNoise(): boolean;
  66423. set blurNoise(value: boolean);
  66424. /**
  66425. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66426. */
  66427. get pentagonBokeh(): boolean;
  66428. set pentagonBokeh(value: boolean);
  66429. /**
  66430. * Gets or sets the highlight grain amount
  66431. */
  66432. get highlightsGain(): number;
  66433. set highlightsGain(value: number);
  66434. /**
  66435. * Gets or sets the highlight threshold
  66436. */
  66437. get highlightsThreshold(): number;
  66438. set highlightsThreshold(value: number);
  66439. /**
  66440. * Sets the amount of blur at the edges
  66441. * @param amount blur amount
  66442. */
  66443. setEdgeBlur(amount: number): void;
  66444. /**
  66445. * Sets edge blur to 0
  66446. */
  66447. disableEdgeBlur(): void;
  66448. /**
  66449. * Sets the amout of grain
  66450. * @param amount Amount of grain
  66451. */
  66452. setGrainAmount(amount: number): void;
  66453. /**
  66454. * Set grain amount to 0
  66455. */
  66456. disableGrain(): void;
  66457. /**
  66458. * Sets the chromatic aberration amount
  66459. * @param amount amount of chromatic aberration
  66460. */
  66461. setChromaticAberration(amount: number): void;
  66462. /**
  66463. * Sets chromatic aberration amount to 0
  66464. */
  66465. disableChromaticAberration(): void;
  66466. /**
  66467. * Sets the EdgeDistortion amount
  66468. * @param amount amount of EdgeDistortion
  66469. */
  66470. setEdgeDistortion(amount: number): void;
  66471. /**
  66472. * Sets edge distortion to 0
  66473. */
  66474. disableEdgeDistortion(): void;
  66475. /**
  66476. * Sets the FocusDistance amount
  66477. * @param amount amount of FocusDistance
  66478. */
  66479. setFocusDistance(amount: number): void;
  66480. /**
  66481. * Disables depth of field
  66482. */
  66483. disableDepthOfField(): void;
  66484. /**
  66485. * Sets the Aperture amount
  66486. * @param amount amount of Aperture
  66487. */
  66488. setAperture(amount: number): void;
  66489. /**
  66490. * Sets the DarkenOutOfFocus amount
  66491. * @param amount amount of DarkenOutOfFocus
  66492. */
  66493. setDarkenOutOfFocus(amount: number): void;
  66494. private _pentagonBokehIsEnabled;
  66495. /**
  66496. * Creates a pentagon bokeh effect
  66497. */
  66498. enablePentagonBokeh(): void;
  66499. /**
  66500. * Disables the pentagon bokeh effect
  66501. */
  66502. disablePentagonBokeh(): void;
  66503. /**
  66504. * Enables noise blur
  66505. */
  66506. enableNoiseBlur(): void;
  66507. /**
  66508. * Disables noise blur
  66509. */
  66510. disableNoiseBlur(): void;
  66511. /**
  66512. * Sets the HighlightsGain amount
  66513. * @param amount amount of HighlightsGain
  66514. */
  66515. setHighlightsGain(amount: number): void;
  66516. /**
  66517. * Sets the HighlightsThreshold amount
  66518. * @param amount amount of HighlightsThreshold
  66519. */
  66520. setHighlightsThreshold(amount: number): void;
  66521. /**
  66522. * Disables highlights
  66523. */
  66524. disableHighlights(): void;
  66525. /**
  66526. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66527. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66528. */
  66529. dispose(disableDepthRender?: boolean): void;
  66530. private _createChromaticAberrationPostProcess;
  66531. private _createHighlightsPostProcess;
  66532. private _createDepthOfFieldPostProcess;
  66533. private _createGrainTexture;
  66534. }
  66535. }
  66536. declare module BABYLON {
  66537. /** @hidden */
  66538. export var ssao2PixelShader: {
  66539. name: string;
  66540. shader: string;
  66541. };
  66542. }
  66543. declare module BABYLON {
  66544. /** @hidden */
  66545. export var ssaoCombinePixelShader: {
  66546. name: string;
  66547. shader: string;
  66548. };
  66549. }
  66550. declare module BABYLON {
  66551. /**
  66552. * Render pipeline to produce ssao effect
  66553. */
  66554. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66555. /**
  66556. * @ignore
  66557. * The PassPostProcess id in the pipeline that contains the original scene color
  66558. */
  66559. SSAOOriginalSceneColorEffect: string;
  66560. /**
  66561. * @ignore
  66562. * The SSAO PostProcess id in the pipeline
  66563. */
  66564. SSAORenderEffect: string;
  66565. /**
  66566. * @ignore
  66567. * The horizontal blur PostProcess id in the pipeline
  66568. */
  66569. SSAOBlurHRenderEffect: string;
  66570. /**
  66571. * @ignore
  66572. * The vertical blur PostProcess id in the pipeline
  66573. */
  66574. SSAOBlurVRenderEffect: string;
  66575. /**
  66576. * @ignore
  66577. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66578. */
  66579. SSAOCombineRenderEffect: string;
  66580. /**
  66581. * The output strength of the SSAO post-process. Default value is 1.0.
  66582. */
  66583. totalStrength: number;
  66584. /**
  66585. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66586. */
  66587. maxZ: number;
  66588. /**
  66589. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66590. */
  66591. minZAspect: number;
  66592. private _samples;
  66593. /**
  66594. * Number of samples used for the SSAO calculations. Default value is 8
  66595. */
  66596. set samples(n: number);
  66597. get samples(): number;
  66598. private _textureSamples;
  66599. /**
  66600. * Number of samples to use for antialiasing
  66601. */
  66602. set textureSamples(n: number);
  66603. get textureSamples(): number;
  66604. /**
  66605. * Ratio object used for SSAO ratio and blur ratio
  66606. */
  66607. private _ratio;
  66608. /**
  66609. * Dynamically generated sphere sampler.
  66610. */
  66611. private _sampleSphere;
  66612. /**
  66613. * Blur filter offsets
  66614. */
  66615. private _samplerOffsets;
  66616. private _expensiveBlur;
  66617. /**
  66618. * If bilateral blur should be used
  66619. */
  66620. set expensiveBlur(b: boolean);
  66621. get expensiveBlur(): boolean;
  66622. /**
  66623. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66624. */
  66625. radius: number;
  66626. /**
  66627. * The base color of the SSAO post-process
  66628. * The final result is "base + ssao" between [0, 1]
  66629. */
  66630. base: number;
  66631. /**
  66632. * Support test.
  66633. */
  66634. static get IsSupported(): boolean;
  66635. private _scene;
  66636. private _depthTexture;
  66637. private _normalTexture;
  66638. private _randomTexture;
  66639. private _originalColorPostProcess;
  66640. private _ssaoPostProcess;
  66641. private _blurHPostProcess;
  66642. private _blurVPostProcess;
  66643. private _ssaoCombinePostProcess;
  66644. /**
  66645. * Gets active scene
  66646. */
  66647. get scene(): Scene;
  66648. /**
  66649. * @constructor
  66650. * @param name The rendering pipeline name
  66651. * @param scene The scene linked to this pipeline
  66652. * @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 }
  66653. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66654. */
  66655. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66656. /**
  66657. * Get the class name
  66658. * @returns "SSAO2RenderingPipeline"
  66659. */
  66660. getClassName(): string;
  66661. /**
  66662. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66663. */
  66664. dispose(disableGeometryBufferRenderer?: boolean): void;
  66665. private _createBlurPostProcess;
  66666. /** @hidden */
  66667. _rebuild(): void;
  66668. private _bits;
  66669. private _radicalInverse_VdC;
  66670. private _hammersley;
  66671. private _hemisphereSample_uniform;
  66672. private _generateHemisphere;
  66673. private _createSSAOPostProcess;
  66674. private _createSSAOCombinePostProcess;
  66675. private _createRandomTexture;
  66676. /**
  66677. * Serialize the rendering pipeline (Used when exporting)
  66678. * @returns the serialized object
  66679. */
  66680. serialize(): any;
  66681. /**
  66682. * Parse the serialized pipeline
  66683. * @param source Source pipeline.
  66684. * @param scene The scene to load the pipeline to.
  66685. * @param rootUrl The URL of the serialized pipeline.
  66686. * @returns An instantiated pipeline from the serialized object.
  66687. */
  66688. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66689. }
  66690. }
  66691. declare module BABYLON {
  66692. /** @hidden */
  66693. export var ssaoPixelShader: {
  66694. name: string;
  66695. shader: string;
  66696. };
  66697. }
  66698. declare module BABYLON {
  66699. /**
  66700. * Render pipeline to produce ssao effect
  66701. */
  66702. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66703. /**
  66704. * @ignore
  66705. * The PassPostProcess id in the pipeline that contains the original scene color
  66706. */
  66707. SSAOOriginalSceneColorEffect: string;
  66708. /**
  66709. * @ignore
  66710. * The SSAO PostProcess id in the pipeline
  66711. */
  66712. SSAORenderEffect: string;
  66713. /**
  66714. * @ignore
  66715. * The horizontal blur PostProcess id in the pipeline
  66716. */
  66717. SSAOBlurHRenderEffect: string;
  66718. /**
  66719. * @ignore
  66720. * The vertical blur PostProcess id in the pipeline
  66721. */
  66722. SSAOBlurVRenderEffect: string;
  66723. /**
  66724. * @ignore
  66725. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66726. */
  66727. SSAOCombineRenderEffect: string;
  66728. /**
  66729. * The output strength of the SSAO post-process. Default value is 1.0.
  66730. */
  66731. totalStrength: number;
  66732. /**
  66733. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66734. */
  66735. radius: number;
  66736. /**
  66737. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66738. * Must not be equal to fallOff and superior to fallOff.
  66739. * Default value is 0.0075
  66740. */
  66741. area: number;
  66742. /**
  66743. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66744. * Must not be equal to area and inferior to area.
  66745. * Default value is 0.000001
  66746. */
  66747. fallOff: number;
  66748. /**
  66749. * The base color of the SSAO post-process
  66750. * The final result is "base + ssao" between [0, 1]
  66751. */
  66752. base: number;
  66753. private _scene;
  66754. private _depthTexture;
  66755. private _randomTexture;
  66756. private _originalColorPostProcess;
  66757. private _ssaoPostProcess;
  66758. private _blurHPostProcess;
  66759. private _blurVPostProcess;
  66760. private _ssaoCombinePostProcess;
  66761. private _firstUpdate;
  66762. /**
  66763. * Gets active scene
  66764. */
  66765. get scene(): Scene;
  66766. /**
  66767. * @constructor
  66768. * @param name - The rendering pipeline name
  66769. * @param scene - The scene linked to this pipeline
  66770. * @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 }
  66771. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66772. */
  66773. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66774. /**
  66775. * Get the class name
  66776. * @returns "SSAORenderingPipeline"
  66777. */
  66778. getClassName(): string;
  66779. /**
  66780. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66781. */
  66782. dispose(disableDepthRender?: boolean): void;
  66783. private _createBlurPostProcess;
  66784. /** @hidden */
  66785. _rebuild(): void;
  66786. private _createSSAOPostProcess;
  66787. private _createSSAOCombinePostProcess;
  66788. private _createRandomTexture;
  66789. }
  66790. }
  66791. declare module BABYLON {
  66792. /** @hidden */
  66793. export var screenSpaceReflectionPixelShader: {
  66794. name: string;
  66795. shader: string;
  66796. };
  66797. }
  66798. declare module BABYLON {
  66799. /**
  66800. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66801. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66802. */
  66803. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66804. /**
  66805. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66806. */
  66807. threshold: number;
  66808. /**
  66809. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66810. */
  66811. strength: number;
  66812. /**
  66813. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66814. */
  66815. reflectionSpecularFalloffExponent: number;
  66816. /**
  66817. * 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]
  66818. */
  66819. step: number;
  66820. /**
  66821. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66822. */
  66823. roughnessFactor: number;
  66824. private _geometryBufferRenderer;
  66825. private _enableSmoothReflections;
  66826. private _reflectionSamples;
  66827. private _smoothSteps;
  66828. /**
  66829. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66830. * @param name The name of the effect.
  66831. * @param scene The scene containing the objects to calculate reflections.
  66832. * @param options The required width/height ratio to downsize to before computing the render pass.
  66833. * @param camera The camera to apply the render pass to.
  66834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66835. * @param engine The engine which the post process will be applied. (default: current engine)
  66836. * @param reusable If the post process can be reused on the same frame. (default: false)
  66837. * @param textureType Type of textures used when performing the post process. (default: 0)
  66838. * @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)
  66839. */
  66840. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66841. /**
  66842. * Gets wether or not smoothing reflections is enabled.
  66843. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66844. */
  66845. get enableSmoothReflections(): boolean;
  66846. /**
  66847. * Sets wether or not smoothing reflections is enabled.
  66848. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66849. */
  66850. set enableSmoothReflections(enabled: boolean);
  66851. /**
  66852. * Gets the number of samples taken while computing reflections. More samples count is high,
  66853. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66854. */
  66855. get reflectionSamples(): number;
  66856. /**
  66857. * Sets the number of samples taken while computing reflections. More samples count is high,
  66858. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66859. */
  66860. set reflectionSamples(samples: number);
  66861. /**
  66862. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66863. * more the post-process will require GPU power and can generate a drop in FPS.
  66864. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66865. */
  66866. get smoothSteps(): number;
  66867. set smoothSteps(steps: number);
  66868. private _updateEffectDefines;
  66869. }
  66870. }
  66871. declare module BABYLON {
  66872. /** @hidden */
  66873. export var standardPixelShader: {
  66874. name: string;
  66875. shader: string;
  66876. };
  66877. }
  66878. declare module BABYLON {
  66879. /**
  66880. * Standard rendering pipeline
  66881. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66882. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66883. */
  66884. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66885. /**
  66886. * Public members
  66887. */
  66888. /**
  66889. * Post-process which contains the original scene color before the pipeline applies all the effects
  66890. */
  66891. originalPostProcess: Nullable<PostProcess>;
  66892. /**
  66893. * Post-process used to down scale an image x4
  66894. */
  66895. downSampleX4PostProcess: Nullable<PostProcess>;
  66896. /**
  66897. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66898. */
  66899. brightPassPostProcess: Nullable<PostProcess>;
  66900. /**
  66901. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66902. */
  66903. blurHPostProcesses: PostProcess[];
  66904. /**
  66905. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66906. */
  66907. blurVPostProcesses: PostProcess[];
  66908. /**
  66909. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66910. */
  66911. textureAdderPostProcess: Nullable<PostProcess>;
  66912. /**
  66913. * Post-process used to create volumetric lighting effect
  66914. */
  66915. volumetricLightPostProcess: Nullable<PostProcess>;
  66916. /**
  66917. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66918. */
  66919. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66920. /**
  66921. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66922. */
  66923. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66924. /**
  66925. * Post-process used to merge the volumetric light effect and the real scene color
  66926. */
  66927. volumetricLightMergePostProces: Nullable<PostProcess>;
  66928. /**
  66929. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66930. */
  66931. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66932. /**
  66933. * Base post-process used to calculate the average luminance of the final image for HDR
  66934. */
  66935. luminancePostProcess: Nullable<PostProcess>;
  66936. /**
  66937. * Post-processes used to create down sample post-processes in order to get
  66938. * the average luminance of the final image for HDR
  66939. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66940. */
  66941. luminanceDownSamplePostProcesses: PostProcess[];
  66942. /**
  66943. * Post-process used to create a HDR effect (light adaptation)
  66944. */
  66945. hdrPostProcess: Nullable<PostProcess>;
  66946. /**
  66947. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66948. */
  66949. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66950. /**
  66951. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66952. */
  66953. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66954. /**
  66955. * Post-process used to merge the final HDR post-process and the real scene color
  66956. */
  66957. hdrFinalPostProcess: Nullable<PostProcess>;
  66958. /**
  66959. * Post-process used to create a lens flare effect
  66960. */
  66961. lensFlarePostProcess: Nullable<PostProcess>;
  66962. /**
  66963. * Post-process that merges the result of the lens flare post-process and the real scene color
  66964. */
  66965. lensFlareComposePostProcess: Nullable<PostProcess>;
  66966. /**
  66967. * Post-process used to create a motion blur effect
  66968. */
  66969. motionBlurPostProcess: Nullable<PostProcess>;
  66970. /**
  66971. * Post-process used to create a depth of field effect
  66972. */
  66973. depthOfFieldPostProcess: Nullable<PostProcess>;
  66974. /**
  66975. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66976. */
  66977. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66978. /**
  66979. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66980. */
  66981. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66982. /**
  66983. * Represents the brightness threshold in order to configure the illuminated surfaces
  66984. */
  66985. brightThreshold: number;
  66986. /**
  66987. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66988. */
  66989. blurWidth: number;
  66990. /**
  66991. * Sets if the blur for highlighted surfaces must be only horizontal
  66992. */
  66993. horizontalBlur: boolean;
  66994. /**
  66995. * Gets the overall exposure used by the pipeline
  66996. */
  66997. get exposure(): number;
  66998. /**
  66999. * Sets the overall exposure used by the pipeline
  67000. */
  67001. set exposure(value: number);
  67002. /**
  67003. * Texture used typically to simulate "dirty" on camera lens
  67004. */
  67005. lensTexture: Nullable<Texture>;
  67006. /**
  67007. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67008. */
  67009. volumetricLightCoefficient: number;
  67010. /**
  67011. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67012. */
  67013. volumetricLightPower: number;
  67014. /**
  67015. * Used the set the blur intensity to smooth the volumetric lights
  67016. */
  67017. volumetricLightBlurScale: number;
  67018. /**
  67019. * Light (spot or directional) used to generate the volumetric lights rays
  67020. * The source light must have a shadow generate so the pipeline can get its
  67021. * depth map
  67022. */
  67023. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67024. /**
  67025. * For eye adaptation, represents the minimum luminance the eye can see
  67026. */
  67027. hdrMinimumLuminance: number;
  67028. /**
  67029. * For eye adaptation, represents the decrease luminance speed
  67030. */
  67031. hdrDecreaseRate: number;
  67032. /**
  67033. * For eye adaptation, represents the increase luminance speed
  67034. */
  67035. hdrIncreaseRate: number;
  67036. /**
  67037. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67038. */
  67039. get hdrAutoExposure(): boolean;
  67040. /**
  67041. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67042. */
  67043. set hdrAutoExposure(value: boolean);
  67044. /**
  67045. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67046. */
  67047. lensColorTexture: Nullable<Texture>;
  67048. /**
  67049. * The overall strengh for the lens flare effect
  67050. */
  67051. lensFlareStrength: number;
  67052. /**
  67053. * Dispersion coefficient for lens flare ghosts
  67054. */
  67055. lensFlareGhostDispersal: number;
  67056. /**
  67057. * Main lens flare halo width
  67058. */
  67059. lensFlareHaloWidth: number;
  67060. /**
  67061. * Based on the lens distortion effect, defines how much the lens flare result
  67062. * is distorted
  67063. */
  67064. lensFlareDistortionStrength: number;
  67065. /**
  67066. * Configures the blur intensity used for for lens flare (halo)
  67067. */
  67068. lensFlareBlurWidth: number;
  67069. /**
  67070. * Lens star texture must be used to simulate rays on the flares and is available
  67071. * in the documentation
  67072. */
  67073. lensStarTexture: Nullable<Texture>;
  67074. /**
  67075. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67076. * flare effect by taking account of the dirt texture
  67077. */
  67078. lensFlareDirtTexture: Nullable<Texture>;
  67079. /**
  67080. * Represents the focal length for the depth of field effect
  67081. */
  67082. depthOfFieldDistance: number;
  67083. /**
  67084. * Represents the blur intensity for the blurred part of the depth of field effect
  67085. */
  67086. depthOfFieldBlurWidth: number;
  67087. /**
  67088. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67089. */
  67090. get motionStrength(): number;
  67091. /**
  67092. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67093. */
  67094. set motionStrength(strength: number);
  67095. /**
  67096. * Gets wether or not the motion blur post-process is object based or screen based.
  67097. */
  67098. get objectBasedMotionBlur(): boolean;
  67099. /**
  67100. * Sets wether or not the motion blur post-process should be object based or screen based
  67101. */
  67102. set objectBasedMotionBlur(value: boolean);
  67103. /**
  67104. * List of animations for the pipeline (IAnimatable implementation)
  67105. */
  67106. animations: Animation[];
  67107. /**
  67108. * Private members
  67109. */
  67110. private _scene;
  67111. private _currentDepthOfFieldSource;
  67112. private _basePostProcess;
  67113. private _fixedExposure;
  67114. private _currentExposure;
  67115. private _hdrAutoExposure;
  67116. private _hdrCurrentLuminance;
  67117. private _motionStrength;
  67118. private _isObjectBasedMotionBlur;
  67119. private _floatTextureType;
  67120. private _camerasToBeAttached;
  67121. private _ratio;
  67122. private _bloomEnabled;
  67123. private _depthOfFieldEnabled;
  67124. private _vlsEnabled;
  67125. private _lensFlareEnabled;
  67126. private _hdrEnabled;
  67127. private _motionBlurEnabled;
  67128. private _fxaaEnabled;
  67129. private _screenSpaceReflectionsEnabled;
  67130. private _motionBlurSamples;
  67131. private _volumetricLightStepsCount;
  67132. private _samples;
  67133. /**
  67134. * @ignore
  67135. * Specifies if the bloom pipeline is enabled
  67136. */
  67137. get BloomEnabled(): boolean;
  67138. set BloomEnabled(enabled: boolean);
  67139. /**
  67140. * @ignore
  67141. * Specifies if the depth of field pipeline is enabed
  67142. */
  67143. get DepthOfFieldEnabled(): boolean;
  67144. set DepthOfFieldEnabled(enabled: boolean);
  67145. /**
  67146. * @ignore
  67147. * Specifies if the lens flare pipeline is enabed
  67148. */
  67149. get LensFlareEnabled(): boolean;
  67150. set LensFlareEnabled(enabled: boolean);
  67151. /**
  67152. * @ignore
  67153. * Specifies if the HDR pipeline is enabled
  67154. */
  67155. get HDREnabled(): boolean;
  67156. set HDREnabled(enabled: boolean);
  67157. /**
  67158. * @ignore
  67159. * Specifies if the volumetric lights scattering effect is enabled
  67160. */
  67161. get VLSEnabled(): boolean;
  67162. set VLSEnabled(enabled: boolean);
  67163. /**
  67164. * @ignore
  67165. * Specifies if the motion blur effect is enabled
  67166. */
  67167. get MotionBlurEnabled(): boolean;
  67168. set MotionBlurEnabled(enabled: boolean);
  67169. /**
  67170. * Specifies if anti-aliasing is enabled
  67171. */
  67172. get fxaaEnabled(): boolean;
  67173. set fxaaEnabled(enabled: boolean);
  67174. /**
  67175. * Specifies if screen space reflections are enabled.
  67176. */
  67177. get screenSpaceReflectionsEnabled(): boolean;
  67178. set screenSpaceReflectionsEnabled(enabled: boolean);
  67179. /**
  67180. * Specifies the number of steps used to calculate the volumetric lights
  67181. * Typically in interval [50, 200]
  67182. */
  67183. get volumetricLightStepsCount(): number;
  67184. set volumetricLightStepsCount(count: number);
  67185. /**
  67186. * Specifies the number of samples used for the motion blur effect
  67187. * Typically in interval [16, 64]
  67188. */
  67189. get motionBlurSamples(): number;
  67190. set motionBlurSamples(samples: number);
  67191. /**
  67192. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67193. */
  67194. get samples(): number;
  67195. set samples(sampleCount: number);
  67196. /**
  67197. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67198. * @constructor
  67199. * @param name The rendering pipeline name
  67200. * @param scene The scene linked to this pipeline
  67201. * @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)
  67202. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67203. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67204. */
  67205. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67206. private _buildPipeline;
  67207. private _createDownSampleX4PostProcess;
  67208. private _createBrightPassPostProcess;
  67209. private _createBlurPostProcesses;
  67210. private _createTextureAdderPostProcess;
  67211. private _createVolumetricLightPostProcess;
  67212. private _createLuminancePostProcesses;
  67213. private _createHdrPostProcess;
  67214. private _createLensFlarePostProcess;
  67215. private _createDepthOfFieldPostProcess;
  67216. private _createMotionBlurPostProcess;
  67217. private _getDepthTexture;
  67218. private _disposePostProcesses;
  67219. /**
  67220. * Dispose of the pipeline and stop all post processes
  67221. */
  67222. dispose(): void;
  67223. /**
  67224. * Serialize the rendering pipeline (Used when exporting)
  67225. * @returns the serialized object
  67226. */
  67227. serialize(): any;
  67228. /**
  67229. * Parse the serialized pipeline
  67230. * @param source Source pipeline.
  67231. * @param scene The scene to load the pipeline to.
  67232. * @param rootUrl The URL of the serialized pipeline.
  67233. * @returns An instantiated pipeline from the serialized object.
  67234. */
  67235. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67236. /**
  67237. * Luminance steps
  67238. */
  67239. static LuminanceSteps: number;
  67240. }
  67241. }
  67242. declare module BABYLON {
  67243. /** @hidden */
  67244. export var stereoscopicInterlacePixelShader: {
  67245. name: string;
  67246. shader: string;
  67247. };
  67248. }
  67249. declare module BABYLON {
  67250. /**
  67251. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  67252. */
  67253. export class StereoscopicInterlacePostProcessI extends PostProcess {
  67254. private _stepSize;
  67255. private _passedProcess;
  67256. /**
  67257. * Initializes a StereoscopicInterlacePostProcessI
  67258. * @param name The name of the effect.
  67259. * @param rigCameras The rig cameras to be appled to the post process
  67260. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  67261. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  67262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67263. * @param engine The engine which the post process will be applied. (default: current engine)
  67264. * @param reusable If the post process can be reused on the same frame. (default: false)
  67265. */
  67266. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67267. }
  67268. /**
  67269. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  67270. */
  67271. export class StereoscopicInterlacePostProcess extends PostProcess {
  67272. private _stepSize;
  67273. private _passedProcess;
  67274. /**
  67275. * Initializes a StereoscopicInterlacePostProcess
  67276. * @param name The name of the effect.
  67277. * @param rigCameras The rig cameras to be appled to the post process
  67278. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  67279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67280. * @param engine The engine which the post process will be applied. (default: current engine)
  67281. * @param reusable If the post process can be reused on the same frame. (default: false)
  67282. */
  67283. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67284. }
  67285. }
  67286. declare module BABYLON {
  67287. /** @hidden */
  67288. export var tonemapPixelShader: {
  67289. name: string;
  67290. shader: string;
  67291. };
  67292. }
  67293. declare module BABYLON {
  67294. /** Defines operator used for tonemapping */
  67295. export enum TonemappingOperator {
  67296. /** Hable */
  67297. Hable = 0,
  67298. /** Reinhard */
  67299. Reinhard = 1,
  67300. /** HejiDawson */
  67301. HejiDawson = 2,
  67302. /** Photographic */
  67303. Photographic = 3
  67304. }
  67305. /**
  67306. * Defines a post process to apply tone mapping
  67307. */
  67308. export class TonemapPostProcess extends PostProcess {
  67309. private _operator;
  67310. /** Defines the required exposure adjustement */
  67311. exposureAdjustment: number;
  67312. /**
  67313. * Creates a new TonemapPostProcess
  67314. * @param name defines the name of the postprocess
  67315. * @param _operator defines the operator to use
  67316. * @param exposureAdjustment defines the required exposure adjustement
  67317. * @param camera defines the camera to use (can be null)
  67318. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67319. * @param engine defines the hosting engine (can be ignore if camera is set)
  67320. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67321. */
  67322. constructor(name: string, _operator: TonemappingOperator,
  67323. /** Defines the required exposure adjustement */
  67324. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67325. }
  67326. }
  67327. declare module BABYLON {
  67328. /** @hidden */
  67329. export var volumetricLightScatteringPixelShader: {
  67330. name: string;
  67331. shader: string;
  67332. };
  67333. }
  67334. declare module BABYLON {
  67335. /** @hidden */
  67336. export var volumetricLightScatteringPassVertexShader: {
  67337. name: string;
  67338. shader: string;
  67339. };
  67340. }
  67341. declare module BABYLON {
  67342. /** @hidden */
  67343. export var volumetricLightScatteringPassPixelShader: {
  67344. name: string;
  67345. shader: string;
  67346. };
  67347. }
  67348. declare module BABYLON {
  67349. /**
  67350. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67351. */
  67352. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67353. private _volumetricLightScatteringPass;
  67354. private _volumetricLightScatteringRTT;
  67355. private _viewPort;
  67356. private _screenCoordinates;
  67357. private _cachedDefines;
  67358. /**
  67359. * If not undefined, the mesh position is computed from the attached node position
  67360. */
  67361. attachedNode: {
  67362. position: Vector3;
  67363. };
  67364. /**
  67365. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67366. */
  67367. customMeshPosition: Vector3;
  67368. /**
  67369. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67370. */
  67371. useCustomMeshPosition: boolean;
  67372. /**
  67373. * If the post-process should inverse the light scattering direction
  67374. */
  67375. invert: boolean;
  67376. /**
  67377. * The internal mesh used by the post-process
  67378. */
  67379. mesh: Mesh;
  67380. /**
  67381. * @hidden
  67382. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67383. */
  67384. get useDiffuseColor(): boolean;
  67385. set useDiffuseColor(useDiffuseColor: boolean);
  67386. /**
  67387. * Array containing the excluded meshes not rendered in the internal pass
  67388. */
  67389. excludedMeshes: AbstractMesh[];
  67390. /**
  67391. * Controls the overall intensity of the post-process
  67392. */
  67393. exposure: number;
  67394. /**
  67395. * Dissipates each sample's contribution in range [0, 1]
  67396. */
  67397. decay: number;
  67398. /**
  67399. * Controls the overall intensity of each sample
  67400. */
  67401. weight: number;
  67402. /**
  67403. * Controls the density of each sample
  67404. */
  67405. density: number;
  67406. /**
  67407. * @constructor
  67408. * @param name The post-process name
  67409. * @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)
  67410. * @param camera The camera that the post-process will be attached to
  67411. * @param mesh The mesh used to create the light scattering
  67412. * @param samples The post-process quality, default 100
  67413. * @param samplingModeThe post-process filtering mode
  67414. * @param engine The babylon engine
  67415. * @param reusable If the post-process is reusable
  67416. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67417. */
  67418. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67419. /**
  67420. * Returns the string "VolumetricLightScatteringPostProcess"
  67421. * @returns "VolumetricLightScatteringPostProcess"
  67422. */
  67423. getClassName(): string;
  67424. private _isReady;
  67425. /**
  67426. * Sets the new light position for light scattering effect
  67427. * @param position The new custom light position
  67428. */
  67429. setCustomMeshPosition(position: Vector3): void;
  67430. /**
  67431. * Returns the light position for light scattering effect
  67432. * @return Vector3 The custom light position
  67433. */
  67434. getCustomMeshPosition(): Vector3;
  67435. /**
  67436. * Disposes the internal assets and detaches the post-process from the camera
  67437. */
  67438. dispose(camera: Camera): void;
  67439. /**
  67440. * Returns the render target texture used by the post-process
  67441. * @return the render target texture used by the post-process
  67442. */
  67443. getPass(): RenderTargetTexture;
  67444. private _meshExcluded;
  67445. private _createPass;
  67446. private _updateMeshScreenCoordinates;
  67447. /**
  67448. * Creates a default mesh for the Volumeric Light Scattering post-process
  67449. * @param name The mesh name
  67450. * @param scene The scene where to create the mesh
  67451. * @return the default mesh
  67452. */
  67453. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67454. }
  67455. }
  67456. declare module BABYLON {
  67457. interface Scene {
  67458. /** @hidden (Backing field) */
  67459. _boundingBoxRenderer: BoundingBoxRenderer;
  67460. /** @hidden (Backing field) */
  67461. _forceShowBoundingBoxes: boolean;
  67462. /**
  67463. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67464. */
  67465. forceShowBoundingBoxes: boolean;
  67466. /**
  67467. * Gets the bounding box renderer associated with the scene
  67468. * @returns a BoundingBoxRenderer
  67469. */
  67470. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67471. }
  67472. interface AbstractMesh {
  67473. /** @hidden (Backing field) */
  67474. _showBoundingBox: boolean;
  67475. /**
  67476. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67477. */
  67478. showBoundingBox: boolean;
  67479. }
  67480. /**
  67481. * Component responsible of rendering the bounding box of the meshes in a scene.
  67482. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67483. */
  67484. export class BoundingBoxRenderer implements ISceneComponent {
  67485. /**
  67486. * The component name helpfull to identify the component in the list of scene components.
  67487. */
  67488. readonly name: string;
  67489. /**
  67490. * The scene the component belongs to.
  67491. */
  67492. scene: Scene;
  67493. /**
  67494. * Color of the bounding box lines placed in front of an object
  67495. */
  67496. frontColor: Color3;
  67497. /**
  67498. * Color of the bounding box lines placed behind an object
  67499. */
  67500. backColor: Color3;
  67501. /**
  67502. * Defines if the renderer should show the back lines or not
  67503. */
  67504. showBackLines: boolean;
  67505. /**
  67506. * @hidden
  67507. */
  67508. renderList: SmartArray<BoundingBox>;
  67509. private _colorShader;
  67510. private _vertexBuffers;
  67511. private _indexBuffer;
  67512. private _fillIndexBuffer;
  67513. private _fillIndexData;
  67514. /**
  67515. * Instantiates a new bounding box renderer in a scene.
  67516. * @param scene the scene the renderer renders in
  67517. */
  67518. constructor(scene: Scene);
  67519. /**
  67520. * Registers the component in a given scene
  67521. */
  67522. register(): void;
  67523. private _evaluateSubMesh;
  67524. private _activeMesh;
  67525. private _prepareRessources;
  67526. private _createIndexBuffer;
  67527. /**
  67528. * Rebuilds the elements related to this component in case of
  67529. * context lost for instance.
  67530. */
  67531. rebuild(): void;
  67532. /**
  67533. * @hidden
  67534. */
  67535. reset(): void;
  67536. /**
  67537. * Render the bounding boxes of a specific rendering group
  67538. * @param renderingGroupId defines the rendering group to render
  67539. */
  67540. render(renderingGroupId: number): void;
  67541. /**
  67542. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67543. * @param mesh Define the mesh to render the occlusion bounding box for
  67544. */
  67545. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67546. /**
  67547. * Dispose and release the resources attached to this renderer.
  67548. */
  67549. dispose(): void;
  67550. }
  67551. }
  67552. declare module BABYLON {
  67553. interface Scene {
  67554. /** @hidden (Backing field) */
  67555. _depthRenderer: {
  67556. [id: string]: DepthRenderer;
  67557. };
  67558. /**
  67559. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67560. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67561. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67562. * @returns the created depth renderer
  67563. */
  67564. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67565. /**
  67566. * Disables a depth renderer for a given camera
  67567. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67568. */
  67569. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67570. }
  67571. /**
  67572. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67573. * in several rendering techniques.
  67574. */
  67575. export class DepthRendererSceneComponent implements ISceneComponent {
  67576. /**
  67577. * The component name helpfull to identify the component in the list of scene components.
  67578. */
  67579. readonly name: string;
  67580. /**
  67581. * The scene the component belongs to.
  67582. */
  67583. scene: Scene;
  67584. /**
  67585. * Creates a new instance of the component for the given scene
  67586. * @param scene Defines the scene to register the component in
  67587. */
  67588. constructor(scene: Scene);
  67589. /**
  67590. * Registers the component in a given scene
  67591. */
  67592. register(): void;
  67593. /**
  67594. * Rebuilds the elements related to this component in case of
  67595. * context lost for instance.
  67596. */
  67597. rebuild(): void;
  67598. /**
  67599. * Disposes the component and the associated ressources
  67600. */
  67601. dispose(): void;
  67602. private _gatherRenderTargets;
  67603. private _gatherActiveCameraRenderTargets;
  67604. }
  67605. }
  67606. declare module BABYLON {
  67607. /** @hidden */
  67608. export var outlinePixelShader: {
  67609. name: string;
  67610. shader: string;
  67611. };
  67612. }
  67613. declare module BABYLON {
  67614. /** @hidden */
  67615. export var outlineVertexShader: {
  67616. name: string;
  67617. shader: string;
  67618. };
  67619. }
  67620. declare module BABYLON {
  67621. interface Scene {
  67622. /** @hidden */
  67623. _outlineRenderer: OutlineRenderer;
  67624. /**
  67625. * Gets the outline renderer associated with the scene
  67626. * @returns a OutlineRenderer
  67627. */
  67628. getOutlineRenderer(): OutlineRenderer;
  67629. }
  67630. interface AbstractMesh {
  67631. /** @hidden (Backing field) */
  67632. _renderOutline: boolean;
  67633. /**
  67634. * Gets or sets a boolean indicating if the outline must be rendered as well
  67635. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67636. */
  67637. renderOutline: boolean;
  67638. /** @hidden (Backing field) */
  67639. _renderOverlay: boolean;
  67640. /**
  67641. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67642. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67643. */
  67644. renderOverlay: boolean;
  67645. }
  67646. /**
  67647. * This class is responsible to draw bothe outline/overlay of meshes.
  67648. * It should not be used directly but through the available method on mesh.
  67649. */
  67650. export class OutlineRenderer implements ISceneComponent {
  67651. /**
  67652. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67653. */
  67654. private static _StencilReference;
  67655. /**
  67656. * The name of the component. Each component must have a unique name.
  67657. */
  67658. name: string;
  67659. /**
  67660. * The scene the component belongs to.
  67661. */
  67662. scene: Scene;
  67663. /**
  67664. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67665. */
  67666. zOffset: number;
  67667. private _engine;
  67668. private _effect;
  67669. private _cachedDefines;
  67670. private _savedDepthWrite;
  67671. /**
  67672. * Instantiates a new outline renderer. (There could be only one per scene).
  67673. * @param scene Defines the scene it belongs to
  67674. */
  67675. constructor(scene: Scene);
  67676. /**
  67677. * Register the component to one instance of a scene.
  67678. */
  67679. register(): void;
  67680. /**
  67681. * Rebuilds the elements related to this component in case of
  67682. * context lost for instance.
  67683. */
  67684. rebuild(): void;
  67685. /**
  67686. * Disposes the component and the associated ressources.
  67687. */
  67688. dispose(): void;
  67689. /**
  67690. * Renders the outline in the canvas.
  67691. * @param subMesh Defines the sumesh to render
  67692. * @param batch Defines the batch of meshes in case of instances
  67693. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67694. */
  67695. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67696. /**
  67697. * Returns whether or not the outline renderer is ready for a given submesh.
  67698. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67699. * @param subMesh Defines the submesh to check readyness for
  67700. * @param useInstances Defines wheter wee are trying to render instances or not
  67701. * @returns true if ready otherwise false
  67702. */
  67703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67704. private _beforeRenderingMesh;
  67705. private _afterRenderingMesh;
  67706. }
  67707. }
  67708. declare module BABYLON {
  67709. /**
  67710. * Defines the basic options interface of a Sprite Frame Source Size.
  67711. */
  67712. export interface ISpriteJSONSpriteSourceSize {
  67713. /**
  67714. * number of the original width of the Frame
  67715. */
  67716. w: number;
  67717. /**
  67718. * number of the original height of the Frame
  67719. */
  67720. h: number;
  67721. }
  67722. /**
  67723. * Defines the basic options interface of a Sprite Frame Data.
  67724. */
  67725. export interface ISpriteJSONSpriteFrameData {
  67726. /**
  67727. * number of the x offset of the Frame
  67728. */
  67729. x: number;
  67730. /**
  67731. * number of the y offset of the Frame
  67732. */
  67733. y: number;
  67734. /**
  67735. * number of the width of the Frame
  67736. */
  67737. w: number;
  67738. /**
  67739. * number of the height of the Frame
  67740. */
  67741. h: number;
  67742. }
  67743. /**
  67744. * Defines the basic options interface of a JSON Sprite.
  67745. */
  67746. export interface ISpriteJSONSprite {
  67747. /**
  67748. * string name of the Frame
  67749. */
  67750. filename: string;
  67751. /**
  67752. * ISpriteJSONSpriteFrame basic object of the frame data
  67753. */
  67754. frame: ISpriteJSONSpriteFrameData;
  67755. /**
  67756. * boolean to flag is the frame was rotated.
  67757. */
  67758. rotated: boolean;
  67759. /**
  67760. * boolean to flag is the frame was trimmed.
  67761. */
  67762. trimmed: boolean;
  67763. /**
  67764. * ISpriteJSONSpriteFrame basic object of the source data
  67765. */
  67766. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67767. /**
  67768. * ISpriteJSONSpriteFrame basic object of the source data
  67769. */
  67770. sourceSize: ISpriteJSONSpriteSourceSize;
  67771. }
  67772. /**
  67773. * Defines the basic options interface of a JSON atlas.
  67774. */
  67775. export interface ISpriteJSONAtlas {
  67776. /**
  67777. * Array of objects that contain the frame data.
  67778. */
  67779. frames: Array<ISpriteJSONSprite>;
  67780. /**
  67781. * object basic object containing the sprite meta data.
  67782. */
  67783. meta?: object;
  67784. }
  67785. }
  67786. declare module BABYLON {
  67787. /** @hidden */
  67788. export var spriteMapPixelShader: {
  67789. name: string;
  67790. shader: string;
  67791. };
  67792. }
  67793. declare module BABYLON {
  67794. /** @hidden */
  67795. export var spriteMapVertexShader: {
  67796. name: string;
  67797. shader: string;
  67798. };
  67799. }
  67800. declare module BABYLON {
  67801. /**
  67802. * Defines the basic options interface of a SpriteMap
  67803. */
  67804. export interface ISpriteMapOptions {
  67805. /**
  67806. * Vector2 of the number of cells in the grid.
  67807. */
  67808. stageSize?: Vector2;
  67809. /**
  67810. * Vector2 of the size of the output plane in World Units.
  67811. */
  67812. outputSize?: Vector2;
  67813. /**
  67814. * Vector3 of the position of the output plane in World Units.
  67815. */
  67816. outputPosition?: Vector3;
  67817. /**
  67818. * Vector3 of the rotation of the output plane.
  67819. */
  67820. outputRotation?: Vector3;
  67821. /**
  67822. * number of layers that the system will reserve in resources.
  67823. */
  67824. layerCount?: number;
  67825. /**
  67826. * number of max animation frames a single cell will reserve in resources.
  67827. */
  67828. maxAnimationFrames?: number;
  67829. /**
  67830. * number cell index of the base tile when the system compiles.
  67831. */
  67832. baseTile?: number;
  67833. /**
  67834. * boolean flip the sprite after its been repositioned by the framing data.
  67835. */
  67836. flipU?: boolean;
  67837. /**
  67838. * Vector3 scalar of the global RGB values of the SpriteMap.
  67839. */
  67840. colorMultiply?: Vector3;
  67841. }
  67842. /**
  67843. * Defines the IDisposable interface in order to be cleanable from resources.
  67844. */
  67845. export interface ISpriteMap extends IDisposable {
  67846. /**
  67847. * String name of the SpriteMap.
  67848. */
  67849. name: string;
  67850. /**
  67851. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67852. */
  67853. atlasJSON: ISpriteJSONAtlas;
  67854. /**
  67855. * Texture of the SpriteMap.
  67856. */
  67857. spriteSheet: Texture;
  67858. /**
  67859. * The parameters to initialize the SpriteMap with.
  67860. */
  67861. options: ISpriteMapOptions;
  67862. }
  67863. /**
  67864. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67865. */
  67866. export class SpriteMap implements ISpriteMap {
  67867. /** The Name of the spriteMap */
  67868. name: string;
  67869. /** The JSON file with the frame and meta data */
  67870. atlasJSON: ISpriteJSONAtlas;
  67871. /** The systems Sprite Sheet Texture */
  67872. spriteSheet: Texture;
  67873. /** Arguments passed with the Constructor */
  67874. options: ISpriteMapOptions;
  67875. /** Public Sprite Storage array, parsed from atlasJSON */
  67876. sprites: Array<ISpriteJSONSprite>;
  67877. /** Returns the Number of Sprites in the System */
  67878. get spriteCount(): number;
  67879. /** Returns the Position of Output Plane*/
  67880. get position(): Vector3;
  67881. /** Returns the Position of Output Plane*/
  67882. set position(v: Vector3);
  67883. /** Returns the Rotation of Output Plane*/
  67884. get rotation(): Vector3;
  67885. /** Returns the Rotation of Output Plane*/
  67886. set rotation(v: Vector3);
  67887. /** Sets the AnimationMap*/
  67888. get animationMap(): RawTexture;
  67889. /** Sets the AnimationMap*/
  67890. set animationMap(v: RawTexture);
  67891. /** Scene that the SpriteMap was created in */
  67892. private _scene;
  67893. /** Texture Buffer of Float32 that holds tile frame data*/
  67894. private _frameMap;
  67895. /** Texture Buffers of Float32 that holds tileMap data*/
  67896. private _tileMaps;
  67897. /** Texture Buffer of Float32 that holds Animation Data*/
  67898. private _animationMap;
  67899. /** Custom ShaderMaterial Central to the System*/
  67900. private _material;
  67901. /** Custom ShaderMaterial Central to the System*/
  67902. private _output;
  67903. /** Systems Time Ticker*/
  67904. private _time;
  67905. /**
  67906. * Creates a new SpriteMap
  67907. * @param name defines the SpriteMaps Name
  67908. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67909. * @param spriteSheet is the Texture that the Sprites are on.
  67910. * @param options a basic deployment configuration
  67911. * @param scene The Scene that the map is deployed on
  67912. */
  67913. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67914. /**
  67915. * Returns tileID location
  67916. * @returns Vector2 the cell position ID
  67917. */
  67918. getTileID(): Vector2;
  67919. /**
  67920. * Gets the UV location of the mouse over the SpriteMap.
  67921. * @returns Vector2 the UV position of the mouse interaction
  67922. */
  67923. getMousePosition(): Vector2;
  67924. /**
  67925. * Creates the "frame" texture Buffer
  67926. * -------------------------------------
  67927. * Structure of frames
  67928. * "filename": "Falling-Water-2.png",
  67929. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67930. * "rotated": true,
  67931. * "trimmed": true,
  67932. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67933. * "sourceSize": {"w":32,"h":32}
  67934. * @returns RawTexture of the frameMap
  67935. */
  67936. private _createFrameBuffer;
  67937. /**
  67938. * Creates the tileMap texture Buffer
  67939. * @param buffer normally and array of numbers, or a false to generate from scratch
  67940. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67941. * @returns RawTexture of the tileMap
  67942. */
  67943. private _createTileBuffer;
  67944. /**
  67945. * Modifies the data of the tileMaps
  67946. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67947. * @param pos is the iVector2 Coordinates of the Tile
  67948. * @param tile The SpriteIndex of the new Tile
  67949. */
  67950. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67951. /**
  67952. * Creates the animationMap texture Buffer
  67953. * @param buffer normally and array of numbers, or a false to generate from scratch
  67954. * @returns RawTexture of the animationMap
  67955. */
  67956. private _createTileAnimationBuffer;
  67957. /**
  67958. * Modifies the data of the animationMap
  67959. * @param cellID is the Index of the Sprite
  67960. * @param _frame is the target Animation frame
  67961. * @param toCell is the Target Index of the next frame of the animation
  67962. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67963. * @param speed is a global scalar of the time variable on the map.
  67964. */
  67965. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67966. /**
  67967. * Exports the .tilemaps file
  67968. */
  67969. saveTileMaps(): void;
  67970. /**
  67971. * Imports the .tilemaps file
  67972. * @param url of the .tilemaps file
  67973. */
  67974. loadTileMaps(url: string): void;
  67975. /**
  67976. * Release associated resources
  67977. */
  67978. dispose(): void;
  67979. }
  67980. }
  67981. declare module BABYLON {
  67982. /**
  67983. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67984. * @see http://doc.babylonjs.com/babylon101/sprites
  67985. */
  67986. export class SpritePackedManager extends SpriteManager {
  67987. /** defines the packed manager's name */
  67988. name: string;
  67989. /**
  67990. * Creates a new sprite manager from a packed sprite sheet
  67991. * @param name defines the manager's name
  67992. * @param imgUrl defines the sprite sheet url
  67993. * @param capacity defines the maximum allowed number of sprites
  67994. * @param scene defines the hosting scene
  67995. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67996. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67997. * @param samplingMode defines the smapling mode to use with spritesheet
  67998. * @param fromPacked set to true; do not alter
  67999. */
  68000. constructor(
  68001. /** defines the packed manager's name */
  68002. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68003. }
  68004. }
  68005. declare module BABYLON {
  68006. /**
  68007. * Defines the list of states available for a task inside a AssetsManager
  68008. */
  68009. export enum AssetTaskState {
  68010. /**
  68011. * Initialization
  68012. */
  68013. INIT = 0,
  68014. /**
  68015. * Running
  68016. */
  68017. RUNNING = 1,
  68018. /**
  68019. * Done
  68020. */
  68021. DONE = 2,
  68022. /**
  68023. * Error
  68024. */
  68025. ERROR = 3
  68026. }
  68027. /**
  68028. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68029. */
  68030. export abstract class AbstractAssetTask {
  68031. /**
  68032. * Task name
  68033. */ name: string;
  68034. /**
  68035. * Callback called when the task is successful
  68036. */
  68037. onSuccess: (task: any) => void;
  68038. /**
  68039. * Callback called when the task is not successful
  68040. */
  68041. onError: (task: any, message?: string, exception?: any) => void;
  68042. /**
  68043. * Creates a new AssetsManager
  68044. * @param name defines the name of the task
  68045. */
  68046. constructor(
  68047. /**
  68048. * Task name
  68049. */ name: string);
  68050. private _isCompleted;
  68051. private _taskState;
  68052. private _errorObject;
  68053. /**
  68054. * Get if the task is completed
  68055. */
  68056. get isCompleted(): boolean;
  68057. /**
  68058. * Gets the current state of the task
  68059. */
  68060. get taskState(): AssetTaskState;
  68061. /**
  68062. * Gets the current error object (if task is in error)
  68063. */
  68064. get errorObject(): {
  68065. message?: string;
  68066. exception?: any;
  68067. };
  68068. /**
  68069. * Internal only
  68070. * @hidden
  68071. */
  68072. _setErrorObject(message?: string, exception?: any): void;
  68073. /**
  68074. * Execute the current task
  68075. * @param scene defines the scene where you want your assets to be loaded
  68076. * @param onSuccess is a callback called when the task is successfully executed
  68077. * @param onError is a callback called if an error occurs
  68078. */
  68079. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68080. /**
  68081. * Execute the current task
  68082. * @param scene defines the scene where you want your assets to be loaded
  68083. * @param onSuccess is a callback called when the task is successfully executed
  68084. * @param onError is a callback called if an error occurs
  68085. */
  68086. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68087. /**
  68088. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68089. * This can be used with failed tasks that have the reason for failure fixed.
  68090. */
  68091. reset(): void;
  68092. private onErrorCallback;
  68093. private onDoneCallback;
  68094. }
  68095. /**
  68096. * Define the interface used by progress events raised during assets loading
  68097. */
  68098. export interface IAssetsProgressEvent {
  68099. /**
  68100. * Defines the number of remaining tasks to process
  68101. */
  68102. remainingCount: number;
  68103. /**
  68104. * Defines the total number of tasks
  68105. */
  68106. totalCount: number;
  68107. /**
  68108. * Defines the task that was just processed
  68109. */
  68110. task: AbstractAssetTask;
  68111. }
  68112. /**
  68113. * Class used to share progress information about assets loading
  68114. */
  68115. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68116. /**
  68117. * Defines the number of remaining tasks to process
  68118. */
  68119. remainingCount: number;
  68120. /**
  68121. * Defines the total number of tasks
  68122. */
  68123. totalCount: number;
  68124. /**
  68125. * Defines the task that was just processed
  68126. */
  68127. task: AbstractAssetTask;
  68128. /**
  68129. * Creates a AssetsProgressEvent
  68130. * @param remainingCount defines the number of remaining tasks to process
  68131. * @param totalCount defines the total number of tasks
  68132. * @param task defines the task that was just processed
  68133. */
  68134. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68135. }
  68136. /**
  68137. * Define a task used by AssetsManager to load meshes
  68138. */
  68139. export class MeshAssetTask extends AbstractAssetTask {
  68140. /**
  68141. * Defines the name of the task
  68142. */
  68143. name: string;
  68144. /**
  68145. * Defines the list of mesh's names you want to load
  68146. */
  68147. meshesNames: any;
  68148. /**
  68149. * Defines the root url to use as a base to load your meshes and associated resources
  68150. */
  68151. rootUrl: string;
  68152. /**
  68153. * Defines the filename of the scene to load from
  68154. */
  68155. sceneFilename: string;
  68156. /**
  68157. * Gets the list of loaded meshes
  68158. */
  68159. loadedMeshes: Array<AbstractMesh>;
  68160. /**
  68161. * Gets the list of loaded particle systems
  68162. */
  68163. loadedParticleSystems: Array<IParticleSystem>;
  68164. /**
  68165. * Gets the list of loaded skeletons
  68166. */
  68167. loadedSkeletons: Array<Skeleton>;
  68168. /**
  68169. * Gets the list of loaded animation groups
  68170. */
  68171. loadedAnimationGroups: Array<AnimationGroup>;
  68172. /**
  68173. * Callback called when the task is successful
  68174. */
  68175. onSuccess: (task: MeshAssetTask) => void;
  68176. /**
  68177. * Callback called when the task is successful
  68178. */
  68179. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68180. /**
  68181. * Creates a new MeshAssetTask
  68182. * @param name defines the name of the task
  68183. * @param meshesNames defines the list of mesh's names you want to load
  68184. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68185. * @param sceneFilename defines the filename of the scene to load from
  68186. */
  68187. constructor(
  68188. /**
  68189. * Defines the name of the task
  68190. */
  68191. name: string,
  68192. /**
  68193. * Defines the list of mesh's names you want to load
  68194. */
  68195. meshesNames: any,
  68196. /**
  68197. * Defines the root url to use as a base to load your meshes and associated resources
  68198. */
  68199. rootUrl: string,
  68200. /**
  68201. * Defines the filename of the scene to load from
  68202. */
  68203. sceneFilename: string);
  68204. /**
  68205. * Execute the current task
  68206. * @param scene defines the scene where you want your assets to be loaded
  68207. * @param onSuccess is a callback called when the task is successfully executed
  68208. * @param onError is a callback called if an error occurs
  68209. */
  68210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68211. }
  68212. /**
  68213. * Define a task used by AssetsManager to load text content
  68214. */
  68215. export class TextFileAssetTask extends AbstractAssetTask {
  68216. /**
  68217. * Defines the name of the task
  68218. */
  68219. name: string;
  68220. /**
  68221. * Defines the location of the file to load
  68222. */
  68223. url: string;
  68224. /**
  68225. * Gets the loaded text string
  68226. */
  68227. text: string;
  68228. /**
  68229. * Callback called when the task is successful
  68230. */
  68231. onSuccess: (task: TextFileAssetTask) => void;
  68232. /**
  68233. * Callback called when the task is successful
  68234. */
  68235. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68236. /**
  68237. * Creates a new TextFileAssetTask object
  68238. * @param name defines the name of the task
  68239. * @param url defines the location of the file to load
  68240. */
  68241. constructor(
  68242. /**
  68243. * Defines the name of the task
  68244. */
  68245. name: string,
  68246. /**
  68247. * Defines the location of the file to load
  68248. */
  68249. url: string);
  68250. /**
  68251. * Execute the current task
  68252. * @param scene defines the scene where you want your assets to be loaded
  68253. * @param onSuccess is a callback called when the task is successfully executed
  68254. * @param onError is a callback called if an error occurs
  68255. */
  68256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68257. }
  68258. /**
  68259. * Define a task used by AssetsManager to load binary data
  68260. */
  68261. export class BinaryFileAssetTask extends AbstractAssetTask {
  68262. /**
  68263. * Defines the name of the task
  68264. */
  68265. name: string;
  68266. /**
  68267. * Defines the location of the file to load
  68268. */
  68269. url: string;
  68270. /**
  68271. * Gets the lodaded data (as an array buffer)
  68272. */
  68273. data: ArrayBuffer;
  68274. /**
  68275. * Callback called when the task is successful
  68276. */
  68277. onSuccess: (task: BinaryFileAssetTask) => void;
  68278. /**
  68279. * Callback called when the task is successful
  68280. */
  68281. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68282. /**
  68283. * Creates a new BinaryFileAssetTask object
  68284. * @param name defines the name of the new task
  68285. * @param url defines the location of the file to load
  68286. */
  68287. constructor(
  68288. /**
  68289. * Defines the name of the task
  68290. */
  68291. name: string,
  68292. /**
  68293. * Defines the location of the file to load
  68294. */
  68295. url: string);
  68296. /**
  68297. * Execute the current task
  68298. * @param scene defines the scene where you want your assets to be loaded
  68299. * @param onSuccess is a callback called when the task is successfully executed
  68300. * @param onError is a callback called if an error occurs
  68301. */
  68302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68303. }
  68304. /**
  68305. * Define a task used by AssetsManager to load images
  68306. */
  68307. export class ImageAssetTask extends AbstractAssetTask {
  68308. /**
  68309. * Defines the name of the task
  68310. */
  68311. name: string;
  68312. /**
  68313. * Defines the location of the image to load
  68314. */
  68315. url: string;
  68316. /**
  68317. * Gets the loaded images
  68318. */
  68319. image: HTMLImageElement;
  68320. /**
  68321. * Callback called when the task is successful
  68322. */
  68323. onSuccess: (task: ImageAssetTask) => void;
  68324. /**
  68325. * Callback called when the task is successful
  68326. */
  68327. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68328. /**
  68329. * Creates a new ImageAssetTask
  68330. * @param name defines the name of the task
  68331. * @param url defines the location of the image to load
  68332. */
  68333. constructor(
  68334. /**
  68335. * Defines the name of the task
  68336. */
  68337. name: string,
  68338. /**
  68339. * Defines the location of the image to load
  68340. */
  68341. url: string);
  68342. /**
  68343. * Execute the current task
  68344. * @param scene defines the scene where you want your assets to be loaded
  68345. * @param onSuccess is a callback called when the task is successfully executed
  68346. * @param onError is a callback called if an error occurs
  68347. */
  68348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68349. }
  68350. /**
  68351. * Defines the interface used by texture loading tasks
  68352. */
  68353. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68354. /**
  68355. * Gets the loaded texture
  68356. */
  68357. texture: TEX;
  68358. }
  68359. /**
  68360. * Define a task used by AssetsManager to load 2D textures
  68361. */
  68362. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68363. /**
  68364. * Defines the name of the task
  68365. */
  68366. name: string;
  68367. /**
  68368. * Defines the location of the file to load
  68369. */
  68370. url: string;
  68371. /**
  68372. * Defines if mipmap should not be generated (default is false)
  68373. */
  68374. noMipmap?: boolean | undefined;
  68375. /**
  68376. * Defines if texture must be inverted on Y axis (default is true)
  68377. */
  68378. invertY: boolean;
  68379. /**
  68380. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68381. */
  68382. samplingMode: number;
  68383. /**
  68384. * Gets the loaded texture
  68385. */
  68386. texture: Texture;
  68387. /**
  68388. * Callback called when the task is successful
  68389. */
  68390. onSuccess: (task: TextureAssetTask) => void;
  68391. /**
  68392. * Callback called when the task is successful
  68393. */
  68394. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68395. /**
  68396. * Creates a new TextureAssetTask object
  68397. * @param name defines the name of the task
  68398. * @param url defines the location of the file to load
  68399. * @param noMipmap defines if mipmap should not be generated (default is false)
  68400. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68401. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68402. */
  68403. constructor(
  68404. /**
  68405. * Defines the name of the task
  68406. */
  68407. name: string,
  68408. /**
  68409. * Defines the location of the file to load
  68410. */
  68411. url: string,
  68412. /**
  68413. * Defines if mipmap should not be generated (default is false)
  68414. */
  68415. noMipmap?: boolean | undefined,
  68416. /**
  68417. * Defines if texture must be inverted on Y axis (default is true)
  68418. */
  68419. invertY?: boolean,
  68420. /**
  68421. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68422. */
  68423. samplingMode?: number);
  68424. /**
  68425. * Execute the current task
  68426. * @param scene defines the scene where you want your assets to be loaded
  68427. * @param onSuccess is a callback called when the task is successfully executed
  68428. * @param onError is a callback called if an error occurs
  68429. */
  68430. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68431. }
  68432. /**
  68433. * Define a task used by AssetsManager to load cube textures
  68434. */
  68435. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68436. /**
  68437. * Defines the name of the task
  68438. */
  68439. name: string;
  68440. /**
  68441. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68442. */
  68443. url: string;
  68444. /**
  68445. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68446. */
  68447. extensions?: string[] | undefined;
  68448. /**
  68449. * Defines if mipmaps should not be generated (default is false)
  68450. */
  68451. noMipmap?: boolean | undefined;
  68452. /**
  68453. * Defines the explicit list of files (undefined by default)
  68454. */
  68455. files?: string[] | undefined;
  68456. /**
  68457. * Gets the loaded texture
  68458. */
  68459. texture: CubeTexture;
  68460. /**
  68461. * Callback called when the task is successful
  68462. */
  68463. onSuccess: (task: CubeTextureAssetTask) => void;
  68464. /**
  68465. * Callback called when the task is successful
  68466. */
  68467. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68468. /**
  68469. * Creates a new CubeTextureAssetTask
  68470. * @param name defines the name of the task
  68471. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68472. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68473. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68474. * @param files defines the explicit list of files (undefined by default)
  68475. */
  68476. constructor(
  68477. /**
  68478. * Defines the name of the task
  68479. */
  68480. name: string,
  68481. /**
  68482. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68483. */
  68484. url: string,
  68485. /**
  68486. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68487. */
  68488. extensions?: string[] | undefined,
  68489. /**
  68490. * Defines if mipmaps should not be generated (default is false)
  68491. */
  68492. noMipmap?: boolean | undefined,
  68493. /**
  68494. * Defines the explicit list of files (undefined by default)
  68495. */
  68496. files?: string[] | undefined);
  68497. /**
  68498. * Execute the current task
  68499. * @param scene defines the scene where you want your assets to be loaded
  68500. * @param onSuccess is a callback called when the task is successfully executed
  68501. * @param onError is a callback called if an error occurs
  68502. */
  68503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68504. }
  68505. /**
  68506. * Define a task used by AssetsManager to load HDR cube textures
  68507. */
  68508. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68509. /**
  68510. * Defines the name of the task
  68511. */
  68512. name: string;
  68513. /**
  68514. * Defines the location of the file to load
  68515. */
  68516. url: string;
  68517. /**
  68518. * Defines the desired size (the more it increases the longer the generation will be)
  68519. */
  68520. size: number;
  68521. /**
  68522. * Defines if mipmaps should not be generated (default is false)
  68523. */
  68524. noMipmap: boolean;
  68525. /**
  68526. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68527. */
  68528. generateHarmonics: boolean;
  68529. /**
  68530. * 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)
  68531. */
  68532. gammaSpace: boolean;
  68533. /**
  68534. * Internal Use Only
  68535. */
  68536. reserved: boolean;
  68537. /**
  68538. * Gets the loaded texture
  68539. */
  68540. texture: HDRCubeTexture;
  68541. /**
  68542. * Callback called when the task is successful
  68543. */
  68544. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68545. /**
  68546. * Callback called when the task is successful
  68547. */
  68548. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68549. /**
  68550. * Creates a new HDRCubeTextureAssetTask object
  68551. * @param name defines the name of the task
  68552. * @param url defines the location of the file to load
  68553. * @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.
  68554. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68555. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68556. * @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)
  68557. * @param reserved Internal use only
  68558. */
  68559. constructor(
  68560. /**
  68561. * Defines the name of the task
  68562. */
  68563. name: string,
  68564. /**
  68565. * Defines the location of the file to load
  68566. */
  68567. url: string,
  68568. /**
  68569. * Defines the desired size (the more it increases the longer the generation will be)
  68570. */
  68571. size: number,
  68572. /**
  68573. * Defines if mipmaps should not be generated (default is false)
  68574. */
  68575. noMipmap?: boolean,
  68576. /**
  68577. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68578. */
  68579. generateHarmonics?: boolean,
  68580. /**
  68581. * 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)
  68582. */
  68583. gammaSpace?: boolean,
  68584. /**
  68585. * Internal Use Only
  68586. */
  68587. reserved?: boolean);
  68588. /**
  68589. * Execute the current task
  68590. * @param scene defines the scene where you want your assets to be loaded
  68591. * @param onSuccess is a callback called when the task is successfully executed
  68592. * @param onError is a callback called if an error occurs
  68593. */
  68594. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68595. }
  68596. /**
  68597. * Define a task used by AssetsManager to load Equirectangular cube textures
  68598. */
  68599. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68600. /**
  68601. * Defines the name of the task
  68602. */
  68603. name: string;
  68604. /**
  68605. * Defines the location of the file to load
  68606. */
  68607. url: string;
  68608. /**
  68609. * Defines the desired size (the more it increases the longer the generation will be)
  68610. */
  68611. size: number;
  68612. /**
  68613. * Defines if mipmaps should not be generated (default is false)
  68614. */
  68615. noMipmap: boolean;
  68616. /**
  68617. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68618. * but the standard material would require them in Gamma space) (default is true)
  68619. */
  68620. gammaSpace: boolean;
  68621. /**
  68622. * Gets the loaded texture
  68623. */
  68624. texture: EquiRectangularCubeTexture;
  68625. /**
  68626. * Callback called when the task is successful
  68627. */
  68628. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68629. /**
  68630. * Callback called when the task is successful
  68631. */
  68632. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68633. /**
  68634. * Creates a new EquiRectangularCubeTextureAssetTask object
  68635. * @param name defines the name of the task
  68636. * @param url defines the location of the file to load
  68637. * @param size defines the desired size (the more it increases the longer the generation will be)
  68638. * If the size is omitted this implies you are using a preprocessed cubemap.
  68639. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68640. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68641. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68642. * (default is true)
  68643. */
  68644. constructor(
  68645. /**
  68646. * Defines the name of the task
  68647. */
  68648. name: string,
  68649. /**
  68650. * Defines the location of the file to load
  68651. */
  68652. url: string,
  68653. /**
  68654. * Defines the desired size (the more it increases the longer the generation will be)
  68655. */
  68656. size: number,
  68657. /**
  68658. * Defines if mipmaps should not be generated (default is false)
  68659. */
  68660. noMipmap?: boolean,
  68661. /**
  68662. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68663. * but the standard material would require them in Gamma space) (default is true)
  68664. */
  68665. gammaSpace?: boolean);
  68666. /**
  68667. * Execute the current task
  68668. * @param scene defines the scene where you want your assets to be loaded
  68669. * @param onSuccess is a callback called when the task is successfully executed
  68670. * @param onError is a callback called if an error occurs
  68671. */
  68672. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68673. }
  68674. /**
  68675. * This class can be used to easily import assets into a scene
  68676. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68677. */
  68678. export class AssetsManager {
  68679. private _scene;
  68680. private _isLoading;
  68681. protected _tasks: AbstractAssetTask[];
  68682. protected _waitingTasksCount: number;
  68683. protected _totalTasksCount: number;
  68684. /**
  68685. * Callback called when all tasks are processed
  68686. */
  68687. onFinish: (tasks: AbstractAssetTask[]) => void;
  68688. /**
  68689. * Callback called when a task is successful
  68690. */
  68691. onTaskSuccess: (task: AbstractAssetTask) => void;
  68692. /**
  68693. * Callback called when a task had an error
  68694. */
  68695. onTaskError: (task: AbstractAssetTask) => void;
  68696. /**
  68697. * Callback called when a task is done (whatever the result is)
  68698. */
  68699. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68700. /**
  68701. * Observable called when all tasks are processed
  68702. */
  68703. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68704. /**
  68705. * Observable called when a task had an error
  68706. */
  68707. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68708. /**
  68709. * Observable called when all tasks were executed
  68710. */
  68711. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68712. /**
  68713. * Observable called when a task is done (whatever the result is)
  68714. */
  68715. onProgressObservable: Observable<IAssetsProgressEvent>;
  68716. /**
  68717. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68718. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68719. */
  68720. useDefaultLoadingScreen: boolean;
  68721. /**
  68722. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68723. * when all assets have been downloaded.
  68724. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68725. */
  68726. autoHideLoadingUI: boolean;
  68727. /**
  68728. * Creates a new AssetsManager
  68729. * @param scene defines the scene to work on
  68730. */
  68731. constructor(scene: Scene);
  68732. /**
  68733. * Add a MeshAssetTask to the list of active tasks
  68734. * @param taskName defines the name of the new task
  68735. * @param meshesNames defines the name of meshes to load
  68736. * @param rootUrl defines the root url to use to locate files
  68737. * @param sceneFilename defines the filename of the scene file
  68738. * @returns a new MeshAssetTask object
  68739. */
  68740. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68741. /**
  68742. * Add a TextFileAssetTask to the list of active tasks
  68743. * @param taskName defines the name of the new task
  68744. * @param url defines the url of the file to load
  68745. * @returns a new TextFileAssetTask object
  68746. */
  68747. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68748. /**
  68749. * Add a BinaryFileAssetTask to the list of active tasks
  68750. * @param taskName defines the name of the new task
  68751. * @param url defines the url of the file to load
  68752. * @returns a new BinaryFileAssetTask object
  68753. */
  68754. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68755. /**
  68756. * Add a ImageAssetTask to the list of active tasks
  68757. * @param taskName defines the name of the new task
  68758. * @param url defines the url of the file to load
  68759. * @returns a new ImageAssetTask object
  68760. */
  68761. addImageTask(taskName: string, url: string): ImageAssetTask;
  68762. /**
  68763. * Add a TextureAssetTask to the list of active tasks
  68764. * @param taskName defines the name of the new task
  68765. * @param url defines the url of the file to load
  68766. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68767. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68768. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68769. * @returns a new TextureAssetTask object
  68770. */
  68771. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68772. /**
  68773. * Add a CubeTextureAssetTask to the list of active tasks
  68774. * @param taskName defines the name of the new task
  68775. * @param url defines the url of the file to load
  68776. * @param extensions defines the extension to use to load the cube map (can be null)
  68777. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68778. * @param files defines the list of files to load (can be null)
  68779. * @returns a new CubeTextureAssetTask object
  68780. */
  68781. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68782. /**
  68783. *
  68784. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68785. * @param taskName defines the name of the new task
  68786. * @param url defines the url of the file to load
  68787. * @param size defines the size you want for the cubemap (can be null)
  68788. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68789. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68790. * @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)
  68791. * @param reserved Internal use only
  68792. * @returns a new HDRCubeTextureAssetTask object
  68793. */
  68794. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68795. /**
  68796. *
  68797. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68798. * @param taskName defines the name of the new task
  68799. * @param url defines the url of the file to load
  68800. * @param size defines the size you want for the cubemap (can be null)
  68801. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68802. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68803. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68804. * @returns a new EquiRectangularCubeTextureAssetTask object
  68805. */
  68806. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68807. /**
  68808. * Remove a task from the assets manager.
  68809. * @param task the task to remove
  68810. */
  68811. removeTask(task: AbstractAssetTask): void;
  68812. private _decreaseWaitingTasksCount;
  68813. private _runTask;
  68814. /**
  68815. * Reset the AssetsManager and remove all tasks
  68816. * @return the current instance of the AssetsManager
  68817. */
  68818. reset(): AssetsManager;
  68819. /**
  68820. * Start the loading process
  68821. * @return the current instance of the AssetsManager
  68822. */
  68823. load(): AssetsManager;
  68824. /**
  68825. * Start the loading process as an async operation
  68826. * @return a promise returning the list of failed tasks
  68827. */
  68828. loadAsync(): Promise<void>;
  68829. }
  68830. }
  68831. declare module BABYLON {
  68832. /**
  68833. * Wrapper class for promise with external resolve and reject.
  68834. */
  68835. export class Deferred<T> {
  68836. /**
  68837. * The promise associated with this deferred object.
  68838. */
  68839. readonly promise: Promise<T>;
  68840. private _resolve;
  68841. private _reject;
  68842. /**
  68843. * The resolve method of the promise associated with this deferred object.
  68844. */
  68845. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68846. /**
  68847. * The reject method of the promise associated with this deferred object.
  68848. */
  68849. get reject(): (reason?: any) => void;
  68850. /**
  68851. * Constructor for this deferred object.
  68852. */
  68853. constructor();
  68854. }
  68855. }
  68856. declare module BABYLON {
  68857. /**
  68858. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68859. */
  68860. export class MeshExploder {
  68861. private _centerMesh;
  68862. private _meshes;
  68863. private _meshesOrigins;
  68864. private _toCenterVectors;
  68865. private _scaledDirection;
  68866. private _newPosition;
  68867. private _centerPosition;
  68868. /**
  68869. * Explodes meshes from a center mesh.
  68870. * @param meshes The meshes to explode.
  68871. * @param centerMesh The mesh to be center of explosion.
  68872. */
  68873. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68874. private _setCenterMesh;
  68875. /**
  68876. * Get class name
  68877. * @returns "MeshExploder"
  68878. */
  68879. getClassName(): string;
  68880. /**
  68881. * "Exploded meshes"
  68882. * @returns Array of meshes with the centerMesh at index 0.
  68883. */
  68884. getMeshes(): Array<Mesh>;
  68885. /**
  68886. * Explodes meshes giving a specific direction
  68887. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68888. */
  68889. explode(direction?: number): void;
  68890. }
  68891. }
  68892. declare module BABYLON {
  68893. /**
  68894. * Class used to help managing file picking and drag'n'drop
  68895. */
  68896. export class FilesInput {
  68897. /**
  68898. * List of files ready to be loaded
  68899. */
  68900. static get FilesToLoad(): {
  68901. [key: string]: File;
  68902. };
  68903. /**
  68904. * Callback called when a file is processed
  68905. */
  68906. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68907. private _engine;
  68908. private _currentScene;
  68909. private _sceneLoadedCallback;
  68910. private _progressCallback;
  68911. private _additionalRenderLoopLogicCallback;
  68912. private _textureLoadingCallback;
  68913. private _startingProcessingFilesCallback;
  68914. private _onReloadCallback;
  68915. private _errorCallback;
  68916. private _elementToMonitor;
  68917. private _sceneFileToLoad;
  68918. private _filesToLoad;
  68919. /**
  68920. * Creates a new FilesInput
  68921. * @param engine defines the rendering engine
  68922. * @param scene defines the hosting scene
  68923. * @param sceneLoadedCallback callback called when scene is loaded
  68924. * @param progressCallback callback called to track progress
  68925. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68926. * @param textureLoadingCallback callback called when a texture is loading
  68927. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68928. * @param onReloadCallback callback called when a reload is requested
  68929. * @param errorCallback callback call if an error occurs
  68930. */
  68931. 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);
  68932. private _dragEnterHandler;
  68933. private _dragOverHandler;
  68934. private _dropHandler;
  68935. /**
  68936. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68937. * @param elementToMonitor defines the DOM element to track
  68938. */
  68939. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68940. /**
  68941. * Release all associated resources
  68942. */
  68943. dispose(): void;
  68944. private renderFunction;
  68945. private drag;
  68946. private drop;
  68947. private _traverseFolder;
  68948. private _processFiles;
  68949. /**
  68950. * Load files from a drop event
  68951. * @param event defines the drop event to use as source
  68952. */
  68953. loadFiles(event: any): void;
  68954. private _processReload;
  68955. /**
  68956. * Reload the current scene from the loaded files
  68957. */
  68958. reload(): void;
  68959. }
  68960. }
  68961. declare module BABYLON {
  68962. /**
  68963. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68964. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68965. */
  68966. export class SceneOptimization {
  68967. /**
  68968. * Defines the priority of this optimization (0 by default which means first in the list)
  68969. */
  68970. priority: number;
  68971. /**
  68972. * Gets a string describing the action executed by the current optimization
  68973. * @returns description string
  68974. */
  68975. getDescription(): string;
  68976. /**
  68977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68978. * @param scene defines the current scene where to apply this optimization
  68979. * @param optimizer defines the current optimizer
  68980. * @returns true if everything that can be done was applied
  68981. */
  68982. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68983. /**
  68984. * Creates the SceneOptimization object
  68985. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68986. * @param desc defines the description associated with the optimization
  68987. */
  68988. constructor(
  68989. /**
  68990. * Defines the priority of this optimization (0 by default which means first in the list)
  68991. */
  68992. priority?: number);
  68993. }
  68994. /**
  68995. * Defines an optimization used to reduce the size of render target textures
  68996. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68997. */
  68998. export class TextureOptimization extends SceneOptimization {
  68999. /**
  69000. * Defines the priority of this optimization (0 by default which means first in the list)
  69001. */
  69002. priority: number;
  69003. /**
  69004. * 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
  69005. */
  69006. maximumSize: number;
  69007. /**
  69008. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69009. */
  69010. step: number;
  69011. /**
  69012. * Gets a string describing the action executed by the current optimization
  69013. * @returns description string
  69014. */
  69015. getDescription(): string;
  69016. /**
  69017. * Creates the TextureOptimization object
  69018. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69019. * @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
  69020. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69021. */
  69022. constructor(
  69023. /**
  69024. * Defines the priority of this optimization (0 by default which means first in the list)
  69025. */
  69026. priority?: number,
  69027. /**
  69028. * 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
  69029. */
  69030. maximumSize?: number,
  69031. /**
  69032. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69033. */
  69034. step?: number);
  69035. /**
  69036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69037. * @param scene defines the current scene where to apply this optimization
  69038. * @param optimizer defines the current optimizer
  69039. * @returns true if everything that can be done was applied
  69040. */
  69041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69042. }
  69043. /**
  69044. * Defines an optimization used to increase or decrease the rendering resolution
  69045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69046. */
  69047. export class HardwareScalingOptimization extends SceneOptimization {
  69048. /**
  69049. * Defines the priority of this optimization (0 by default which means first in the list)
  69050. */
  69051. priority: number;
  69052. /**
  69053. * Defines the maximum scale to use (2 by default)
  69054. */
  69055. maximumScale: number;
  69056. /**
  69057. * Defines the step to use between two passes (0.5 by default)
  69058. */
  69059. step: number;
  69060. private _currentScale;
  69061. private _directionOffset;
  69062. /**
  69063. * Gets a string describing the action executed by the current optimization
  69064. * @return description string
  69065. */
  69066. getDescription(): string;
  69067. /**
  69068. * Creates the HardwareScalingOptimization object
  69069. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69070. * @param maximumScale defines the maximum scale to use (2 by default)
  69071. * @param step defines the step to use between two passes (0.5 by default)
  69072. */
  69073. constructor(
  69074. /**
  69075. * Defines the priority of this optimization (0 by default which means first in the list)
  69076. */
  69077. priority?: number,
  69078. /**
  69079. * Defines the maximum scale to use (2 by default)
  69080. */
  69081. maximumScale?: number,
  69082. /**
  69083. * Defines the step to use between two passes (0.5 by default)
  69084. */
  69085. step?: number);
  69086. /**
  69087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69088. * @param scene defines the current scene where to apply this optimization
  69089. * @param optimizer defines the current optimizer
  69090. * @returns true if everything that can be done was applied
  69091. */
  69092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69093. }
  69094. /**
  69095. * Defines an optimization used to remove shadows
  69096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69097. */
  69098. export class ShadowsOptimization extends SceneOptimization {
  69099. /**
  69100. * Gets a string describing the action executed by the current optimization
  69101. * @return description string
  69102. */
  69103. getDescription(): string;
  69104. /**
  69105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69106. * @param scene defines the current scene where to apply this optimization
  69107. * @param optimizer defines the current optimizer
  69108. * @returns true if everything that can be done was applied
  69109. */
  69110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69111. }
  69112. /**
  69113. * Defines an optimization used to turn post-processes off
  69114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69115. */
  69116. export class PostProcessesOptimization extends SceneOptimization {
  69117. /**
  69118. * Gets a string describing the action executed by the current optimization
  69119. * @return description string
  69120. */
  69121. getDescription(): string;
  69122. /**
  69123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69124. * @param scene defines the current scene where to apply this optimization
  69125. * @param optimizer defines the current optimizer
  69126. * @returns true if everything that can be done was applied
  69127. */
  69128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69129. }
  69130. /**
  69131. * Defines an optimization used to turn lens flares off
  69132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69133. */
  69134. export class LensFlaresOptimization extends SceneOptimization {
  69135. /**
  69136. * Gets a string describing the action executed by the current optimization
  69137. * @return description string
  69138. */
  69139. getDescription(): string;
  69140. /**
  69141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69142. * @param scene defines the current scene where to apply this optimization
  69143. * @param optimizer defines the current optimizer
  69144. * @returns true if everything that can be done was applied
  69145. */
  69146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69147. }
  69148. /**
  69149. * Defines an optimization based on user defined callback.
  69150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69151. */
  69152. export class CustomOptimization extends SceneOptimization {
  69153. /**
  69154. * Callback called to apply the custom optimization.
  69155. */
  69156. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69157. /**
  69158. * Callback called to get custom description
  69159. */
  69160. onGetDescription: () => string;
  69161. /**
  69162. * Gets a string describing the action executed by the current optimization
  69163. * @returns description string
  69164. */
  69165. getDescription(): string;
  69166. /**
  69167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69168. * @param scene defines the current scene where to apply this optimization
  69169. * @param optimizer defines the current optimizer
  69170. * @returns true if everything that can be done was applied
  69171. */
  69172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69173. }
  69174. /**
  69175. * Defines an optimization used to turn particles off
  69176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69177. */
  69178. export class ParticlesOptimization extends SceneOptimization {
  69179. /**
  69180. * Gets a string describing the action executed by the current optimization
  69181. * @return description string
  69182. */
  69183. getDescription(): string;
  69184. /**
  69185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69186. * @param scene defines the current scene where to apply this optimization
  69187. * @param optimizer defines the current optimizer
  69188. * @returns true if everything that can be done was applied
  69189. */
  69190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69191. }
  69192. /**
  69193. * Defines an optimization used to turn render targets off
  69194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69195. */
  69196. export class RenderTargetsOptimization extends SceneOptimization {
  69197. /**
  69198. * Gets a string describing the action executed by the current optimization
  69199. * @return description string
  69200. */
  69201. getDescription(): string;
  69202. /**
  69203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69204. * @param scene defines the current scene where to apply this optimization
  69205. * @param optimizer defines the current optimizer
  69206. * @returns true if everything that can be done was applied
  69207. */
  69208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69209. }
  69210. /**
  69211. * Defines an optimization used to merge meshes with compatible materials
  69212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69213. */
  69214. export class MergeMeshesOptimization extends SceneOptimization {
  69215. private static _UpdateSelectionTree;
  69216. /**
  69217. * Gets or sets a boolean which defines if optimization octree has to be updated
  69218. */
  69219. static get UpdateSelectionTree(): boolean;
  69220. /**
  69221. * Gets or sets a boolean which defines if optimization octree has to be updated
  69222. */
  69223. static set UpdateSelectionTree(value: boolean);
  69224. /**
  69225. * Gets a string describing the action executed by the current optimization
  69226. * @return description string
  69227. */
  69228. getDescription(): string;
  69229. private _canBeMerged;
  69230. /**
  69231. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69232. * @param scene defines the current scene where to apply this optimization
  69233. * @param optimizer defines the current optimizer
  69234. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69235. * @returns true if everything that can be done was applied
  69236. */
  69237. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69238. }
  69239. /**
  69240. * Defines a list of options used by SceneOptimizer
  69241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69242. */
  69243. export class SceneOptimizerOptions {
  69244. /**
  69245. * Defines the target frame rate to reach (60 by default)
  69246. */
  69247. targetFrameRate: number;
  69248. /**
  69249. * Defines the interval between two checkes (2000ms by default)
  69250. */
  69251. trackerDuration: number;
  69252. /**
  69253. * Gets the list of optimizations to apply
  69254. */
  69255. optimizations: SceneOptimization[];
  69256. /**
  69257. * Creates a new list of options used by SceneOptimizer
  69258. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69259. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69260. */
  69261. constructor(
  69262. /**
  69263. * Defines the target frame rate to reach (60 by default)
  69264. */
  69265. targetFrameRate?: number,
  69266. /**
  69267. * Defines the interval between two checkes (2000ms by default)
  69268. */
  69269. trackerDuration?: number);
  69270. /**
  69271. * Add a new optimization
  69272. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69273. * @returns the current SceneOptimizerOptions
  69274. */
  69275. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69276. /**
  69277. * Add a new custom optimization
  69278. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69279. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69280. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69281. * @returns the current SceneOptimizerOptions
  69282. */
  69283. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69284. /**
  69285. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69286. * @param targetFrameRate defines the target frame rate (60 by default)
  69287. * @returns a SceneOptimizerOptions object
  69288. */
  69289. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69290. /**
  69291. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69292. * @param targetFrameRate defines the target frame rate (60 by default)
  69293. * @returns a SceneOptimizerOptions object
  69294. */
  69295. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69296. /**
  69297. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69298. * @param targetFrameRate defines the target frame rate (60 by default)
  69299. * @returns a SceneOptimizerOptions object
  69300. */
  69301. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69302. }
  69303. /**
  69304. * Class used to run optimizations in order to reach a target frame rate
  69305. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69306. */
  69307. export class SceneOptimizer implements IDisposable {
  69308. private _isRunning;
  69309. private _options;
  69310. private _scene;
  69311. private _currentPriorityLevel;
  69312. private _targetFrameRate;
  69313. private _trackerDuration;
  69314. private _currentFrameRate;
  69315. private _sceneDisposeObserver;
  69316. private _improvementMode;
  69317. /**
  69318. * Defines an observable called when the optimizer reaches the target frame rate
  69319. */
  69320. onSuccessObservable: Observable<SceneOptimizer>;
  69321. /**
  69322. * Defines an observable called when the optimizer enables an optimization
  69323. */
  69324. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69325. /**
  69326. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69327. */
  69328. onFailureObservable: Observable<SceneOptimizer>;
  69329. /**
  69330. * Gets a boolean indicating if the optimizer is in improvement mode
  69331. */
  69332. get isInImprovementMode(): boolean;
  69333. /**
  69334. * Gets the current priority level (0 at start)
  69335. */
  69336. get currentPriorityLevel(): number;
  69337. /**
  69338. * Gets the current frame rate checked by the SceneOptimizer
  69339. */
  69340. get currentFrameRate(): number;
  69341. /**
  69342. * Gets or sets the current target frame rate (60 by default)
  69343. */
  69344. get targetFrameRate(): number;
  69345. /**
  69346. * Gets or sets the current target frame rate (60 by default)
  69347. */
  69348. set targetFrameRate(value: number);
  69349. /**
  69350. * Gets or sets the current interval between two checks (every 2000ms by default)
  69351. */
  69352. get trackerDuration(): number;
  69353. /**
  69354. * Gets or sets the current interval between two checks (every 2000ms by default)
  69355. */
  69356. set trackerDuration(value: number);
  69357. /**
  69358. * Gets the list of active optimizations
  69359. */
  69360. get optimizations(): SceneOptimization[];
  69361. /**
  69362. * Creates a new SceneOptimizer
  69363. * @param scene defines the scene to work on
  69364. * @param options defines the options to use with the SceneOptimizer
  69365. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69366. * @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)
  69367. */
  69368. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69369. /**
  69370. * Stops the current optimizer
  69371. */
  69372. stop(): void;
  69373. /**
  69374. * Reset the optimizer to initial step (current priority level = 0)
  69375. */
  69376. reset(): void;
  69377. /**
  69378. * Start the optimizer. By default it will try to reach a specific framerate
  69379. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69380. */
  69381. start(): void;
  69382. private _checkCurrentState;
  69383. /**
  69384. * Release all resources
  69385. */
  69386. dispose(): void;
  69387. /**
  69388. * Helper function to create a SceneOptimizer with one single line of code
  69389. * @param scene defines the scene to work on
  69390. * @param options defines the options to use with the SceneOptimizer
  69391. * @param onSuccess defines a callback to call on success
  69392. * @param onFailure defines a callback to call on failure
  69393. * @returns the new SceneOptimizer object
  69394. */
  69395. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69396. }
  69397. }
  69398. declare module BABYLON {
  69399. /**
  69400. * Class used to serialize a scene into a string
  69401. */
  69402. export class SceneSerializer {
  69403. /**
  69404. * Clear cache used by a previous serialization
  69405. */
  69406. static ClearCache(): void;
  69407. /**
  69408. * Serialize a scene into a JSON compatible object
  69409. * @param scene defines the scene to serialize
  69410. * @returns a JSON compatible object
  69411. */
  69412. static Serialize(scene: Scene): any;
  69413. /**
  69414. * Serialize a mesh into a JSON compatible object
  69415. * @param toSerialize defines the mesh to serialize
  69416. * @param withParents defines if parents must be serialized as well
  69417. * @param withChildren defines if children must be serialized as well
  69418. * @returns a JSON compatible object
  69419. */
  69420. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69421. }
  69422. }
  69423. declare module BABYLON {
  69424. /**
  69425. * Class used to host texture specific utilities
  69426. */
  69427. export class TextureTools {
  69428. /**
  69429. * Uses the GPU to create a copy texture rescaled at a given size
  69430. * @param texture Texture to copy from
  69431. * @param width defines the desired width
  69432. * @param height defines the desired height
  69433. * @param useBilinearMode defines if bilinear mode has to be used
  69434. * @return the generated texture
  69435. */
  69436. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69437. }
  69438. }
  69439. declare module BABYLON {
  69440. /**
  69441. * This represents the different options available for the video capture.
  69442. */
  69443. export interface VideoRecorderOptions {
  69444. /** Defines the mime type of the video. */
  69445. mimeType: string;
  69446. /** Defines the FPS the video should be recorded at. */
  69447. fps: number;
  69448. /** Defines the chunk size for the recording data. */
  69449. recordChunckSize: number;
  69450. /** The audio tracks to attach to the recording. */
  69451. audioTracks?: MediaStreamTrack[];
  69452. }
  69453. /**
  69454. * This can help with recording videos from BabylonJS.
  69455. * This is based on the available WebRTC functionalities of the browser.
  69456. *
  69457. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69458. */
  69459. export class VideoRecorder {
  69460. private static readonly _defaultOptions;
  69461. /**
  69462. * Returns whether or not the VideoRecorder is available in your browser.
  69463. * @param engine Defines the Babylon Engine.
  69464. * @returns true if supported otherwise false.
  69465. */
  69466. static IsSupported(engine: Engine): boolean;
  69467. private readonly _options;
  69468. private _canvas;
  69469. private _mediaRecorder;
  69470. private _recordedChunks;
  69471. private _fileName;
  69472. private _resolve;
  69473. private _reject;
  69474. /**
  69475. * True when a recording is already in progress.
  69476. */
  69477. get isRecording(): boolean;
  69478. /**
  69479. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69480. * @param engine Defines the BabylonJS Engine you wish to record.
  69481. * @param options Defines options that can be used to customize the capture.
  69482. */
  69483. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69484. /**
  69485. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69486. */
  69487. stopRecording(): void;
  69488. /**
  69489. * Starts recording the canvas for a max duration specified in parameters.
  69490. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69491. * If null no automatic download will start and you can rely on the promise to get the data back.
  69492. * @param maxDuration Defines the maximum recording time in seconds.
  69493. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69494. * @return A promise callback at the end of the recording with the video data in Blob.
  69495. */
  69496. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69497. /**
  69498. * Releases internal resources used during the recording.
  69499. */
  69500. dispose(): void;
  69501. private _handleDataAvailable;
  69502. private _handleError;
  69503. private _handleStop;
  69504. }
  69505. }
  69506. declare module BABYLON {
  69507. /**
  69508. * Class containing a set of static utilities functions for screenshots
  69509. */
  69510. export class ScreenshotTools {
  69511. /**
  69512. * Captures a screenshot of the current rendering
  69513. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69514. * @param engine defines the rendering engine
  69515. * @param camera defines the source camera
  69516. * @param size This parameter can be set to a single number or to an object with the
  69517. * following (optional) properties: precision, width, height. If a single number is passed,
  69518. * it will be used for both width and height. If an object is passed, the screenshot size
  69519. * will be derived from the parameters. The precision property is a multiplier allowing
  69520. * rendering at a higher or lower resolution
  69521. * @param successCallback defines the callback receives a single parameter which contains the
  69522. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69523. * src parameter of an <img> to display it
  69524. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69525. * Check your browser for supported MIME types
  69526. */
  69527. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69528. /**
  69529. * Captures a screenshot of the current rendering
  69530. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69531. * @param engine defines the rendering engine
  69532. * @param camera defines the source camera
  69533. * @param size This parameter can be set to a single number or to an object with the
  69534. * following (optional) properties: precision, width, height. If a single number is passed,
  69535. * it will be used for both width and height. If an object is passed, the screenshot size
  69536. * will be derived from the parameters. The precision property is a multiplier allowing
  69537. * rendering at a higher or lower resolution
  69538. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69539. * Check your browser for supported MIME types
  69540. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69541. * to the src parameter of an <img> to display it
  69542. */
  69543. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69544. /**
  69545. * Generates an image screenshot from the specified camera.
  69546. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69547. * @param engine The engine to use for rendering
  69548. * @param camera The camera to use for rendering
  69549. * @param size This parameter can be set to a single number or to an object with the
  69550. * following (optional) properties: precision, width, height. If a single number is passed,
  69551. * it will be used for both width and height. If an object is passed, the screenshot size
  69552. * will be derived from the parameters. The precision property is a multiplier allowing
  69553. * rendering at a higher or lower resolution
  69554. * @param successCallback The callback receives a single parameter which contains the
  69555. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69556. * src parameter of an <img> to display it
  69557. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69558. * Check your browser for supported MIME types
  69559. * @param samples Texture samples (default: 1)
  69560. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69561. * @param fileName A name for for the downloaded file.
  69562. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69563. */
  69564. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69565. /**
  69566. * Generates an image screenshot from the specified camera.
  69567. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69568. * @param engine The engine to use for rendering
  69569. * @param camera The camera to use for rendering
  69570. * @param size This parameter can be set to a single number or to an object with the
  69571. * following (optional) properties: precision, width, height. If a single number is passed,
  69572. * it will be used for both width and height. If an object is passed, the screenshot size
  69573. * will be derived from the parameters. The precision property is a multiplier allowing
  69574. * rendering at a higher or lower resolution
  69575. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69576. * Check your browser for supported MIME types
  69577. * @param samples Texture samples (default: 1)
  69578. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69579. * @param fileName A name for for the downloaded file.
  69580. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69581. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69582. * to the src parameter of an <img> to display it
  69583. */
  69584. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69585. /**
  69586. * Gets height and width for screenshot size
  69587. * @private
  69588. */
  69589. private static _getScreenshotSize;
  69590. }
  69591. }
  69592. declare module BABYLON {
  69593. /**
  69594. * Interface for a data buffer
  69595. */
  69596. export interface IDataBuffer {
  69597. /**
  69598. * Reads bytes from the data buffer.
  69599. * @param byteOffset The byte offset to read
  69600. * @param byteLength The byte length to read
  69601. * @returns A promise that resolves when the bytes are read
  69602. */
  69603. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69604. /**
  69605. * The byte length of the buffer.
  69606. */
  69607. readonly byteLength: number;
  69608. }
  69609. /**
  69610. * Utility class for reading from a data buffer
  69611. */
  69612. export class DataReader {
  69613. /**
  69614. * The data buffer associated with this data reader.
  69615. */
  69616. readonly buffer: IDataBuffer;
  69617. /**
  69618. * The current byte offset from the beginning of the data buffer.
  69619. */
  69620. byteOffset: number;
  69621. private _dataView;
  69622. private _dataByteOffset;
  69623. /**
  69624. * Constructor
  69625. * @param buffer The buffer to read
  69626. */
  69627. constructor(buffer: IDataBuffer);
  69628. /**
  69629. * Loads the given byte length.
  69630. * @param byteLength The byte length to load
  69631. * @returns A promise that resolves when the load is complete
  69632. */
  69633. loadAsync(byteLength: number): Promise<void>;
  69634. /**
  69635. * Read a unsigned 32-bit integer from the currently loaded data range.
  69636. * @returns The 32-bit integer read
  69637. */
  69638. readUint32(): number;
  69639. /**
  69640. * Read a byte array from the currently loaded data range.
  69641. * @param byteLength The byte length to read
  69642. * @returns The byte array read
  69643. */
  69644. readUint8Array(byteLength: number): Uint8Array;
  69645. /**
  69646. * Read a string from the currently loaded data range.
  69647. * @param byteLength The byte length to read
  69648. * @returns The string read
  69649. */
  69650. readString(byteLength: number): string;
  69651. /**
  69652. * Skips the given byte length the currently loaded data range.
  69653. * @param byteLength The byte length to skip
  69654. */
  69655. skipBytes(byteLength: number): void;
  69656. }
  69657. }
  69658. declare module BABYLON {
  69659. /**
  69660. * Class for storing data to local storage if available or in-memory storage otherwise
  69661. */
  69662. export class DataStorage {
  69663. private static _Storage;
  69664. private static _GetStorage;
  69665. /**
  69666. * Reads a string from the data storage
  69667. * @param key The key to read
  69668. * @param defaultValue The value if the key doesn't exist
  69669. * @returns The string value
  69670. */
  69671. static ReadString(key: string, defaultValue: string): string;
  69672. /**
  69673. * Writes a string to the data storage
  69674. * @param key The key to write
  69675. * @param value The value to write
  69676. */
  69677. static WriteString(key: string, value: string): void;
  69678. /**
  69679. * Reads a boolean from the data storage
  69680. * @param key The key to read
  69681. * @param defaultValue The value if the key doesn't exist
  69682. * @returns The boolean value
  69683. */
  69684. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69685. /**
  69686. * Writes a boolean to the data storage
  69687. * @param key The key to write
  69688. * @param value The value to write
  69689. */
  69690. static WriteBoolean(key: string, value: boolean): void;
  69691. /**
  69692. * Reads a number from the data storage
  69693. * @param key The key to read
  69694. * @param defaultValue The value if the key doesn't exist
  69695. * @returns The number value
  69696. */
  69697. static ReadNumber(key: string, defaultValue: number): number;
  69698. /**
  69699. * Writes a number to the data storage
  69700. * @param key The key to write
  69701. * @param value The value to write
  69702. */
  69703. static WriteNumber(key: string, value: number): void;
  69704. }
  69705. }
  69706. declare module BABYLON {
  69707. /**
  69708. * Options used for hit testing
  69709. */
  69710. export interface IWebXRLegacyHitTestOptions {
  69711. /**
  69712. * Only test when user interacted with the scene. Default - hit test every frame
  69713. */
  69714. testOnPointerDownOnly?: boolean;
  69715. /**
  69716. * The node to use to transform the local results to world coordinates
  69717. */
  69718. worldParentNode?: TransformNode;
  69719. }
  69720. /**
  69721. * Interface defining the babylon result of raycasting/hit-test
  69722. */
  69723. export interface IWebXRLegacyHitResult {
  69724. /**
  69725. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69726. */
  69727. transformationMatrix: Matrix;
  69728. /**
  69729. * The native hit test result
  69730. */
  69731. xrHitResult: XRHitResult | XRHitTestResult;
  69732. }
  69733. /**
  69734. * The currently-working hit-test module.
  69735. * Hit test (or Ray-casting) is used to interact with the real world.
  69736. * For further information read here - https://github.com/immersive-web/hit-test
  69737. */
  69738. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69739. /**
  69740. * options to use when constructing this feature
  69741. */
  69742. readonly options: IWebXRLegacyHitTestOptions;
  69743. private _direction;
  69744. private _mat;
  69745. private _onSelectEnabled;
  69746. private _origin;
  69747. /**
  69748. * The module's name
  69749. */
  69750. static readonly Name: string;
  69751. /**
  69752. * The (Babylon) version of this module.
  69753. * This is an integer representing the implementation version.
  69754. * This number does not correspond to the WebXR specs version
  69755. */
  69756. static readonly Version: number;
  69757. /**
  69758. * Populated with the last native XR Hit Results
  69759. */
  69760. lastNativeXRHitResults: XRHitResult[];
  69761. /**
  69762. * Triggered when new babylon (transformed) hit test results are available
  69763. */
  69764. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69765. /**
  69766. * Creates a new instance of the (legacy version) hit test feature
  69767. * @param _xrSessionManager an instance of WebXRSessionManager
  69768. * @param options options to use when constructing this feature
  69769. */
  69770. constructor(_xrSessionManager: WebXRSessionManager,
  69771. /**
  69772. * options to use when constructing this feature
  69773. */
  69774. options?: IWebXRLegacyHitTestOptions);
  69775. /**
  69776. * execute a hit test with an XR Ray
  69777. *
  69778. * @param xrSession a native xrSession that will execute this hit test
  69779. * @param xrRay the ray (position and direction) to use for ray-casting
  69780. * @param referenceSpace native XR reference space to use for the hit-test
  69781. * @param filter filter function that will filter the results
  69782. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69783. */
  69784. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69785. /**
  69786. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69787. * @param event the (select) event to use to select with
  69788. * @param referenceSpace the reference space to use for this hit test
  69789. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69790. */
  69791. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69792. /**
  69793. * attach this feature
  69794. * Will usually be called by the features manager
  69795. *
  69796. * @returns true if successful.
  69797. */
  69798. attach(): boolean;
  69799. /**
  69800. * detach this feature.
  69801. * Will usually be called by the features manager
  69802. *
  69803. * @returns true if successful.
  69804. */
  69805. detach(): boolean;
  69806. /**
  69807. * Dispose this feature and all of the resources attached
  69808. */
  69809. dispose(): void;
  69810. protected _onXRFrame(frame: XRFrame): void;
  69811. private _onHitTestResults;
  69812. private _onSelect;
  69813. }
  69814. }
  69815. declare module BABYLON {
  69816. /**
  69817. * Options used in the plane detector module
  69818. */
  69819. export interface IWebXRPlaneDetectorOptions {
  69820. /**
  69821. * The node to use to transform the local results to world coordinates
  69822. */
  69823. worldParentNode?: TransformNode;
  69824. }
  69825. /**
  69826. * A babylon interface for a WebXR plane.
  69827. * A Plane is actually a polygon, built from N points in space
  69828. *
  69829. * Supported in chrome 79, not supported in canary 81 ATM
  69830. */
  69831. export interface IWebXRPlane {
  69832. /**
  69833. * a babylon-assigned ID for this polygon
  69834. */
  69835. id: number;
  69836. /**
  69837. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69838. */
  69839. polygonDefinition: Array<Vector3>;
  69840. /**
  69841. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69842. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69843. */
  69844. transformationMatrix: Matrix;
  69845. /**
  69846. * the native xr-plane object
  69847. */
  69848. xrPlane: XRPlane;
  69849. }
  69850. /**
  69851. * The plane detector is used to detect planes in the real world when in AR
  69852. * For more information see https://github.com/immersive-web/real-world-geometry/
  69853. */
  69854. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69855. private _options;
  69856. private _detectedPlanes;
  69857. private _enabled;
  69858. private _lastFrameDetected;
  69859. /**
  69860. * The module's name
  69861. */
  69862. static readonly Name: string;
  69863. /**
  69864. * The (Babylon) version of this module.
  69865. * This is an integer representing the implementation version.
  69866. * This number does not correspond to the WebXR specs version
  69867. */
  69868. static readonly Version: number;
  69869. /**
  69870. * Observers registered here will be executed when a new plane was added to the session
  69871. */
  69872. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69873. /**
  69874. * Observers registered here will be executed when a plane is no longer detected in the session
  69875. */
  69876. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69877. /**
  69878. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69879. * This can execute N times every frame
  69880. */
  69881. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69882. /**
  69883. * construct a new Plane Detector
  69884. * @param _xrSessionManager an instance of xr Session manager
  69885. * @param _options configuration to use when constructing this feature
  69886. */
  69887. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69888. /**
  69889. * Dispose this feature and all of the resources attached
  69890. */
  69891. dispose(): void;
  69892. protected _onXRFrame(frame: XRFrame): void;
  69893. private _init;
  69894. private _updatePlaneWithXRPlane;
  69895. /**
  69896. * avoiding using Array.find for global support.
  69897. * @param xrPlane the plane to find in the array
  69898. */
  69899. private findIndexInPlaneArray;
  69900. }
  69901. }
  69902. declare module BABYLON {
  69903. /**
  69904. * Configuration options of the anchor system
  69905. */
  69906. export interface IWebXRAnchorSystemOptions {
  69907. /**
  69908. * Should a new anchor be added every time a select event is triggered
  69909. */
  69910. addAnchorOnSelect?: boolean;
  69911. /**
  69912. * should the anchor system use plane detection.
  69913. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69914. */
  69915. usePlaneDetection?: boolean;
  69916. /**
  69917. * a node that will be used to convert local to world coordinates
  69918. */
  69919. worldParentNode?: TransformNode;
  69920. }
  69921. /**
  69922. * A babylon container for an XR Anchor
  69923. */
  69924. export interface IWebXRAnchor {
  69925. /**
  69926. * A babylon-assigned ID for this anchor
  69927. */
  69928. id: number;
  69929. /**
  69930. * Transformation matrix to apply to an object attached to this anchor
  69931. */
  69932. transformationMatrix: Matrix;
  69933. /**
  69934. * The native anchor object
  69935. */
  69936. xrAnchor: XRAnchor;
  69937. }
  69938. /**
  69939. * An implementation of the anchor system of WebXR.
  69940. * Note that the current documented implementation is not available in any browser. Future implementations
  69941. * will use the frame to create an anchor and not the session or a detected plane
  69942. * For further information see https://github.com/immersive-web/anchors/
  69943. */
  69944. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69945. private _options;
  69946. private _enabled;
  69947. private _hitTestModule;
  69948. private _lastFrameDetected;
  69949. private _onSelect;
  69950. private _planeDetector;
  69951. private _trackedAnchors;
  69952. /**
  69953. * The module's name
  69954. */
  69955. static readonly Name: string;
  69956. /**
  69957. * The (Babylon) version of this module.
  69958. * This is an integer representing the implementation version.
  69959. * This number does not correspond to the WebXR specs version
  69960. */
  69961. static readonly Version: number;
  69962. /**
  69963. * Observers registered here will be executed when a new anchor was added to the session
  69964. */
  69965. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69966. /**
  69967. * Observers registered here will be executed when an anchor was removed from the session
  69968. */
  69969. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69970. /**
  69971. * Observers registered here will be executed when an existing anchor updates
  69972. * This can execute N times every frame
  69973. */
  69974. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69975. /**
  69976. * constructs a new anchor system
  69977. * @param _xrSessionManager an instance of WebXRSessionManager
  69978. * @param _options configuration object for this feature
  69979. */
  69980. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69981. /**
  69982. * Add anchor at a specific XR point.
  69983. *
  69984. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69985. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69986. * @returns a promise the fulfills when the anchor was created
  69987. */
  69988. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69989. /**
  69990. * attach this feature
  69991. * Will usually be called by the features manager
  69992. *
  69993. * @returns true if successful.
  69994. */
  69995. attach(): boolean;
  69996. /**
  69997. * detach this feature.
  69998. * Will usually be called by the features manager
  69999. *
  70000. * @returns true if successful.
  70001. */
  70002. detach(): boolean;
  70003. /**
  70004. * Dispose this feature and all of the resources attached
  70005. */
  70006. dispose(): void;
  70007. /**
  70008. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  70009. * @param hitTestModule the hit-test module to use.
  70010. */
  70011. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  70012. /**
  70013. * set the plane detector to use in order to create anchors from frames
  70014. * @param planeDetector the plane-detector module to use
  70015. * @param enable enable plane-anchors. default is true
  70016. */
  70017. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  70018. protected _onXRFrame(frame: XRFrame): void;
  70019. /**
  70020. * avoiding using Array.find for global support.
  70021. * @param xrAnchor the plane to find in the array
  70022. */
  70023. private _findIndexInAnchorArray;
  70024. private _updateAnchorWithXRFrame;
  70025. }
  70026. }
  70027. declare module BABYLON {
  70028. /**
  70029. * Options interface for the background remover plugin
  70030. */
  70031. export interface IWebXRBackgroundRemoverOptions {
  70032. /**
  70033. * Further background meshes to disable when entering AR
  70034. */
  70035. backgroundMeshes?: AbstractMesh[];
  70036. /**
  70037. * flags to configure the removal of the environment helper.
  70038. * If not set, the entire background will be removed. If set, flags should be set as well.
  70039. */
  70040. environmentHelperRemovalFlags?: {
  70041. /**
  70042. * Should the skybox be removed (default false)
  70043. */
  70044. skyBox?: boolean;
  70045. /**
  70046. * Should the ground be removed (default false)
  70047. */
  70048. ground?: boolean;
  70049. };
  70050. /**
  70051. * don't disable the environment helper
  70052. */
  70053. ignoreEnvironmentHelper?: boolean;
  70054. }
  70055. /**
  70056. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  70057. */
  70058. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  70059. /**
  70060. * read-only options to be used in this module
  70061. */
  70062. readonly options: IWebXRBackgroundRemoverOptions;
  70063. /**
  70064. * The module's name
  70065. */
  70066. static readonly Name: string;
  70067. /**
  70068. * The (Babylon) version of this module.
  70069. * This is an integer representing the implementation version.
  70070. * This number does not correspond to the WebXR specs version
  70071. */
  70072. static readonly Version: number;
  70073. /**
  70074. * registered observers will be triggered when the background state changes
  70075. */
  70076. onBackgroundStateChangedObservable: Observable<boolean>;
  70077. /**
  70078. * constructs a new background remover module
  70079. * @param _xrSessionManager the session manager for this module
  70080. * @param options read-only options to be used in this module
  70081. */
  70082. constructor(_xrSessionManager: WebXRSessionManager,
  70083. /**
  70084. * read-only options to be used in this module
  70085. */
  70086. options?: IWebXRBackgroundRemoverOptions);
  70087. /**
  70088. * attach this feature
  70089. * Will usually be called by the features manager
  70090. *
  70091. * @returns true if successful.
  70092. */
  70093. attach(): boolean;
  70094. /**
  70095. * detach this feature.
  70096. * Will usually be called by the features manager
  70097. *
  70098. * @returns true if successful.
  70099. */
  70100. detach(): boolean;
  70101. /**
  70102. * Dispose this feature and all of the resources attached
  70103. */
  70104. dispose(): void;
  70105. protected _onXRFrame(_xrFrame: XRFrame): void;
  70106. private _setBackgroundState;
  70107. }
  70108. }
  70109. declare module BABYLON {
  70110. /**
  70111. * Options for the controller physics feature
  70112. */
  70113. export class IWebXRControllerPhysicsOptions {
  70114. /**
  70115. * Should the headset get its own impostor
  70116. */
  70117. enableHeadsetImpostor?: boolean;
  70118. /**
  70119. * Optional parameters for the headset impostor
  70120. */
  70121. headsetImpostorParams?: {
  70122. /**
  70123. * The type of impostor to create. Default is sphere
  70124. */
  70125. impostorType: number;
  70126. /**
  70127. * the size of the impostor. Defaults to 10cm
  70128. */
  70129. impostorSize?: number | {
  70130. width: number;
  70131. height: number;
  70132. depth: number;
  70133. };
  70134. /**
  70135. * Friction definitions
  70136. */
  70137. friction?: number;
  70138. /**
  70139. * Restitution
  70140. */
  70141. restitution?: number;
  70142. };
  70143. /**
  70144. * The physics properties of the future impostors
  70145. */
  70146. physicsProperties?: {
  70147. /**
  70148. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  70149. * Note that this requires a physics engine that supports mesh impostors!
  70150. */
  70151. useControllerMesh?: boolean;
  70152. /**
  70153. * The type of impostor to create. Default is sphere
  70154. */
  70155. impostorType?: number;
  70156. /**
  70157. * the size of the impostor. Defaults to 10cm
  70158. */
  70159. impostorSize?: number | {
  70160. width: number;
  70161. height: number;
  70162. depth: number;
  70163. };
  70164. /**
  70165. * Friction definitions
  70166. */
  70167. friction?: number;
  70168. /**
  70169. * Restitution
  70170. */
  70171. restitution?: number;
  70172. };
  70173. /**
  70174. * the xr input to use with this pointer selection
  70175. */
  70176. xrInput: WebXRInput;
  70177. }
  70178. /**
  70179. * Add physics impostor to your webxr controllers,
  70180. * including naive calculation of their linear and angular velocity
  70181. */
  70182. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  70183. private readonly _options;
  70184. private _attachController;
  70185. private _controllers;
  70186. private _debugMode;
  70187. private _delta;
  70188. private _headsetImpostor?;
  70189. private _headsetMesh?;
  70190. private _lastTimestamp;
  70191. private _tmpQuaternion;
  70192. private _tmpVector;
  70193. /**
  70194. * The module's name
  70195. */
  70196. static readonly Name: string;
  70197. /**
  70198. * The (Babylon) version of this module.
  70199. * This is an integer representing the implementation version.
  70200. * This number does not correspond to the webxr specs version
  70201. */
  70202. static readonly Version: number;
  70203. /**
  70204. * Construct a new Controller Physics Feature
  70205. * @param _xrSessionManager the corresponding xr session manager
  70206. * @param _options options to create this feature with
  70207. */
  70208. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  70209. /**
  70210. * @hidden
  70211. * enable debugging - will show console outputs and the impostor mesh
  70212. */
  70213. _enablePhysicsDebug(): void;
  70214. /**
  70215. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  70216. * @param xrController the controller to add
  70217. */
  70218. addController(xrController: WebXRInputSource): void;
  70219. /**
  70220. * attach this feature
  70221. * Will usually be called by the features manager
  70222. *
  70223. * @returns true if successful.
  70224. */
  70225. attach(): boolean;
  70226. /**
  70227. * detach this feature.
  70228. * Will usually be called by the features manager
  70229. *
  70230. * @returns true if successful.
  70231. */
  70232. detach(): boolean;
  70233. /**
  70234. * Get the headset impostor, if enabled
  70235. * @returns the impostor
  70236. */
  70237. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70238. /**
  70239. * Get the physics impostor of a specific controller.
  70240. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70241. * @param controller the controller or the controller id of which to get the impostor
  70242. * @returns the impostor or null
  70243. */
  70244. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70245. /**
  70246. * Update the physics properties provided in the constructor
  70247. * @param newProperties the new properties object
  70248. */
  70249. setPhysicsProperties(newProperties: {
  70250. impostorType?: number;
  70251. impostorSize?: number | {
  70252. width: number;
  70253. height: number;
  70254. depth: number;
  70255. };
  70256. friction?: number;
  70257. restitution?: number;
  70258. }): void;
  70259. protected _onXRFrame(_xrFrame: any): void;
  70260. private _detachController;
  70261. }
  70262. }
  70263. declare module BABYLON {
  70264. /**
  70265. * Options used for hit testing (version 2)
  70266. */
  70267. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70268. /**
  70269. * Do not create a permanent hit test. Will usually be used when only
  70270. * transient inputs are needed.
  70271. */
  70272. disablePermanentHitTest?: boolean;
  70273. /**
  70274. * Enable transient (for example touch-based) hit test inspections
  70275. */
  70276. enableTransientHitTest?: boolean;
  70277. /**
  70278. * Offset ray for the permanent hit test
  70279. */
  70280. offsetRay?: Vector3;
  70281. /**
  70282. * Offset ray for the transient hit test
  70283. */
  70284. transientOffsetRay?: Vector3;
  70285. /**
  70286. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70287. */
  70288. useReferenceSpace?: boolean;
  70289. }
  70290. /**
  70291. * Interface defining the babylon result of hit-test
  70292. */
  70293. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70294. /**
  70295. * The input source that generated this hit test (if transient)
  70296. */
  70297. inputSource?: XRInputSource;
  70298. /**
  70299. * Is this a transient hit test
  70300. */
  70301. isTransient?: boolean;
  70302. /**
  70303. * Position of the hit test result
  70304. */
  70305. position: Vector3;
  70306. /**
  70307. * Rotation of the hit test result
  70308. */
  70309. rotationQuaternion: Quaternion;
  70310. }
  70311. /**
  70312. * The currently-working hit-test module.
  70313. * Hit test (or Ray-casting) is used to interact with the real world.
  70314. * For further information read here - https://github.com/immersive-web/hit-test
  70315. *
  70316. * Tested on chrome (mobile) 80.
  70317. */
  70318. export class WebXRHitTest extends WebXRAbstractFeature {
  70319. /**
  70320. * options to use when constructing this feature
  70321. */
  70322. readonly options: IWebXRHitTestOptions;
  70323. private _tmpMat;
  70324. private _tmpPos;
  70325. private _tmpQuat;
  70326. private _transientXrHitTestSource;
  70327. private _xrHitTestSource;
  70328. private initHitTestSource;
  70329. /**
  70330. * The module's name
  70331. */
  70332. static readonly Name: string;
  70333. /**
  70334. * The (Babylon) version of this module.
  70335. * This is an integer representing the implementation version.
  70336. * This number does not correspond to the WebXR specs version
  70337. */
  70338. static readonly Version: number;
  70339. /**
  70340. * When set to true, each hit test will have its own position/rotation objects
  70341. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70342. * the developers will clone them or copy them as they see fit.
  70343. */
  70344. autoCloneTransformation: boolean;
  70345. /**
  70346. * Populated with the last native XR Hit Results
  70347. */
  70348. lastNativeXRHitResults: XRHitResult[];
  70349. /**
  70350. * Triggered when new babylon (transformed) hit test results are available
  70351. */
  70352. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70353. /**
  70354. * Use this to temporarily pause hit test checks.
  70355. */
  70356. paused: boolean;
  70357. /**
  70358. * Creates a new instance of the hit test feature
  70359. * @param _xrSessionManager an instance of WebXRSessionManager
  70360. * @param options options to use when constructing this feature
  70361. */
  70362. constructor(_xrSessionManager: WebXRSessionManager,
  70363. /**
  70364. * options to use when constructing this feature
  70365. */
  70366. options?: IWebXRHitTestOptions);
  70367. /**
  70368. * attach this feature
  70369. * Will usually be called by the features manager
  70370. *
  70371. * @returns true if successful.
  70372. */
  70373. attach(): boolean;
  70374. /**
  70375. * detach this feature.
  70376. * Will usually be called by the features manager
  70377. *
  70378. * @returns true if successful.
  70379. */
  70380. detach(): boolean;
  70381. /**
  70382. * Dispose this feature and all of the resources attached
  70383. */
  70384. dispose(): void;
  70385. protected _onXRFrame(frame: XRFrame): void;
  70386. private _processWebXRHitTestResult;
  70387. }
  70388. }
  70389. declare module BABYLON {
  70390. /**
  70391. * The motion controller class for all microsoft mixed reality controllers
  70392. */
  70393. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70394. protected readonly _mapping: {
  70395. defaultButton: {
  70396. valueNodeName: string;
  70397. unpressedNodeName: string;
  70398. pressedNodeName: string;
  70399. };
  70400. defaultAxis: {
  70401. valueNodeName: string;
  70402. minNodeName: string;
  70403. maxNodeName: string;
  70404. };
  70405. buttons: {
  70406. "xr-standard-trigger": {
  70407. rootNodeName: string;
  70408. componentProperty: string;
  70409. states: string[];
  70410. };
  70411. "xr-standard-squeeze": {
  70412. rootNodeName: string;
  70413. componentProperty: string;
  70414. states: string[];
  70415. };
  70416. "xr-standard-touchpad": {
  70417. rootNodeName: string;
  70418. labelAnchorNodeName: string;
  70419. touchPointNodeName: string;
  70420. };
  70421. "xr-standard-thumbstick": {
  70422. rootNodeName: string;
  70423. componentProperty: string;
  70424. states: string[];
  70425. };
  70426. };
  70427. axes: {
  70428. "xr-standard-touchpad": {
  70429. "x-axis": {
  70430. rootNodeName: string;
  70431. };
  70432. "y-axis": {
  70433. rootNodeName: string;
  70434. };
  70435. };
  70436. "xr-standard-thumbstick": {
  70437. "x-axis": {
  70438. rootNodeName: string;
  70439. };
  70440. "y-axis": {
  70441. rootNodeName: string;
  70442. };
  70443. };
  70444. };
  70445. };
  70446. /**
  70447. * The base url used to load the left and right controller models
  70448. */
  70449. static MODEL_BASE_URL: string;
  70450. /**
  70451. * The name of the left controller model file
  70452. */
  70453. static MODEL_LEFT_FILENAME: string;
  70454. /**
  70455. * The name of the right controller model file
  70456. */
  70457. static MODEL_RIGHT_FILENAME: string;
  70458. profileId: string;
  70459. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70460. protected _getFilenameAndPath(): {
  70461. filename: string;
  70462. path: string;
  70463. };
  70464. protected _getModelLoadingConstraints(): boolean;
  70465. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70466. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70467. protected _updateModel(): void;
  70468. }
  70469. }
  70470. declare module BABYLON {
  70471. /**
  70472. * The motion controller class for oculus touch (quest, rift).
  70473. * This class supports legacy mapping as well the standard xr mapping
  70474. */
  70475. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70476. private _forceLegacyControllers;
  70477. private _modelRootNode;
  70478. /**
  70479. * The base url used to load the left and right controller models
  70480. */
  70481. static MODEL_BASE_URL: string;
  70482. /**
  70483. * The name of the left controller model file
  70484. */
  70485. static MODEL_LEFT_FILENAME: string;
  70486. /**
  70487. * The name of the right controller model file
  70488. */
  70489. static MODEL_RIGHT_FILENAME: string;
  70490. /**
  70491. * Base Url for the Quest controller model.
  70492. */
  70493. static QUEST_MODEL_BASE_URL: string;
  70494. profileId: string;
  70495. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70496. protected _getFilenameAndPath(): {
  70497. filename: string;
  70498. path: string;
  70499. };
  70500. protected _getModelLoadingConstraints(): boolean;
  70501. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70502. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70503. protected _updateModel(): void;
  70504. /**
  70505. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70506. * between the touch and touch 2.
  70507. */
  70508. private _isQuest;
  70509. }
  70510. }
  70511. declare module BABYLON {
  70512. /**
  70513. * The motion controller class for the standard HTC-Vive controllers
  70514. */
  70515. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70516. private _modelRootNode;
  70517. /**
  70518. * The base url used to load the left and right controller models
  70519. */
  70520. static MODEL_BASE_URL: string;
  70521. /**
  70522. * File name for the controller model.
  70523. */
  70524. static MODEL_FILENAME: string;
  70525. profileId: string;
  70526. /**
  70527. * Create a new Vive motion controller object
  70528. * @param scene the scene to use to create this controller
  70529. * @param gamepadObject the corresponding gamepad object
  70530. * @param handness the handness of the controller
  70531. */
  70532. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70533. protected _getFilenameAndPath(): {
  70534. filename: string;
  70535. path: string;
  70536. };
  70537. protected _getModelLoadingConstraints(): boolean;
  70538. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70539. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70540. protected _updateModel(): void;
  70541. }
  70542. }
  70543. declare module BABYLON {
  70544. /**
  70545. * A cursor which tracks a point on a path
  70546. */
  70547. export class PathCursor {
  70548. private path;
  70549. /**
  70550. * Stores path cursor callbacks for when an onchange event is triggered
  70551. */
  70552. private _onchange;
  70553. /**
  70554. * The value of the path cursor
  70555. */
  70556. value: number;
  70557. /**
  70558. * The animation array of the path cursor
  70559. */
  70560. animations: Animation[];
  70561. /**
  70562. * Initializes the path cursor
  70563. * @param path The path to track
  70564. */
  70565. constructor(path: Path2);
  70566. /**
  70567. * Gets the cursor point on the path
  70568. * @returns A point on the path cursor at the cursor location
  70569. */
  70570. getPoint(): Vector3;
  70571. /**
  70572. * Moves the cursor ahead by the step amount
  70573. * @param step The amount to move the cursor forward
  70574. * @returns This path cursor
  70575. */
  70576. moveAhead(step?: number): PathCursor;
  70577. /**
  70578. * Moves the cursor behind by the step amount
  70579. * @param step The amount to move the cursor back
  70580. * @returns This path cursor
  70581. */
  70582. moveBack(step?: number): PathCursor;
  70583. /**
  70584. * Moves the cursor by the step amount
  70585. * If the step amount is greater than one, an exception is thrown
  70586. * @param step The amount to move the cursor
  70587. * @returns This path cursor
  70588. */
  70589. move(step: number): PathCursor;
  70590. /**
  70591. * Ensures that the value is limited between zero and one
  70592. * @returns This path cursor
  70593. */
  70594. private ensureLimits;
  70595. /**
  70596. * Runs onchange callbacks on change (used by the animation engine)
  70597. * @returns This path cursor
  70598. */
  70599. private raiseOnChange;
  70600. /**
  70601. * Executes a function on change
  70602. * @param f A path cursor onchange callback
  70603. * @returns This path cursor
  70604. */
  70605. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70606. }
  70607. }
  70608. declare module BABYLON {
  70609. /** @hidden */
  70610. export var blurPixelShader: {
  70611. name: string;
  70612. shader: string;
  70613. };
  70614. }
  70615. declare module BABYLON {
  70616. /** @hidden */
  70617. export var pointCloudVertexDeclaration: {
  70618. name: string;
  70619. shader: string;
  70620. };
  70621. }
  70622. // Mixins
  70623. interface Window {
  70624. mozIndexedDB: IDBFactory;
  70625. webkitIndexedDB: IDBFactory;
  70626. msIndexedDB: IDBFactory;
  70627. webkitURL: typeof URL;
  70628. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70629. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70630. WebGLRenderingContext: WebGLRenderingContext;
  70631. MSGesture: MSGesture;
  70632. CANNON: any;
  70633. AudioContext: AudioContext;
  70634. webkitAudioContext: AudioContext;
  70635. PointerEvent: any;
  70636. Math: Math;
  70637. Uint8Array: Uint8ArrayConstructor;
  70638. Float32Array: Float32ArrayConstructor;
  70639. mozURL: typeof URL;
  70640. msURL: typeof URL;
  70641. VRFrameData: any; // WebVR, from specs 1.1
  70642. DracoDecoderModule: any;
  70643. setImmediate(handler: (...args: any[]) => void): number;
  70644. }
  70645. interface HTMLCanvasElement {
  70646. requestPointerLock(): void;
  70647. msRequestPointerLock?(): void;
  70648. mozRequestPointerLock?(): void;
  70649. webkitRequestPointerLock?(): void;
  70650. /** Track wether a record is in progress */
  70651. isRecording: boolean;
  70652. /** Capture Stream method defined by some browsers */
  70653. captureStream(fps?: number): MediaStream;
  70654. }
  70655. interface CanvasRenderingContext2D {
  70656. msImageSmoothingEnabled: boolean;
  70657. }
  70658. interface MouseEvent {
  70659. mozMovementX: number;
  70660. mozMovementY: number;
  70661. webkitMovementX: number;
  70662. webkitMovementY: number;
  70663. msMovementX: number;
  70664. msMovementY: number;
  70665. }
  70666. interface Navigator {
  70667. mozGetVRDevices: (any: any) => any;
  70668. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70669. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70670. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70671. webkitGetGamepads(): Gamepad[];
  70672. msGetGamepads(): Gamepad[];
  70673. webkitGamepads(): Gamepad[];
  70674. }
  70675. interface HTMLVideoElement {
  70676. mozSrcObject: any;
  70677. }
  70678. interface Math {
  70679. fround(x: number): number;
  70680. imul(a: number, b: number): number;
  70681. }
  70682. interface WebGLRenderingContext {
  70683. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70684. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70685. vertexAttribDivisor(index: number, divisor: number): void;
  70686. createVertexArray(): any;
  70687. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70688. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70689. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70690. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70691. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70692. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70693. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70694. // Queries
  70695. createQuery(): WebGLQuery;
  70696. deleteQuery(query: WebGLQuery): void;
  70697. beginQuery(target: number, query: WebGLQuery): void;
  70698. endQuery(target: number): void;
  70699. getQueryParameter(query: WebGLQuery, pname: number): any;
  70700. getQuery(target: number, pname: number): any;
  70701. MAX_SAMPLES: number;
  70702. RGBA8: number;
  70703. READ_FRAMEBUFFER: number;
  70704. DRAW_FRAMEBUFFER: number;
  70705. UNIFORM_BUFFER: number;
  70706. HALF_FLOAT_OES: number;
  70707. RGBA16F: number;
  70708. RGBA32F: number;
  70709. R32F: number;
  70710. RG32F: number;
  70711. RGB32F: number;
  70712. R16F: number;
  70713. RG16F: number;
  70714. RGB16F: number;
  70715. RED: number;
  70716. RG: number;
  70717. R8: number;
  70718. RG8: number;
  70719. UNSIGNED_INT_24_8: number;
  70720. DEPTH24_STENCIL8: number;
  70721. MIN: number;
  70722. MAX: number;
  70723. /* Multiple Render Targets */
  70724. drawBuffers(buffers: number[]): void;
  70725. readBuffer(src: number): void;
  70726. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70727. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70728. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70729. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70730. // Occlusion Query
  70731. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70732. ANY_SAMPLES_PASSED: number;
  70733. QUERY_RESULT_AVAILABLE: number;
  70734. QUERY_RESULT: number;
  70735. }
  70736. interface WebGLProgram {
  70737. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70738. }
  70739. interface EXT_disjoint_timer_query {
  70740. QUERY_COUNTER_BITS_EXT: number;
  70741. TIME_ELAPSED_EXT: number;
  70742. TIMESTAMP_EXT: number;
  70743. GPU_DISJOINT_EXT: number;
  70744. QUERY_RESULT_EXT: number;
  70745. QUERY_RESULT_AVAILABLE_EXT: number;
  70746. queryCounterEXT(query: WebGLQuery, target: number): void;
  70747. createQueryEXT(): WebGLQuery;
  70748. beginQueryEXT(target: number, query: WebGLQuery): void;
  70749. endQueryEXT(target: number): void;
  70750. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70751. deleteQueryEXT(query: WebGLQuery): void;
  70752. }
  70753. interface WebGLUniformLocation {
  70754. _currentState: any;
  70755. }
  70756. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70757. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70758. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70759. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70760. interface WebGLRenderingContext {
  70761. readonly RASTERIZER_DISCARD: number;
  70762. readonly DEPTH_COMPONENT24: number;
  70763. readonly TEXTURE_3D: number;
  70764. readonly TEXTURE_2D_ARRAY: number;
  70765. readonly TEXTURE_COMPARE_FUNC: number;
  70766. readonly TEXTURE_COMPARE_MODE: number;
  70767. readonly COMPARE_REF_TO_TEXTURE: number;
  70768. readonly TEXTURE_WRAP_R: number;
  70769. readonly HALF_FLOAT: number;
  70770. readonly RGB8: number;
  70771. readonly RED_INTEGER: number;
  70772. readonly RG_INTEGER: number;
  70773. readonly RGB_INTEGER: number;
  70774. readonly RGBA_INTEGER: number;
  70775. readonly R8_SNORM: number;
  70776. readonly RG8_SNORM: number;
  70777. readonly RGB8_SNORM: number;
  70778. readonly RGBA8_SNORM: number;
  70779. readonly R8I: number;
  70780. readonly RG8I: number;
  70781. readonly RGB8I: number;
  70782. readonly RGBA8I: number;
  70783. readonly R8UI: number;
  70784. readonly RG8UI: number;
  70785. readonly RGB8UI: number;
  70786. readonly RGBA8UI: number;
  70787. readonly R16I: number;
  70788. readonly RG16I: number;
  70789. readonly RGB16I: number;
  70790. readonly RGBA16I: number;
  70791. readonly R16UI: number;
  70792. readonly RG16UI: number;
  70793. readonly RGB16UI: number;
  70794. readonly RGBA16UI: number;
  70795. readonly R32I: number;
  70796. readonly RG32I: number;
  70797. readonly RGB32I: number;
  70798. readonly RGBA32I: number;
  70799. readonly R32UI: number;
  70800. readonly RG32UI: number;
  70801. readonly RGB32UI: number;
  70802. readonly RGBA32UI: number;
  70803. readonly RGB10_A2UI: number;
  70804. readonly R11F_G11F_B10F: number;
  70805. readonly RGB9_E5: number;
  70806. readonly RGB10_A2: number;
  70807. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70808. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70809. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70810. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70811. readonly DEPTH_COMPONENT32F: number;
  70812. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70813. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70814. 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;
  70815. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70816. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70817. readonly TRANSFORM_FEEDBACK: number;
  70818. readonly INTERLEAVED_ATTRIBS: number;
  70819. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70820. createTransformFeedback(): WebGLTransformFeedback;
  70821. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70822. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70823. beginTransformFeedback(primitiveMode: number): void;
  70824. endTransformFeedback(): void;
  70825. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70826. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70827. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70828. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70829. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70830. }
  70831. interface ImageBitmap {
  70832. readonly width: number;
  70833. readonly height: number;
  70834. close(): void;
  70835. }
  70836. interface WebGLQuery extends WebGLObject {
  70837. }
  70838. declare var WebGLQuery: {
  70839. prototype: WebGLQuery;
  70840. new(): WebGLQuery;
  70841. };
  70842. interface WebGLSampler extends WebGLObject {
  70843. }
  70844. declare var WebGLSampler: {
  70845. prototype: WebGLSampler;
  70846. new(): WebGLSampler;
  70847. };
  70848. interface WebGLSync extends WebGLObject {
  70849. }
  70850. declare var WebGLSync: {
  70851. prototype: WebGLSync;
  70852. new(): WebGLSync;
  70853. };
  70854. interface WebGLTransformFeedback extends WebGLObject {
  70855. }
  70856. declare var WebGLTransformFeedback: {
  70857. prototype: WebGLTransformFeedback;
  70858. new(): WebGLTransformFeedback;
  70859. };
  70860. interface WebGLVertexArrayObject extends WebGLObject {
  70861. }
  70862. declare var WebGLVertexArrayObject: {
  70863. prototype: WebGLVertexArrayObject;
  70864. new(): WebGLVertexArrayObject;
  70865. };
  70866. // Type definitions for WebVR API
  70867. // Project: https://w3c.github.io/webvr/
  70868. // Definitions by: six a <https://github.com/lostfictions>
  70869. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70870. interface VRDisplay extends EventTarget {
  70871. /**
  70872. * Dictionary of capabilities describing the VRDisplay.
  70873. */
  70874. readonly capabilities: VRDisplayCapabilities;
  70875. /**
  70876. * z-depth defining the far plane of the eye view frustum
  70877. * enables mapping of values in the render target depth
  70878. * attachment to scene coordinates. Initially set to 10000.0.
  70879. */
  70880. depthFar: number;
  70881. /**
  70882. * z-depth defining the near plane of the eye view frustum
  70883. * enables mapping of values in the render target depth
  70884. * attachment to scene coordinates. Initially set to 0.01.
  70885. */
  70886. depthNear: number;
  70887. /**
  70888. * An identifier for this distinct VRDisplay. Used as an
  70889. * association point in the Gamepad API.
  70890. */
  70891. readonly displayId: number;
  70892. /**
  70893. * A display name, a user-readable name identifying it.
  70894. */
  70895. readonly displayName: string;
  70896. readonly isConnected: boolean;
  70897. readonly isPresenting: boolean;
  70898. /**
  70899. * If this VRDisplay supports room-scale experiences, the optional
  70900. * stage attribute contains details on the room-scale parameters.
  70901. */
  70902. readonly stageParameters: VRStageParameters | null;
  70903. /**
  70904. * Passing the value returned by `requestAnimationFrame` to
  70905. * `cancelAnimationFrame` will unregister the callback.
  70906. * @param handle Define the hanle of the request to cancel
  70907. */
  70908. cancelAnimationFrame(handle: number): void;
  70909. /**
  70910. * Stops presenting to the VRDisplay.
  70911. * @returns a promise to know when it stopped
  70912. */
  70913. exitPresent(): Promise<void>;
  70914. /**
  70915. * Return the current VREyeParameters for the given eye.
  70916. * @param whichEye Define the eye we want the parameter for
  70917. * @returns the eye parameters
  70918. */
  70919. getEyeParameters(whichEye: string): VREyeParameters;
  70920. /**
  70921. * Populates the passed VRFrameData with the information required to render
  70922. * the current frame.
  70923. * @param frameData Define the data structure to populate
  70924. * @returns true if ok otherwise false
  70925. */
  70926. getFrameData(frameData: VRFrameData): boolean;
  70927. /**
  70928. * Get the layers currently being presented.
  70929. * @returns the list of VR layers
  70930. */
  70931. getLayers(): VRLayer[];
  70932. /**
  70933. * Return a VRPose containing the future predicted pose of the VRDisplay
  70934. * when the current frame will be presented. The value returned will not
  70935. * change until JavaScript has returned control to the browser.
  70936. *
  70937. * The VRPose will contain the position, orientation, velocity,
  70938. * and acceleration of each of these properties.
  70939. * @returns the pose object
  70940. */
  70941. getPose(): VRPose;
  70942. /**
  70943. * Return the current instantaneous pose of the VRDisplay, with no
  70944. * prediction applied.
  70945. * @returns the current instantaneous pose
  70946. */
  70947. getImmediatePose(): VRPose;
  70948. /**
  70949. * The callback passed to `requestAnimationFrame` will be called
  70950. * any time a new frame should be rendered. When the VRDisplay is
  70951. * presenting the callback will be called at the native refresh
  70952. * rate of the HMD. When not presenting this function acts
  70953. * identically to how window.requestAnimationFrame acts. Content should
  70954. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70955. * asynchronously from other displays and at differing refresh rates.
  70956. * @param callback Define the eaction to run next frame
  70957. * @returns the request handle it
  70958. */
  70959. requestAnimationFrame(callback: FrameRequestCallback): number;
  70960. /**
  70961. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70962. * Repeat calls while already presenting will update the VRLayers being displayed.
  70963. * @param layers Define the list of layer to present
  70964. * @returns a promise to know when the request has been fulfilled
  70965. */
  70966. requestPresent(layers: VRLayer[]): Promise<void>;
  70967. /**
  70968. * Reset the pose for this display, treating its current position and
  70969. * orientation as the "origin/zero" values. VRPose.position,
  70970. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70971. * updated when calling resetPose(). This should be called in only
  70972. * sitting-space experiences.
  70973. */
  70974. resetPose(): void;
  70975. /**
  70976. * The VRLayer provided to the VRDisplay will be captured and presented
  70977. * in the HMD. Calling this function has the same effect on the source
  70978. * canvas as any other operation that uses its source image, and canvases
  70979. * created without preserveDrawingBuffer set to true will be cleared.
  70980. * @param pose Define the pose to submit
  70981. */
  70982. submitFrame(pose?: VRPose): void;
  70983. }
  70984. declare var VRDisplay: {
  70985. prototype: VRDisplay;
  70986. new(): VRDisplay;
  70987. };
  70988. interface VRLayer {
  70989. leftBounds?: number[] | Float32Array | null;
  70990. rightBounds?: number[] | Float32Array | null;
  70991. source?: HTMLCanvasElement | null;
  70992. }
  70993. interface VRDisplayCapabilities {
  70994. readonly canPresent: boolean;
  70995. readonly hasExternalDisplay: boolean;
  70996. readonly hasOrientation: boolean;
  70997. readonly hasPosition: boolean;
  70998. readonly maxLayers: number;
  70999. }
  71000. interface VREyeParameters {
  71001. /** @deprecated */
  71002. readonly fieldOfView: VRFieldOfView;
  71003. readonly offset: Float32Array;
  71004. readonly renderHeight: number;
  71005. readonly renderWidth: number;
  71006. }
  71007. interface VRFieldOfView {
  71008. readonly downDegrees: number;
  71009. readonly leftDegrees: number;
  71010. readonly rightDegrees: number;
  71011. readonly upDegrees: number;
  71012. }
  71013. interface VRFrameData {
  71014. readonly leftProjectionMatrix: Float32Array;
  71015. readonly leftViewMatrix: Float32Array;
  71016. readonly pose: VRPose;
  71017. readonly rightProjectionMatrix: Float32Array;
  71018. readonly rightViewMatrix: Float32Array;
  71019. readonly timestamp: number;
  71020. }
  71021. interface VRPose {
  71022. readonly angularAcceleration: Float32Array | null;
  71023. readonly angularVelocity: Float32Array | null;
  71024. readonly linearAcceleration: Float32Array | null;
  71025. readonly linearVelocity: Float32Array | null;
  71026. readonly orientation: Float32Array | null;
  71027. readonly position: Float32Array | null;
  71028. readonly timestamp: number;
  71029. }
  71030. interface VRStageParameters {
  71031. sittingToStandingTransform?: Float32Array;
  71032. sizeX?: number;
  71033. sizeY?: number;
  71034. }
  71035. interface Navigator {
  71036. getVRDisplays(): Promise<VRDisplay[]>;
  71037. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  71038. }
  71039. interface Window {
  71040. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  71041. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  71042. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  71043. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71044. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71045. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  71046. }
  71047. interface Gamepad {
  71048. readonly displayId: number;
  71049. }
  71050. type XRSessionMode =
  71051. | "inline"
  71052. | "immersive-vr"
  71053. | "immersive-ar";
  71054. type XRReferenceSpaceType =
  71055. | "viewer"
  71056. | "local"
  71057. | "local-floor"
  71058. | "bounded-floor"
  71059. | "unbounded";
  71060. type XREnvironmentBlendMode =
  71061. | "opaque"
  71062. | "additive"
  71063. | "alpha-blend";
  71064. type XRVisibilityState =
  71065. | "visible"
  71066. | "visible-blurred"
  71067. | "hidden";
  71068. type XRHandedness =
  71069. | "none"
  71070. | "left"
  71071. | "right";
  71072. type XRTargetRayMode =
  71073. | "gaze"
  71074. | "tracked-pointer"
  71075. | "screen";
  71076. type XREye =
  71077. | "none"
  71078. | "left"
  71079. | "right";
  71080. type XREventType =
  71081. | "devicechange"
  71082. | "visibilitychange"
  71083. | "end"
  71084. | "inputsourceschange"
  71085. | "select"
  71086. | "selectstart"
  71087. | "selectend"
  71088. | "squeeze"
  71089. | "squeezestart"
  71090. | "squeezeend"
  71091. | "reset";
  71092. interface XRSpace extends EventTarget {
  71093. }
  71094. interface XRRenderState {
  71095. depthNear?: number;
  71096. depthFar?: number;
  71097. inlineVerticalFieldOfView?: number;
  71098. baseLayer?: XRWebGLLayer;
  71099. }
  71100. interface XRInputSource {
  71101. handedness: XRHandedness;
  71102. targetRayMode: XRTargetRayMode;
  71103. targetRaySpace: XRSpace;
  71104. gripSpace: XRSpace | undefined;
  71105. gamepad: Gamepad | undefined;
  71106. profiles: Array<string>;
  71107. }
  71108. interface XRSessionInit {
  71109. optionalFeatures?: XRReferenceSpaceType[];
  71110. requiredFeatures?: XRReferenceSpaceType[];
  71111. }
  71112. interface XRSession extends XRAnchorCreator {
  71113. addEventListener: Function;
  71114. removeEventListener: Function;
  71115. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  71116. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  71117. requestAnimationFrame: Function;
  71118. end(): Promise<void>;
  71119. renderState: XRRenderState;
  71120. inputSources: Array<XRInputSource>;
  71121. // hit test
  71122. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  71123. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  71124. // legacy AR hit test
  71125. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71126. // legacy plane detection
  71127. updateWorldTrackingState(options: {
  71128. planeDetectionState?: { enabled: boolean; }
  71129. }): void;
  71130. }
  71131. interface XRReferenceSpace extends XRSpace {
  71132. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  71133. onreset: any;
  71134. }
  71135. type XRPlaneSet = Set<XRPlane>;
  71136. type XRAnchorSet = Set<XRAnchor>;
  71137. interface XRFrame {
  71138. session: XRSession;
  71139. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  71140. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  71141. // AR
  71142. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  71143. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  71144. // Anchors
  71145. trackedAnchors?: XRAnchorSet;
  71146. // Planes
  71147. worldInformation: {
  71148. detectedPlanes?: XRPlaneSet;
  71149. };
  71150. }
  71151. interface XRViewerPose extends XRPose {
  71152. views: Array<XRView>;
  71153. }
  71154. interface XRPose {
  71155. transform: XRRigidTransform;
  71156. emulatedPosition: boolean;
  71157. }
  71158. interface XRWebGLLayerOptions {
  71159. antialias?: boolean;
  71160. depth?: boolean;
  71161. stencil?: boolean;
  71162. alpha?: boolean;
  71163. multiview?: boolean;
  71164. framebufferScaleFactor?: number;
  71165. }
  71166. declare var XRWebGLLayer: {
  71167. prototype: XRWebGLLayer;
  71168. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  71169. };
  71170. interface XRWebGLLayer {
  71171. framebuffer: WebGLFramebuffer;
  71172. framebufferWidth: number;
  71173. framebufferHeight: number;
  71174. getViewport: Function;
  71175. }
  71176. declare class XRRigidTransform {
  71177. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  71178. position: DOMPointReadOnly;
  71179. orientation: DOMPointReadOnly;
  71180. matrix: Float32Array;
  71181. inverse: XRRigidTransform;
  71182. }
  71183. interface XRView {
  71184. eye: XREye;
  71185. projectionMatrix: Float32Array;
  71186. transform: XRRigidTransform;
  71187. }
  71188. interface XRInputSourceChangeEvent {
  71189. session: XRSession;
  71190. removed: Array<XRInputSource>;
  71191. added: Array<XRInputSource>;
  71192. }
  71193. interface XRInputSourceEvent extends Event {
  71194. readonly frame: XRFrame;
  71195. readonly inputSource: XRInputSource;
  71196. }
  71197. // Experimental(er) features
  71198. declare class XRRay {
  71199. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  71200. origin: DOMPointReadOnly;
  71201. direction: DOMPointReadOnly;
  71202. matrix: Float32Array;
  71203. }
  71204. declare enum XRHitTestTrackableType {
  71205. "point",
  71206. "plane"
  71207. }
  71208. interface XRHitResult {
  71209. hitMatrix: Float32Array;
  71210. }
  71211. interface XRTransientInputHitTestResult {
  71212. readonly inputSource: XRInputSource;
  71213. readonly results: Array<XRHitTestResult>;
  71214. }
  71215. interface XRHitTestResult {
  71216. getPose(baseSpace: XRSpace): XRPose | undefined;
  71217. }
  71218. interface XRHitTestSource {
  71219. cancel(): void;
  71220. }
  71221. interface XRTransientInputHitTestSource {
  71222. cancel(): void;
  71223. }
  71224. interface XRHitTestOptionsInit {
  71225. space: XRSpace;
  71226. entityTypes?: Array<XRHitTestTrackableType>;
  71227. offsetRay?: XRRay;
  71228. }
  71229. interface XRTransientInputHitTestOptionsInit {
  71230. profile: string;
  71231. entityTypes?: Array<XRHitTestTrackableType>;
  71232. offsetRay?: XRRay;
  71233. }
  71234. interface XRAnchor {
  71235. // remove?
  71236. id?: string;
  71237. anchorSpace: XRSpace;
  71238. lastChangedTime: number;
  71239. detach(): void;
  71240. }
  71241. interface XRPlane extends XRAnchorCreator {
  71242. orientation: "Horizontal" | "Vertical";
  71243. planeSpace: XRSpace;
  71244. polygon: Array<DOMPointReadOnly>;
  71245. lastChangedTime: number;
  71246. }
  71247. interface XRAnchorCreator {
  71248. // AR Anchors
  71249. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71250. }
  71251. /**
  71252. * @ignore
  71253. */
  71254. declare module BABYLON.GLTF2.Exporter {
  71255. }
  71256. /**
  71257. * @ignore
  71258. */
  71259. declare module BABYLON.GLTF1 {
  71260. }
  71261. declare module BABYLON.GUI {
  71262. /**
  71263. * Class used to specific a value and its associated unit
  71264. */
  71265. export class ValueAndUnit {
  71266. /** defines the unit to store */
  71267. unit: number;
  71268. /** defines a boolean indicating if the value can be negative */
  71269. negativeValueAllowed: boolean;
  71270. private _value;
  71271. private _originalUnit;
  71272. /**
  71273. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71274. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71275. */
  71276. ignoreAdaptiveScaling: boolean;
  71277. /**
  71278. * Creates a new ValueAndUnit
  71279. * @param value defines the value to store
  71280. * @param unit defines the unit to store
  71281. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71282. */
  71283. constructor(value: number,
  71284. /** defines the unit to store */
  71285. unit?: number,
  71286. /** defines a boolean indicating if the value can be negative */
  71287. negativeValueAllowed?: boolean);
  71288. /** Gets a boolean indicating if the value is a percentage */
  71289. get isPercentage(): boolean;
  71290. /** Gets a boolean indicating if the value is store as pixel */
  71291. get isPixel(): boolean;
  71292. /** Gets direct internal value */
  71293. get internalValue(): number;
  71294. /**
  71295. * Gets value as pixel
  71296. * @param host defines the root host
  71297. * @param refValue defines the reference value for percentages
  71298. * @returns the value as pixel
  71299. */
  71300. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71301. /**
  71302. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71303. * @param value defines the value to store
  71304. * @param unit defines the unit to store
  71305. * @returns the current ValueAndUnit
  71306. */
  71307. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71308. /**
  71309. * Gets the value accordingly to its unit
  71310. * @param host defines the root host
  71311. * @returns the value
  71312. */
  71313. getValue(host: AdvancedDynamicTexture): number;
  71314. /**
  71315. * Gets a string representation of the value
  71316. * @param host defines the root host
  71317. * @param decimals defines an optional number of decimals to display
  71318. * @returns a string
  71319. */
  71320. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71321. /**
  71322. * Store a value parsed from a string
  71323. * @param source defines the source string
  71324. * @returns true if the value was successfully parsed
  71325. */
  71326. fromString(source: string | number): boolean;
  71327. private static _Regex;
  71328. private static _UNITMODE_PERCENTAGE;
  71329. private static _UNITMODE_PIXEL;
  71330. /** UNITMODE_PERCENTAGE */
  71331. static get UNITMODE_PERCENTAGE(): number;
  71332. /** UNITMODE_PIXEL */
  71333. static get UNITMODE_PIXEL(): number;
  71334. }
  71335. }
  71336. declare module BABYLON.GUI {
  71337. /**
  71338. * Define a style used by control to automatically setup properties based on a template.
  71339. * Only support font related properties so far
  71340. */
  71341. export class Style implements BABYLON.IDisposable {
  71342. private _fontFamily;
  71343. private _fontStyle;
  71344. private _fontWeight;
  71345. /** @hidden */
  71346. _host: AdvancedDynamicTexture;
  71347. /** @hidden */
  71348. _fontSize: ValueAndUnit;
  71349. /**
  71350. * BABYLON.Observable raised when the style values are changed
  71351. */
  71352. onChangedObservable: BABYLON.Observable<Style>;
  71353. /**
  71354. * Creates a new style object
  71355. * @param host defines the AdvancedDynamicTexture which hosts this style
  71356. */
  71357. constructor(host: AdvancedDynamicTexture);
  71358. /**
  71359. * Gets or sets the font size
  71360. */
  71361. get fontSize(): string | number;
  71362. set fontSize(value: string | number);
  71363. /**
  71364. * Gets or sets the font family
  71365. */
  71366. get fontFamily(): string;
  71367. set fontFamily(value: string);
  71368. /**
  71369. * Gets or sets the font style
  71370. */
  71371. get fontStyle(): string;
  71372. set fontStyle(value: string);
  71373. /** Gets or sets font weight */
  71374. get fontWeight(): string;
  71375. set fontWeight(value: string);
  71376. /** Dispose all associated resources */
  71377. dispose(): void;
  71378. }
  71379. }
  71380. declare module BABYLON.GUI {
  71381. /**
  71382. * Class used to transport BABYLON.Vector2 information for pointer events
  71383. */
  71384. export class Vector2WithInfo extends BABYLON.Vector2 {
  71385. /** defines the current mouse button index */
  71386. buttonIndex: number;
  71387. /**
  71388. * Creates a new Vector2WithInfo
  71389. * @param source defines the vector2 data to transport
  71390. * @param buttonIndex defines the current mouse button index
  71391. */
  71392. constructor(source: BABYLON.Vector2,
  71393. /** defines the current mouse button index */
  71394. buttonIndex?: number);
  71395. }
  71396. /** Class used to provide 2D matrix features */
  71397. export class Matrix2D {
  71398. /** Gets the internal array of 6 floats used to store matrix data */
  71399. m: Float32Array;
  71400. /**
  71401. * Creates a new matrix
  71402. * @param m00 defines value for (0, 0)
  71403. * @param m01 defines value for (0, 1)
  71404. * @param m10 defines value for (1, 0)
  71405. * @param m11 defines value for (1, 1)
  71406. * @param m20 defines value for (2, 0)
  71407. * @param m21 defines value for (2, 1)
  71408. */
  71409. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71410. /**
  71411. * Fills the matrix from direct values
  71412. * @param m00 defines value for (0, 0)
  71413. * @param m01 defines value for (0, 1)
  71414. * @param m10 defines value for (1, 0)
  71415. * @param m11 defines value for (1, 1)
  71416. * @param m20 defines value for (2, 0)
  71417. * @param m21 defines value for (2, 1)
  71418. * @returns the current modified matrix
  71419. */
  71420. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71421. /**
  71422. * Gets matrix determinant
  71423. * @returns the determinant
  71424. */
  71425. determinant(): number;
  71426. /**
  71427. * Inverses the matrix and stores it in a target matrix
  71428. * @param result defines the target matrix
  71429. * @returns the current matrix
  71430. */
  71431. invertToRef(result: Matrix2D): Matrix2D;
  71432. /**
  71433. * Multiplies the current matrix with another one
  71434. * @param other defines the second operand
  71435. * @param result defines the target matrix
  71436. * @returns the current matrix
  71437. */
  71438. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71439. /**
  71440. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71441. * @param x defines the x coordinate to transform
  71442. * @param y defines the x coordinate to transform
  71443. * @param result defines the target vector2
  71444. * @returns the current matrix
  71445. */
  71446. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71447. /**
  71448. * Creates an identity matrix
  71449. * @returns a new matrix
  71450. */
  71451. static Identity(): Matrix2D;
  71452. /**
  71453. * Creates a translation matrix and stores it in a target matrix
  71454. * @param x defines the x coordinate of the translation
  71455. * @param y defines the y coordinate of the translation
  71456. * @param result defines the target matrix
  71457. */
  71458. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71459. /**
  71460. * Creates a scaling matrix and stores it in a target matrix
  71461. * @param x defines the x coordinate of the scaling
  71462. * @param y defines the y coordinate of the scaling
  71463. * @param result defines the target matrix
  71464. */
  71465. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71466. /**
  71467. * Creates a rotation matrix and stores it in a target matrix
  71468. * @param angle defines the rotation angle
  71469. * @param result defines the target matrix
  71470. */
  71471. static RotationToRef(angle: number, result: Matrix2D): void;
  71472. private static _TempPreTranslationMatrix;
  71473. private static _TempPostTranslationMatrix;
  71474. private static _TempRotationMatrix;
  71475. private static _TempScalingMatrix;
  71476. private static _TempCompose0;
  71477. private static _TempCompose1;
  71478. private static _TempCompose2;
  71479. /**
  71480. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71481. * @param tx defines the x coordinate of the translation
  71482. * @param ty defines the y coordinate of the translation
  71483. * @param angle defines the rotation angle
  71484. * @param scaleX defines the x coordinate of the scaling
  71485. * @param scaleY defines the y coordinate of the scaling
  71486. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71487. * @param result defines the target matrix
  71488. */
  71489. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71490. }
  71491. }
  71492. declare module BABYLON.GUI {
  71493. /**
  71494. * Class used to store 2D control sizes
  71495. */
  71496. export class Measure {
  71497. /** defines left coordinate */
  71498. left: number;
  71499. /** defines top coordinate */
  71500. top: number;
  71501. /** defines width dimension */
  71502. width: number;
  71503. /** defines height dimension */
  71504. height: number;
  71505. /**
  71506. * Creates a new measure
  71507. * @param left defines left coordinate
  71508. * @param top defines top coordinate
  71509. * @param width defines width dimension
  71510. * @param height defines height dimension
  71511. */
  71512. constructor(
  71513. /** defines left coordinate */
  71514. left: number,
  71515. /** defines top coordinate */
  71516. top: number,
  71517. /** defines width dimension */
  71518. width: number,
  71519. /** defines height dimension */
  71520. height: number);
  71521. /**
  71522. * Copy from another measure
  71523. * @param other defines the other measure to copy from
  71524. */
  71525. copyFrom(other: Measure): void;
  71526. /**
  71527. * Copy from a group of 4 floats
  71528. * @param left defines left coordinate
  71529. * @param top defines top coordinate
  71530. * @param width defines width dimension
  71531. * @param height defines height dimension
  71532. */
  71533. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71534. /**
  71535. * Computes the axis aligned bounding box measure for two given measures
  71536. * @param a Input measure
  71537. * @param b Input measure
  71538. * @param result the resulting bounding measure
  71539. */
  71540. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71541. /**
  71542. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71543. * @param transform the matrix to transform the measure before computing the AABB
  71544. * @param result the resulting AABB
  71545. */
  71546. transformToRef(transform: Matrix2D, result: Measure): void;
  71547. /**
  71548. * Check equality between this measure and another one
  71549. * @param other defines the other measures
  71550. * @returns true if both measures are equals
  71551. */
  71552. isEqualsTo(other: Measure): boolean;
  71553. /**
  71554. * Creates an empty measure
  71555. * @returns a new measure
  71556. */
  71557. static Empty(): Measure;
  71558. }
  71559. }
  71560. declare module BABYLON.GUI {
  71561. /**
  71562. * Interface used to define a control that can receive focus
  71563. */
  71564. export interface IFocusableControl {
  71565. /**
  71566. * Function called when the control receives the focus
  71567. */
  71568. onFocus(): void;
  71569. /**
  71570. * Function called when the control loses the focus
  71571. */
  71572. onBlur(): void;
  71573. /**
  71574. * Function called to let the control handle keyboard events
  71575. * @param evt defines the current keyboard event
  71576. */
  71577. processKeyboard(evt: KeyboardEvent): void;
  71578. /**
  71579. * Function called to get the list of controls that should not steal the focus from this control
  71580. * @returns an array of controls
  71581. */
  71582. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71583. }
  71584. /**
  71585. * Class used to create texture to support 2D GUI elements
  71586. * @see http://doc.babylonjs.com/how_to/gui
  71587. */
  71588. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71589. private _isDirty;
  71590. private _renderObserver;
  71591. private _resizeObserver;
  71592. private _preKeyboardObserver;
  71593. private _pointerMoveObserver;
  71594. private _pointerObserver;
  71595. private _canvasPointerOutObserver;
  71596. private _background;
  71597. /** @hidden */
  71598. _rootContainer: Container;
  71599. /** @hidden */
  71600. _lastPickedControl: Control;
  71601. /** @hidden */
  71602. _lastControlOver: {
  71603. [pointerId: number]: Control;
  71604. };
  71605. /** @hidden */
  71606. _lastControlDown: {
  71607. [pointerId: number]: Control;
  71608. };
  71609. /** @hidden */
  71610. _capturingControl: {
  71611. [pointerId: number]: Control;
  71612. };
  71613. /** @hidden */
  71614. _shouldBlockPointer: boolean;
  71615. /** @hidden */
  71616. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71617. /** @hidden */
  71618. _linkedControls: Control[];
  71619. private _isFullscreen;
  71620. private _fullscreenViewport;
  71621. private _idealWidth;
  71622. private _idealHeight;
  71623. private _useSmallestIdeal;
  71624. private _renderAtIdealSize;
  71625. private _focusedControl;
  71626. private _blockNextFocusCheck;
  71627. private _renderScale;
  71628. private _rootElement;
  71629. private _cursorChanged;
  71630. private _defaultMousePointerId;
  71631. /** @hidden */
  71632. _numLayoutCalls: number;
  71633. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71634. get numLayoutCalls(): number;
  71635. /** @hidden */
  71636. _numRenderCalls: number;
  71637. /** Gets the number of render calls made the last time the ADT has been rendered */
  71638. get numRenderCalls(): number;
  71639. /**
  71640. * Define type to string to ensure compatibility across browsers
  71641. * Safari doesn't support DataTransfer constructor
  71642. */
  71643. private _clipboardData;
  71644. /**
  71645. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71646. */
  71647. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71648. /**
  71649. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71650. */
  71651. onControlPickedObservable: BABYLON.Observable<Control>;
  71652. /**
  71653. * BABYLON.Observable event triggered before layout is evaluated
  71654. */
  71655. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71656. /**
  71657. * BABYLON.Observable event triggered after the layout was evaluated
  71658. */
  71659. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71660. /**
  71661. * BABYLON.Observable event triggered before the texture is rendered
  71662. */
  71663. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71664. /**
  71665. * BABYLON.Observable event triggered after the texture was rendered
  71666. */
  71667. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71668. /**
  71669. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71670. */
  71671. premulAlpha: boolean;
  71672. /**
  71673. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71674. * Useful when you want more antialiasing
  71675. */
  71676. get renderScale(): number;
  71677. set renderScale(value: number);
  71678. /** Gets or sets the background color */
  71679. get background(): string;
  71680. set background(value: string);
  71681. /**
  71682. * Gets or sets the ideal width used to design controls.
  71683. * The GUI will then rescale everything accordingly
  71684. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71685. */
  71686. get idealWidth(): number;
  71687. set idealWidth(value: number);
  71688. /**
  71689. * Gets or sets the ideal height used to design controls.
  71690. * The GUI will then rescale everything accordingly
  71691. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71692. */
  71693. get idealHeight(): number;
  71694. set idealHeight(value: number);
  71695. /**
  71696. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71697. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71698. */
  71699. get useSmallestIdeal(): boolean;
  71700. set useSmallestIdeal(value: boolean);
  71701. /**
  71702. * Gets or sets a boolean indicating if adaptive scaling must be used
  71703. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71704. */
  71705. get renderAtIdealSize(): boolean;
  71706. set renderAtIdealSize(value: boolean);
  71707. /**
  71708. * Gets the ratio used when in "ideal mode"
  71709. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71710. * */
  71711. get idealRatio(): number;
  71712. /**
  71713. * Gets the underlying layer used to render the texture when in fullscreen mode
  71714. */
  71715. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71716. /**
  71717. * Gets the root container control
  71718. */
  71719. get rootContainer(): Container;
  71720. /**
  71721. * Returns an array containing the root container.
  71722. * This is mostly used to let the Inspector introspects the ADT
  71723. * @returns an array containing the rootContainer
  71724. */
  71725. getChildren(): Array<Container>;
  71726. /**
  71727. * Will return all controls that are inside this texture
  71728. * @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
  71729. * @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
  71730. * @return all child controls
  71731. */
  71732. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71733. /**
  71734. * Gets or sets the current focused control
  71735. */
  71736. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71737. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71738. /**
  71739. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71740. */
  71741. get isForeground(): boolean;
  71742. set isForeground(value: boolean);
  71743. /**
  71744. * Gets or set information about clipboardData
  71745. */
  71746. get clipboardData(): string;
  71747. set clipboardData(value: string);
  71748. /**
  71749. * Creates a new AdvancedDynamicTexture
  71750. * @param name defines the name of the texture
  71751. * @param width defines the width of the texture
  71752. * @param height defines the height of the texture
  71753. * @param scene defines the hosting scene
  71754. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71755. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71756. */
  71757. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71758. /**
  71759. * Get the current class name of the texture useful for serialization or dynamic coding.
  71760. * @returns "AdvancedDynamicTexture"
  71761. */
  71762. getClassName(): string;
  71763. /**
  71764. * Function used to execute a function on all controls
  71765. * @param func defines the function to execute
  71766. * @param container defines the container where controls belong. If null the root container will be used
  71767. */
  71768. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71769. private _useInvalidateRectOptimization;
  71770. /**
  71771. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71772. */
  71773. get useInvalidateRectOptimization(): boolean;
  71774. set useInvalidateRectOptimization(value: boolean);
  71775. private _invalidatedRectangle;
  71776. /**
  71777. * Invalidates a rectangle area on the gui texture
  71778. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71779. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71780. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71781. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71782. */
  71783. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71784. /**
  71785. * Marks the texture as dirty forcing a complete update
  71786. */
  71787. markAsDirty(): void;
  71788. /**
  71789. * Helper function used to create a new style
  71790. * @returns a new style
  71791. * @see http://doc.babylonjs.com/how_to/gui#styles
  71792. */
  71793. createStyle(): Style;
  71794. /**
  71795. * Adds a new control to the root container
  71796. * @param control defines the control to add
  71797. * @returns the current texture
  71798. */
  71799. addControl(control: Control): AdvancedDynamicTexture;
  71800. /**
  71801. * Removes a control from the root container
  71802. * @param control defines the control to remove
  71803. * @returns the current texture
  71804. */
  71805. removeControl(control: Control): AdvancedDynamicTexture;
  71806. /**
  71807. * Release all resources
  71808. */
  71809. dispose(): void;
  71810. private _onResize;
  71811. /** @hidden */
  71812. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71813. /**
  71814. * Get screen coordinates for a vector3
  71815. * @param position defines the position to project
  71816. * @param worldMatrix defines the world matrix to use
  71817. * @returns the projected position
  71818. */
  71819. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71820. private _checkUpdate;
  71821. private _clearMeasure;
  71822. private _render;
  71823. /** @hidden */
  71824. _changeCursor(cursor: string): void;
  71825. /** @hidden */
  71826. _registerLastControlDown(control: Control, pointerId: number): void;
  71827. private _doPicking;
  71828. /** @hidden */
  71829. _cleanControlAfterRemovalFromList(list: {
  71830. [pointerId: number]: Control;
  71831. }, control: Control): void;
  71832. /** @hidden */
  71833. _cleanControlAfterRemoval(control: Control): void;
  71834. /** Attach to all scene events required to support pointer events */
  71835. attach(): void;
  71836. /** @hidden */
  71837. private onClipboardCopy;
  71838. /** @hidden */
  71839. private onClipboardCut;
  71840. /** @hidden */
  71841. private onClipboardPaste;
  71842. /**
  71843. * Register the clipboard Events onto the canvas
  71844. */
  71845. registerClipboardEvents(): void;
  71846. /**
  71847. * Unregister the clipboard Events from the canvas
  71848. */
  71849. unRegisterClipboardEvents(): void;
  71850. /**
  71851. * Connect the texture to a hosting mesh to enable interactions
  71852. * @param mesh defines the mesh to attach to
  71853. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71854. */
  71855. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71856. /**
  71857. * Move the focus to a specific control
  71858. * @param control defines the control which will receive the focus
  71859. */
  71860. moveFocusToControl(control: IFocusableControl): void;
  71861. private _manageFocus;
  71862. private _attachToOnPointerOut;
  71863. /**
  71864. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71865. * @param mesh defines the mesh which will receive the texture
  71866. * @param width defines the texture width (1024 by default)
  71867. * @param height defines the texture height (1024 by default)
  71868. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71869. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71870. * @returns a new AdvancedDynamicTexture
  71871. */
  71872. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71873. /**
  71874. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71875. * In this mode the texture will rely on a layer for its rendering.
  71876. * This allows it to be treated like any other layer.
  71877. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71878. * LayerMask is set through advancedTexture.layer.layerMask
  71879. * @param name defines name for the texture
  71880. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71881. * @param scene defines the hsoting scene
  71882. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71883. * @returns a new AdvancedDynamicTexture
  71884. */
  71885. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71886. }
  71887. }
  71888. declare module BABYLON.GUI {
  71889. /**
  71890. * Root class used for all 2D controls
  71891. * @see http://doc.babylonjs.com/how_to/gui#controls
  71892. */
  71893. export class Control {
  71894. /** defines the name of the control */
  71895. name?: string | undefined;
  71896. /**
  71897. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71898. */
  71899. static AllowAlphaInheritance: boolean;
  71900. private _alpha;
  71901. private _alphaSet;
  71902. private _zIndex;
  71903. /** @hidden */
  71904. _host: AdvancedDynamicTexture;
  71905. /** Gets or sets the control parent */
  71906. parent: BABYLON.Nullable<Container>;
  71907. /** @hidden */
  71908. _currentMeasure: Measure;
  71909. private _fontFamily;
  71910. private _fontStyle;
  71911. private _fontWeight;
  71912. private _fontSize;
  71913. private _font;
  71914. /** @hidden */
  71915. _width: ValueAndUnit;
  71916. /** @hidden */
  71917. _height: ValueAndUnit;
  71918. /** @hidden */
  71919. protected _fontOffset: {
  71920. ascent: number;
  71921. height: number;
  71922. descent: number;
  71923. };
  71924. private _color;
  71925. private _style;
  71926. private _styleObserver;
  71927. /** @hidden */
  71928. protected _horizontalAlignment: number;
  71929. /** @hidden */
  71930. protected _verticalAlignment: number;
  71931. /** @hidden */
  71932. protected _isDirty: boolean;
  71933. /** @hidden */
  71934. protected _wasDirty: boolean;
  71935. /** @hidden */
  71936. _tempParentMeasure: Measure;
  71937. /** @hidden */
  71938. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71939. /** @hidden */
  71940. protected _cachedParentMeasure: Measure;
  71941. private _paddingLeft;
  71942. private _paddingRight;
  71943. private _paddingTop;
  71944. private _paddingBottom;
  71945. /** @hidden */
  71946. _left: ValueAndUnit;
  71947. /** @hidden */
  71948. _top: ValueAndUnit;
  71949. private _scaleX;
  71950. private _scaleY;
  71951. private _rotation;
  71952. private _transformCenterX;
  71953. private _transformCenterY;
  71954. /** @hidden */
  71955. _transformMatrix: Matrix2D;
  71956. /** @hidden */
  71957. protected _invertTransformMatrix: Matrix2D;
  71958. /** @hidden */
  71959. protected _transformedPosition: BABYLON.Vector2;
  71960. private _isMatrixDirty;
  71961. private _cachedOffsetX;
  71962. private _cachedOffsetY;
  71963. private _isVisible;
  71964. private _isHighlighted;
  71965. /** @hidden */
  71966. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71967. private _fontSet;
  71968. private _dummyVector2;
  71969. private _downCount;
  71970. private _enterCount;
  71971. private _doNotRender;
  71972. private _downPointerIds;
  71973. protected _isEnabled: boolean;
  71974. protected _disabledColor: string;
  71975. protected _disabledColorItem: string;
  71976. /** @hidden */
  71977. protected _rebuildLayout: boolean;
  71978. /** @hidden */
  71979. _customData: any;
  71980. /** @hidden */
  71981. _isClipped: boolean;
  71982. /** @hidden */
  71983. _automaticSize: boolean;
  71984. /** @hidden */
  71985. _tag: any;
  71986. /**
  71987. * 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
  71988. */
  71989. uniqueId: number;
  71990. /**
  71991. * Gets or sets an object used to store user defined information for the node
  71992. */
  71993. metadata: any;
  71994. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71995. isHitTestVisible: boolean;
  71996. /** Gets or sets a boolean indicating if the control can block pointer events */
  71997. isPointerBlocker: boolean;
  71998. /** Gets or sets a boolean indicating if the control can be focusable */
  71999. isFocusInvisible: boolean;
  72000. /**
  72001. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  72002. * 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
  72003. */
  72004. clipChildren: boolean;
  72005. /**
  72006. * Gets or sets a boolean indicating that control content must be clipped
  72007. * 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
  72008. */
  72009. clipContent: boolean;
  72010. /**
  72011. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  72012. */
  72013. useBitmapCache: boolean;
  72014. private _cacheData;
  72015. private _shadowOffsetX;
  72016. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  72017. get shadowOffsetX(): number;
  72018. set shadowOffsetX(value: number);
  72019. private _shadowOffsetY;
  72020. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  72021. get shadowOffsetY(): number;
  72022. set shadowOffsetY(value: number);
  72023. private _shadowBlur;
  72024. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  72025. get shadowBlur(): number;
  72026. set shadowBlur(value: number);
  72027. private _shadowColor;
  72028. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  72029. get shadowColor(): string;
  72030. set shadowColor(value: string);
  72031. /** Gets or sets the cursor to use when the control is hovered */
  72032. hoverCursor: string;
  72033. /** @hidden */
  72034. protected _linkOffsetX: ValueAndUnit;
  72035. /** @hidden */
  72036. protected _linkOffsetY: ValueAndUnit;
  72037. /** Gets the control type name */
  72038. get typeName(): string;
  72039. /**
  72040. * Get the current class name of the control.
  72041. * @returns current class name
  72042. */
  72043. getClassName(): string;
  72044. /**
  72045. * An event triggered when pointer wheel is scrolled
  72046. */
  72047. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  72048. /**
  72049. * An event triggered when the pointer move over the control.
  72050. */
  72051. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  72052. /**
  72053. * An event triggered when the pointer move out of the control.
  72054. */
  72055. onPointerOutObservable: BABYLON.Observable<Control>;
  72056. /**
  72057. * An event triggered when the pointer taps the control
  72058. */
  72059. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  72060. /**
  72061. * An event triggered when pointer up
  72062. */
  72063. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  72064. /**
  72065. * An event triggered when a control is clicked on
  72066. */
  72067. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  72068. /**
  72069. * An event triggered when pointer enters the control
  72070. */
  72071. onPointerEnterObservable: BABYLON.Observable<Control>;
  72072. /**
  72073. * An event triggered when the control is marked as dirty
  72074. */
  72075. onDirtyObservable: BABYLON.Observable<Control>;
  72076. /**
  72077. * An event triggered before drawing the control
  72078. */
  72079. onBeforeDrawObservable: BABYLON.Observable<Control>;
  72080. /**
  72081. * An event triggered after the control was drawn
  72082. */
  72083. onAfterDrawObservable: BABYLON.Observable<Control>;
  72084. /**
  72085. * Get the hosting AdvancedDynamicTexture
  72086. */
  72087. get host(): AdvancedDynamicTexture;
  72088. /** Gets or set information about font offsets (used to render and align text) */
  72089. get fontOffset(): {
  72090. ascent: number;
  72091. height: number;
  72092. descent: number;
  72093. };
  72094. set fontOffset(offset: {
  72095. ascent: number;
  72096. height: number;
  72097. descent: number;
  72098. });
  72099. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  72100. get alpha(): number;
  72101. set alpha(value: number);
  72102. /**
  72103. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  72104. */
  72105. get isHighlighted(): boolean;
  72106. set isHighlighted(value: boolean);
  72107. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  72108. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72109. */
  72110. get scaleX(): number;
  72111. set scaleX(value: number);
  72112. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  72113. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72114. */
  72115. get scaleY(): number;
  72116. set scaleY(value: number);
  72117. /** Gets or sets the rotation angle (0 by default)
  72118. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72119. */
  72120. get rotation(): number;
  72121. set rotation(value: number);
  72122. /** Gets or sets the transformation center on Y axis (0 by default)
  72123. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72124. */
  72125. get transformCenterY(): number;
  72126. set transformCenterY(value: number);
  72127. /** Gets or sets the transformation center on X axis (0 by default)
  72128. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72129. */
  72130. get transformCenterX(): number;
  72131. set transformCenterX(value: number);
  72132. /**
  72133. * Gets or sets the horizontal alignment
  72134. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72135. */
  72136. get horizontalAlignment(): number;
  72137. set horizontalAlignment(value: number);
  72138. /**
  72139. * Gets or sets the vertical alignment
  72140. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72141. */
  72142. get verticalAlignment(): number;
  72143. set verticalAlignment(value: number);
  72144. /**
  72145. * Gets or sets control width
  72146. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72147. */
  72148. get width(): string | number;
  72149. set width(value: string | number);
  72150. /**
  72151. * Gets or sets the control width in pixel
  72152. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72153. */
  72154. get widthInPixels(): number;
  72155. set widthInPixels(value: number);
  72156. /**
  72157. * Gets or sets control height
  72158. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72159. */
  72160. get height(): string | number;
  72161. set height(value: string | number);
  72162. /**
  72163. * Gets or sets control height in pixel
  72164. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72165. */
  72166. get heightInPixels(): number;
  72167. set heightInPixels(value: number);
  72168. /** Gets or set font family */
  72169. get fontFamily(): string;
  72170. set fontFamily(value: string);
  72171. /** Gets or sets font style */
  72172. get fontStyle(): string;
  72173. set fontStyle(value: string);
  72174. /** Gets or sets font weight */
  72175. get fontWeight(): string;
  72176. set fontWeight(value: string);
  72177. /**
  72178. * Gets or sets style
  72179. * @see http://doc.babylonjs.com/how_to/gui#styles
  72180. */
  72181. get style(): BABYLON.Nullable<Style>;
  72182. set style(value: BABYLON.Nullable<Style>);
  72183. /** @hidden */
  72184. get _isFontSizeInPercentage(): boolean;
  72185. /** Gets or sets font size in pixels */
  72186. get fontSizeInPixels(): number;
  72187. set fontSizeInPixels(value: number);
  72188. /** Gets or sets font size */
  72189. get fontSize(): string | number;
  72190. set fontSize(value: string | number);
  72191. /** Gets or sets foreground color */
  72192. get color(): string;
  72193. set color(value: string);
  72194. /** Gets or sets z index which is used to reorder controls on the z axis */
  72195. get zIndex(): number;
  72196. set zIndex(value: number);
  72197. /** Gets or sets a boolean indicating if the control can be rendered */
  72198. get notRenderable(): boolean;
  72199. set notRenderable(value: boolean);
  72200. /** Gets or sets a boolean indicating if the control is visible */
  72201. get isVisible(): boolean;
  72202. set isVisible(value: boolean);
  72203. /** Gets a boolean indicating that the control needs to update its rendering */
  72204. get isDirty(): boolean;
  72205. /**
  72206. * Gets the current linked mesh (or null if none)
  72207. */
  72208. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72209. /**
  72210. * Gets or sets a value indicating the padding to use on the left of the control
  72211. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72212. */
  72213. get paddingLeft(): string | number;
  72214. set paddingLeft(value: string | number);
  72215. /**
  72216. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  72217. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72218. */
  72219. get paddingLeftInPixels(): number;
  72220. set paddingLeftInPixels(value: number);
  72221. /**
  72222. * Gets or sets a value indicating the padding to use on the right of the control
  72223. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72224. */
  72225. get paddingRight(): string | number;
  72226. set paddingRight(value: string | number);
  72227. /**
  72228. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72229. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72230. */
  72231. get paddingRightInPixels(): number;
  72232. set paddingRightInPixels(value: number);
  72233. /**
  72234. * Gets or sets a value indicating the padding to use on the top of the control
  72235. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72236. */
  72237. get paddingTop(): string | number;
  72238. set paddingTop(value: string | number);
  72239. /**
  72240. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72241. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72242. */
  72243. get paddingTopInPixels(): number;
  72244. set paddingTopInPixels(value: number);
  72245. /**
  72246. * Gets or sets a value indicating the padding to use on the bottom of the control
  72247. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72248. */
  72249. get paddingBottom(): string | number;
  72250. set paddingBottom(value: string | number);
  72251. /**
  72252. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72253. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72254. */
  72255. get paddingBottomInPixels(): number;
  72256. set paddingBottomInPixels(value: number);
  72257. /**
  72258. * Gets or sets a value indicating the left coordinate of the control
  72259. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72260. */
  72261. get left(): string | number;
  72262. set left(value: string | number);
  72263. /**
  72264. * Gets or sets a value indicating the left coordinate in pixels of the control
  72265. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72266. */
  72267. get leftInPixels(): number;
  72268. set leftInPixels(value: number);
  72269. /**
  72270. * Gets or sets a value indicating the top coordinate of the control
  72271. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72272. */
  72273. get top(): string | number;
  72274. set top(value: string | number);
  72275. /**
  72276. * Gets or sets a value indicating the top coordinate in pixels of the control
  72277. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72278. */
  72279. get topInPixels(): number;
  72280. set topInPixels(value: number);
  72281. /**
  72282. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72283. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72284. */
  72285. get linkOffsetX(): string | number;
  72286. set linkOffsetX(value: string | number);
  72287. /**
  72288. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72289. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72290. */
  72291. get linkOffsetXInPixels(): number;
  72292. set linkOffsetXInPixels(value: number);
  72293. /**
  72294. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72295. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72296. */
  72297. get linkOffsetY(): string | number;
  72298. set linkOffsetY(value: string | number);
  72299. /**
  72300. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72301. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72302. */
  72303. get linkOffsetYInPixels(): number;
  72304. set linkOffsetYInPixels(value: number);
  72305. /** Gets the center coordinate on X axis */
  72306. get centerX(): number;
  72307. /** Gets the center coordinate on Y axis */
  72308. get centerY(): number;
  72309. /** Gets or sets if control is Enabled*/
  72310. get isEnabled(): boolean;
  72311. set isEnabled(value: boolean);
  72312. /** Gets or sets background color of control if it's disabled*/
  72313. get disabledColor(): string;
  72314. set disabledColor(value: string);
  72315. /** Gets or sets front color of control if it's disabled*/
  72316. get disabledColorItem(): string;
  72317. set disabledColorItem(value: string);
  72318. /**
  72319. * Creates a new control
  72320. * @param name defines the name of the control
  72321. */
  72322. constructor(
  72323. /** defines the name of the control */
  72324. name?: string | undefined);
  72325. /** @hidden */
  72326. protected _getTypeName(): string;
  72327. /**
  72328. * Gets the first ascendant in the hierarchy of the given type
  72329. * @param className defines the required type
  72330. * @returns the ascendant or null if not found
  72331. */
  72332. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72333. /** @hidden */
  72334. _resetFontCache(): void;
  72335. /**
  72336. * Determines if a container is an ascendant of the current control
  72337. * @param container defines the container to look for
  72338. * @returns true if the container is one of the ascendant of the control
  72339. */
  72340. isAscendant(container: Control): boolean;
  72341. /**
  72342. * Gets coordinates in local control space
  72343. * @param globalCoordinates defines the coordinates to transform
  72344. * @returns the new coordinates in local space
  72345. */
  72346. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72347. /**
  72348. * Gets coordinates in local control space
  72349. * @param globalCoordinates defines the coordinates to transform
  72350. * @param result defines the target vector2 where to store the result
  72351. * @returns the current control
  72352. */
  72353. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72354. /**
  72355. * Gets coordinates in parent local control space
  72356. * @param globalCoordinates defines the coordinates to transform
  72357. * @returns the new coordinates in parent local space
  72358. */
  72359. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72360. /**
  72361. * Move the current control to a vector3 position projected onto the screen.
  72362. * @param position defines the target position
  72363. * @param scene defines the hosting scene
  72364. */
  72365. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72366. /**
  72367. * Will store all controls that have this control as ascendant in a given array
  72368. * @param results defines the array where to store the descendants
  72369. * @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
  72370. * @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
  72371. */
  72372. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72373. /**
  72374. * Will return all controls that have this control as ascendant
  72375. * @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
  72376. * @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
  72377. * @return all child controls
  72378. */
  72379. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72380. /**
  72381. * Link current control with a target mesh
  72382. * @param mesh defines the mesh to link with
  72383. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72384. */
  72385. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72386. /** @hidden */
  72387. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72388. /** @hidden */
  72389. _offsetLeft(offset: number): void;
  72390. /** @hidden */
  72391. _offsetTop(offset: number): void;
  72392. /** @hidden */
  72393. _markMatrixAsDirty(): void;
  72394. /** @hidden */
  72395. _flagDescendantsAsMatrixDirty(): void;
  72396. /** @hidden */
  72397. _intersectsRect(rect: Measure): boolean;
  72398. /** @hidden */
  72399. protected invalidateRect(): void;
  72400. /** @hidden */
  72401. _markAsDirty(force?: boolean): void;
  72402. /** @hidden */
  72403. _markAllAsDirty(): void;
  72404. /** @hidden */
  72405. _link(host: AdvancedDynamicTexture): void;
  72406. /** @hidden */
  72407. protected _transform(context?: CanvasRenderingContext2D): void;
  72408. /** @hidden */
  72409. _renderHighlight(context: CanvasRenderingContext2D): void;
  72410. /** @hidden */
  72411. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72412. /** @hidden */
  72413. protected _applyStates(context: CanvasRenderingContext2D): void;
  72414. /** @hidden */
  72415. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72416. /** @hidden */
  72417. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72418. protected _evaluateClippingState(parentMeasure: Measure): void;
  72419. /** @hidden */
  72420. _measure(): void;
  72421. /** @hidden */
  72422. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72423. /** @hidden */
  72424. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72425. /** @hidden */
  72426. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72427. /** @hidden */
  72428. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72429. private static _ClipMeasure;
  72430. private _tmpMeasureA;
  72431. private _clip;
  72432. /** @hidden */
  72433. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72434. /** @hidden */
  72435. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72436. /**
  72437. * Tests if a given coordinates belong to the current control
  72438. * @param x defines x coordinate to test
  72439. * @param y defines y coordinate to test
  72440. * @returns true if the coordinates are inside the control
  72441. */
  72442. contains(x: number, y: number): boolean;
  72443. /** @hidden */
  72444. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72445. /** @hidden */
  72446. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72447. /** @hidden */
  72448. _onPointerEnter(target: Control): boolean;
  72449. /** @hidden */
  72450. _onPointerOut(target: Control, force?: boolean): void;
  72451. /** @hidden */
  72452. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72453. /** @hidden */
  72454. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72455. /** @hidden */
  72456. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72457. /** @hidden */
  72458. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72459. /** @hidden */
  72460. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72461. private _prepareFont;
  72462. /** Releases associated resources */
  72463. dispose(): void;
  72464. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72465. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72466. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72467. private static _VERTICAL_ALIGNMENT_TOP;
  72468. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72469. private static _VERTICAL_ALIGNMENT_CENTER;
  72470. /** HORIZONTAL_ALIGNMENT_LEFT */
  72471. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72472. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72473. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72474. /** HORIZONTAL_ALIGNMENT_CENTER */
  72475. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72476. /** VERTICAL_ALIGNMENT_TOP */
  72477. static get VERTICAL_ALIGNMENT_TOP(): number;
  72478. /** VERTICAL_ALIGNMENT_BOTTOM */
  72479. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72480. /** VERTICAL_ALIGNMENT_CENTER */
  72481. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72482. private static _FontHeightSizes;
  72483. /** @hidden */
  72484. static _GetFontOffset(font: string): {
  72485. ascent: number;
  72486. height: number;
  72487. descent: number;
  72488. };
  72489. /**
  72490. * Creates a stack panel that can be used to render headers
  72491. * @param control defines the control to associate with the header
  72492. * @param text defines the text of the header
  72493. * @param size defines the size of the header
  72494. * @param options defines options used to configure the header
  72495. * @returns a new StackPanel
  72496. * @ignore
  72497. * @hidden
  72498. */
  72499. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72500. isHorizontal: boolean;
  72501. controlFirst: boolean;
  72502. }) => any;
  72503. /** @hidden */
  72504. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72505. }
  72506. }
  72507. declare module BABYLON.GUI {
  72508. /**
  72509. * Root class for 2D containers
  72510. * @see http://doc.babylonjs.com/how_to/gui#containers
  72511. */
  72512. export class Container extends Control {
  72513. name?: string | undefined;
  72514. /** @hidden */
  72515. _children: Control[];
  72516. /** @hidden */
  72517. protected _measureForChildren: Measure;
  72518. /** @hidden */
  72519. protected _background: string;
  72520. /** @hidden */
  72521. protected _adaptWidthToChildren: boolean;
  72522. /** @hidden */
  72523. protected _adaptHeightToChildren: boolean;
  72524. /**
  72525. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72526. */
  72527. logLayoutCycleErrors: boolean;
  72528. /**
  72529. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72530. */
  72531. maxLayoutCycle: number;
  72532. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72533. get adaptHeightToChildren(): boolean;
  72534. set adaptHeightToChildren(value: boolean);
  72535. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72536. get adaptWidthToChildren(): boolean;
  72537. set adaptWidthToChildren(value: boolean);
  72538. /** Gets or sets background color */
  72539. get background(): string;
  72540. set background(value: string);
  72541. /** Gets the list of children */
  72542. get children(): Control[];
  72543. /**
  72544. * Creates a new Container
  72545. * @param name defines the name of the container
  72546. */
  72547. constructor(name?: string | undefined);
  72548. protected _getTypeName(): string;
  72549. _flagDescendantsAsMatrixDirty(): void;
  72550. /**
  72551. * Gets a child using its name
  72552. * @param name defines the child name to look for
  72553. * @returns the child control if found
  72554. */
  72555. getChildByName(name: string): BABYLON.Nullable<Control>;
  72556. /**
  72557. * Gets a child using its type and its name
  72558. * @param name defines the child name to look for
  72559. * @param type defines the child type to look for
  72560. * @returns the child control if found
  72561. */
  72562. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72563. /**
  72564. * Search for a specific control in children
  72565. * @param control defines the control to look for
  72566. * @returns true if the control is in child list
  72567. */
  72568. containsControl(control: Control): boolean;
  72569. /**
  72570. * Adds a new control to the current container
  72571. * @param control defines the control to add
  72572. * @returns the current container
  72573. */
  72574. addControl(control: BABYLON.Nullable<Control>): Container;
  72575. /**
  72576. * Removes all controls from the current container
  72577. * @returns the current container
  72578. */
  72579. clearControls(): Container;
  72580. /**
  72581. * Removes a control from the current container
  72582. * @param control defines the control to remove
  72583. * @returns the current container
  72584. */
  72585. removeControl(control: Control): Container;
  72586. /** @hidden */
  72587. _reOrderControl(control: Control): void;
  72588. /** @hidden */
  72589. _offsetLeft(offset: number): void;
  72590. /** @hidden */
  72591. _offsetTop(offset: number): void;
  72592. /** @hidden */
  72593. _markAllAsDirty(): void;
  72594. /** @hidden */
  72595. protected _localDraw(context: CanvasRenderingContext2D): void;
  72596. /** @hidden */
  72597. _link(host: AdvancedDynamicTexture): void;
  72598. /** @hidden */
  72599. protected _beforeLayout(): void;
  72600. /** @hidden */
  72601. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72602. /** @hidden */
  72603. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72604. protected _postMeasure(): void;
  72605. /** @hidden */
  72606. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72607. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72608. /** @hidden */
  72609. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72610. /** @hidden */
  72611. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72612. /** Releases associated resources */
  72613. dispose(): void;
  72614. }
  72615. }
  72616. declare module BABYLON.GUI {
  72617. /** Class used to create rectangle container */
  72618. export class Rectangle extends Container {
  72619. name?: string | undefined;
  72620. private _thickness;
  72621. private _cornerRadius;
  72622. /** Gets or sets border thickness */
  72623. get thickness(): number;
  72624. set thickness(value: number);
  72625. /** Gets or sets the corner radius angle */
  72626. get cornerRadius(): number;
  72627. set cornerRadius(value: number);
  72628. /**
  72629. * Creates a new Rectangle
  72630. * @param name defines the control name
  72631. */
  72632. constructor(name?: string | undefined);
  72633. protected _getTypeName(): string;
  72634. protected _localDraw(context: CanvasRenderingContext2D): void;
  72635. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72636. private _drawRoundedRect;
  72637. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72638. }
  72639. }
  72640. declare module BABYLON.GUI {
  72641. /**
  72642. * Enum that determines the text-wrapping mode to use.
  72643. */
  72644. export enum TextWrapping {
  72645. /**
  72646. * Clip the text when it's larger than Control.width; this is the default mode.
  72647. */
  72648. Clip = 0,
  72649. /**
  72650. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72651. */
  72652. WordWrap = 1,
  72653. /**
  72654. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72655. */
  72656. Ellipsis = 2
  72657. }
  72658. /**
  72659. * Class used to create text block control
  72660. */
  72661. export class TextBlock extends Control {
  72662. /**
  72663. * Defines the name of the control
  72664. */
  72665. name?: string | undefined;
  72666. private _text;
  72667. private _textWrapping;
  72668. private _textHorizontalAlignment;
  72669. private _textVerticalAlignment;
  72670. private _lines;
  72671. private _resizeToFit;
  72672. private _lineSpacing;
  72673. private _outlineWidth;
  72674. private _outlineColor;
  72675. /**
  72676. * An event triggered after the text is changed
  72677. */
  72678. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72679. /**
  72680. * An event triggered after the text was broken up into lines
  72681. */
  72682. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72683. /**
  72684. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72685. */
  72686. get lines(): any[];
  72687. /**
  72688. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72689. */
  72690. get resizeToFit(): boolean;
  72691. /**
  72692. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72693. */
  72694. set resizeToFit(value: boolean);
  72695. /**
  72696. * Gets or sets a boolean indicating if text must be wrapped
  72697. */
  72698. get textWrapping(): TextWrapping | boolean;
  72699. /**
  72700. * Gets or sets a boolean indicating if text must be wrapped
  72701. */
  72702. set textWrapping(value: TextWrapping | boolean);
  72703. /**
  72704. * Gets or sets text to display
  72705. */
  72706. get text(): string;
  72707. /**
  72708. * Gets or sets text to display
  72709. */
  72710. set text(value: string);
  72711. /**
  72712. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72713. */
  72714. get textHorizontalAlignment(): number;
  72715. /**
  72716. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72717. */
  72718. set textHorizontalAlignment(value: number);
  72719. /**
  72720. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72721. */
  72722. get textVerticalAlignment(): number;
  72723. /**
  72724. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72725. */
  72726. set textVerticalAlignment(value: number);
  72727. /**
  72728. * Gets or sets line spacing value
  72729. */
  72730. set lineSpacing(value: string | number);
  72731. /**
  72732. * Gets or sets line spacing value
  72733. */
  72734. get lineSpacing(): string | number;
  72735. /**
  72736. * Gets or sets outlineWidth of the text to display
  72737. */
  72738. get outlineWidth(): number;
  72739. /**
  72740. * Gets or sets outlineWidth of the text to display
  72741. */
  72742. set outlineWidth(value: number);
  72743. /**
  72744. * Gets or sets outlineColor of the text to display
  72745. */
  72746. get outlineColor(): string;
  72747. /**
  72748. * Gets or sets outlineColor of the text to display
  72749. */
  72750. set outlineColor(value: string);
  72751. /**
  72752. * Creates a new TextBlock object
  72753. * @param name defines the name of the control
  72754. * @param text defines the text to display (emptry string by default)
  72755. */
  72756. constructor(
  72757. /**
  72758. * Defines the name of the control
  72759. */
  72760. name?: string | undefined, text?: string);
  72761. protected _getTypeName(): string;
  72762. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72763. private _drawText;
  72764. /** @hidden */
  72765. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72766. protected _applyStates(context: CanvasRenderingContext2D): void;
  72767. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72768. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72769. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72770. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72771. protected _renderLines(context: CanvasRenderingContext2D): void;
  72772. /**
  72773. * Given a width constraint applied on the text block, find the expected height
  72774. * @returns expected height
  72775. */
  72776. computeExpectedHeight(): number;
  72777. dispose(): void;
  72778. }
  72779. }
  72780. declare module BABYLON.GUI {
  72781. /**
  72782. * Class used to create 2D images
  72783. */
  72784. export class Image extends Control {
  72785. name?: string | undefined;
  72786. private _workingCanvas;
  72787. private _domImage;
  72788. private _imageWidth;
  72789. private _imageHeight;
  72790. private _loaded;
  72791. private _stretch;
  72792. private _source;
  72793. private _autoScale;
  72794. private _sourceLeft;
  72795. private _sourceTop;
  72796. private _sourceWidth;
  72797. private _sourceHeight;
  72798. private _svgAttributesComputationCompleted;
  72799. private _isSVG;
  72800. private _cellWidth;
  72801. private _cellHeight;
  72802. private _cellId;
  72803. private _populateNinePatchSlicesFromImage;
  72804. private _sliceLeft;
  72805. private _sliceRight;
  72806. private _sliceTop;
  72807. private _sliceBottom;
  72808. private _detectPointerOnOpaqueOnly;
  72809. /**
  72810. * BABYLON.Observable notified when the content is loaded
  72811. */
  72812. onImageLoadedObservable: BABYLON.Observable<Image>;
  72813. /**
  72814. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72815. */
  72816. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72817. /**
  72818. * Gets a boolean indicating that the content is loaded
  72819. */
  72820. get isLoaded(): boolean;
  72821. /**
  72822. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72823. */
  72824. get populateNinePatchSlicesFromImage(): boolean;
  72825. set populateNinePatchSlicesFromImage(value: boolean);
  72826. /**
  72827. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72828. * Beware using this as this will comsume more memory as the image has to be stored twice
  72829. */
  72830. get detectPointerOnOpaqueOnly(): boolean;
  72831. set detectPointerOnOpaqueOnly(value: boolean);
  72832. /**
  72833. * Gets or sets the left value for slicing (9-patch)
  72834. */
  72835. get sliceLeft(): number;
  72836. set sliceLeft(value: number);
  72837. /**
  72838. * Gets or sets the right value for slicing (9-patch)
  72839. */
  72840. get sliceRight(): number;
  72841. set sliceRight(value: number);
  72842. /**
  72843. * Gets or sets the top value for slicing (9-patch)
  72844. */
  72845. get sliceTop(): number;
  72846. set sliceTop(value: number);
  72847. /**
  72848. * Gets or sets the bottom value for slicing (9-patch)
  72849. */
  72850. get sliceBottom(): number;
  72851. set sliceBottom(value: number);
  72852. /**
  72853. * Gets or sets the left coordinate in the source image
  72854. */
  72855. get sourceLeft(): number;
  72856. set sourceLeft(value: number);
  72857. /**
  72858. * Gets or sets the top coordinate in the source image
  72859. */
  72860. get sourceTop(): number;
  72861. set sourceTop(value: number);
  72862. /**
  72863. * Gets or sets the width to capture in the source image
  72864. */
  72865. get sourceWidth(): number;
  72866. set sourceWidth(value: number);
  72867. /**
  72868. * Gets or sets the height to capture in the source image
  72869. */
  72870. get sourceHeight(): number;
  72871. set sourceHeight(value: number);
  72872. /** Indicates if the format of the image is SVG */
  72873. get isSVG(): boolean;
  72874. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72875. get svgAttributesComputationCompleted(): boolean;
  72876. /**
  72877. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72878. * @see http://doc.babylonjs.com/how_to/gui#image
  72879. */
  72880. get autoScale(): boolean;
  72881. set autoScale(value: boolean);
  72882. /** Gets or sets the streching mode used by the image */
  72883. get stretch(): number;
  72884. set stretch(value: number);
  72885. /** @hidden */
  72886. _rotate90(n: number, preserveProperties?: boolean): Image;
  72887. private _handleRotationForSVGImage;
  72888. private _rotate90SourceProperties;
  72889. /**
  72890. * Gets or sets the internal DOM image used to render the control
  72891. */
  72892. set domImage(value: HTMLImageElement);
  72893. get domImage(): HTMLImageElement;
  72894. private _onImageLoaded;
  72895. private _extractNinePatchSliceDataFromImage;
  72896. /**
  72897. * Gets or sets image source url
  72898. */
  72899. set source(value: BABYLON.Nullable<string>);
  72900. /**
  72901. * Checks for svg document with icon id present
  72902. */
  72903. private _svgCheck;
  72904. /**
  72905. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72906. * given external svg file and icon id
  72907. */
  72908. private _getSVGAttribs;
  72909. /**
  72910. * Gets or sets the cell width to use when animation sheet is enabled
  72911. * @see http://doc.babylonjs.com/how_to/gui#image
  72912. */
  72913. get cellWidth(): number;
  72914. set cellWidth(value: number);
  72915. /**
  72916. * Gets or sets the cell height to use when animation sheet is enabled
  72917. * @see http://doc.babylonjs.com/how_to/gui#image
  72918. */
  72919. get cellHeight(): number;
  72920. set cellHeight(value: number);
  72921. /**
  72922. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72923. * @see http://doc.babylonjs.com/how_to/gui#image
  72924. */
  72925. get cellId(): number;
  72926. set cellId(value: number);
  72927. /**
  72928. * Creates a new Image
  72929. * @param name defines the control name
  72930. * @param url defines the image url
  72931. */
  72932. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72933. /**
  72934. * Tests if a given coordinates belong to the current control
  72935. * @param x defines x coordinate to test
  72936. * @param y defines y coordinate to test
  72937. * @returns true if the coordinates are inside the control
  72938. */
  72939. contains(x: number, y: number): boolean;
  72940. protected _getTypeName(): string;
  72941. /** Force the control to synchronize with its content */
  72942. synchronizeSizeWithContent(): void;
  72943. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72944. private _prepareWorkingCanvasForOpaqueDetection;
  72945. private _drawImage;
  72946. _draw(context: CanvasRenderingContext2D): void;
  72947. private _renderCornerPatch;
  72948. private _renderNinePatch;
  72949. dispose(): void;
  72950. /** STRETCH_NONE */
  72951. static readonly STRETCH_NONE: number;
  72952. /** STRETCH_FILL */
  72953. static readonly STRETCH_FILL: number;
  72954. /** STRETCH_UNIFORM */
  72955. static readonly STRETCH_UNIFORM: number;
  72956. /** STRETCH_EXTEND */
  72957. static readonly STRETCH_EXTEND: number;
  72958. /** NINE_PATCH */
  72959. static readonly STRETCH_NINE_PATCH: number;
  72960. }
  72961. }
  72962. declare module BABYLON.GUI {
  72963. /**
  72964. * Class used to create 2D buttons
  72965. */
  72966. export class Button extends Rectangle {
  72967. name?: string | undefined;
  72968. /**
  72969. * Function called to generate a pointer enter animation
  72970. */
  72971. pointerEnterAnimation: () => void;
  72972. /**
  72973. * Function called to generate a pointer out animation
  72974. */
  72975. pointerOutAnimation: () => void;
  72976. /**
  72977. * Function called to generate a pointer down animation
  72978. */
  72979. pointerDownAnimation: () => void;
  72980. /**
  72981. * Function called to generate a pointer up animation
  72982. */
  72983. pointerUpAnimation: () => void;
  72984. /**
  72985. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72986. */
  72987. delegatePickingToChildren: boolean;
  72988. private _image;
  72989. /**
  72990. * Returns the image part of the button (if any)
  72991. */
  72992. get image(): BABYLON.Nullable<Image>;
  72993. private _textBlock;
  72994. /**
  72995. * Returns the image part of the button (if any)
  72996. */
  72997. get textBlock(): BABYLON.Nullable<TextBlock>;
  72998. /**
  72999. * Creates a new Button
  73000. * @param name defines the name of the button
  73001. */
  73002. constructor(name?: string | undefined);
  73003. protected _getTypeName(): string;
  73004. /** @hidden */
  73005. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73006. /** @hidden */
  73007. _onPointerEnter(target: Control): boolean;
  73008. /** @hidden */
  73009. _onPointerOut(target: Control, force?: boolean): void;
  73010. /** @hidden */
  73011. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73012. /** @hidden */
  73013. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73014. /**
  73015. * Creates a new button made with an image and a text
  73016. * @param name defines the name of the button
  73017. * @param text defines the text of the button
  73018. * @param imageUrl defines the url of the image
  73019. * @returns a new Button
  73020. */
  73021. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  73022. /**
  73023. * Creates a new button made with an image
  73024. * @param name defines the name of the button
  73025. * @param imageUrl defines the url of the image
  73026. * @returns a new Button
  73027. */
  73028. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  73029. /**
  73030. * Creates a new button made with a text
  73031. * @param name defines the name of the button
  73032. * @param text defines the text of the button
  73033. * @returns a new Button
  73034. */
  73035. static CreateSimpleButton(name: string, text: string): Button;
  73036. /**
  73037. * Creates a new button made with an image and a centered text
  73038. * @param name defines the name of the button
  73039. * @param text defines the text of the button
  73040. * @param imageUrl defines the url of the image
  73041. * @returns a new Button
  73042. */
  73043. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  73044. }
  73045. }
  73046. declare module BABYLON.GUI {
  73047. /**
  73048. * Class used to create a 2D stack panel container
  73049. */
  73050. export class StackPanel extends Container {
  73051. name?: string | undefined;
  73052. private _isVertical;
  73053. private _manualWidth;
  73054. private _manualHeight;
  73055. private _doNotTrackManualChanges;
  73056. /**
  73057. * Gets or sets a boolean indicating that layou warnings should be ignored
  73058. */
  73059. ignoreLayoutWarnings: boolean;
  73060. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  73061. get isVertical(): boolean;
  73062. set isVertical(value: boolean);
  73063. /**
  73064. * Gets or sets panel width.
  73065. * This value should not be set when in horizontal mode as it will be computed automatically
  73066. */
  73067. set width(value: string | number);
  73068. get width(): string | number;
  73069. /**
  73070. * Gets or sets panel height.
  73071. * This value should not be set when in vertical mode as it will be computed automatically
  73072. */
  73073. set height(value: string | number);
  73074. get height(): string | number;
  73075. /**
  73076. * Creates a new StackPanel
  73077. * @param name defines control name
  73078. */
  73079. constructor(name?: string | undefined);
  73080. protected _getTypeName(): string;
  73081. /** @hidden */
  73082. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73083. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73084. protected _postMeasure(): void;
  73085. }
  73086. }
  73087. declare module BABYLON.GUI {
  73088. /**
  73089. * Class used to represent a 2D checkbox
  73090. */
  73091. export class Checkbox extends Control {
  73092. name?: string | undefined;
  73093. private _isChecked;
  73094. private _background;
  73095. private _checkSizeRatio;
  73096. private _thickness;
  73097. /** Gets or sets border thickness */
  73098. get thickness(): number;
  73099. set thickness(value: number);
  73100. /**
  73101. * BABYLON.Observable raised when isChecked property changes
  73102. */
  73103. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73104. /** Gets or sets a value indicating the ratio between overall size and check size */
  73105. get checkSizeRatio(): number;
  73106. set checkSizeRatio(value: number);
  73107. /** Gets or sets background color */
  73108. get background(): string;
  73109. set background(value: string);
  73110. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73111. get isChecked(): boolean;
  73112. set isChecked(value: boolean);
  73113. /**
  73114. * Creates a new CheckBox
  73115. * @param name defines the control name
  73116. */
  73117. constructor(name?: string | undefined);
  73118. protected _getTypeName(): string;
  73119. /** @hidden */
  73120. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73121. /** @hidden */
  73122. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73123. /**
  73124. * Utility function to easily create a checkbox with a header
  73125. * @param title defines the label to use for the header
  73126. * @param onValueChanged defines the callback to call when value changes
  73127. * @returns a StackPanel containing the checkbox and a textBlock
  73128. */
  73129. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  73130. }
  73131. }
  73132. declare module BABYLON.GUI {
  73133. /**
  73134. * Class used to store key control properties
  73135. */
  73136. export class KeyPropertySet {
  73137. /** Width */
  73138. width?: string;
  73139. /** Height */
  73140. height?: string;
  73141. /** Left padding */
  73142. paddingLeft?: string;
  73143. /** Right padding */
  73144. paddingRight?: string;
  73145. /** Top padding */
  73146. paddingTop?: string;
  73147. /** Bottom padding */
  73148. paddingBottom?: string;
  73149. /** Foreground color */
  73150. color?: string;
  73151. /** Background color */
  73152. background?: string;
  73153. }
  73154. /**
  73155. * Class used to create virtual keyboard
  73156. */
  73157. export class VirtualKeyboard extends StackPanel {
  73158. /** BABYLON.Observable raised when a key is pressed */
  73159. onKeyPressObservable: BABYLON.Observable<string>;
  73160. /** Gets or sets default key button width */
  73161. defaultButtonWidth: string;
  73162. /** Gets or sets default key button height */
  73163. defaultButtonHeight: string;
  73164. /** Gets or sets default key button left padding */
  73165. defaultButtonPaddingLeft: string;
  73166. /** Gets or sets default key button right padding */
  73167. defaultButtonPaddingRight: string;
  73168. /** Gets or sets default key button top padding */
  73169. defaultButtonPaddingTop: string;
  73170. /** Gets or sets default key button bottom padding */
  73171. defaultButtonPaddingBottom: string;
  73172. /** Gets or sets default key button foreground color */
  73173. defaultButtonColor: string;
  73174. /** Gets or sets default key button background color */
  73175. defaultButtonBackground: string;
  73176. /** Gets or sets shift button foreground color */
  73177. shiftButtonColor: string;
  73178. /** Gets or sets shift button thickness*/
  73179. selectedShiftThickness: number;
  73180. /** Gets shift key state */
  73181. shiftState: number;
  73182. protected _getTypeName(): string;
  73183. private _createKey;
  73184. /**
  73185. * Adds a new row of keys
  73186. * @param keys defines the list of keys to add
  73187. * @param propertySets defines the associated property sets
  73188. */
  73189. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  73190. /**
  73191. * Set the shift key to a specific state
  73192. * @param shiftState defines the new shift state
  73193. */
  73194. applyShiftState(shiftState: number): void;
  73195. private _currentlyConnectedInputText;
  73196. private _connectedInputTexts;
  73197. private _onKeyPressObserver;
  73198. /** Gets the input text control currently attached to the keyboard */
  73199. get connectedInputText(): BABYLON.Nullable<InputText>;
  73200. /**
  73201. * Connects the keyboard with an input text control
  73202. *
  73203. * @param input defines the target control
  73204. */
  73205. connect(input: InputText): void;
  73206. /**
  73207. * Disconnects the keyboard from connected InputText controls
  73208. *
  73209. * @param input optionally defines a target control, otherwise all are disconnected
  73210. */
  73211. disconnect(input?: InputText): void;
  73212. private _removeConnectedInputObservables;
  73213. /**
  73214. * Release all resources
  73215. */
  73216. dispose(): void;
  73217. /**
  73218. * Creates a new keyboard using a default layout
  73219. *
  73220. * @param name defines control name
  73221. * @returns a new VirtualKeyboard
  73222. */
  73223. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  73224. }
  73225. }
  73226. declare module BABYLON.GUI {
  73227. /**
  73228. * Class used to create input text control
  73229. */
  73230. export class InputText extends Control implements IFocusableControl {
  73231. name?: string | undefined;
  73232. private _text;
  73233. private _placeholderText;
  73234. private _background;
  73235. private _focusedBackground;
  73236. private _focusedColor;
  73237. private _placeholderColor;
  73238. private _thickness;
  73239. private _margin;
  73240. private _autoStretchWidth;
  73241. private _maxWidth;
  73242. private _isFocused;
  73243. private _blinkTimeout;
  73244. private _blinkIsEven;
  73245. private _cursorOffset;
  73246. private _scrollLeft;
  73247. private _textWidth;
  73248. private _clickedCoordinate;
  73249. private _deadKey;
  73250. private _addKey;
  73251. private _currentKey;
  73252. private _isTextHighlightOn;
  73253. private _textHighlightColor;
  73254. private _highligherOpacity;
  73255. private _highlightedText;
  73256. private _startHighlightIndex;
  73257. private _endHighlightIndex;
  73258. private _cursorIndex;
  73259. private _onFocusSelectAll;
  73260. private _isPointerDown;
  73261. private _onClipboardObserver;
  73262. private _onPointerDblTapObserver;
  73263. /** @hidden */
  73264. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73265. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73266. promptMessage: string;
  73267. /** Force disable prompt on mobile device */
  73268. disableMobilePrompt: boolean;
  73269. /** BABYLON.Observable raised when the text changes */
  73270. onTextChangedObservable: BABYLON.Observable<InputText>;
  73271. /** BABYLON.Observable raised just before an entered character is to be added */
  73272. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73273. /** BABYLON.Observable raised when the control gets the focus */
  73274. onFocusObservable: BABYLON.Observable<InputText>;
  73275. /** BABYLON.Observable raised when the control loses the focus */
  73276. onBlurObservable: BABYLON.Observable<InputText>;
  73277. /**Observable raised when the text is highlighted */
  73278. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73279. /**Observable raised when copy event is triggered */
  73280. onTextCopyObservable: BABYLON.Observable<InputText>;
  73281. /** BABYLON.Observable raised when cut event is triggered */
  73282. onTextCutObservable: BABYLON.Observable<InputText>;
  73283. /** BABYLON.Observable raised when paste event is triggered */
  73284. onTextPasteObservable: BABYLON.Observable<InputText>;
  73285. /** BABYLON.Observable raised when a key event was processed */
  73286. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73287. /** Gets or sets the maximum width allowed by the control */
  73288. get maxWidth(): string | number;
  73289. /** Gets the maximum width allowed by the control in pixels */
  73290. get maxWidthInPixels(): number;
  73291. set maxWidth(value: string | number);
  73292. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73293. get highligherOpacity(): number;
  73294. set highligherOpacity(value: number);
  73295. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73296. get onFocusSelectAll(): boolean;
  73297. set onFocusSelectAll(value: boolean);
  73298. /** Gets or sets the text hightlight color */
  73299. get textHighlightColor(): string;
  73300. set textHighlightColor(value: string);
  73301. /** Gets or sets control margin */
  73302. get margin(): string;
  73303. /** Gets control margin in pixels */
  73304. get marginInPixels(): number;
  73305. set margin(value: string);
  73306. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73307. get autoStretchWidth(): boolean;
  73308. set autoStretchWidth(value: boolean);
  73309. /** Gets or sets border thickness */
  73310. get thickness(): number;
  73311. set thickness(value: number);
  73312. /** Gets or sets the background color when focused */
  73313. get focusedBackground(): string;
  73314. set focusedBackground(value: string);
  73315. /** Gets or sets the background color when focused */
  73316. get focusedColor(): string;
  73317. set focusedColor(value: string);
  73318. /** Gets or sets the background color */
  73319. get background(): string;
  73320. set background(value: string);
  73321. /** Gets or sets the placeholder color */
  73322. get placeholderColor(): string;
  73323. set placeholderColor(value: string);
  73324. /** Gets or sets the text displayed when the control is empty */
  73325. get placeholderText(): string;
  73326. set placeholderText(value: string);
  73327. /** Gets or sets the dead key flag */
  73328. get deadKey(): boolean;
  73329. set deadKey(flag: boolean);
  73330. /** Gets or sets the highlight text */
  73331. get highlightedText(): string;
  73332. set highlightedText(text: string);
  73333. /** Gets or sets if the current key should be added */
  73334. get addKey(): boolean;
  73335. set addKey(flag: boolean);
  73336. /** Gets or sets the value of the current key being entered */
  73337. get currentKey(): string;
  73338. set currentKey(key: string);
  73339. /** Gets or sets the text displayed in the control */
  73340. get text(): string;
  73341. set text(value: string);
  73342. /** Gets or sets control width */
  73343. get width(): string | number;
  73344. set width(value: string | number);
  73345. /**
  73346. * Creates a new InputText
  73347. * @param name defines the control name
  73348. * @param text defines the text of the control
  73349. */
  73350. constructor(name?: string | undefined, text?: string);
  73351. /** @hidden */
  73352. onBlur(): void;
  73353. /** @hidden */
  73354. onFocus(): void;
  73355. protected _getTypeName(): string;
  73356. /**
  73357. * Function called to get the list of controls that should not steal the focus from this control
  73358. * @returns an array of controls
  73359. */
  73360. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73361. /** @hidden */
  73362. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73363. /** @hidden */
  73364. private _updateValueFromCursorIndex;
  73365. /** @hidden */
  73366. private _processDblClick;
  73367. /** @hidden */
  73368. private _selectAllText;
  73369. /**
  73370. * Handles the keyboard event
  73371. * @param evt Defines the KeyboardEvent
  73372. */
  73373. processKeyboard(evt: KeyboardEvent): void;
  73374. /** @hidden */
  73375. private _onCopyText;
  73376. /** @hidden */
  73377. private _onCutText;
  73378. /** @hidden */
  73379. private _onPasteText;
  73380. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73381. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73382. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73383. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73384. protected _beforeRenderText(text: string): string;
  73385. dispose(): void;
  73386. }
  73387. }
  73388. declare module BABYLON.GUI {
  73389. /**
  73390. * Class used to create a 2D grid container
  73391. */
  73392. export class Grid extends Container {
  73393. name?: string | undefined;
  73394. private _rowDefinitions;
  73395. private _columnDefinitions;
  73396. private _cells;
  73397. private _childControls;
  73398. /**
  73399. * Gets the number of columns
  73400. */
  73401. get columnCount(): number;
  73402. /**
  73403. * Gets the number of rows
  73404. */
  73405. get rowCount(): number;
  73406. /** Gets the list of children */
  73407. get children(): Control[];
  73408. /** Gets the list of cells (e.g. the containers) */
  73409. get cells(): {
  73410. [key: string]: Container;
  73411. };
  73412. /**
  73413. * Gets the definition of a specific row
  73414. * @param index defines the index of the row
  73415. * @returns the row definition
  73416. */
  73417. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73418. /**
  73419. * Gets the definition of a specific column
  73420. * @param index defines the index of the column
  73421. * @returns the column definition
  73422. */
  73423. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73424. /**
  73425. * Adds a new row to the grid
  73426. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73427. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73428. * @returns the current grid
  73429. */
  73430. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73431. /**
  73432. * Adds a new column to the grid
  73433. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73434. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73435. * @returns the current grid
  73436. */
  73437. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73438. /**
  73439. * Update a row definition
  73440. * @param index defines the index of the row to update
  73441. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73442. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73443. * @returns the current grid
  73444. */
  73445. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73446. /**
  73447. * Update a column definition
  73448. * @param index defines the index of the column to update
  73449. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73450. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73451. * @returns the current grid
  73452. */
  73453. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73454. /**
  73455. * Gets the list of children stored in a specific cell
  73456. * @param row defines the row to check
  73457. * @param column defines the column to check
  73458. * @returns the list of controls
  73459. */
  73460. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73461. /**
  73462. * Gets a string representing the child cell info (row x column)
  73463. * @param child defines the control to get info from
  73464. * @returns a string containing the child cell info (row x column)
  73465. */
  73466. getChildCellInfo(child: Control): string;
  73467. private _removeCell;
  73468. private _offsetCell;
  73469. /**
  73470. * Remove a column definition at specified index
  73471. * @param index defines the index of the column to remove
  73472. * @returns the current grid
  73473. */
  73474. removeColumnDefinition(index: number): Grid;
  73475. /**
  73476. * Remove a row definition at specified index
  73477. * @param index defines the index of the row to remove
  73478. * @returns the current grid
  73479. */
  73480. removeRowDefinition(index: number): Grid;
  73481. /**
  73482. * Adds a new control to the current grid
  73483. * @param control defines the control to add
  73484. * @param row defines the row where to add the control (0 by default)
  73485. * @param column defines the column where to add the control (0 by default)
  73486. * @returns the current grid
  73487. */
  73488. addControl(control: Control, row?: number, column?: number): Grid;
  73489. /**
  73490. * Removes a control from the current container
  73491. * @param control defines the control to remove
  73492. * @returns the current container
  73493. */
  73494. removeControl(control: Control): Container;
  73495. /**
  73496. * Creates a new Grid
  73497. * @param name defines control name
  73498. */
  73499. constructor(name?: string | undefined);
  73500. protected _getTypeName(): string;
  73501. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73502. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73503. _flagDescendantsAsMatrixDirty(): void;
  73504. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73505. /** Releases associated resources */
  73506. dispose(): void;
  73507. }
  73508. }
  73509. declare module BABYLON.GUI {
  73510. /** Class used to create color pickers */
  73511. export class ColorPicker extends Control {
  73512. name?: string | undefined;
  73513. private static _Epsilon;
  73514. private _colorWheelCanvas;
  73515. private _value;
  73516. private _tmpColor;
  73517. private _pointerStartedOnSquare;
  73518. private _pointerStartedOnWheel;
  73519. private _squareLeft;
  73520. private _squareTop;
  73521. private _squareSize;
  73522. private _h;
  73523. private _s;
  73524. private _v;
  73525. private _lastPointerDownID;
  73526. /**
  73527. * BABYLON.Observable raised when the value changes
  73528. */
  73529. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73530. /** Gets or sets the color of the color picker */
  73531. get value(): BABYLON.Color3;
  73532. set value(value: BABYLON.Color3);
  73533. /**
  73534. * Gets or sets control width
  73535. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73536. */
  73537. get width(): string | number;
  73538. set width(value: string | number);
  73539. /**
  73540. * Gets or sets control height
  73541. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73542. */
  73543. get height(): string | number;
  73544. /** Gets or sets control height */
  73545. set height(value: string | number);
  73546. /** Gets or sets control size */
  73547. get size(): string | number;
  73548. set size(value: string | number);
  73549. /**
  73550. * Creates a new ColorPicker
  73551. * @param name defines the control name
  73552. */
  73553. constructor(name?: string | undefined);
  73554. protected _getTypeName(): string;
  73555. /** @hidden */
  73556. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73557. private _updateSquareProps;
  73558. private _drawGradientSquare;
  73559. private _drawCircle;
  73560. private _createColorWheelCanvas;
  73561. /** @hidden */
  73562. _draw(context: CanvasRenderingContext2D): void;
  73563. private _pointerIsDown;
  73564. private _updateValueFromPointer;
  73565. private _isPointOnSquare;
  73566. private _isPointOnWheel;
  73567. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73568. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73569. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73570. /**
  73571. * This function expands the color picker by creating a color picker dialog with manual
  73572. * color value input and the ability to save colors into an array to be used later in
  73573. * subsequent launches of the dialogue.
  73574. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73575. * @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.
  73576. * @returns picked color as a hex string and the saved colors array as hex strings.
  73577. */
  73578. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73579. pickerWidth?: string;
  73580. pickerHeight?: string;
  73581. headerHeight?: string;
  73582. lastColor?: string;
  73583. swatchLimit?: number;
  73584. numSwatchesPerLine?: number;
  73585. savedColors?: Array<string>;
  73586. }): Promise<{
  73587. savedColors?: string[];
  73588. pickedColor: string;
  73589. }>;
  73590. }
  73591. }
  73592. declare module BABYLON.GUI {
  73593. /** Class used to create 2D ellipse containers */
  73594. export class Ellipse extends Container {
  73595. name?: string | undefined;
  73596. private _thickness;
  73597. /** Gets or sets border thickness */
  73598. get thickness(): number;
  73599. set thickness(value: number);
  73600. /**
  73601. * Creates a new Ellipse
  73602. * @param name defines the control name
  73603. */
  73604. constructor(name?: string | undefined);
  73605. protected _getTypeName(): string;
  73606. protected _localDraw(context: CanvasRenderingContext2D): void;
  73607. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73608. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73609. }
  73610. }
  73611. declare module BABYLON.GUI {
  73612. /**
  73613. * Class used to create a password control
  73614. */
  73615. export class InputPassword extends InputText {
  73616. protected _beforeRenderText(text: string): string;
  73617. }
  73618. }
  73619. declare module BABYLON.GUI {
  73620. /** Class used to render 2D lines */
  73621. export class Line extends Control {
  73622. name?: string | undefined;
  73623. private _lineWidth;
  73624. private _x1;
  73625. private _y1;
  73626. private _x2;
  73627. private _y2;
  73628. private _dash;
  73629. private _connectedControl;
  73630. private _connectedControlDirtyObserver;
  73631. /** Gets or sets the dash pattern */
  73632. get dash(): Array<number>;
  73633. set dash(value: Array<number>);
  73634. /** Gets or sets the control connected with the line end */
  73635. get connectedControl(): Control;
  73636. set connectedControl(value: Control);
  73637. /** Gets or sets start coordinates on X axis */
  73638. get x1(): string | number;
  73639. set x1(value: string | number);
  73640. /** Gets or sets start coordinates on Y axis */
  73641. get y1(): string | number;
  73642. set y1(value: string | number);
  73643. /** Gets or sets end coordinates on X axis */
  73644. get x2(): string | number;
  73645. set x2(value: string | number);
  73646. /** Gets or sets end coordinates on Y axis */
  73647. get y2(): string | number;
  73648. set y2(value: string | number);
  73649. /** Gets or sets line width */
  73650. get lineWidth(): number;
  73651. set lineWidth(value: number);
  73652. /** Gets or sets horizontal alignment */
  73653. set horizontalAlignment(value: number);
  73654. /** Gets or sets vertical alignment */
  73655. set verticalAlignment(value: number);
  73656. private get _effectiveX2();
  73657. private get _effectiveY2();
  73658. /**
  73659. * Creates a new Line
  73660. * @param name defines the control name
  73661. */
  73662. constructor(name?: string | undefined);
  73663. protected _getTypeName(): string;
  73664. _draw(context: CanvasRenderingContext2D): void;
  73665. _measure(): void;
  73666. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73667. /**
  73668. * Move one end of the line given 3D cartesian coordinates.
  73669. * @param position Targeted world position
  73670. * @param scene BABYLON.Scene
  73671. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73672. */
  73673. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73674. /**
  73675. * Move one end of the line to a position in screen absolute space.
  73676. * @param projectedPosition Position in screen absolute space (X, Y)
  73677. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73678. */
  73679. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73680. }
  73681. }
  73682. declare module BABYLON.GUI {
  73683. /**
  73684. * Class used to store a point for a MultiLine object.
  73685. * The point can be pure 2D coordinates, a mesh or a control
  73686. */
  73687. export class MultiLinePoint {
  73688. private _multiLine;
  73689. private _x;
  73690. private _y;
  73691. private _control;
  73692. private _mesh;
  73693. private _controlObserver;
  73694. private _meshObserver;
  73695. /** @hidden */
  73696. _point: BABYLON.Vector2;
  73697. /**
  73698. * Creates a new MultiLinePoint
  73699. * @param multiLine defines the source MultiLine object
  73700. */
  73701. constructor(multiLine: MultiLine);
  73702. /** Gets or sets x coordinate */
  73703. get x(): string | number;
  73704. set x(value: string | number);
  73705. /** Gets or sets y coordinate */
  73706. get y(): string | number;
  73707. set y(value: string | number);
  73708. /** Gets or sets the control associated with this point */
  73709. get control(): BABYLON.Nullable<Control>;
  73710. set control(value: BABYLON.Nullable<Control>);
  73711. /** Gets or sets the mesh associated with this point */
  73712. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73713. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73714. /** Resets links */
  73715. resetLinks(): void;
  73716. /**
  73717. * Gets a translation vector
  73718. * @returns the translation vector
  73719. */
  73720. translate(): BABYLON.Vector2;
  73721. private _translatePoint;
  73722. /** Release associated resources */
  73723. dispose(): void;
  73724. }
  73725. }
  73726. declare module BABYLON.GUI {
  73727. /**
  73728. * Class used to create multi line control
  73729. */
  73730. export class MultiLine extends Control {
  73731. name?: string | undefined;
  73732. private _lineWidth;
  73733. private _dash;
  73734. private _points;
  73735. private _minX;
  73736. private _minY;
  73737. private _maxX;
  73738. private _maxY;
  73739. /**
  73740. * Creates a new MultiLine
  73741. * @param name defines the control name
  73742. */
  73743. constructor(name?: string | undefined);
  73744. /** Gets or sets dash pattern */
  73745. get dash(): Array<number>;
  73746. set dash(value: Array<number>);
  73747. /**
  73748. * Gets point stored at specified index
  73749. * @param index defines the index to look for
  73750. * @returns the requested point if found
  73751. */
  73752. getAt(index: number): MultiLinePoint;
  73753. /** Function called when a point is updated */
  73754. onPointUpdate: () => void;
  73755. /**
  73756. * Adds new points to the point collection
  73757. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73758. * @returns the list of created MultiLinePoint
  73759. */
  73760. add(...items: (AbstractMesh | Control | {
  73761. x: string | number;
  73762. y: string | number;
  73763. })[]): MultiLinePoint[];
  73764. /**
  73765. * Adds a new point to the point collection
  73766. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73767. * @returns the created MultiLinePoint
  73768. */
  73769. push(item?: (AbstractMesh | Control | {
  73770. x: string | number;
  73771. y: string | number;
  73772. })): MultiLinePoint;
  73773. /**
  73774. * Remove a specific value or point from the active point collection
  73775. * @param value defines the value or point to remove
  73776. */
  73777. remove(value: number | MultiLinePoint): void;
  73778. /**
  73779. * Resets this object to initial state (no point)
  73780. */
  73781. reset(): void;
  73782. /**
  73783. * Resets all links
  73784. */
  73785. resetLinks(): void;
  73786. /** Gets or sets line width */
  73787. get lineWidth(): number;
  73788. set lineWidth(value: number);
  73789. set horizontalAlignment(value: number);
  73790. set verticalAlignment(value: number);
  73791. protected _getTypeName(): string;
  73792. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73793. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73794. _measure(): void;
  73795. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73796. dispose(): void;
  73797. }
  73798. }
  73799. declare module BABYLON.GUI {
  73800. /**
  73801. * Class used to create radio button controls
  73802. */
  73803. export class RadioButton extends Control {
  73804. name?: string | undefined;
  73805. private _isChecked;
  73806. private _background;
  73807. private _checkSizeRatio;
  73808. private _thickness;
  73809. /** Gets or sets border thickness */
  73810. get thickness(): number;
  73811. set thickness(value: number);
  73812. /** Gets or sets group name */
  73813. group: string;
  73814. /** BABYLON.Observable raised when isChecked is changed */
  73815. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73816. /** Gets or sets a value indicating the ratio between overall size and check size */
  73817. get checkSizeRatio(): number;
  73818. set checkSizeRatio(value: number);
  73819. /** Gets or sets background color */
  73820. get background(): string;
  73821. set background(value: string);
  73822. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73823. get isChecked(): boolean;
  73824. set isChecked(value: boolean);
  73825. /**
  73826. * Creates a new RadioButton
  73827. * @param name defines the control name
  73828. */
  73829. constructor(name?: string | undefined);
  73830. protected _getTypeName(): string;
  73831. _draw(context: CanvasRenderingContext2D): void;
  73832. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73833. /**
  73834. * Utility function to easily create a radio button with a header
  73835. * @param title defines the label to use for the header
  73836. * @param group defines the group to use for the radio button
  73837. * @param isChecked defines the initial state of the radio button
  73838. * @param onValueChanged defines the callback to call when value changes
  73839. * @returns a StackPanel containing the radio button and a textBlock
  73840. */
  73841. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73842. }
  73843. }
  73844. declare module BABYLON.GUI {
  73845. /**
  73846. * Class used to create slider controls
  73847. */
  73848. export class BaseSlider extends Control {
  73849. name?: string | undefined;
  73850. protected _thumbWidth: ValueAndUnit;
  73851. private _minimum;
  73852. private _maximum;
  73853. private _value;
  73854. private _isVertical;
  73855. protected _barOffset: ValueAndUnit;
  73856. private _isThumbClamped;
  73857. protected _displayThumb: boolean;
  73858. private _step;
  73859. private _lastPointerDownID;
  73860. protected _effectiveBarOffset: number;
  73861. protected _renderLeft: number;
  73862. protected _renderTop: number;
  73863. protected _renderWidth: number;
  73864. protected _renderHeight: number;
  73865. protected _backgroundBoxLength: number;
  73866. protected _backgroundBoxThickness: number;
  73867. protected _effectiveThumbThickness: number;
  73868. /** BABYLON.Observable raised when the sldier value changes */
  73869. onValueChangedObservable: BABYLON.Observable<number>;
  73870. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73871. get displayThumb(): boolean;
  73872. set displayThumb(value: boolean);
  73873. /** Gets or sets a step to apply to values (0 by default) */
  73874. get step(): number;
  73875. set step(value: number);
  73876. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73877. get barOffset(): string | number;
  73878. /** Gets main bar offset in pixels*/
  73879. get barOffsetInPixels(): number;
  73880. set barOffset(value: string | number);
  73881. /** Gets or sets thumb width */
  73882. get thumbWidth(): string | number;
  73883. /** Gets thumb width in pixels */
  73884. get thumbWidthInPixels(): number;
  73885. set thumbWidth(value: string | number);
  73886. /** Gets or sets minimum value */
  73887. get minimum(): number;
  73888. set minimum(value: number);
  73889. /** Gets or sets maximum value */
  73890. get maximum(): number;
  73891. set maximum(value: number);
  73892. /** Gets or sets current value */
  73893. get value(): number;
  73894. set value(value: number);
  73895. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73896. get isVertical(): boolean;
  73897. set isVertical(value: boolean);
  73898. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73899. get isThumbClamped(): boolean;
  73900. set isThumbClamped(value: boolean);
  73901. /**
  73902. * Creates a new BaseSlider
  73903. * @param name defines the control name
  73904. */
  73905. constructor(name?: string | undefined);
  73906. protected _getTypeName(): string;
  73907. protected _getThumbPosition(): number;
  73908. protected _getThumbThickness(type: string): number;
  73909. protected _prepareRenderingData(type: string): void;
  73910. private _pointerIsDown;
  73911. /** @hidden */
  73912. protected _updateValueFromPointer(x: number, y: number): void;
  73913. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73914. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73915. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73916. }
  73917. }
  73918. declare module BABYLON.GUI {
  73919. /**
  73920. * Class used to create slider controls
  73921. */
  73922. export class Slider extends BaseSlider {
  73923. name?: string | undefined;
  73924. private _background;
  73925. private _borderColor;
  73926. private _isThumbCircle;
  73927. protected _displayValueBar: boolean;
  73928. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73929. get displayValueBar(): boolean;
  73930. set displayValueBar(value: boolean);
  73931. /** Gets or sets border color */
  73932. get borderColor(): string;
  73933. set borderColor(value: string);
  73934. /** Gets or sets background color */
  73935. get background(): string;
  73936. set background(value: string);
  73937. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73938. get isThumbCircle(): boolean;
  73939. set isThumbCircle(value: boolean);
  73940. /**
  73941. * Creates a new Slider
  73942. * @param name defines the control name
  73943. */
  73944. constructor(name?: string | undefined);
  73945. protected _getTypeName(): string;
  73946. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73947. }
  73948. }
  73949. declare module BABYLON.GUI {
  73950. /** Class used to create a RadioGroup
  73951. * which contains groups of radio buttons
  73952. */
  73953. export class SelectorGroup {
  73954. /** name of SelectorGroup */
  73955. name: string;
  73956. private _groupPanel;
  73957. private _selectors;
  73958. private _groupHeader;
  73959. /**
  73960. * Creates a new SelectorGroup
  73961. * @param name of group, used as a group heading
  73962. */
  73963. constructor(
  73964. /** name of SelectorGroup */
  73965. name: string);
  73966. /** Gets the groupPanel of the SelectorGroup */
  73967. get groupPanel(): StackPanel;
  73968. /** Gets the selectors array */
  73969. get selectors(): StackPanel[];
  73970. /** Gets and sets the group header */
  73971. get header(): string;
  73972. set header(label: string);
  73973. /** @hidden */
  73974. private _addGroupHeader;
  73975. /** @hidden*/
  73976. _getSelector(selectorNb: number): StackPanel | undefined;
  73977. /** Removes the selector at the given position
  73978. * @param selectorNb the position of the selector within the group
  73979. */
  73980. removeSelector(selectorNb: number): void;
  73981. }
  73982. /** Class used to create a CheckboxGroup
  73983. * which contains groups of checkbox buttons
  73984. */
  73985. export class CheckboxGroup extends SelectorGroup {
  73986. /** Adds a checkbox as a control
  73987. * @param text is the label for the selector
  73988. * @param func is the function called when the Selector is checked
  73989. * @param checked is true when Selector is checked
  73990. */
  73991. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73992. /** @hidden */
  73993. _setSelectorLabel(selectorNb: number, label: string): void;
  73994. /** @hidden */
  73995. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73996. /** @hidden */
  73997. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73998. /** @hidden */
  73999. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74000. }
  74001. /** Class used to create a RadioGroup
  74002. * which contains groups of radio buttons
  74003. */
  74004. export class RadioGroup extends SelectorGroup {
  74005. private _selectNb;
  74006. /** Adds a radio button as a control
  74007. * @param label is the label for the selector
  74008. * @param func is the function called when the Selector is checked
  74009. * @param checked is true when Selector is checked
  74010. */
  74011. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  74012. /** @hidden */
  74013. _setSelectorLabel(selectorNb: number, label: string): void;
  74014. /** @hidden */
  74015. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74016. /** @hidden */
  74017. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74018. /** @hidden */
  74019. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74020. }
  74021. /** Class used to create a SliderGroup
  74022. * which contains groups of slider buttons
  74023. */
  74024. export class SliderGroup extends SelectorGroup {
  74025. /**
  74026. * Adds a slider to the SelectorGroup
  74027. * @param label is the label for the SliderBar
  74028. * @param func is the function called when the Slider moves
  74029. * @param unit is a string describing the units used, eg degrees or metres
  74030. * @param min is the minimum value for the Slider
  74031. * @param max is the maximum value for the Slider
  74032. * @param value is the start value for the Slider between min and max
  74033. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  74034. */
  74035. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  74036. /** @hidden */
  74037. _setSelectorLabel(selectorNb: number, label: string): void;
  74038. /** @hidden */
  74039. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74040. /** @hidden */
  74041. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74042. /** @hidden */
  74043. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74044. }
  74045. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  74046. * @see http://doc.babylonjs.com/how_to/selector
  74047. */
  74048. export class SelectionPanel extends Rectangle {
  74049. /** name of SelectionPanel */
  74050. name: string;
  74051. /** an array of SelectionGroups */
  74052. groups: SelectorGroup[];
  74053. private _panel;
  74054. private _buttonColor;
  74055. private _buttonBackground;
  74056. private _headerColor;
  74057. private _barColor;
  74058. private _barHeight;
  74059. private _spacerHeight;
  74060. private _labelColor;
  74061. private _groups;
  74062. private _bars;
  74063. /**
  74064. * Creates a new SelectionPanel
  74065. * @param name of SelectionPanel
  74066. * @param groups is an array of SelectionGroups
  74067. */
  74068. constructor(
  74069. /** name of SelectionPanel */
  74070. name: string,
  74071. /** an array of SelectionGroups */
  74072. groups?: SelectorGroup[]);
  74073. protected _getTypeName(): string;
  74074. /** Gets or sets the headerColor */
  74075. get headerColor(): string;
  74076. set headerColor(color: string);
  74077. private _setHeaderColor;
  74078. /** Gets or sets the button color */
  74079. get buttonColor(): string;
  74080. set buttonColor(color: string);
  74081. private _setbuttonColor;
  74082. /** Gets or sets the label color */
  74083. get labelColor(): string;
  74084. set labelColor(color: string);
  74085. private _setLabelColor;
  74086. /** Gets or sets the button background */
  74087. get buttonBackground(): string;
  74088. set buttonBackground(color: string);
  74089. private _setButtonBackground;
  74090. /** Gets or sets the color of separator bar */
  74091. get barColor(): string;
  74092. set barColor(color: string);
  74093. private _setBarColor;
  74094. /** Gets or sets the height of separator bar */
  74095. get barHeight(): string;
  74096. set barHeight(value: string);
  74097. private _setBarHeight;
  74098. /** Gets or sets the height of spacers*/
  74099. get spacerHeight(): string;
  74100. set spacerHeight(value: string);
  74101. private _setSpacerHeight;
  74102. /** Adds a bar between groups */
  74103. private _addSpacer;
  74104. /** Add a group to the selection panel
  74105. * @param group is the selector group to add
  74106. */
  74107. addGroup(group: SelectorGroup): void;
  74108. /** Remove the group from the given position
  74109. * @param groupNb is the position of the group in the list
  74110. */
  74111. removeGroup(groupNb: number): void;
  74112. /** Change a group header label
  74113. * @param label is the new group header label
  74114. * @param groupNb is the number of the group to relabel
  74115. * */
  74116. setHeaderName(label: string, groupNb: number): void;
  74117. /** Change selector label to the one given
  74118. * @param label is the new selector label
  74119. * @param groupNb is the number of the groupcontaining the selector
  74120. * @param selectorNb is the number of the selector within a group to relabel
  74121. * */
  74122. relabel(label: string, groupNb: number, selectorNb: number): void;
  74123. /** For a given group position remove the selector at the given position
  74124. * @param groupNb is the number of the group to remove the selector from
  74125. * @param selectorNb is the number of the selector within the group
  74126. */
  74127. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  74128. /** For a given group position of correct type add a checkbox button
  74129. * @param groupNb is the number of the group to remove the selector from
  74130. * @param label is the label for the selector
  74131. * @param func is the function called when the Selector is checked
  74132. * @param checked is true when Selector is checked
  74133. */
  74134. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74135. /** For a given group position of correct type add a radio button
  74136. * @param groupNb is the number of the group to remove the selector from
  74137. * @param label is the label for the selector
  74138. * @param func is the function called when the Selector is checked
  74139. * @param checked is true when Selector is checked
  74140. */
  74141. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74142. /**
  74143. * For a given slider group add a slider
  74144. * @param groupNb is the number of the group to add the slider to
  74145. * @param label is the label for the Slider
  74146. * @param func is the function called when the Slider moves
  74147. * @param unit is a string describing the units used, eg degrees or metres
  74148. * @param min is the minimum value for the Slider
  74149. * @param max is the maximum value for the Slider
  74150. * @param value is the start value for the Slider between min and max
  74151. * @param onVal is the function used to format the value displayed, eg radians to degrees
  74152. */
  74153. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  74154. }
  74155. }
  74156. declare module BABYLON.GUI {
  74157. /**
  74158. * Class used to hold a the container for ScrollViewer
  74159. * @hidden
  74160. */
  74161. export class _ScrollViewerWindow extends Container {
  74162. parentClientWidth: number;
  74163. parentClientHeight: number;
  74164. private _freezeControls;
  74165. private _parentMeasure;
  74166. private _oldLeft;
  74167. private _oldTop;
  74168. get freezeControls(): boolean;
  74169. set freezeControls(value: boolean);
  74170. private _bucketWidth;
  74171. private _bucketHeight;
  74172. private _buckets;
  74173. private _bucketLen;
  74174. get bucketWidth(): number;
  74175. get bucketHeight(): number;
  74176. setBucketSizes(width: number, height: number): void;
  74177. private _useBuckets;
  74178. private _makeBuckets;
  74179. private _dispatchInBuckets;
  74180. private _updateMeasures;
  74181. private _updateChildrenMeasures;
  74182. private _restoreMeasures;
  74183. /**
  74184. * Creates a new ScrollViewerWindow
  74185. * @param name of ScrollViewerWindow
  74186. */
  74187. constructor(name?: string);
  74188. protected _getTypeName(): string;
  74189. /** @hidden */
  74190. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74191. /** @hidden */
  74192. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74193. private _scrollChildren;
  74194. private _scrollChildrenWithBuckets;
  74195. /** @hidden */
  74196. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74197. protected _postMeasure(): void;
  74198. }
  74199. }
  74200. declare module BABYLON.GUI {
  74201. /**
  74202. * Class used to create slider controls
  74203. */
  74204. export class ScrollBar extends BaseSlider {
  74205. name?: string | undefined;
  74206. private _background;
  74207. private _borderColor;
  74208. private _tempMeasure;
  74209. /** Gets or sets border color */
  74210. get borderColor(): string;
  74211. set borderColor(value: string);
  74212. /** Gets or sets background color */
  74213. get background(): string;
  74214. set background(value: string);
  74215. /**
  74216. * Creates a new Slider
  74217. * @param name defines the control name
  74218. */
  74219. constructor(name?: string | undefined);
  74220. protected _getTypeName(): string;
  74221. protected _getThumbThickness(): number;
  74222. _draw(context: CanvasRenderingContext2D): void;
  74223. private _first;
  74224. private _originX;
  74225. private _originY;
  74226. /** @hidden */
  74227. protected _updateValueFromPointer(x: number, y: number): void;
  74228. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74229. }
  74230. }
  74231. declare module BABYLON.GUI {
  74232. /**
  74233. * Class used to create slider controls
  74234. */
  74235. export class ImageScrollBar extends BaseSlider {
  74236. name?: string | undefined;
  74237. private _backgroundBaseImage;
  74238. private _backgroundImage;
  74239. private _thumbImage;
  74240. private _thumbBaseImage;
  74241. private _thumbLength;
  74242. private _thumbHeight;
  74243. private _barImageHeight;
  74244. private _tempMeasure;
  74245. /** Number of 90° rotation to apply on the images when in vertical mode */
  74246. num90RotationInVerticalMode: number;
  74247. /**
  74248. * Gets or sets the image used to render the background for horizontal bar
  74249. */
  74250. get backgroundImage(): Image;
  74251. set backgroundImage(value: Image);
  74252. /**
  74253. * Gets or sets the image used to render the thumb
  74254. */
  74255. get thumbImage(): Image;
  74256. set thumbImage(value: Image);
  74257. /**
  74258. * Gets or sets the length of the thumb
  74259. */
  74260. get thumbLength(): number;
  74261. set thumbLength(value: number);
  74262. /**
  74263. * Gets or sets the height of the thumb
  74264. */
  74265. get thumbHeight(): number;
  74266. set thumbHeight(value: number);
  74267. /**
  74268. * Gets or sets the height of the bar image
  74269. */
  74270. get barImageHeight(): number;
  74271. set barImageHeight(value: number);
  74272. /**
  74273. * Creates a new ImageScrollBar
  74274. * @param name defines the control name
  74275. */
  74276. constructor(name?: string | undefined);
  74277. protected _getTypeName(): string;
  74278. protected _getThumbThickness(): number;
  74279. _draw(context: CanvasRenderingContext2D): void;
  74280. private _first;
  74281. private _originX;
  74282. private _originY;
  74283. /** @hidden */
  74284. protected _updateValueFromPointer(x: number, y: number): void;
  74285. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74286. }
  74287. }
  74288. declare module BABYLON.GUI {
  74289. /**
  74290. * Class used to hold a viewer window and sliders in a grid
  74291. */
  74292. export class ScrollViewer extends Rectangle {
  74293. private _grid;
  74294. private _horizontalBarSpace;
  74295. private _verticalBarSpace;
  74296. private _dragSpace;
  74297. private _horizontalBar;
  74298. private _verticalBar;
  74299. private _barColor;
  74300. private _barBackground;
  74301. private _barImage;
  74302. private _horizontalBarImage;
  74303. private _verticalBarImage;
  74304. private _barBackgroundImage;
  74305. private _horizontalBarBackgroundImage;
  74306. private _verticalBarBackgroundImage;
  74307. private _barSize;
  74308. private _window;
  74309. private _pointerIsOver;
  74310. private _wheelPrecision;
  74311. private _onWheelObserver;
  74312. private _clientWidth;
  74313. private _clientHeight;
  74314. private _useImageBar;
  74315. private _thumbLength;
  74316. private _thumbHeight;
  74317. private _barImageHeight;
  74318. private _horizontalBarImageHeight;
  74319. private _verticalBarImageHeight;
  74320. private _oldWindowContentsWidth;
  74321. private _oldWindowContentsHeight;
  74322. /**
  74323. * Gets the horizontal scrollbar
  74324. */
  74325. get horizontalBar(): ScrollBar | ImageScrollBar;
  74326. /**
  74327. * Gets the vertical scrollbar
  74328. */
  74329. get verticalBar(): ScrollBar | ImageScrollBar;
  74330. /**
  74331. * Adds a new control to the current container
  74332. * @param control defines the control to add
  74333. * @returns the current container
  74334. */
  74335. addControl(control: BABYLON.Nullable<Control>): Container;
  74336. /**
  74337. * Removes a control from the current container
  74338. * @param control defines the control to remove
  74339. * @returns the current container
  74340. */
  74341. removeControl(control: Control): Container;
  74342. /** Gets the list of children */
  74343. get children(): Control[];
  74344. _flagDescendantsAsMatrixDirty(): void;
  74345. /**
  74346. * Freezes or unfreezes the controls in the window.
  74347. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74348. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74349. */
  74350. get freezeControls(): boolean;
  74351. set freezeControls(value: boolean);
  74352. /** Gets the bucket width */
  74353. get bucketWidth(): number;
  74354. /** Gets the bucket height */
  74355. get bucketHeight(): number;
  74356. /**
  74357. * Sets the bucket sizes.
  74358. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74359. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74360. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74361. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74362. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74363. * used), that's why it is not enabled by default.
  74364. * @param width width of the bucket
  74365. * @param height height of the bucket
  74366. */
  74367. setBucketSizes(width: number, height: number): void;
  74368. private _forceHorizontalBar;
  74369. private _forceVerticalBar;
  74370. /**
  74371. * Forces the horizontal scroll bar to be displayed
  74372. */
  74373. get forceHorizontalBar(): boolean;
  74374. set forceHorizontalBar(value: boolean);
  74375. /**
  74376. * Forces the vertical scroll bar to be displayed
  74377. */
  74378. get forceVerticalBar(): boolean;
  74379. set forceVerticalBar(value: boolean);
  74380. /**
  74381. * Creates a new ScrollViewer
  74382. * @param name of ScrollViewer
  74383. */
  74384. constructor(name?: string, isImageBased?: boolean);
  74385. /** Reset the scroll viewer window to initial size */
  74386. resetWindow(): void;
  74387. protected _getTypeName(): string;
  74388. private _buildClientSizes;
  74389. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74390. protected _postMeasure(): void;
  74391. /**
  74392. * Gets or sets the mouse wheel precision
  74393. * from 0 to 1 with a default value of 0.05
  74394. * */
  74395. get wheelPrecision(): number;
  74396. set wheelPrecision(value: number);
  74397. /** Gets or sets the scroll bar container background color */
  74398. get scrollBackground(): string;
  74399. set scrollBackground(color: string);
  74400. /** Gets or sets the bar color */
  74401. get barColor(): string;
  74402. set barColor(color: string);
  74403. /** Gets or sets the bar image */
  74404. get thumbImage(): Image;
  74405. set thumbImage(value: Image);
  74406. /** Gets or sets the horizontal bar image */
  74407. get horizontalThumbImage(): Image;
  74408. set horizontalThumbImage(value: Image);
  74409. /** Gets or sets the vertical bar image */
  74410. get verticalThumbImage(): Image;
  74411. set verticalThumbImage(value: Image);
  74412. /** Gets or sets the size of the bar */
  74413. get barSize(): number;
  74414. set barSize(value: number);
  74415. /** Gets or sets the length of the thumb */
  74416. get thumbLength(): number;
  74417. set thumbLength(value: number);
  74418. /** Gets or sets the height of the thumb */
  74419. get thumbHeight(): number;
  74420. set thumbHeight(value: number);
  74421. /** Gets or sets the height of the bar image */
  74422. get barImageHeight(): number;
  74423. set barImageHeight(value: number);
  74424. /** Gets or sets the height of the horizontal bar image */
  74425. get horizontalBarImageHeight(): number;
  74426. set horizontalBarImageHeight(value: number);
  74427. /** Gets or sets the height of the vertical bar image */
  74428. get verticalBarImageHeight(): number;
  74429. set verticalBarImageHeight(value: number);
  74430. /** Gets or sets the bar background */
  74431. get barBackground(): string;
  74432. set barBackground(color: string);
  74433. /** Gets or sets the bar background image */
  74434. get barImage(): Image;
  74435. set barImage(value: Image);
  74436. /** Gets or sets the horizontal bar background image */
  74437. get horizontalBarImage(): Image;
  74438. set horizontalBarImage(value: Image);
  74439. /** Gets or sets the vertical bar background image */
  74440. get verticalBarImage(): Image;
  74441. set verticalBarImage(value: Image);
  74442. private _setWindowPosition;
  74443. /** @hidden */
  74444. private _updateScroller;
  74445. _link(host: AdvancedDynamicTexture): void;
  74446. /** @hidden */
  74447. private _addBar;
  74448. /** @hidden */
  74449. private _attachWheel;
  74450. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74451. /** Releases associated resources */
  74452. dispose(): void;
  74453. }
  74454. }
  74455. declare module BABYLON.GUI {
  74456. /** Class used to render a grid */
  74457. export class DisplayGrid extends Control {
  74458. name?: string | undefined;
  74459. private _cellWidth;
  74460. private _cellHeight;
  74461. private _minorLineTickness;
  74462. private _minorLineColor;
  74463. private _majorLineTickness;
  74464. private _majorLineColor;
  74465. private _majorLineFrequency;
  74466. private _background;
  74467. private _displayMajorLines;
  74468. private _displayMinorLines;
  74469. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74470. get displayMinorLines(): boolean;
  74471. set displayMinorLines(value: boolean);
  74472. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74473. get displayMajorLines(): boolean;
  74474. set displayMajorLines(value: boolean);
  74475. /** Gets or sets background color (Black by default) */
  74476. get background(): string;
  74477. set background(value: string);
  74478. /** Gets or sets the width of each cell (20 by default) */
  74479. get cellWidth(): number;
  74480. set cellWidth(value: number);
  74481. /** Gets or sets the height of each cell (20 by default) */
  74482. get cellHeight(): number;
  74483. set cellHeight(value: number);
  74484. /** Gets or sets the tickness of minor lines (1 by default) */
  74485. get minorLineTickness(): number;
  74486. set minorLineTickness(value: number);
  74487. /** Gets or sets the color of minor lines (DarkGray by default) */
  74488. get minorLineColor(): string;
  74489. set minorLineColor(value: string);
  74490. /** Gets or sets the tickness of major lines (2 by default) */
  74491. get majorLineTickness(): number;
  74492. set majorLineTickness(value: number);
  74493. /** Gets or sets the color of major lines (White by default) */
  74494. get majorLineColor(): string;
  74495. set majorLineColor(value: string);
  74496. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74497. get majorLineFrequency(): number;
  74498. set majorLineFrequency(value: number);
  74499. /**
  74500. * Creates a new GridDisplayRectangle
  74501. * @param name defines the control name
  74502. */
  74503. constructor(name?: string | undefined);
  74504. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74505. protected _getTypeName(): string;
  74506. }
  74507. }
  74508. declare module BABYLON.GUI {
  74509. /**
  74510. * Class used to create slider controls based on images
  74511. */
  74512. export class ImageBasedSlider extends BaseSlider {
  74513. name?: string | undefined;
  74514. private _backgroundImage;
  74515. private _thumbImage;
  74516. private _valueBarImage;
  74517. private _tempMeasure;
  74518. get displayThumb(): boolean;
  74519. set displayThumb(value: boolean);
  74520. /**
  74521. * Gets or sets the image used to render the background
  74522. */
  74523. get backgroundImage(): Image;
  74524. set backgroundImage(value: Image);
  74525. /**
  74526. * Gets or sets the image used to render the value bar
  74527. */
  74528. get valueBarImage(): Image;
  74529. set valueBarImage(value: Image);
  74530. /**
  74531. * Gets or sets the image used to render the thumb
  74532. */
  74533. get thumbImage(): Image;
  74534. set thumbImage(value: Image);
  74535. /**
  74536. * Creates a new ImageBasedSlider
  74537. * @param name defines the control name
  74538. */
  74539. constructor(name?: string | undefined);
  74540. protected _getTypeName(): string;
  74541. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74542. }
  74543. }
  74544. declare module BABYLON.GUI {
  74545. /**
  74546. * Forcing an export so that this code will execute
  74547. * @hidden
  74548. */
  74549. const name = "Statics";
  74550. }
  74551. declare module BABYLON.GUI {
  74552. /**
  74553. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74554. */
  74555. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74556. /**
  74557. * Define the instrumented AdvancedDynamicTexture.
  74558. */
  74559. texture: AdvancedDynamicTexture;
  74560. private _captureRenderTime;
  74561. private _renderTime;
  74562. private _captureLayoutTime;
  74563. private _layoutTime;
  74564. private _onBeginRenderObserver;
  74565. private _onEndRenderObserver;
  74566. private _onBeginLayoutObserver;
  74567. private _onEndLayoutObserver;
  74568. /**
  74569. * Gets the perf counter used to capture render time
  74570. */
  74571. get renderTimeCounter(): BABYLON.PerfCounter;
  74572. /**
  74573. * Gets the perf counter used to capture layout time
  74574. */
  74575. get layoutTimeCounter(): BABYLON.PerfCounter;
  74576. /**
  74577. * Enable or disable the render time capture
  74578. */
  74579. get captureRenderTime(): boolean;
  74580. set captureRenderTime(value: boolean);
  74581. /**
  74582. * Enable or disable the layout time capture
  74583. */
  74584. get captureLayoutTime(): boolean;
  74585. set captureLayoutTime(value: boolean);
  74586. /**
  74587. * Instantiates a new advanced dynamic texture instrumentation.
  74588. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74589. * @param texture Defines the AdvancedDynamicTexture to instrument
  74590. */
  74591. constructor(
  74592. /**
  74593. * Define the instrumented AdvancedDynamicTexture.
  74594. */
  74595. texture: AdvancedDynamicTexture);
  74596. /**
  74597. * Dispose and release associated resources.
  74598. */
  74599. dispose(): void;
  74600. }
  74601. }
  74602. declare module BABYLON.GUI {
  74603. /**
  74604. * Class used to load GUI via XML.
  74605. */
  74606. export class XmlLoader {
  74607. private _nodes;
  74608. private _nodeTypes;
  74609. private _isLoaded;
  74610. private _objectAttributes;
  74611. private _parentClass;
  74612. /**
  74613. * Create a new xml loader
  74614. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74615. */
  74616. constructor(parentClass?: null);
  74617. private _getChainElement;
  74618. private _getClassAttribute;
  74619. private _createGuiElement;
  74620. private _parseGrid;
  74621. private _parseElement;
  74622. private _prepareSourceElement;
  74623. private _parseElementsFromSource;
  74624. private _parseXml;
  74625. /**
  74626. * Gets if the loading has finished.
  74627. * @returns whether the loading has finished or not
  74628. */
  74629. isLoaded(): boolean;
  74630. /**
  74631. * Gets a loaded node / control by id.
  74632. * @param id the Controls id set in the xml
  74633. * @returns element of type Control
  74634. */
  74635. getNodeById(id: string): any;
  74636. /**
  74637. * Gets all loaded nodes / controls
  74638. * @returns Array of controls
  74639. */
  74640. getNodes(): any;
  74641. /**
  74642. * Initiates the xml layout loading
  74643. * @param xmlFile defines the xml layout to load
  74644. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74645. * @param callback defines the callback called on layout load.
  74646. */
  74647. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74648. }
  74649. }
  74650. declare module BABYLON.GUI {
  74651. /**
  74652. * Class used to create containers for controls
  74653. */
  74654. export class Container3D extends Control3D {
  74655. private _blockLayout;
  74656. /**
  74657. * Gets the list of child controls
  74658. */
  74659. protected _children: Control3D[];
  74660. /**
  74661. * Gets the list of child controls
  74662. */
  74663. get children(): Array<Control3D>;
  74664. /**
  74665. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74666. * This is helpful to optimize layout operation when adding multiple children in a row
  74667. */
  74668. get blockLayout(): boolean;
  74669. set blockLayout(value: boolean);
  74670. /**
  74671. * Creates a new container
  74672. * @param name defines the container name
  74673. */
  74674. constructor(name?: string);
  74675. /**
  74676. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74677. * @returns the current container
  74678. */
  74679. updateLayout(): Container3D;
  74680. /**
  74681. * Gets a boolean indicating if the given control is in the children of this control
  74682. * @param control defines the control to check
  74683. * @returns true if the control is in the child list
  74684. */
  74685. containsControl(control: Control3D): boolean;
  74686. /**
  74687. * Adds a control to the children of this control
  74688. * @param control defines the control to add
  74689. * @returns the current container
  74690. */
  74691. addControl(control: Control3D): Container3D;
  74692. /**
  74693. * This function will be called everytime a new control is added
  74694. */
  74695. protected _arrangeChildren(): void;
  74696. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74697. /**
  74698. * Removes a control from the children of this control
  74699. * @param control defines the control to remove
  74700. * @returns the current container
  74701. */
  74702. removeControl(control: Control3D): Container3D;
  74703. protected _getTypeName(): string;
  74704. /**
  74705. * Releases all associated resources
  74706. */
  74707. dispose(): void;
  74708. /** Control rotation will remain unchanged */
  74709. static readonly UNSET_ORIENTATION: number;
  74710. /** Control will rotate to make it look at sphere central axis */
  74711. static readonly FACEORIGIN_ORIENTATION: number;
  74712. /** Control will rotate to make it look back at sphere central axis */
  74713. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74714. /** Control will rotate to look at z axis (0, 0, 1) */
  74715. static readonly FACEFORWARD_ORIENTATION: number;
  74716. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74717. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74718. }
  74719. }
  74720. declare module BABYLON.GUI {
  74721. /**
  74722. * Class used to manage 3D user interface
  74723. * @see http://doc.babylonjs.com/how_to/gui3d
  74724. */
  74725. export class GUI3DManager implements BABYLON.IDisposable {
  74726. private _scene;
  74727. private _sceneDisposeObserver;
  74728. private _utilityLayer;
  74729. private _rootContainer;
  74730. private _pointerObserver;
  74731. private _pointerOutObserver;
  74732. /** @hidden */
  74733. _lastPickedControl: Control3D;
  74734. /** @hidden */
  74735. _lastControlOver: {
  74736. [pointerId: number]: Control3D;
  74737. };
  74738. /** @hidden */
  74739. _lastControlDown: {
  74740. [pointerId: number]: Control3D;
  74741. };
  74742. /**
  74743. * BABYLON.Observable raised when the point picked by the pointer events changed
  74744. */
  74745. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74746. /** @hidden */
  74747. _sharedMaterials: {
  74748. [key: string]: BABYLON.Material;
  74749. };
  74750. /** Gets the hosting scene */
  74751. get scene(): BABYLON.Scene;
  74752. /** Gets associated utility layer */
  74753. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74754. /**
  74755. * Creates a new GUI3DManager
  74756. * @param scene
  74757. */
  74758. constructor(scene?: BABYLON.Scene);
  74759. private _handlePointerOut;
  74760. private _doPicking;
  74761. /**
  74762. * Gets the root container
  74763. */
  74764. get rootContainer(): Container3D;
  74765. /**
  74766. * Gets a boolean indicating if the given control is in the root child list
  74767. * @param control defines the control to check
  74768. * @returns true if the control is in the root child list
  74769. */
  74770. containsControl(control: Control3D): boolean;
  74771. /**
  74772. * Adds a control to the root child list
  74773. * @param control defines the control to add
  74774. * @returns the current manager
  74775. */
  74776. addControl(control: Control3D): GUI3DManager;
  74777. /**
  74778. * Removes a control from the root child list
  74779. * @param control defines the control to remove
  74780. * @returns the current container
  74781. */
  74782. removeControl(control: Control3D): GUI3DManager;
  74783. /**
  74784. * Releases all associated resources
  74785. */
  74786. dispose(): void;
  74787. }
  74788. }
  74789. declare module BABYLON.GUI {
  74790. /**
  74791. * Class used to transport BABYLON.Vector3 information for pointer events
  74792. */
  74793. export class Vector3WithInfo extends BABYLON.Vector3 {
  74794. /** defines the current mouse button index */
  74795. buttonIndex: number;
  74796. /**
  74797. * Creates a new Vector3WithInfo
  74798. * @param source defines the vector3 data to transport
  74799. * @param buttonIndex defines the current mouse button index
  74800. */
  74801. constructor(source: BABYLON.Vector3,
  74802. /** defines the current mouse button index */
  74803. buttonIndex?: number);
  74804. }
  74805. }
  74806. declare module BABYLON.GUI {
  74807. /**
  74808. * Class used as base class for controls
  74809. */
  74810. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74811. /** Defines the control name */
  74812. name?: string | undefined;
  74813. /** @hidden */
  74814. _host: GUI3DManager;
  74815. private _node;
  74816. private _downCount;
  74817. private _enterCount;
  74818. private _downPointerIds;
  74819. private _isVisible;
  74820. /** Gets or sets the control position in world space */
  74821. get position(): BABYLON.Vector3;
  74822. set position(value: BABYLON.Vector3);
  74823. /** Gets or sets the control scaling in world space */
  74824. get scaling(): BABYLON.Vector3;
  74825. set scaling(value: BABYLON.Vector3);
  74826. /** Callback used to start pointer enter animation */
  74827. pointerEnterAnimation: () => void;
  74828. /** Callback used to start pointer out animation */
  74829. pointerOutAnimation: () => void;
  74830. /** Callback used to start pointer down animation */
  74831. pointerDownAnimation: () => void;
  74832. /** Callback used to start pointer up animation */
  74833. pointerUpAnimation: () => void;
  74834. /**
  74835. * An event triggered when the pointer move over the control
  74836. */
  74837. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74838. /**
  74839. * An event triggered when the pointer move out of the control
  74840. */
  74841. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74842. /**
  74843. * An event triggered when the pointer taps the control
  74844. */
  74845. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74846. /**
  74847. * An event triggered when pointer is up
  74848. */
  74849. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74850. /**
  74851. * An event triggered when a control is clicked on (with a mouse)
  74852. */
  74853. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74854. /**
  74855. * An event triggered when pointer enters the control
  74856. */
  74857. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74858. /**
  74859. * Gets or sets the parent container
  74860. */
  74861. parent: BABYLON.Nullable<Container3D>;
  74862. private _behaviors;
  74863. /**
  74864. * Gets the list of attached behaviors
  74865. * @see http://doc.babylonjs.com/features/behaviour
  74866. */
  74867. get behaviors(): BABYLON.Behavior<Control3D>[];
  74868. /**
  74869. * Attach a behavior to the control
  74870. * @see http://doc.babylonjs.com/features/behaviour
  74871. * @param behavior defines the behavior to attach
  74872. * @returns the current control
  74873. */
  74874. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74875. /**
  74876. * Remove an attached behavior
  74877. * @see http://doc.babylonjs.com/features/behaviour
  74878. * @param behavior defines the behavior to attach
  74879. * @returns the current control
  74880. */
  74881. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74882. /**
  74883. * Gets an attached behavior by name
  74884. * @param name defines the name of the behavior to look for
  74885. * @see http://doc.babylonjs.com/features/behaviour
  74886. * @returns null if behavior was not found else the requested behavior
  74887. */
  74888. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74889. /** Gets or sets a boolean indicating if the control is visible */
  74890. get isVisible(): boolean;
  74891. set isVisible(value: boolean);
  74892. /**
  74893. * Creates a new control
  74894. * @param name defines the control name
  74895. */
  74896. constructor(
  74897. /** Defines the control name */
  74898. name?: string | undefined);
  74899. /**
  74900. * Gets a string representing the class name
  74901. */
  74902. get typeName(): string;
  74903. /**
  74904. * Get the current class name of the control.
  74905. * @returns current class name
  74906. */
  74907. getClassName(): string;
  74908. protected _getTypeName(): string;
  74909. /**
  74910. * Gets the transform node used by this control
  74911. */
  74912. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74913. /**
  74914. * Gets the mesh used to render this control
  74915. */
  74916. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74917. /**
  74918. * Link the control as child of the given node
  74919. * @param node defines the node to link to. Use null to unlink the control
  74920. * @returns the current control
  74921. */
  74922. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74923. /** @hidden **/
  74924. _prepareNode(scene: BABYLON.Scene): void;
  74925. /**
  74926. * Node creation.
  74927. * Can be overriden by children
  74928. * @param scene defines the scene where the node must be attached
  74929. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74930. */
  74931. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74932. /**
  74933. * Affect a material to the given mesh
  74934. * @param mesh defines the mesh which will represent the control
  74935. */
  74936. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74937. /** @hidden */
  74938. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74939. /** @hidden */
  74940. _onPointerEnter(target: Control3D): boolean;
  74941. /** @hidden */
  74942. _onPointerOut(target: Control3D): void;
  74943. /** @hidden */
  74944. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74945. /** @hidden */
  74946. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74947. /** @hidden */
  74948. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74949. /** @hidden */
  74950. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74951. /** @hidden */
  74952. _disposeNode(): void;
  74953. /**
  74954. * Releases all associated resources
  74955. */
  74956. dispose(): void;
  74957. }
  74958. }
  74959. declare module BABYLON.GUI {
  74960. /**
  74961. * Class used as a root to all buttons
  74962. */
  74963. export class AbstractButton3D extends Control3D {
  74964. /**
  74965. * Creates a new button
  74966. * @param name defines the control name
  74967. */
  74968. constructor(name?: string);
  74969. protected _getTypeName(): string;
  74970. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74971. }
  74972. }
  74973. declare module BABYLON.GUI {
  74974. /**
  74975. * Class used to create a button in 3D
  74976. */
  74977. export class Button3D extends AbstractButton3D {
  74978. /** @hidden */
  74979. protected _currentMaterial: BABYLON.Material;
  74980. private _facadeTexture;
  74981. private _content;
  74982. private _contentResolution;
  74983. private _contentScaleRatio;
  74984. /**
  74985. * Gets or sets the texture resolution used to render content (512 by default)
  74986. */
  74987. get contentResolution(): BABYLON.int;
  74988. set contentResolution(value: BABYLON.int);
  74989. /**
  74990. * Gets or sets the texture scale ratio used to render content (2 by default)
  74991. */
  74992. get contentScaleRatio(): number;
  74993. set contentScaleRatio(value: number);
  74994. protected _disposeFacadeTexture(): void;
  74995. protected _resetContent(): void;
  74996. /**
  74997. * Creates a new button
  74998. * @param name defines the control name
  74999. */
  75000. constructor(name?: string);
  75001. /**
  75002. * Gets or sets the GUI 2D content used to display the button's facade
  75003. */
  75004. get content(): Control;
  75005. set content(value: Control);
  75006. /**
  75007. * Apply the facade texture (created from the content property).
  75008. * This function can be overloaded by child classes
  75009. * @param facadeTexture defines the AdvancedDynamicTexture to use
  75010. */
  75011. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75012. protected _getTypeName(): string;
  75013. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75014. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75015. /**
  75016. * Releases all associated resources
  75017. */
  75018. dispose(): void;
  75019. }
  75020. }
  75021. declare module BABYLON.GUI {
  75022. /**
  75023. * Abstract class used to create a container panel deployed on the surface of a volume
  75024. */
  75025. export abstract class VolumeBasedPanel extends Container3D {
  75026. private _columns;
  75027. private _rows;
  75028. private _rowThenColum;
  75029. private _orientation;
  75030. protected _cellWidth: number;
  75031. protected _cellHeight: number;
  75032. /**
  75033. * Gets or sets the distance between elements
  75034. */
  75035. margin: number;
  75036. /**
  75037. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  75038. * | Value | Type | Description |
  75039. * | ----- | ----------------------------------- | ----------- |
  75040. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  75041. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  75042. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  75043. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  75044. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  75045. */
  75046. get orientation(): number;
  75047. set orientation(value: number);
  75048. /**
  75049. * Gets or sets the number of columns requested (10 by default).
  75050. * The panel will automatically compute the number of rows based on number of child controls.
  75051. */
  75052. get columns(): BABYLON.int;
  75053. set columns(value: BABYLON.int);
  75054. /**
  75055. * Gets or sets a the number of rows requested.
  75056. * The panel will automatically compute the number of columns based on number of child controls.
  75057. */
  75058. get rows(): BABYLON.int;
  75059. set rows(value: BABYLON.int);
  75060. /**
  75061. * Creates new VolumeBasedPanel
  75062. */
  75063. constructor();
  75064. protected _arrangeChildren(): void;
  75065. /** Child classes must implement this function to provide correct control positioning */
  75066. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75067. /** Child classes can implement this function to provide additional processing */
  75068. protected _finalProcessing(): void;
  75069. }
  75070. }
  75071. declare module BABYLON.GUI {
  75072. /**
  75073. * Class used to create a container panel deployed on the surface of a cylinder
  75074. */
  75075. export class CylinderPanel extends VolumeBasedPanel {
  75076. private _radius;
  75077. /**
  75078. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  75079. */
  75080. get radius(): BABYLON.float;
  75081. set radius(value: BABYLON.float);
  75082. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75083. private _cylindricalMapping;
  75084. }
  75085. }
  75086. declare module BABYLON.GUI {
  75087. /** @hidden */
  75088. export var fluentVertexShader: {
  75089. name: string;
  75090. shader: string;
  75091. };
  75092. }
  75093. declare module BABYLON.GUI {
  75094. /** @hidden */
  75095. export var fluentPixelShader: {
  75096. name: string;
  75097. shader: string;
  75098. };
  75099. }
  75100. declare module BABYLON.GUI {
  75101. /** @hidden */
  75102. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  75103. INNERGLOW: boolean;
  75104. BORDER: boolean;
  75105. HOVERLIGHT: boolean;
  75106. TEXTURE: boolean;
  75107. constructor();
  75108. }
  75109. /**
  75110. * Class used to render controls with fluent desgin
  75111. */
  75112. export class FluentMaterial extends BABYLON.PushMaterial {
  75113. /**
  75114. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  75115. */
  75116. innerGlowColorIntensity: number;
  75117. /**
  75118. * Gets or sets the inner glow color (white by default)
  75119. */
  75120. innerGlowColor: BABYLON.Color3;
  75121. /**
  75122. * Gets or sets alpha value (default is 1.0)
  75123. */
  75124. alpha: number;
  75125. /**
  75126. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  75127. */
  75128. albedoColor: BABYLON.Color3;
  75129. /**
  75130. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  75131. */
  75132. renderBorders: boolean;
  75133. /**
  75134. * Gets or sets border width (default is 0.5)
  75135. */
  75136. borderWidth: number;
  75137. /**
  75138. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  75139. */
  75140. edgeSmoothingValue: number;
  75141. /**
  75142. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  75143. */
  75144. borderMinValue: number;
  75145. /**
  75146. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  75147. */
  75148. renderHoverLight: boolean;
  75149. /**
  75150. * Gets or sets the radius used to render the hover light (default is 1.0)
  75151. */
  75152. hoverRadius: number;
  75153. /**
  75154. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  75155. */
  75156. hoverColor: BABYLON.Color4;
  75157. /**
  75158. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  75159. */
  75160. hoverPosition: BABYLON.Vector3;
  75161. private _albedoTexture;
  75162. /** Gets or sets the texture to use for albedo color */
  75163. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75164. /**
  75165. * Creates a new Fluent material
  75166. * @param name defines the name of the material
  75167. * @param scene defines the hosting scene
  75168. */
  75169. constructor(name: string, scene: BABYLON.Scene);
  75170. needAlphaBlending(): boolean;
  75171. needAlphaTesting(): boolean;
  75172. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75173. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75174. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75175. getActiveTextures(): BABYLON.BaseTexture[];
  75176. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75177. dispose(forceDisposeEffect?: boolean): void;
  75178. clone(name: string): FluentMaterial;
  75179. serialize(): any;
  75180. getClassName(): string;
  75181. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  75182. }
  75183. }
  75184. declare module BABYLON.GUI {
  75185. /**
  75186. * Class used to create a holographic button in 3D
  75187. */
  75188. export class HolographicButton extends Button3D {
  75189. private _backPlate;
  75190. private _textPlate;
  75191. private _frontPlate;
  75192. private _text;
  75193. private _imageUrl;
  75194. private _shareMaterials;
  75195. private _frontMaterial;
  75196. private _backMaterial;
  75197. private _plateMaterial;
  75198. private _pickedPointObserver;
  75199. private _tooltipFade;
  75200. private _tooltipTextBlock;
  75201. private _tooltipTexture;
  75202. private _tooltipMesh;
  75203. private _tooltipHoverObserver;
  75204. private _tooltipOutObserver;
  75205. private _disposeTooltip;
  75206. /**
  75207. * Rendering ground id of all the mesh in the button
  75208. */
  75209. set renderingGroupId(id: number);
  75210. get renderingGroupId(): number;
  75211. /**
  75212. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  75213. */
  75214. set tooltipText(text: BABYLON.Nullable<string>);
  75215. get tooltipText(): BABYLON.Nullable<string>;
  75216. /**
  75217. * Gets or sets text for the button
  75218. */
  75219. get text(): string;
  75220. set text(value: string);
  75221. /**
  75222. * Gets or sets the image url for the button
  75223. */
  75224. get imageUrl(): string;
  75225. set imageUrl(value: string);
  75226. /**
  75227. * Gets the back material used by this button
  75228. */
  75229. get backMaterial(): FluentMaterial;
  75230. /**
  75231. * Gets the front material used by this button
  75232. */
  75233. get frontMaterial(): FluentMaterial;
  75234. /**
  75235. * Gets the plate material used by this button
  75236. */
  75237. get plateMaterial(): BABYLON.StandardMaterial;
  75238. /**
  75239. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75240. */
  75241. get shareMaterials(): boolean;
  75242. /**
  75243. * Creates a new button
  75244. * @param name defines the control name
  75245. */
  75246. constructor(name?: string, shareMaterials?: boolean);
  75247. protected _getTypeName(): string;
  75248. private _rebuildContent;
  75249. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75250. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75251. private _createBackMaterial;
  75252. private _createFrontMaterial;
  75253. private _createPlateMaterial;
  75254. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75255. /**
  75256. * Releases all associated resources
  75257. */
  75258. dispose(): void;
  75259. }
  75260. }
  75261. declare module BABYLON.GUI {
  75262. /**
  75263. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75264. */
  75265. export class MeshButton3D extends Button3D {
  75266. /** @hidden */
  75267. protected _currentMesh: BABYLON.Mesh;
  75268. /**
  75269. * Creates a new 3D button based on a mesh
  75270. * @param mesh mesh to become a 3D button
  75271. * @param name defines the control name
  75272. */
  75273. constructor(mesh: BABYLON.Mesh, name?: string);
  75274. protected _getTypeName(): string;
  75275. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75276. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75277. }
  75278. }
  75279. declare module BABYLON.GUI {
  75280. /**
  75281. * Class used to create a container panel deployed on the surface of a plane
  75282. */
  75283. export class PlanePanel extends VolumeBasedPanel {
  75284. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75285. }
  75286. }
  75287. declare module BABYLON.GUI {
  75288. /**
  75289. * Class used to create a container panel where items get randomized planar mapping
  75290. */
  75291. export class ScatterPanel extends VolumeBasedPanel {
  75292. private _iteration;
  75293. /**
  75294. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75295. */
  75296. get iteration(): BABYLON.float;
  75297. set iteration(value: BABYLON.float);
  75298. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75299. private _scatterMapping;
  75300. protected _finalProcessing(): void;
  75301. }
  75302. }
  75303. declare module BABYLON.GUI {
  75304. /**
  75305. * Class used to create a container panel deployed on the surface of a sphere
  75306. */
  75307. export class SpherePanel extends VolumeBasedPanel {
  75308. private _radius;
  75309. /**
  75310. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75311. */
  75312. get radius(): BABYLON.float;
  75313. set radius(value: BABYLON.float);
  75314. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75315. private _sphericalMapping;
  75316. }
  75317. }
  75318. declare module BABYLON.GUI {
  75319. /**
  75320. * Class used to create a stack panel in 3D on XY plane
  75321. */
  75322. export class StackPanel3D extends Container3D {
  75323. private _isVertical;
  75324. /**
  75325. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75326. */
  75327. get isVertical(): boolean;
  75328. set isVertical(value: boolean);
  75329. /**
  75330. * Gets or sets the distance between elements
  75331. */
  75332. margin: number;
  75333. /**
  75334. * Creates new StackPanel
  75335. * @param isVertical
  75336. */
  75337. constructor(isVertical?: boolean);
  75338. protected _arrangeChildren(): void;
  75339. }
  75340. }
  75341. declare module BABYLON {
  75342. /**
  75343. * Configuration for glTF validation
  75344. */
  75345. export interface IGLTFValidationConfiguration {
  75346. /**
  75347. * The url of the glTF validator.
  75348. */
  75349. url: string;
  75350. }
  75351. /**
  75352. * glTF validation
  75353. */
  75354. export class GLTFValidation {
  75355. /**
  75356. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75357. */
  75358. static Configuration: IGLTFValidationConfiguration;
  75359. private static _LoadScriptPromise;
  75360. /**
  75361. * Validate a glTF asset using the glTF-Validator.
  75362. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75363. * @param rootUrl The root url for the glTF
  75364. * @param fileName The file name for the glTF
  75365. * @param getExternalResource The callback to get external resources for the glTF validator
  75366. * @returns A promise that resolves with the glTF validation results once complete
  75367. */
  75368. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75369. }
  75370. }
  75371. declare module BABYLON {
  75372. /**
  75373. * Mode that determines the coordinate system to use.
  75374. */
  75375. export enum GLTFLoaderCoordinateSystemMode {
  75376. /**
  75377. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75378. */
  75379. AUTO = 0,
  75380. /**
  75381. * Sets the useRightHandedSystem flag on the scene.
  75382. */
  75383. FORCE_RIGHT_HANDED = 1
  75384. }
  75385. /**
  75386. * Mode that determines what animations will start.
  75387. */
  75388. export enum GLTFLoaderAnimationStartMode {
  75389. /**
  75390. * No animation will start.
  75391. */
  75392. NONE = 0,
  75393. /**
  75394. * The first animation will start.
  75395. */
  75396. FIRST = 1,
  75397. /**
  75398. * All animations will start.
  75399. */
  75400. ALL = 2
  75401. }
  75402. /**
  75403. * Interface that contains the data for the glTF asset.
  75404. */
  75405. export interface IGLTFLoaderData {
  75406. /**
  75407. * The object that represents the glTF JSON.
  75408. */
  75409. json: Object;
  75410. /**
  75411. * The BIN chunk of a binary glTF.
  75412. */
  75413. bin: Nullable<IDataBuffer>;
  75414. }
  75415. /**
  75416. * Interface for extending the loader.
  75417. */
  75418. export interface IGLTFLoaderExtension {
  75419. /**
  75420. * The name of this extension.
  75421. */
  75422. readonly name: string;
  75423. /**
  75424. * Defines whether this extension is enabled.
  75425. */
  75426. enabled: boolean;
  75427. /**
  75428. * Defines the order of this extension.
  75429. * The loader sorts the extensions using these values when loading.
  75430. */
  75431. order?: number;
  75432. }
  75433. /**
  75434. * Loader state.
  75435. */
  75436. export enum GLTFLoaderState {
  75437. /**
  75438. * The asset is loading.
  75439. */
  75440. LOADING = 0,
  75441. /**
  75442. * The asset is ready for rendering.
  75443. */
  75444. READY = 1,
  75445. /**
  75446. * The asset is completely loaded.
  75447. */
  75448. COMPLETE = 2
  75449. }
  75450. /** @hidden */
  75451. export interface IImportMeshAsyncOutput {
  75452. meshes: AbstractMesh[];
  75453. particleSystems: IParticleSystem[];
  75454. skeletons: Skeleton[];
  75455. animationGroups: AnimationGroup[];
  75456. lights: Light[];
  75457. transformNodes: TransformNode[];
  75458. }
  75459. /** @hidden */
  75460. export interface IGLTFLoader extends IDisposable {
  75461. readonly state: Nullable<GLTFLoaderState>;
  75462. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75463. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75464. }
  75465. /**
  75466. * File loader for loading glTF files into a scene.
  75467. */
  75468. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75469. /** @hidden */
  75470. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75471. /** @hidden */
  75472. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75473. /**
  75474. * Raised when the asset has been parsed
  75475. */
  75476. onParsedObservable: Observable<IGLTFLoaderData>;
  75477. private _onParsedObserver;
  75478. /**
  75479. * Raised when the asset has been parsed
  75480. */
  75481. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75482. /**
  75483. * 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.
  75484. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75485. * Defaults to true.
  75486. * @hidden
  75487. */
  75488. static IncrementalLoading: boolean;
  75489. /**
  75490. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75491. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75492. * @hidden
  75493. */
  75494. static HomogeneousCoordinates: boolean;
  75495. /**
  75496. * The coordinate system mode. Defaults to AUTO.
  75497. */
  75498. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75499. /**
  75500. * The animation start mode. Defaults to FIRST.
  75501. */
  75502. animationStartMode: GLTFLoaderAnimationStartMode;
  75503. /**
  75504. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75505. */
  75506. compileMaterials: boolean;
  75507. /**
  75508. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75509. */
  75510. useClipPlane: boolean;
  75511. /**
  75512. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75513. */
  75514. compileShadowGenerators: boolean;
  75515. /**
  75516. * Defines if the Alpha blended materials are only applied as coverage.
  75517. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75518. * If true, no extra effects are applied to transparent pixels.
  75519. */
  75520. transparencyAsCoverage: boolean;
  75521. /**
  75522. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75523. * Enabling will disable offline support and glTF validator.
  75524. * Defaults to false.
  75525. */
  75526. useRangeRequests: boolean;
  75527. /**
  75528. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75529. */
  75530. createInstances: boolean;
  75531. /**
  75532. * Function called before loading a url referenced by the asset.
  75533. */
  75534. preprocessUrlAsync: (url: string) => Promise<string>;
  75535. /**
  75536. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75537. */
  75538. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75539. private _onMeshLoadedObserver;
  75540. /**
  75541. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75542. */
  75543. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75544. /**
  75545. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75546. */
  75547. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75548. private _onTextureLoadedObserver;
  75549. /**
  75550. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75551. */
  75552. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75553. /**
  75554. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75555. */
  75556. readonly onMaterialLoadedObservable: Observable<Material>;
  75557. private _onMaterialLoadedObserver;
  75558. /**
  75559. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75560. */
  75561. set onMaterialLoaded(callback: (material: Material) => void);
  75562. /**
  75563. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75564. */
  75565. readonly onCameraLoadedObservable: Observable<Camera>;
  75566. private _onCameraLoadedObserver;
  75567. /**
  75568. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75569. */
  75570. set onCameraLoaded(callback: (camera: Camera) => void);
  75571. /**
  75572. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75573. * For assets with LODs, raised when all of the LODs are complete.
  75574. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75575. */
  75576. readonly onCompleteObservable: Observable<void>;
  75577. private _onCompleteObserver;
  75578. /**
  75579. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75580. * For assets with LODs, raised when all of the LODs are complete.
  75581. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75582. */
  75583. set onComplete(callback: () => void);
  75584. /**
  75585. * Observable raised when an error occurs.
  75586. */
  75587. readonly onErrorObservable: Observable<any>;
  75588. private _onErrorObserver;
  75589. /**
  75590. * Callback raised when an error occurs.
  75591. */
  75592. set onError(callback: (reason: any) => void);
  75593. /**
  75594. * Observable raised after the loader is disposed.
  75595. */
  75596. readonly onDisposeObservable: Observable<void>;
  75597. private _onDisposeObserver;
  75598. /**
  75599. * Callback raised after the loader is disposed.
  75600. */
  75601. set onDispose(callback: () => void);
  75602. /**
  75603. * Observable raised after a loader extension is created.
  75604. * Set additional options for a loader extension in this event.
  75605. */
  75606. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75607. private _onExtensionLoadedObserver;
  75608. /**
  75609. * Callback raised after a loader extension is created.
  75610. */
  75611. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75612. /**
  75613. * Defines if the loader logging is enabled.
  75614. */
  75615. get loggingEnabled(): boolean;
  75616. set loggingEnabled(value: boolean);
  75617. /**
  75618. * Defines if the loader should capture performance counters.
  75619. */
  75620. get capturePerformanceCounters(): boolean;
  75621. set capturePerformanceCounters(value: boolean);
  75622. /**
  75623. * Defines if the loader should validate the asset.
  75624. */
  75625. validate: boolean;
  75626. /**
  75627. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75628. */
  75629. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75630. private _onValidatedObserver;
  75631. /**
  75632. * Callback raised after a loader extension is created.
  75633. */
  75634. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75635. private _loader;
  75636. /**
  75637. * Name of the loader ("gltf")
  75638. */
  75639. name: string;
  75640. /** @hidden */
  75641. extensions: ISceneLoaderPluginExtensions;
  75642. /**
  75643. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75644. */
  75645. dispose(): void;
  75646. /** @hidden */
  75647. _clear(): void;
  75648. /** @hidden */
  75649. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75650. /** @hidden */
  75651. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75652. /** @hidden */
  75653. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75654. meshes: AbstractMesh[];
  75655. particleSystems: IParticleSystem[];
  75656. skeletons: Skeleton[];
  75657. animationGroups: AnimationGroup[];
  75658. }>;
  75659. /** @hidden */
  75660. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75661. /** @hidden */
  75662. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75663. /** @hidden */
  75664. canDirectLoad(data: string): boolean;
  75665. /** @hidden */
  75666. directLoad(scene: Scene, data: string): any;
  75667. /**
  75668. * The callback that allows custom handling of the root url based on the response url.
  75669. * @param rootUrl the original root url
  75670. * @param responseURL the response url if available
  75671. * @returns the new root url
  75672. */
  75673. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75674. /** @hidden */
  75675. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75676. /**
  75677. * The loader state or null if the loader is not active.
  75678. */
  75679. get loaderState(): Nullable<GLTFLoaderState>;
  75680. /**
  75681. * Returns a promise that resolves when the asset is completely loaded.
  75682. * @returns a promise that resolves when the asset is completely loaded.
  75683. */
  75684. whenCompleteAsync(): Promise<void>;
  75685. private _validate;
  75686. private _getLoader;
  75687. private _parseJson;
  75688. private _unpackBinaryAsync;
  75689. private _unpackBinaryV1Async;
  75690. private _unpackBinaryV2Async;
  75691. private static _parseVersion;
  75692. private static _compareVersion;
  75693. private static readonly _logSpaces;
  75694. private _logIndentLevel;
  75695. private _loggingEnabled;
  75696. /** @hidden */
  75697. _log: (message: string) => void;
  75698. /** @hidden */
  75699. _logOpen(message: string): void;
  75700. /** @hidden */
  75701. _logClose(): void;
  75702. private _logEnabled;
  75703. private _logDisabled;
  75704. private _capturePerformanceCounters;
  75705. /** @hidden */
  75706. _startPerformanceCounter: (counterName: string) => void;
  75707. /** @hidden */
  75708. _endPerformanceCounter: (counterName: string) => void;
  75709. private _startPerformanceCounterEnabled;
  75710. private _startPerformanceCounterDisabled;
  75711. private _endPerformanceCounterEnabled;
  75712. private _endPerformanceCounterDisabled;
  75713. }
  75714. }
  75715. declare module BABYLON.GLTF1 {
  75716. /**
  75717. * Enums
  75718. * @hidden
  75719. */
  75720. export enum EComponentType {
  75721. BYTE = 5120,
  75722. UNSIGNED_BYTE = 5121,
  75723. SHORT = 5122,
  75724. UNSIGNED_SHORT = 5123,
  75725. FLOAT = 5126
  75726. }
  75727. /** @hidden */
  75728. export enum EShaderType {
  75729. FRAGMENT = 35632,
  75730. VERTEX = 35633
  75731. }
  75732. /** @hidden */
  75733. export enum EParameterType {
  75734. BYTE = 5120,
  75735. UNSIGNED_BYTE = 5121,
  75736. SHORT = 5122,
  75737. UNSIGNED_SHORT = 5123,
  75738. INT = 5124,
  75739. UNSIGNED_INT = 5125,
  75740. FLOAT = 5126,
  75741. FLOAT_VEC2 = 35664,
  75742. FLOAT_VEC3 = 35665,
  75743. FLOAT_VEC4 = 35666,
  75744. INT_VEC2 = 35667,
  75745. INT_VEC3 = 35668,
  75746. INT_VEC4 = 35669,
  75747. BOOL = 35670,
  75748. BOOL_VEC2 = 35671,
  75749. BOOL_VEC3 = 35672,
  75750. BOOL_VEC4 = 35673,
  75751. FLOAT_MAT2 = 35674,
  75752. FLOAT_MAT3 = 35675,
  75753. FLOAT_MAT4 = 35676,
  75754. SAMPLER_2D = 35678
  75755. }
  75756. /** @hidden */
  75757. export enum ETextureWrapMode {
  75758. CLAMP_TO_EDGE = 33071,
  75759. MIRRORED_REPEAT = 33648,
  75760. REPEAT = 10497
  75761. }
  75762. /** @hidden */
  75763. export enum ETextureFilterType {
  75764. NEAREST = 9728,
  75765. LINEAR = 9728,
  75766. NEAREST_MIPMAP_NEAREST = 9984,
  75767. LINEAR_MIPMAP_NEAREST = 9985,
  75768. NEAREST_MIPMAP_LINEAR = 9986,
  75769. LINEAR_MIPMAP_LINEAR = 9987
  75770. }
  75771. /** @hidden */
  75772. export enum ETextureFormat {
  75773. ALPHA = 6406,
  75774. RGB = 6407,
  75775. RGBA = 6408,
  75776. LUMINANCE = 6409,
  75777. LUMINANCE_ALPHA = 6410
  75778. }
  75779. /** @hidden */
  75780. export enum ECullingType {
  75781. FRONT = 1028,
  75782. BACK = 1029,
  75783. FRONT_AND_BACK = 1032
  75784. }
  75785. /** @hidden */
  75786. export enum EBlendingFunction {
  75787. ZERO = 0,
  75788. ONE = 1,
  75789. SRC_COLOR = 768,
  75790. ONE_MINUS_SRC_COLOR = 769,
  75791. DST_COLOR = 774,
  75792. ONE_MINUS_DST_COLOR = 775,
  75793. SRC_ALPHA = 770,
  75794. ONE_MINUS_SRC_ALPHA = 771,
  75795. DST_ALPHA = 772,
  75796. ONE_MINUS_DST_ALPHA = 773,
  75797. CONSTANT_COLOR = 32769,
  75798. ONE_MINUS_CONSTANT_COLOR = 32770,
  75799. CONSTANT_ALPHA = 32771,
  75800. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75801. SRC_ALPHA_SATURATE = 776
  75802. }
  75803. /** @hidden */
  75804. export interface IGLTFProperty {
  75805. extensions?: {
  75806. [key: string]: any;
  75807. };
  75808. extras?: Object;
  75809. }
  75810. /** @hidden */
  75811. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75812. name?: string;
  75813. }
  75814. /** @hidden */
  75815. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75816. bufferView: string;
  75817. byteOffset: number;
  75818. byteStride: number;
  75819. count: number;
  75820. type: string;
  75821. componentType: EComponentType;
  75822. max?: number[];
  75823. min?: number[];
  75824. name?: string;
  75825. }
  75826. /** @hidden */
  75827. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75828. buffer: string;
  75829. byteOffset: number;
  75830. byteLength: number;
  75831. byteStride: number;
  75832. target?: number;
  75833. }
  75834. /** @hidden */
  75835. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75836. uri: string;
  75837. byteLength?: number;
  75838. type?: string;
  75839. }
  75840. /** @hidden */
  75841. export interface IGLTFShader extends IGLTFChildRootProperty {
  75842. uri: string;
  75843. type: EShaderType;
  75844. }
  75845. /** @hidden */
  75846. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75847. attributes: string[];
  75848. fragmentShader: string;
  75849. vertexShader: string;
  75850. }
  75851. /** @hidden */
  75852. export interface IGLTFTechniqueParameter {
  75853. type: number;
  75854. count?: number;
  75855. semantic?: string;
  75856. node?: string;
  75857. value?: number | boolean | string | Array<any>;
  75858. source?: string;
  75859. babylonValue?: any;
  75860. }
  75861. /** @hidden */
  75862. export interface IGLTFTechniqueCommonProfile {
  75863. lightingModel: string;
  75864. texcoordBindings: Object;
  75865. parameters?: Array<any>;
  75866. }
  75867. /** @hidden */
  75868. export interface IGLTFTechniqueStatesFunctions {
  75869. blendColor?: number[];
  75870. blendEquationSeparate?: number[];
  75871. blendFuncSeparate?: number[];
  75872. colorMask: boolean[];
  75873. cullFace: number[];
  75874. }
  75875. /** @hidden */
  75876. export interface IGLTFTechniqueStates {
  75877. enable: number[];
  75878. functions: IGLTFTechniqueStatesFunctions;
  75879. }
  75880. /** @hidden */
  75881. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75882. parameters: {
  75883. [key: string]: IGLTFTechniqueParameter;
  75884. };
  75885. program: string;
  75886. attributes: {
  75887. [key: string]: string;
  75888. };
  75889. uniforms: {
  75890. [key: string]: string;
  75891. };
  75892. states: IGLTFTechniqueStates;
  75893. }
  75894. /** @hidden */
  75895. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75896. technique?: string;
  75897. values: string[];
  75898. }
  75899. /** @hidden */
  75900. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75901. attributes: {
  75902. [key: string]: string;
  75903. };
  75904. indices: string;
  75905. material: string;
  75906. mode?: number;
  75907. }
  75908. /** @hidden */
  75909. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75910. primitives: IGLTFMeshPrimitive[];
  75911. }
  75912. /** @hidden */
  75913. export interface IGLTFImage extends IGLTFChildRootProperty {
  75914. uri: string;
  75915. }
  75916. /** @hidden */
  75917. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75918. magFilter?: number;
  75919. minFilter?: number;
  75920. wrapS?: number;
  75921. wrapT?: number;
  75922. }
  75923. /** @hidden */
  75924. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75925. sampler: string;
  75926. source: string;
  75927. format?: ETextureFormat;
  75928. internalFormat?: ETextureFormat;
  75929. target?: number;
  75930. type?: number;
  75931. babylonTexture?: Texture;
  75932. }
  75933. /** @hidden */
  75934. export interface IGLTFAmbienLight {
  75935. color?: number[];
  75936. }
  75937. /** @hidden */
  75938. export interface IGLTFDirectionalLight {
  75939. color?: number[];
  75940. }
  75941. /** @hidden */
  75942. export interface IGLTFPointLight {
  75943. color?: number[];
  75944. constantAttenuation?: number;
  75945. linearAttenuation?: number;
  75946. quadraticAttenuation?: number;
  75947. }
  75948. /** @hidden */
  75949. export interface IGLTFSpotLight {
  75950. color?: number[];
  75951. constantAttenuation?: number;
  75952. fallOfAngle?: number;
  75953. fallOffExponent?: number;
  75954. linearAttenuation?: number;
  75955. quadraticAttenuation?: number;
  75956. }
  75957. /** @hidden */
  75958. export interface IGLTFLight extends IGLTFChildRootProperty {
  75959. type: string;
  75960. }
  75961. /** @hidden */
  75962. export interface IGLTFCameraOrthographic {
  75963. xmag: number;
  75964. ymag: number;
  75965. zfar: number;
  75966. znear: number;
  75967. }
  75968. /** @hidden */
  75969. export interface IGLTFCameraPerspective {
  75970. aspectRatio: number;
  75971. yfov: number;
  75972. zfar: number;
  75973. znear: number;
  75974. }
  75975. /** @hidden */
  75976. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75977. type: string;
  75978. }
  75979. /** @hidden */
  75980. export interface IGLTFAnimationChannelTarget {
  75981. id: string;
  75982. path: string;
  75983. }
  75984. /** @hidden */
  75985. export interface IGLTFAnimationChannel {
  75986. sampler: string;
  75987. target: IGLTFAnimationChannelTarget;
  75988. }
  75989. /** @hidden */
  75990. export interface IGLTFAnimationSampler {
  75991. input: string;
  75992. output: string;
  75993. interpolation?: string;
  75994. }
  75995. /** @hidden */
  75996. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75997. channels?: IGLTFAnimationChannel[];
  75998. parameters?: {
  75999. [key: string]: string;
  76000. };
  76001. samplers?: {
  76002. [key: string]: IGLTFAnimationSampler;
  76003. };
  76004. }
  76005. /** @hidden */
  76006. export interface IGLTFNodeInstanceSkin {
  76007. skeletons: string[];
  76008. skin: string;
  76009. meshes: string[];
  76010. }
  76011. /** @hidden */
  76012. export interface IGLTFSkins extends IGLTFChildRootProperty {
  76013. bindShapeMatrix: number[];
  76014. inverseBindMatrices: string;
  76015. jointNames: string[];
  76016. babylonSkeleton?: Skeleton;
  76017. }
  76018. /** @hidden */
  76019. export interface IGLTFNode extends IGLTFChildRootProperty {
  76020. camera?: string;
  76021. children: string[];
  76022. skin?: string;
  76023. jointName?: string;
  76024. light?: string;
  76025. matrix: number[];
  76026. mesh?: string;
  76027. meshes?: string[];
  76028. rotation?: number[];
  76029. scale?: number[];
  76030. translation?: number[];
  76031. babylonNode?: Node;
  76032. }
  76033. /** @hidden */
  76034. export interface IGLTFScene extends IGLTFChildRootProperty {
  76035. nodes: string[];
  76036. }
  76037. /** @hidden */
  76038. export interface IGLTFRuntime {
  76039. extensions: {
  76040. [key: string]: any;
  76041. };
  76042. accessors: {
  76043. [key: string]: IGLTFAccessor;
  76044. };
  76045. buffers: {
  76046. [key: string]: IGLTFBuffer;
  76047. };
  76048. bufferViews: {
  76049. [key: string]: IGLTFBufferView;
  76050. };
  76051. meshes: {
  76052. [key: string]: IGLTFMesh;
  76053. };
  76054. lights: {
  76055. [key: string]: IGLTFLight;
  76056. };
  76057. cameras: {
  76058. [key: string]: IGLTFCamera;
  76059. };
  76060. nodes: {
  76061. [key: string]: IGLTFNode;
  76062. };
  76063. images: {
  76064. [key: string]: IGLTFImage;
  76065. };
  76066. textures: {
  76067. [key: string]: IGLTFTexture;
  76068. };
  76069. shaders: {
  76070. [key: string]: IGLTFShader;
  76071. };
  76072. programs: {
  76073. [key: string]: IGLTFProgram;
  76074. };
  76075. samplers: {
  76076. [key: string]: IGLTFSampler;
  76077. };
  76078. techniques: {
  76079. [key: string]: IGLTFTechnique;
  76080. };
  76081. materials: {
  76082. [key: string]: IGLTFMaterial;
  76083. };
  76084. animations: {
  76085. [key: string]: IGLTFAnimation;
  76086. };
  76087. skins: {
  76088. [key: string]: IGLTFSkins;
  76089. };
  76090. currentScene?: Object;
  76091. scenes: {
  76092. [key: string]: IGLTFScene;
  76093. };
  76094. extensionsUsed: string[];
  76095. extensionsRequired?: string[];
  76096. buffersCount: number;
  76097. shaderscount: number;
  76098. scene: Scene;
  76099. rootUrl: string;
  76100. loadedBufferCount: number;
  76101. loadedBufferViews: {
  76102. [name: string]: ArrayBufferView;
  76103. };
  76104. loadedShaderCount: number;
  76105. importOnlyMeshes: boolean;
  76106. importMeshesNames?: string[];
  76107. dummyNodes: Node[];
  76108. forAssetContainer: boolean;
  76109. }
  76110. /** @hidden */
  76111. export interface INodeToRoot {
  76112. bone: Bone;
  76113. node: IGLTFNode;
  76114. id: string;
  76115. }
  76116. /** @hidden */
  76117. export interface IJointNode {
  76118. node: IGLTFNode;
  76119. id: string;
  76120. }
  76121. }
  76122. declare module BABYLON.GLTF1 {
  76123. /**
  76124. * Utils functions for GLTF
  76125. * @hidden
  76126. */
  76127. export class GLTFUtils {
  76128. /**
  76129. * Sets the given "parameter" matrix
  76130. * @param scene: the Scene object
  76131. * @param source: the source node where to pick the matrix
  76132. * @param parameter: the GLTF technique parameter
  76133. * @param uniformName: the name of the shader's uniform
  76134. * @param shaderMaterial: the shader material
  76135. */
  76136. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  76137. /**
  76138. * Sets the given "parameter" matrix
  76139. * @param shaderMaterial: the shader material
  76140. * @param uniform: the name of the shader's uniform
  76141. * @param value: the value of the uniform
  76142. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  76143. */
  76144. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  76145. /**
  76146. * Returns the wrap mode of the texture
  76147. * @param mode: the mode value
  76148. */
  76149. static GetWrapMode(mode: number): number;
  76150. /**
  76151. * Returns the byte stride giving an accessor
  76152. * @param accessor: the GLTF accessor objet
  76153. */
  76154. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  76155. /**
  76156. * Returns the texture filter mode giving a mode value
  76157. * @param mode: the filter mode value
  76158. */
  76159. static GetTextureFilterMode(mode: number): ETextureFilterType;
  76160. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  76161. /**
  76162. * Returns a buffer from its accessor
  76163. * @param gltfRuntime: the GLTF runtime
  76164. * @param accessor: the GLTF accessor
  76165. */
  76166. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  76167. /**
  76168. * Decodes a buffer view into a string
  76169. * @param view: the buffer view
  76170. */
  76171. static DecodeBufferToText(view: ArrayBufferView): string;
  76172. /**
  76173. * Returns the default material of gltf. Related to
  76174. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  76175. * @param scene: the Babylon.js scene
  76176. */
  76177. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  76178. private static _DefaultMaterial;
  76179. }
  76180. }
  76181. declare module BABYLON.GLTF1 {
  76182. /**
  76183. * Implementation of the base glTF spec
  76184. * @hidden
  76185. */
  76186. export class GLTFLoaderBase {
  76187. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  76188. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76189. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  76190. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76191. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  76192. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76193. }
  76194. /**
  76195. * glTF V1 Loader
  76196. * @hidden
  76197. */
  76198. export class GLTFLoader implements IGLTFLoader {
  76199. static Extensions: {
  76200. [name: string]: GLTFLoaderExtension;
  76201. };
  76202. static RegisterExtension(extension: GLTFLoaderExtension): void;
  76203. state: Nullable<GLTFLoaderState>;
  76204. dispose(): void;
  76205. private _importMeshAsync;
  76206. /**
  76207. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  76208. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76209. * @param scene the scene the meshes should be added to
  76210. * @param forAssetContainer defines if the entities must be stored in the scene
  76211. * @param data gltf data containing information of the meshes in a loaded file
  76212. * @param rootUrl root url to load from
  76213. * @param onProgress event that fires when loading progress has occured
  76214. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76215. */
  76216. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  76217. private _loadAsync;
  76218. /**
  76219. * Imports all objects from a loaded gltf file and adds them to the scene
  76220. * @param scene the scene the objects should be added to
  76221. * @param data gltf data containing information of the meshes in a loaded file
  76222. * @param rootUrl root url to load from
  76223. * @param onProgress event that fires when loading progress has occured
  76224. * @returns a promise which completes when objects have been loaded to the scene
  76225. */
  76226. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  76227. private _loadShadersAsync;
  76228. private _loadBuffersAsync;
  76229. private _createNodes;
  76230. }
  76231. /** @hidden */
  76232. export abstract class GLTFLoaderExtension {
  76233. private _name;
  76234. constructor(name: string);
  76235. get name(): string;
  76236. /**
  76237. * Defines an override for loading the runtime
  76238. * Return true to stop further extensions from loading the runtime
  76239. */
  76240. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76241. /**
  76242. * Defines an onverride for creating gltf runtime
  76243. * Return true to stop further extensions from creating the runtime
  76244. */
  76245. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76246. /**
  76247. * Defines an override for loading buffers
  76248. * Return true to stop further extensions from loading this buffer
  76249. */
  76250. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76251. /**
  76252. * Defines an override for loading texture buffers
  76253. * Return true to stop further extensions from loading this texture data
  76254. */
  76255. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76256. /**
  76257. * Defines an override for creating textures
  76258. * Return true to stop further extensions from loading this texture
  76259. */
  76260. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76261. /**
  76262. * Defines an override for loading shader strings
  76263. * Return true to stop further extensions from loading this shader data
  76264. */
  76265. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76266. /**
  76267. * Defines an override for loading materials
  76268. * Return true to stop further extensions from loading this material
  76269. */
  76270. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76271. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76272. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76273. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76274. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76275. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76276. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76277. private static LoadTextureBufferAsync;
  76278. private static CreateTextureAsync;
  76279. private static ApplyExtensions;
  76280. }
  76281. }
  76282. declare module BABYLON.GLTF1 {
  76283. /** @hidden */
  76284. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76285. private _bin;
  76286. constructor();
  76287. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76288. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76289. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76290. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76291. }
  76292. }
  76293. declare module BABYLON.GLTF1 {
  76294. /** @hidden */
  76295. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76296. constructor();
  76297. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76298. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76299. private _loadTexture;
  76300. }
  76301. }
  76302. declare module BABYLON.GLTF2.Loader {
  76303. /**
  76304. * Loader interface with an index field.
  76305. */
  76306. export interface IArrayItem {
  76307. /**
  76308. * The index of this item in the array.
  76309. */
  76310. index: number;
  76311. }
  76312. /**
  76313. * Loader interface with additional members.
  76314. */
  76315. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76316. /** @hidden */
  76317. _data?: Promise<ArrayBufferView>;
  76318. /** @hidden */
  76319. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76320. }
  76321. /**
  76322. * Loader interface with additional members.
  76323. */
  76324. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76325. }
  76326. /** @hidden */
  76327. export interface _IAnimationSamplerData {
  76328. input: Float32Array;
  76329. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76330. output: Float32Array;
  76331. }
  76332. /**
  76333. * Loader interface with additional members.
  76334. */
  76335. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76336. /** @hidden */
  76337. _data?: Promise<_IAnimationSamplerData>;
  76338. }
  76339. /**
  76340. * Loader interface with additional members.
  76341. */
  76342. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76343. channels: IAnimationChannel[];
  76344. samplers: IAnimationSampler[];
  76345. /** @hidden */
  76346. _babylonAnimationGroup?: AnimationGroup;
  76347. }
  76348. /**
  76349. * Loader interface with additional members.
  76350. */
  76351. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76352. /** @hidden */
  76353. _data?: Promise<ArrayBufferView>;
  76354. }
  76355. /**
  76356. * Loader interface with additional members.
  76357. */
  76358. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76359. /** @hidden */
  76360. _data?: Promise<ArrayBufferView>;
  76361. /** @hidden */
  76362. _babylonBuffer?: Promise<Buffer>;
  76363. }
  76364. /**
  76365. * Loader interface with additional members.
  76366. */
  76367. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76368. }
  76369. /**
  76370. * Loader interface with additional members.
  76371. */
  76372. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76373. /** @hidden */
  76374. _data?: Promise<ArrayBufferView>;
  76375. }
  76376. /**
  76377. * Loader interface with additional members.
  76378. */
  76379. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76380. }
  76381. /**
  76382. * Loader interface with additional members.
  76383. */
  76384. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76385. }
  76386. /**
  76387. * Loader interface with additional members.
  76388. */
  76389. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76390. baseColorTexture?: ITextureInfo;
  76391. metallicRoughnessTexture?: ITextureInfo;
  76392. }
  76393. /**
  76394. * Loader interface with additional members.
  76395. */
  76396. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76397. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76398. normalTexture?: IMaterialNormalTextureInfo;
  76399. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76400. emissiveTexture?: ITextureInfo;
  76401. /** @hidden */
  76402. _data?: {
  76403. [babylonDrawMode: number]: {
  76404. babylonMaterial: Material;
  76405. babylonMeshes: AbstractMesh[];
  76406. promise: Promise<void>;
  76407. };
  76408. };
  76409. }
  76410. /**
  76411. * Loader interface with additional members.
  76412. */
  76413. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76414. primitives: IMeshPrimitive[];
  76415. }
  76416. /**
  76417. * Loader interface with additional members.
  76418. */
  76419. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76420. /** @hidden */
  76421. _instanceData?: {
  76422. babylonSourceMesh: Mesh;
  76423. promise: Promise<any>;
  76424. };
  76425. }
  76426. /**
  76427. * Loader interface with additional members.
  76428. */
  76429. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76430. /**
  76431. * The parent glTF node.
  76432. */
  76433. parent?: INode;
  76434. /** @hidden */
  76435. _babylonTransformNode?: TransformNode;
  76436. /** @hidden */
  76437. _primitiveBabylonMeshes?: AbstractMesh[];
  76438. /** @hidden */
  76439. _babylonBones?: Bone[];
  76440. /** @hidden */
  76441. _numMorphTargets?: number;
  76442. }
  76443. /** @hidden */
  76444. export interface _ISamplerData {
  76445. noMipMaps: boolean;
  76446. samplingMode: number;
  76447. wrapU: number;
  76448. wrapV: number;
  76449. }
  76450. /**
  76451. * Loader interface with additional members.
  76452. */
  76453. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76454. /** @hidden */
  76455. _data?: _ISamplerData;
  76456. }
  76457. /**
  76458. * Loader interface with additional members.
  76459. */
  76460. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76461. }
  76462. /**
  76463. * Loader interface with additional members.
  76464. */
  76465. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76466. /** @hidden */
  76467. _data?: {
  76468. babylonSkeleton: Skeleton;
  76469. promise: Promise<void>;
  76470. };
  76471. }
  76472. /**
  76473. * Loader interface with additional members.
  76474. */
  76475. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76476. }
  76477. /**
  76478. * Loader interface with additional members.
  76479. */
  76480. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76481. }
  76482. /**
  76483. * Loader interface with additional members.
  76484. */
  76485. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76486. accessors?: IAccessor[];
  76487. animations?: IAnimation[];
  76488. buffers?: IBuffer[];
  76489. bufferViews?: IBufferView[];
  76490. cameras?: ICamera[];
  76491. images?: IImage[];
  76492. materials?: IMaterial[];
  76493. meshes?: IMesh[];
  76494. nodes?: INode[];
  76495. samplers?: ISampler[];
  76496. scenes?: IScene[];
  76497. skins?: ISkin[];
  76498. textures?: ITexture[];
  76499. }
  76500. }
  76501. declare module BABYLON.GLTF2 {
  76502. /**
  76503. * Interface for a glTF loader extension.
  76504. */
  76505. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76506. /**
  76507. * Called after the loader state changes to LOADING.
  76508. */
  76509. onLoading?(): void;
  76510. /**
  76511. * Called after the loader state changes to READY.
  76512. */
  76513. onReady?(): void;
  76514. /**
  76515. * Define this method to modify the default behavior when loading scenes.
  76516. * @param context The context when loading the asset
  76517. * @param scene The glTF scene property
  76518. * @returns A promise that resolves when the load is complete or null if not handled
  76519. */
  76520. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76521. /**
  76522. * Define this method to modify the default behavior when loading nodes.
  76523. * @param context The context when loading the asset
  76524. * @param node The glTF node property
  76525. * @param assign A function called synchronously after parsing the glTF properties
  76526. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76527. */
  76528. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76529. /**
  76530. * Define this method to modify the default behavior when loading cameras.
  76531. * @param context The context when loading the asset
  76532. * @param camera The glTF camera property
  76533. * @param assign A function called synchronously after parsing the glTF properties
  76534. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76535. */
  76536. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76537. /**
  76538. * @hidden
  76539. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76540. * @param context The context when loading the asset
  76541. * @param primitive The glTF mesh primitive property
  76542. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76543. */
  76544. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76545. /**
  76546. * @hidden
  76547. * Define this method to modify the default behavior when loading data for mesh primitives.
  76548. * @param context The context when loading the asset
  76549. * @param name The mesh name when loading the asset
  76550. * @param node The glTF node when loading the asset
  76551. * @param mesh The glTF mesh when loading the asset
  76552. * @param primitive The glTF mesh primitive property
  76553. * @param assign A function called synchronously after parsing the glTF properties
  76554. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76555. */
  76556. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76557. /**
  76558. * @hidden
  76559. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76560. * @param context The context when loading the asset
  76561. * @param material The glTF material property
  76562. * @param assign A function called synchronously after parsing the glTF properties
  76563. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76564. */
  76565. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76566. /**
  76567. * Define this method to modify the default behavior when creating materials.
  76568. * @param context The context when loading the asset
  76569. * @param material The glTF material property
  76570. * @param babylonDrawMode The draw mode for the Babylon material
  76571. * @returns The Babylon material or null if not handled
  76572. */
  76573. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76574. /**
  76575. * Define this method to modify the default behavior when loading material properties.
  76576. * @param context The context when loading the asset
  76577. * @param material The glTF material property
  76578. * @param babylonMaterial The Babylon material
  76579. * @returns A promise that resolves when the load is complete or null if not handled
  76580. */
  76581. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76582. /**
  76583. * Define this method to modify the default behavior when loading texture infos.
  76584. * @param context The context when loading the asset
  76585. * @param textureInfo The glTF texture info property
  76586. * @param assign A function called synchronously after parsing the glTF properties
  76587. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76588. */
  76589. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76590. /**
  76591. * @hidden
  76592. * Define this method to modify the default behavior when loading textures.
  76593. * @param context The context when loading the asset
  76594. * @param texture The glTF texture property
  76595. * @param assign A function called synchronously after parsing the glTF properties
  76596. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76597. */
  76598. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76599. /**
  76600. * Define this method to modify the default behavior when loading animations.
  76601. * @param context The context when loading the asset
  76602. * @param animation The glTF animation property
  76603. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76604. */
  76605. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76606. /**
  76607. * @hidden
  76608. * Define this method to modify the default behavior when loading skins.
  76609. * @param context The context when loading the asset
  76610. * @param node The glTF node property
  76611. * @param skin The glTF skin property
  76612. * @returns A promise that resolves when the load is complete or null if not handled
  76613. */
  76614. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76615. /**
  76616. * @hidden
  76617. * Define this method to modify the default behavior when loading uris.
  76618. * @param context The context when loading the asset
  76619. * @param property The glTF property associated with the uri
  76620. * @param uri The uri to load
  76621. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76622. */
  76623. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76624. /**
  76625. * Define this method to modify the default behavior when loading buffer views.
  76626. * @param context The context when loading the asset
  76627. * @param bufferView The glTF buffer view property
  76628. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76629. */
  76630. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76631. /**
  76632. * Define this method to modify the default behavior when loading buffers.
  76633. * @param context The context when loading the asset
  76634. * @param buffer The glTF buffer property
  76635. * @param byteOffset The byte offset to load
  76636. * @param byteLength The byte length to load
  76637. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76638. */
  76639. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76640. }
  76641. }
  76642. declare module BABYLON.GLTF2 {
  76643. /**
  76644. * Helper class for working with arrays when loading the glTF asset
  76645. */
  76646. export class ArrayItem {
  76647. /**
  76648. * Gets an item from the given array.
  76649. * @param context The context when loading the asset
  76650. * @param array The array to get the item from
  76651. * @param index The index to the array
  76652. * @returns The array item
  76653. */
  76654. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76655. /**
  76656. * Assign an `index` field to each item of the given array.
  76657. * @param array The array of items
  76658. */
  76659. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76660. }
  76661. /**
  76662. * The glTF 2.0 loader
  76663. */
  76664. export class GLTFLoader implements IGLTFLoader {
  76665. /** @hidden */
  76666. _completePromises: Promise<any>[];
  76667. /** @hidden */
  76668. _forAssetContainer: boolean;
  76669. /** Storage */
  76670. _babylonLights: Light[];
  76671. private _disposed;
  76672. private _parent;
  76673. private _state;
  76674. private _extensions;
  76675. private _rootUrl;
  76676. private _fileName;
  76677. private _uniqueRootUrl;
  76678. private _gltf;
  76679. private _bin;
  76680. private _babylonScene;
  76681. private _rootBabylonMesh;
  76682. private _defaultBabylonMaterialData;
  76683. private _progressCallback?;
  76684. private _requests;
  76685. private static _RegisteredExtensions;
  76686. /**
  76687. * The default glTF sampler.
  76688. */
  76689. static readonly DefaultSampler: ISampler;
  76690. /**
  76691. * Registers a loader extension.
  76692. * @param name The name of the loader extension.
  76693. * @param factory The factory function that creates the loader extension.
  76694. */
  76695. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76696. /**
  76697. * Unregisters a loader extension.
  76698. * @param name The name of the loader extension.
  76699. * @returns A boolean indicating whether the extension has been unregistered
  76700. */
  76701. static UnregisterExtension(name: string): boolean;
  76702. /**
  76703. * The loader state.
  76704. */
  76705. get state(): Nullable<GLTFLoaderState>;
  76706. /**
  76707. * The object that represents the glTF JSON.
  76708. */
  76709. get gltf(): IGLTF;
  76710. /**
  76711. * The BIN chunk of a binary glTF.
  76712. */
  76713. get bin(): Nullable<IDataBuffer>;
  76714. /**
  76715. * The parent file loader.
  76716. */
  76717. get parent(): GLTFFileLoader;
  76718. /**
  76719. * The Babylon scene when loading the asset.
  76720. */
  76721. get babylonScene(): Scene;
  76722. /**
  76723. * The root Babylon mesh when loading the asset.
  76724. */
  76725. get rootBabylonMesh(): Mesh;
  76726. /** @hidden */
  76727. constructor(parent: GLTFFileLoader);
  76728. /** @hidden */
  76729. dispose(): void;
  76730. /** @hidden */
  76731. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76732. /** @hidden */
  76733. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76734. private _loadAsync;
  76735. private _loadData;
  76736. private _setupData;
  76737. private _loadExtensions;
  76738. private _checkExtensions;
  76739. private _setState;
  76740. private _createRootNode;
  76741. /**
  76742. * Loads a glTF scene.
  76743. * @param context The context when loading the asset
  76744. * @param scene The glTF scene property
  76745. * @returns A promise that resolves when the load is complete
  76746. */
  76747. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76748. private _forEachPrimitive;
  76749. private _getMeshes;
  76750. private _getTransformNodes;
  76751. private _getSkeletons;
  76752. private _getAnimationGroups;
  76753. private _startAnimations;
  76754. /**
  76755. * Loads a glTF node.
  76756. * @param context The context when loading the asset
  76757. * @param node The glTF node property
  76758. * @param assign A function called synchronously after parsing the glTF properties
  76759. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76760. */
  76761. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76762. private _loadMeshAsync;
  76763. /**
  76764. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76765. * @param context The context when loading the asset
  76766. * @param name The mesh name when loading the asset
  76767. * @param node The glTF node when loading the asset
  76768. * @param mesh The glTF mesh when loading the asset
  76769. * @param primitive The glTF mesh primitive property
  76770. * @param assign A function called synchronously after parsing the glTF properties
  76771. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76772. */
  76773. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76774. private _loadVertexDataAsync;
  76775. private _createMorphTargets;
  76776. private _loadMorphTargetsAsync;
  76777. private _loadMorphTargetVertexDataAsync;
  76778. private static _LoadTransform;
  76779. private _loadSkinAsync;
  76780. private _loadBones;
  76781. private _loadBone;
  76782. private _loadSkinInverseBindMatricesDataAsync;
  76783. private _updateBoneMatrices;
  76784. private _getNodeMatrix;
  76785. /**
  76786. * Loads a glTF camera.
  76787. * @param context The context when loading the asset
  76788. * @param camera The glTF camera property
  76789. * @param assign A function called synchronously after parsing the glTF properties
  76790. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76791. */
  76792. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76793. private _loadAnimationsAsync;
  76794. /**
  76795. * Loads a glTF animation.
  76796. * @param context The context when loading the asset
  76797. * @param animation The glTF animation property
  76798. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76799. */
  76800. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76801. /**
  76802. * @hidden Loads a glTF animation channel.
  76803. * @param context The context when loading the asset
  76804. * @param animationContext The context of the animation when loading the asset
  76805. * @param animation The glTF animation property
  76806. * @param channel The glTF animation channel property
  76807. * @param babylonAnimationGroup The babylon animation group property
  76808. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76809. * @returns A void promise when the channel load is complete
  76810. */
  76811. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76812. private _loadAnimationSamplerAsync;
  76813. private _loadBufferAsync;
  76814. /**
  76815. * Loads a glTF buffer view.
  76816. * @param context The context when loading the asset
  76817. * @param bufferView The glTF buffer view property
  76818. * @returns A promise that resolves with the loaded data when the load is complete
  76819. */
  76820. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76821. private _loadAccessorAsync;
  76822. /** @hidden */
  76823. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76824. private _loadIndicesAccessorAsync;
  76825. private _loadVertexBufferViewAsync;
  76826. private _loadVertexAccessorAsync;
  76827. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76828. /** @hidden */
  76829. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76830. private _createDefaultMaterial;
  76831. /**
  76832. * Creates a Babylon material from a glTF material.
  76833. * @param context The context when loading the asset
  76834. * @param material The glTF material property
  76835. * @param babylonDrawMode The draw mode for the Babylon material
  76836. * @returns The Babylon material
  76837. */
  76838. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76839. /**
  76840. * Loads properties from a glTF material into a Babylon material.
  76841. * @param context The context when loading the asset
  76842. * @param material The glTF material property
  76843. * @param babylonMaterial The Babylon material
  76844. * @returns A promise that resolves when the load is complete
  76845. */
  76846. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76847. /**
  76848. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76849. * @param context The context when loading the asset
  76850. * @param material The glTF material property
  76851. * @param babylonMaterial The Babylon material
  76852. * @returns A promise that resolves when the load is complete
  76853. */
  76854. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76855. /**
  76856. * Loads the alpha properties from a glTF material into a Babylon material.
  76857. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76858. * @param context The context when loading the asset
  76859. * @param material The glTF material property
  76860. * @param babylonMaterial The Babylon material
  76861. */
  76862. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76863. /**
  76864. * Loads a glTF texture info.
  76865. * @param context The context when loading the asset
  76866. * @param textureInfo The glTF texture info property
  76867. * @param assign A function called synchronously after parsing the glTF properties
  76868. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76869. */
  76870. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76871. /** @hidden */
  76872. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76873. /** @hidden */
  76874. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76875. private _loadSampler;
  76876. /**
  76877. * Loads a glTF image.
  76878. * @param context The context when loading the asset
  76879. * @param image The glTF image property
  76880. * @returns A promise that resolves with the loaded data when the load is complete
  76881. */
  76882. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76883. /**
  76884. * Loads a glTF uri.
  76885. * @param context The context when loading the asset
  76886. * @param property The glTF property associated with the uri
  76887. * @param uri The base64 or relative uri
  76888. * @returns A promise that resolves with the loaded data when the load is complete
  76889. */
  76890. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76891. private _onProgress;
  76892. /**
  76893. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76894. * @param babylonObject the Babylon object with metadata
  76895. * @param pointer the JSON pointer
  76896. */
  76897. static AddPointerMetadata(babylonObject: {
  76898. metadata: any;
  76899. }, pointer: string): void;
  76900. private static _GetTextureWrapMode;
  76901. private static _GetTextureSamplingMode;
  76902. private static _GetTypedArrayConstructor;
  76903. private static _GetTypedArray;
  76904. private static _GetNumComponents;
  76905. private static _ValidateUri;
  76906. private static _GetDrawMode;
  76907. private _compileMaterialsAsync;
  76908. private _compileShadowGeneratorsAsync;
  76909. private _forEachExtensions;
  76910. private _applyExtensions;
  76911. private _extensionsOnLoading;
  76912. private _extensionsOnReady;
  76913. private _extensionsLoadSceneAsync;
  76914. private _extensionsLoadNodeAsync;
  76915. private _extensionsLoadCameraAsync;
  76916. private _extensionsLoadVertexDataAsync;
  76917. private _extensionsLoadMeshPrimitiveAsync;
  76918. private _extensionsLoadMaterialAsync;
  76919. private _extensionsCreateMaterial;
  76920. private _extensionsLoadMaterialPropertiesAsync;
  76921. private _extensionsLoadTextureInfoAsync;
  76922. private _extensionsLoadTextureAsync;
  76923. private _extensionsLoadAnimationAsync;
  76924. private _extensionsLoadSkinAsync;
  76925. private _extensionsLoadUriAsync;
  76926. private _extensionsLoadBufferViewAsync;
  76927. private _extensionsLoadBufferAsync;
  76928. /**
  76929. * Helper method called by a loader extension to load an glTF extension.
  76930. * @param context The context when loading the asset
  76931. * @param property The glTF property to load the extension from
  76932. * @param extensionName The name of the extension to load
  76933. * @param actionAsync The action to run
  76934. * @returns The promise returned by actionAsync or null if the extension does not exist
  76935. */
  76936. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76937. /**
  76938. * Helper method called by a loader extension to load a glTF extra.
  76939. * @param context The context when loading the asset
  76940. * @param property The glTF property to load the extra from
  76941. * @param extensionName The name of the extension to load
  76942. * @param actionAsync The action to run
  76943. * @returns The promise returned by actionAsync or null if the extra does not exist
  76944. */
  76945. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76946. /**
  76947. * Checks for presence of an extension.
  76948. * @param name The name of the extension to check
  76949. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76950. */
  76951. isExtensionUsed(name: string): boolean;
  76952. /**
  76953. * Increments the indentation level and logs a message.
  76954. * @param message The message to log
  76955. */
  76956. logOpen(message: string): void;
  76957. /**
  76958. * Decrements the indentation level.
  76959. */
  76960. logClose(): void;
  76961. /**
  76962. * Logs a message
  76963. * @param message The message to log
  76964. */
  76965. log(message: string): void;
  76966. /**
  76967. * Starts a performance counter.
  76968. * @param counterName The name of the performance counter
  76969. */
  76970. startPerformanceCounter(counterName: string): void;
  76971. /**
  76972. * Ends a performance counter.
  76973. * @param counterName The name of the performance counter
  76974. */
  76975. endPerformanceCounter(counterName: string): void;
  76976. }
  76977. }
  76978. declare module BABYLON.GLTF2.Loader.Extensions {
  76979. /**
  76980. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76981. */
  76982. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76983. /**
  76984. * The name of this extension.
  76985. */
  76986. readonly name: string;
  76987. /**
  76988. * Defines whether this extension is enabled.
  76989. */
  76990. enabled: boolean;
  76991. private _loader;
  76992. private _lights?;
  76993. /** @hidden */
  76994. constructor(loader: GLTFLoader);
  76995. /** @hidden */
  76996. dispose(): void;
  76997. /** @hidden */
  76998. onLoading(): void;
  76999. /** @hidden */
  77000. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77001. private _loadLightAsync;
  77002. }
  77003. }
  77004. declare module BABYLON.GLTF2.Loader.Extensions {
  77005. /**
  77006. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  77007. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  77008. * !!! Experimental Extension Subject to Changes !!!
  77009. */
  77010. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  77011. /**
  77012. * The name of this extension.
  77013. */
  77014. readonly name: string;
  77015. /**
  77016. * Defines whether this extension is enabled.
  77017. */
  77018. enabled: boolean;
  77019. private _loader;
  77020. /** @hidden */
  77021. constructor(loader: GLTFLoader);
  77022. /** @hidden */
  77023. dispose(): void;
  77024. /** @hidden */
  77025. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77026. }
  77027. }
  77028. declare module BABYLON.GLTF2.Loader.Extensions {
  77029. /**
  77030. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  77031. */
  77032. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  77033. /**
  77034. * The name of this extension.
  77035. */
  77036. readonly name: string;
  77037. /**
  77038. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  77039. */
  77040. dracoCompression?: DracoCompression;
  77041. /**
  77042. * Defines whether this extension is enabled.
  77043. */
  77044. enabled: boolean;
  77045. private _loader;
  77046. /** @hidden */
  77047. constructor(loader: GLTFLoader);
  77048. /** @hidden */
  77049. dispose(): void;
  77050. /** @hidden */
  77051. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77052. }
  77053. }
  77054. declare module BABYLON.GLTF2.Loader.Extensions {
  77055. /**
  77056. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  77057. */
  77058. export class KHR_lights implements IGLTFLoaderExtension {
  77059. /**
  77060. * The name of this extension.
  77061. */
  77062. readonly name: string;
  77063. /**
  77064. * Defines whether this extension is enabled.
  77065. */
  77066. enabled: boolean;
  77067. private _loader;
  77068. private _lights?;
  77069. /** @hidden */
  77070. constructor(loader: GLTFLoader);
  77071. /** @hidden */
  77072. dispose(): void;
  77073. /** @hidden */
  77074. onLoading(): void;
  77075. /** @hidden */
  77076. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77077. }
  77078. }
  77079. declare module BABYLON.GLTF2.Loader.Extensions {
  77080. /**
  77081. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  77082. */
  77083. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  77084. /**
  77085. * The name of this extension.
  77086. */
  77087. readonly name: string;
  77088. /**
  77089. * Defines whether this extension is enabled.
  77090. */
  77091. enabled: boolean;
  77092. /**
  77093. * Defines a number that determines the order the extensions are applied.
  77094. */
  77095. order: number;
  77096. private _loader;
  77097. /** @hidden */
  77098. constructor(loader: GLTFLoader);
  77099. /** @hidden */
  77100. dispose(): void;
  77101. /** @hidden */
  77102. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77103. private _loadSpecularGlossinessPropertiesAsync;
  77104. }
  77105. }
  77106. declare module BABYLON.GLTF2.Loader.Extensions {
  77107. /**
  77108. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  77109. */
  77110. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  77111. /**
  77112. * The name of this extension.
  77113. */
  77114. readonly name: string;
  77115. /**
  77116. * Defines whether this extension is enabled.
  77117. */
  77118. enabled: boolean;
  77119. /**
  77120. * Defines a number that determines the order the extensions are applied.
  77121. */
  77122. order: number;
  77123. private _loader;
  77124. /** @hidden */
  77125. constructor(loader: GLTFLoader);
  77126. /** @hidden */
  77127. dispose(): void;
  77128. /** @hidden */
  77129. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77130. private _loadUnlitPropertiesAsync;
  77131. }
  77132. }
  77133. declare module BABYLON.GLTF2.Loader.Extensions {
  77134. /**
  77135. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77136. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  77137. * !!! Experimental Extension Subject to Changes !!!
  77138. */
  77139. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  77140. /**
  77141. * The name of this extension.
  77142. */
  77143. readonly name: string;
  77144. /**
  77145. * Defines whether this extension is enabled.
  77146. */
  77147. enabled: boolean;
  77148. /**
  77149. * Defines a number that determines the order the extensions are applied.
  77150. */
  77151. order: number;
  77152. private _loader;
  77153. /** @hidden */
  77154. constructor(loader: GLTFLoader);
  77155. /** @hidden */
  77156. dispose(): void;
  77157. /** @hidden */
  77158. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77159. private _loadClearCoatPropertiesAsync;
  77160. }
  77161. }
  77162. declare module BABYLON.GLTF2.Loader.Extensions {
  77163. /**
  77164. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  77165. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77166. * !!! Experimental Extension Subject to Changes !!!
  77167. */
  77168. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  77169. /**
  77170. * The name of this extension.
  77171. */
  77172. readonly name: string;
  77173. /**
  77174. * Defines whether this extension is enabled.
  77175. */
  77176. enabled: boolean;
  77177. /**
  77178. * Defines a number that determines the order the extensions are applied.
  77179. */
  77180. order: number;
  77181. private _loader;
  77182. /** @hidden */
  77183. constructor(loader: GLTFLoader);
  77184. /** @hidden */
  77185. dispose(): void;
  77186. /** @hidden */
  77187. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77188. private _loadSheenPropertiesAsync;
  77189. }
  77190. }
  77191. declare module BABYLON.GLTF2.Loader.Extensions {
  77192. /**
  77193. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77194. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77195. * !!! Experimental Extension Subject to Changes !!!
  77196. */
  77197. export class KHR_materials_specular implements IGLTFLoaderExtension {
  77198. /**
  77199. * The name of this extension.
  77200. */
  77201. readonly name: string;
  77202. /**
  77203. * Defines whether this extension is enabled.
  77204. */
  77205. enabled: boolean;
  77206. /**
  77207. * Defines a number that determines the order the extensions are applied.
  77208. */
  77209. order: number;
  77210. private _loader;
  77211. /** @hidden */
  77212. constructor(loader: GLTFLoader);
  77213. /** @hidden */
  77214. dispose(): void;
  77215. /** @hidden */
  77216. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77217. private _loadSpecularPropertiesAsync;
  77218. }
  77219. }
  77220. declare module BABYLON.GLTF2.Loader.Extensions {
  77221. /**
  77222. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  77223. */
  77224. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  77225. /**
  77226. * The name of this extension.
  77227. */
  77228. readonly name: string;
  77229. /**
  77230. * Defines whether this extension is enabled.
  77231. */
  77232. enabled: boolean;
  77233. /** @hidden */
  77234. constructor(loader: GLTFLoader);
  77235. /** @hidden */
  77236. dispose(): void;
  77237. }
  77238. }
  77239. declare module BABYLON.GLTF2.Loader.Extensions {
  77240. /**
  77241. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77242. * !!! Experimental Extension Subject to Changes !!!
  77243. */
  77244. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77245. /** The name of this extension. */
  77246. readonly name: string;
  77247. /** Defines whether this extension is enabled. */
  77248. enabled: boolean;
  77249. private _loader;
  77250. /** @hidden */
  77251. constructor(loader: GLTFLoader);
  77252. /** @hidden */
  77253. dispose(): void;
  77254. /** @hidden */
  77255. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77256. }
  77257. }
  77258. declare module BABYLON.GLTF2.Loader.Extensions {
  77259. /**
  77260. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77261. */
  77262. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77263. /**
  77264. * The name of this extension.
  77265. */
  77266. readonly name: string;
  77267. /**
  77268. * Defines whether this extension is enabled.
  77269. */
  77270. enabled: boolean;
  77271. private _loader;
  77272. /** @hidden */
  77273. constructor(loader: GLTFLoader);
  77274. /** @hidden */
  77275. dispose(): void;
  77276. /** @hidden */
  77277. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77278. }
  77279. }
  77280. declare module BABYLON.GLTF2.Loader.Extensions {
  77281. /**
  77282. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77283. */
  77284. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77285. /**
  77286. * The name of this extension.
  77287. */
  77288. readonly name: string;
  77289. /**
  77290. * Defines whether this extension is enabled.
  77291. */
  77292. enabled: boolean;
  77293. private _loader;
  77294. private _clips;
  77295. private _emitters;
  77296. /** @hidden */
  77297. constructor(loader: GLTFLoader);
  77298. /** @hidden */
  77299. dispose(): void;
  77300. /** @hidden */
  77301. onLoading(): void;
  77302. /** @hidden */
  77303. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77304. /** @hidden */
  77305. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77306. /** @hidden */
  77307. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77308. private _loadClipAsync;
  77309. private _loadEmitterAsync;
  77310. private _getEventAction;
  77311. private _loadAnimationEventAsync;
  77312. }
  77313. }
  77314. declare module BABYLON.GLTF2.Loader.Extensions {
  77315. /**
  77316. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77317. */
  77318. export class MSFT_lod implements IGLTFLoaderExtension {
  77319. /**
  77320. * The name of this extension.
  77321. */
  77322. readonly name: string;
  77323. /**
  77324. * Defines whether this extension is enabled.
  77325. */
  77326. enabled: boolean;
  77327. /**
  77328. * Defines a number that determines the order the extensions are applied.
  77329. */
  77330. order: number;
  77331. /**
  77332. * Maximum number of LODs to load, starting from the lowest LOD.
  77333. */
  77334. maxLODsToLoad: number;
  77335. /**
  77336. * Observable raised when all node LODs of one level are loaded.
  77337. * The event data is the index of the loaded LOD starting from zero.
  77338. * Dispose the loader to cancel the loading of the next level of LODs.
  77339. */
  77340. onNodeLODsLoadedObservable: Observable<number>;
  77341. /**
  77342. * Observable raised when all material LODs of one level are loaded.
  77343. * The event data is the index of the loaded LOD starting from zero.
  77344. * Dispose the loader to cancel the loading of the next level of LODs.
  77345. */
  77346. onMaterialLODsLoadedObservable: Observable<number>;
  77347. private _loader;
  77348. private _nodeIndexLOD;
  77349. private _nodeSignalLODs;
  77350. private _nodePromiseLODs;
  77351. private _materialIndexLOD;
  77352. private _materialSignalLODs;
  77353. private _materialPromiseLODs;
  77354. private _indexLOD;
  77355. private _bufferLODs;
  77356. /** @hidden */
  77357. constructor(loader: GLTFLoader);
  77358. /** @hidden */
  77359. dispose(): void;
  77360. /** @hidden */
  77361. onReady(): void;
  77362. /** @hidden */
  77363. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77364. /** @hidden */
  77365. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77366. /** @hidden */
  77367. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77368. /** @hidden */
  77369. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77370. /** @hidden */
  77371. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77372. private _loadBufferLOD;
  77373. /**
  77374. * Gets an array of LOD properties from lowest to highest.
  77375. */
  77376. private _getLODs;
  77377. private _disposeTransformNode;
  77378. private _disposeMaterials;
  77379. }
  77380. }
  77381. declare module BABYLON.GLTF2.Loader.Extensions {
  77382. /** @hidden */
  77383. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77384. readonly name: string;
  77385. enabled: boolean;
  77386. private _loader;
  77387. constructor(loader: GLTFLoader);
  77388. dispose(): void;
  77389. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77390. }
  77391. }
  77392. declare module BABYLON.GLTF2.Loader.Extensions {
  77393. /** @hidden */
  77394. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77395. readonly name: string;
  77396. enabled: boolean;
  77397. private _loader;
  77398. constructor(loader: GLTFLoader);
  77399. dispose(): void;
  77400. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77401. }
  77402. }
  77403. declare module BABYLON.GLTF2.Loader.Extensions {
  77404. /**
  77405. * Store glTF extras (if present) in BJS objects' metadata
  77406. */
  77407. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77408. /**
  77409. * The name of this extension.
  77410. */
  77411. readonly name: string;
  77412. /**
  77413. * Defines whether this extension is enabled.
  77414. */
  77415. enabled: boolean;
  77416. private _loader;
  77417. private _assignExtras;
  77418. /** @hidden */
  77419. constructor(loader: GLTFLoader);
  77420. /** @hidden */
  77421. dispose(): void;
  77422. /** @hidden */
  77423. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77424. /** @hidden */
  77425. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77426. /** @hidden */
  77427. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77428. }
  77429. }
  77430. declare module BABYLON {
  77431. /**
  77432. * Class reading and parsing the MTL file bundled with the obj file.
  77433. */
  77434. export class MTLFileLoader {
  77435. /**
  77436. * Invert Y-Axis of referenced textures on load
  77437. */
  77438. static INVERT_TEXTURE_Y: boolean;
  77439. /**
  77440. * All material loaded from the mtl will be set here
  77441. */
  77442. materials: StandardMaterial[];
  77443. /**
  77444. * This function will read the mtl file and create each material described inside
  77445. * This function could be improve by adding :
  77446. * -some component missing (Ni, Tf...)
  77447. * -including the specific options available
  77448. *
  77449. * @param scene defines the scene the material will be created in
  77450. * @param data defines the mtl data to parse
  77451. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77452. * @param forAssetContainer defines if the material should be registered in the scene
  77453. */
  77454. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77455. /**
  77456. * Gets the texture for the material.
  77457. *
  77458. * If the material is imported from input file,
  77459. * We sanitize the url to ensure it takes the textre from aside the material.
  77460. *
  77461. * @param rootUrl The root url to load from
  77462. * @param value The value stored in the mtl
  77463. * @return The Texture
  77464. */
  77465. private static _getTexture;
  77466. }
  77467. }
  77468. declare module BABYLON {
  77469. /**
  77470. * Options for loading OBJ/MTL files
  77471. */
  77472. type MeshLoadOptions = {
  77473. /**
  77474. * Defines if UVs are optimized by default during load.
  77475. */
  77476. OptimizeWithUV: boolean;
  77477. /**
  77478. * Defines custom scaling of UV coordinates of loaded meshes.
  77479. */
  77480. UVScaling: Vector2;
  77481. /**
  77482. * Invert model on y-axis (does a model scaling inversion)
  77483. */
  77484. InvertY: boolean;
  77485. /**
  77486. * Invert Y-Axis of referenced textures on load
  77487. */
  77488. InvertTextureY: boolean;
  77489. /**
  77490. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77491. */
  77492. ImportVertexColors: boolean;
  77493. /**
  77494. * Compute the normals for the model, even if normals are present in the file.
  77495. */
  77496. ComputeNormals: boolean;
  77497. /**
  77498. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77499. */
  77500. SkipMaterials: boolean;
  77501. /**
  77502. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77503. */
  77504. MaterialLoadingFailsSilently: boolean;
  77505. };
  77506. /**
  77507. * OBJ file type loader.
  77508. * This is a babylon scene loader plugin.
  77509. */
  77510. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77511. /**
  77512. * Defines if UVs are optimized by default during load.
  77513. */
  77514. static OPTIMIZE_WITH_UV: boolean;
  77515. /**
  77516. * Invert model on y-axis (does a model scaling inversion)
  77517. */
  77518. static INVERT_Y: boolean;
  77519. /**
  77520. * Invert Y-Axis of referenced textures on load
  77521. */
  77522. static get INVERT_TEXTURE_Y(): boolean;
  77523. static set INVERT_TEXTURE_Y(value: boolean);
  77524. /**
  77525. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77526. */
  77527. static IMPORT_VERTEX_COLORS: boolean;
  77528. /**
  77529. * Compute the normals for the model, even if normals are present in the file.
  77530. */
  77531. static COMPUTE_NORMALS: boolean;
  77532. /**
  77533. * Defines custom scaling of UV coordinates of loaded meshes.
  77534. */
  77535. static UV_SCALING: Vector2;
  77536. /**
  77537. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77538. */
  77539. static SKIP_MATERIALS: boolean;
  77540. /**
  77541. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77542. *
  77543. * Defaults to true for backwards compatibility.
  77544. */
  77545. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77546. /**
  77547. * Defines the name of the plugin.
  77548. */
  77549. name: string;
  77550. /**
  77551. * Defines the extension the plugin is able to load.
  77552. */
  77553. extensions: string;
  77554. /** @hidden */
  77555. obj: RegExp;
  77556. /** @hidden */
  77557. group: RegExp;
  77558. /** @hidden */
  77559. mtllib: RegExp;
  77560. /** @hidden */
  77561. usemtl: RegExp;
  77562. /** @hidden */
  77563. smooth: RegExp;
  77564. /** @hidden */
  77565. vertexPattern: RegExp;
  77566. /** @hidden */
  77567. normalPattern: RegExp;
  77568. /** @hidden */
  77569. uvPattern: RegExp;
  77570. /** @hidden */
  77571. facePattern1: RegExp;
  77572. /** @hidden */
  77573. facePattern2: RegExp;
  77574. /** @hidden */
  77575. facePattern3: RegExp;
  77576. /** @hidden */
  77577. facePattern4: RegExp;
  77578. /** @hidden */
  77579. facePattern5: RegExp;
  77580. private _forAssetContainer;
  77581. private _meshLoadOptions;
  77582. /**
  77583. * Creates loader for .OBJ files
  77584. *
  77585. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77586. */
  77587. constructor(meshLoadOptions?: MeshLoadOptions);
  77588. private static get currentMeshLoadOptions();
  77589. /**
  77590. * Calls synchronously the MTL file attached to this obj.
  77591. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77592. * Without this function materials are not displayed in the first frame (but displayed after).
  77593. * In consequence it is impossible to get material information in your HTML file
  77594. *
  77595. * @param url The URL of the MTL file
  77596. * @param rootUrl
  77597. * @param onSuccess Callback function to be called when the MTL file is loaded
  77598. * @private
  77599. */
  77600. private _loadMTL;
  77601. /**
  77602. * Instantiates a OBJ file loader plugin.
  77603. * @returns the created plugin
  77604. */
  77605. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77606. /**
  77607. * If the data string can be loaded directly.
  77608. *
  77609. * @param data string containing the file data
  77610. * @returns if the data can be loaded directly
  77611. */
  77612. canDirectLoad(data: string): boolean;
  77613. /**
  77614. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77615. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77616. * @param scene the scene the meshes should be added to
  77617. * @param data the OBJ data to load
  77618. * @param rootUrl root url to load from
  77619. * @param onProgress event that fires when loading progress has occured
  77620. * @param fileName Defines the name of the file to load
  77621. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77622. */
  77623. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77624. meshes: AbstractMesh[];
  77625. particleSystems: IParticleSystem[];
  77626. skeletons: Skeleton[];
  77627. animationGroups: AnimationGroup[];
  77628. }>;
  77629. /**
  77630. * Imports all objects from the loaded OBJ data and adds them to the scene
  77631. * @param scene the scene the objects should be added to
  77632. * @param data the OBJ data to load
  77633. * @param rootUrl root url to load from
  77634. * @param onProgress event that fires when loading progress has occured
  77635. * @param fileName Defines the name of the file to load
  77636. * @returns a promise which completes when objects have been loaded to the scene
  77637. */
  77638. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77639. /**
  77640. * Load into an asset container.
  77641. * @param scene The scene to load into
  77642. * @param data The data to import
  77643. * @param rootUrl The root url for scene and resources
  77644. * @param onProgress The callback when the load progresses
  77645. * @param fileName Defines the name of the file to load
  77646. * @returns The loaded asset container
  77647. */
  77648. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77649. /**
  77650. * Read the OBJ file and create an Array of meshes.
  77651. * Each mesh contains all information given by the OBJ and the MTL file.
  77652. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77653. *
  77654. * @param meshesNames
  77655. * @param scene Scene The scene where are displayed the data
  77656. * @param data String The content of the obj file
  77657. * @param rootUrl String The path to the folder
  77658. * @returns Array<AbstractMesh>
  77659. * @private
  77660. */
  77661. private _parseSolid;
  77662. }
  77663. }
  77664. declare module BABYLON {
  77665. /**
  77666. * STL file type loader.
  77667. * This is a babylon scene loader plugin.
  77668. */
  77669. export class STLFileLoader implements ISceneLoaderPlugin {
  77670. /** @hidden */
  77671. solidPattern: RegExp;
  77672. /** @hidden */
  77673. facetsPattern: RegExp;
  77674. /** @hidden */
  77675. normalPattern: RegExp;
  77676. /** @hidden */
  77677. vertexPattern: RegExp;
  77678. /**
  77679. * Defines the name of the plugin.
  77680. */
  77681. name: string;
  77682. /**
  77683. * Defines the extensions the stl loader is able to load.
  77684. * force data to come in as an ArrayBuffer
  77685. * we'll convert to string if it looks like it's an ASCII .stl
  77686. */
  77687. extensions: ISceneLoaderPluginExtensions;
  77688. /**
  77689. * Import meshes into a scene.
  77690. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77691. * @param scene The scene to import into
  77692. * @param data The data to import
  77693. * @param rootUrl The root url for scene and resources
  77694. * @param meshes The meshes array to import into
  77695. * @param particleSystems The particle systems array to import into
  77696. * @param skeletons The skeletons array to import into
  77697. * @param onError The callback when import fails
  77698. * @returns True if successful or false otherwise
  77699. */
  77700. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77701. /**
  77702. * Load into a scene.
  77703. * @param scene The scene to load into
  77704. * @param data The data to import
  77705. * @param rootUrl The root url for scene and resources
  77706. * @param onError The callback when import fails
  77707. * @returns true if successful or false otherwise
  77708. */
  77709. load(scene: Scene, data: any, rootUrl: string): boolean;
  77710. /**
  77711. * Load into an asset container.
  77712. * @param scene The scene to load into
  77713. * @param data The data to import
  77714. * @param rootUrl The root url for scene and resources
  77715. * @param onError The callback when import fails
  77716. * @returns The loaded asset container
  77717. */
  77718. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77719. private _isBinary;
  77720. private _parseBinary;
  77721. private _parseASCII;
  77722. }
  77723. }
  77724. declare module BABYLON {
  77725. /**
  77726. * Class for generating OBJ data from a Babylon scene.
  77727. */
  77728. export class OBJExport {
  77729. /**
  77730. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77731. * @param mesh defines the list of meshes to serialize
  77732. * @param materials defines if materials should be exported
  77733. * @param matlibname defines the name of the associated mtl file
  77734. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77735. * @returns the OBJ content
  77736. */
  77737. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77738. /**
  77739. * Exports the material(s) of a mesh in .MTL file format (text)
  77740. * @param mesh defines the mesh to extract the material from
  77741. * @returns the mtl content
  77742. */
  77743. static MTL(mesh: Mesh): string;
  77744. }
  77745. }
  77746. declare module BABYLON {
  77747. /** @hidden */
  77748. export var __IGLTFExporterExtension: number;
  77749. /**
  77750. * Interface for extending the exporter
  77751. * @hidden
  77752. */
  77753. export interface IGLTFExporterExtension {
  77754. /**
  77755. * The name of this extension
  77756. */
  77757. readonly name: string;
  77758. /**
  77759. * Defines whether this extension is enabled
  77760. */
  77761. enabled: boolean;
  77762. /**
  77763. * Defines whether this extension is required
  77764. */
  77765. required: boolean;
  77766. }
  77767. }
  77768. declare module BABYLON.GLTF2.Exporter {
  77769. /** @hidden */
  77770. export var __IGLTFExporterExtensionV2: number;
  77771. /**
  77772. * Interface for a glTF exporter extension
  77773. * @hidden
  77774. */
  77775. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77776. /**
  77777. * Define this method to modify the default behavior before exporting a texture
  77778. * @param context The context when loading the asset
  77779. * @param babylonTexture The Babylon.js texture
  77780. * @param mimeType The mime-type of the generated image
  77781. * @returns A promise that resolves with the exported texture
  77782. */
  77783. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77784. /**
  77785. * Define this method to get notified when a texture info is created
  77786. * @param context The context when loading the asset
  77787. * @param textureInfo The glTF texture info
  77788. * @param babylonTexture The Babylon.js texture
  77789. */
  77790. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77791. /**
  77792. * Define this method to modify the default behavior when exporting texture info
  77793. * @param context The context when loading the asset
  77794. * @param meshPrimitive glTF mesh primitive
  77795. * @param babylonSubMesh Babylon submesh
  77796. * @param binaryWriter glTF serializer binary writer instance
  77797. * @returns nullable IMeshPrimitive promise
  77798. */
  77799. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77800. /**
  77801. * Define this method to modify the default behavior when exporting a node
  77802. * @param context The context when exporting the node
  77803. * @param node glTF node
  77804. * @param babylonNode BabylonJS node
  77805. * @returns nullable INode promise
  77806. */
  77807. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77808. [key: number]: number;
  77809. }): Promise<Nullable<INode>>;
  77810. /**
  77811. * Define this method to modify the default behavior when exporting a material
  77812. * @param material glTF material
  77813. * @param babylonMaterial BabylonJS material
  77814. * @returns nullable IMaterial promise
  77815. */
  77816. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77817. /**
  77818. * Define this method to return additional textures to export from a material
  77819. * @param material glTF material
  77820. * @param babylonMaterial BabylonJS material
  77821. * @returns List of textures
  77822. */
  77823. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77824. /** Gets a boolean indicating that this extension was used */
  77825. wasUsed: boolean;
  77826. /** Gets a boolean indicating that this extension is required for the file to work */
  77827. required: boolean;
  77828. /**
  77829. * Called after the exporter state changes to EXPORTING
  77830. */
  77831. onExporting?(): void;
  77832. }
  77833. }
  77834. declare module BABYLON.GLTF2.Exporter {
  77835. /**
  77836. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77837. * @hidden
  77838. */
  77839. export class _GLTFMaterialExporter {
  77840. /**
  77841. * Represents the dielectric specular values for R, G and B
  77842. */
  77843. private static readonly _DielectricSpecular;
  77844. /**
  77845. * Allows the maximum specular power to be defined for material calculations
  77846. */
  77847. private static readonly _MaxSpecularPower;
  77848. /**
  77849. * Mapping to store textures
  77850. */
  77851. private _textureMap;
  77852. /**
  77853. * Numeric tolerance value
  77854. */
  77855. private static readonly _Epsilon;
  77856. /**
  77857. * Reference to the glTF Exporter
  77858. */
  77859. private _exporter;
  77860. constructor(exporter: _Exporter);
  77861. /**
  77862. * Specifies if two colors are approximately equal in value
  77863. * @param color1 first color to compare to
  77864. * @param color2 second color to compare to
  77865. * @param epsilon threshold value
  77866. */
  77867. private static FuzzyEquals;
  77868. /**
  77869. * Gets the materials from a Babylon scene and converts them to glTF materials
  77870. * @param scene babylonjs scene
  77871. * @param mimeType texture mime type
  77872. * @param images array of images
  77873. * @param textures array of textures
  77874. * @param materials array of materials
  77875. * @param imageData mapping of texture names to base64 textures
  77876. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77877. */
  77878. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77879. /**
  77880. * Makes a copy of the glTF material without the texture parameters
  77881. * @param originalMaterial original glTF material
  77882. * @returns glTF material without texture parameters
  77883. */
  77884. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77885. /**
  77886. * Specifies if the material has any texture parameters present
  77887. * @param material glTF Material
  77888. * @returns boolean specifying if texture parameters are present
  77889. */
  77890. _hasTexturesPresent(material: IMaterial): boolean;
  77891. /**
  77892. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77893. * @param babylonStandardMaterial
  77894. * @returns glTF Metallic Roughness Material representation
  77895. */
  77896. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77897. /**
  77898. * Computes the metallic factor
  77899. * @param diffuse diffused value
  77900. * @param specular specular value
  77901. * @param oneMinusSpecularStrength one minus the specular strength
  77902. * @returns metallic value
  77903. */
  77904. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77905. /**
  77906. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77907. * @param glTFMaterial glTF material
  77908. * @param babylonMaterial Babylon material
  77909. */
  77910. private static _SetAlphaMode;
  77911. /**
  77912. * Converts a Babylon Standard Material to a glTF Material
  77913. * @param babylonStandardMaterial BJS Standard Material
  77914. * @param mimeType mime type to use for the textures
  77915. * @param images array of glTF image interfaces
  77916. * @param textures array of glTF texture interfaces
  77917. * @param materials array of glTF material interfaces
  77918. * @param imageData map of image file name to data
  77919. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77920. */
  77921. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77922. private _finishMaterial;
  77923. /**
  77924. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77925. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77926. * @param mimeType mime type to use for the textures
  77927. * @param images array of glTF image interfaces
  77928. * @param textures array of glTF texture interfaces
  77929. * @param materials array of glTF material interfaces
  77930. * @param imageData map of image file name to data
  77931. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77932. */
  77933. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77934. /**
  77935. * Converts an image typed array buffer to a base64 image
  77936. * @param buffer typed array buffer
  77937. * @param width width of the image
  77938. * @param height height of the image
  77939. * @param mimeType mimetype of the image
  77940. * @returns base64 image string
  77941. */
  77942. private _createBase64FromCanvasAsync;
  77943. /**
  77944. * Generates a white texture based on the specified width and height
  77945. * @param width width of the texture in pixels
  77946. * @param height height of the texture in pixels
  77947. * @param scene babylonjs scene
  77948. * @returns white texture
  77949. */
  77950. private _createWhiteTexture;
  77951. /**
  77952. * 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
  77953. * @param texture1 first texture to resize
  77954. * @param texture2 second texture to resize
  77955. * @param scene babylonjs scene
  77956. * @returns resized textures or null
  77957. */
  77958. private _resizeTexturesToSameDimensions;
  77959. /**
  77960. * Converts an array of pixels to a Float32Array
  77961. * Throws an error if the pixel format is not supported
  77962. * @param pixels - array buffer containing pixel values
  77963. * @returns Float32 of pixels
  77964. */
  77965. private _convertPixelArrayToFloat32;
  77966. /**
  77967. * Convert Specular Glossiness Textures to Metallic Roughness
  77968. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77969. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77970. * @param diffuseTexture texture used to store diffuse information
  77971. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77972. * @param factors specular glossiness material factors
  77973. * @param mimeType the mime type to use for the texture
  77974. * @returns pbr metallic roughness interface or null
  77975. */
  77976. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77977. /**
  77978. * Converts specular glossiness material properties to metallic roughness
  77979. * @param specularGlossiness interface with specular glossiness material properties
  77980. * @returns interface with metallic roughness material properties
  77981. */
  77982. private _convertSpecularGlossinessToMetallicRoughness;
  77983. /**
  77984. * Calculates the surface reflectance, independent of lighting conditions
  77985. * @param color Color source to calculate brightness from
  77986. * @returns number representing the perceived brightness, or zero if color is undefined
  77987. */
  77988. private _getPerceivedBrightness;
  77989. /**
  77990. * Returns the maximum color component value
  77991. * @param color
  77992. * @returns maximum color component value, or zero if color is null or undefined
  77993. */
  77994. private _getMaxComponent;
  77995. /**
  77996. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77997. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77998. * @param mimeType mime type to use for the textures
  77999. * @param images array of glTF image interfaces
  78000. * @param textures array of glTF texture interfaces
  78001. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78002. * @param imageData map of image file name to data
  78003. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78004. * @returns glTF PBR Metallic Roughness factors
  78005. */
  78006. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  78007. private _getGLTFTextureSampler;
  78008. private _getGLTFTextureWrapMode;
  78009. private _getGLTFTextureWrapModesSampler;
  78010. /**
  78011. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  78012. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78013. * @param mimeType mime type to use for the textures
  78014. * @param images array of glTF image interfaces
  78015. * @param textures array of glTF texture interfaces
  78016. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78017. * @param imageData map of image file name to data
  78018. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78019. * @returns glTF PBR Metallic Roughness factors
  78020. */
  78021. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  78022. /**
  78023. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  78024. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78025. * @param mimeType mime type to use for the textures
  78026. * @param images array of glTF image interfaces
  78027. * @param textures array of glTF texture interfaces
  78028. * @param materials array of glTF material interfaces
  78029. * @param imageData map of image file name to data
  78030. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78031. */
  78032. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  78033. private setMetallicRoughnessPbrMaterial;
  78034. private getPixelsFromTexture;
  78035. /**
  78036. * Extracts a texture from a Babylon texture into file data and glTF data
  78037. * @param babylonTexture Babylon texture to extract
  78038. * @param mimeType Mime Type of the babylonTexture
  78039. * @return glTF texture info, or null if the texture format is not supported
  78040. */
  78041. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78042. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78043. /**
  78044. * Builds a texture from base64 string
  78045. * @param base64Texture base64 texture string
  78046. * @param baseTextureName Name to use for the texture
  78047. * @param mimeType image mime type for the texture
  78048. * @param images array of images
  78049. * @param textures array of textures
  78050. * @param imageData map of image data
  78051. * @returns glTF texture info, or null if the texture format is not supported
  78052. */
  78053. private _getTextureInfoFromBase64;
  78054. }
  78055. }
  78056. declare module BABYLON {
  78057. /**
  78058. * Class for holding and downloading glTF file data
  78059. */
  78060. export class GLTFData {
  78061. /**
  78062. * Object which contains the file name as the key and its data as the value
  78063. */
  78064. glTFFiles: {
  78065. [fileName: string]: string | Blob;
  78066. };
  78067. /**
  78068. * Initializes the glTF file object
  78069. */
  78070. constructor();
  78071. /**
  78072. * Downloads the glTF data as files based on their names and data
  78073. */
  78074. downloadFiles(): void;
  78075. }
  78076. }
  78077. declare module BABYLON {
  78078. /**
  78079. * Holds a collection of exporter options and parameters
  78080. */
  78081. export interface IExportOptions {
  78082. /**
  78083. * Function which indicates whether a babylon node should be exported or not
  78084. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  78085. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  78086. */
  78087. shouldExportNode?(node: Node): boolean;
  78088. /**
  78089. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  78090. * @param metadata source metadata to read from
  78091. * @returns the data to store to glTF node extras
  78092. */
  78093. metadataSelector?(metadata: any): any;
  78094. /**
  78095. * The sample rate to bake animation curves
  78096. */
  78097. animationSampleRate?: number;
  78098. /**
  78099. * Begin serialization without waiting for the scene to be ready
  78100. */
  78101. exportWithoutWaitingForScene?: boolean;
  78102. /**
  78103. * Indicates if coordinate system swapping root nodes should be included in export
  78104. */
  78105. includeCoordinateSystemConversionNodes?: boolean;
  78106. }
  78107. /**
  78108. * Class for generating glTF data from a Babylon scene.
  78109. */
  78110. export class GLTF2Export {
  78111. /**
  78112. * Exports the geometry of the scene to .gltf file format asynchronously
  78113. * @param scene Babylon scene with scene hierarchy information
  78114. * @param filePrefix File prefix to use when generating the glTF file
  78115. * @param options Exporter options
  78116. * @returns Returns an object with a .gltf file and associates texture names
  78117. * as keys and their data and paths as values
  78118. */
  78119. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78120. private static _PreExportAsync;
  78121. private static _PostExportAsync;
  78122. /**
  78123. * Exports the geometry of the scene to .glb file format asychronously
  78124. * @param scene Babylon scene with scene hierarchy information
  78125. * @param filePrefix File prefix to use when generating glb file
  78126. * @param options Exporter options
  78127. * @returns Returns an object with a .glb filename as key and data as value
  78128. */
  78129. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78130. }
  78131. }
  78132. declare module BABYLON.GLTF2.Exporter {
  78133. /**
  78134. * @hidden
  78135. */
  78136. export class _GLTFUtilities {
  78137. /**
  78138. * Creates a buffer view based on the supplied arguments
  78139. * @param bufferIndex index value of the specified buffer
  78140. * @param byteOffset byte offset value
  78141. * @param byteLength byte length of the bufferView
  78142. * @param byteStride byte distance between conequential elements
  78143. * @param name name of the buffer view
  78144. * @returns bufferView for glTF
  78145. */
  78146. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  78147. /**
  78148. * Creates an accessor based on the supplied arguments
  78149. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  78150. * @param name The name of the accessor
  78151. * @param type The type of the accessor
  78152. * @param componentType The datatype of components in the attribute
  78153. * @param count The number of attributes referenced by this accessor
  78154. * @param byteOffset The offset relative to the start of the bufferView in bytes
  78155. * @param min Minimum value of each component in this attribute
  78156. * @param max Maximum value of each component in this attribute
  78157. * @returns accessor for glTF
  78158. */
  78159. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  78160. /**
  78161. * Calculates the minimum and maximum values of an array of position floats
  78162. * @param positions Positions array of a mesh
  78163. * @param vertexStart Starting vertex offset to calculate min and max values
  78164. * @param vertexCount Number of vertices to check for min and max values
  78165. * @returns min number array and max number array
  78166. */
  78167. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  78168. min: number[];
  78169. max: number[];
  78170. };
  78171. /**
  78172. * Converts a new right-handed Vector3
  78173. * @param vector vector3 array
  78174. * @returns right-handed Vector3
  78175. */
  78176. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  78177. /**
  78178. * Converts a Vector3 to right-handed
  78179. * @param vector Vector3 to convert to right-handed
  78180. */
  78181. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  78182. /**
  78183. * Converts a three element number array to right-handed
  78184. * @param vector number array to convert to right-handed
  78185. */
  78186. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  78187. /**
  78188. * Converts a new right-handed Vector3
  78189. * @param vector vector3 array
  78190. * @returns right-handed Vector3
  78191. */
  78192. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  78193. /**
  78194. * Converts a Vector3 to right-handed
  78195. * @param vector Vector3 to convert to right-handed
  78196. */
  78197. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  78198. /**
  78199. * Converts a three element number array to right-handed
  78200. * @param vector number array to convert to right-handed
  78201. */
  78202. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  78203. /**
  78204. * Converts a Vector4 to right-handed
  78205. * @param vector Vector4 to convert to right-handed
  78206. */
  78207. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  78208. /**
  78209. * Converts a Vector4 to right-handed
  78210. * @param vector Vector4 to convert to right-handed
  78211. */
  78212. static _GetRightHandedArray4FromRef(vector: number[]): void;
  78213. /**
  78214. * Converts a Quaternion to right-handed
  78215. * @param quaternion Source quaternion to convert to right-handed
  78216. */
  78217. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  78218. /**
  78219. * Converts a Quaternion to right-handed
  78220. * @param quaternion Source quaternion to convert to right-handed
  78221. */
  78222. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  78223. static _NormalizeTangentFromRef(tangent: Vector4): void;
  78224. }
  78225. }
  78226. declare module BABYLON.GLTF2.Exporter {
  78227. /**
  78228. * Converts Babylon Scene into glTF 2.0.
  78229. * @hidden
  78230. */
  78231. export class _Exporter {
  78232. /**
  78233. * Stores the glTF to export
  78234. */
  78235. _glTF: IGLTF;
  78236. /**
  78237. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78238. */
  78239. _bufferViews: IBufferView[];
  78240. /**
  78241. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78242. */
  78243. _accessors: IAccessor[];
  78244. /**
  78245. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78246. */
  78247. _nodes: INode[];
  78248. /**
  78249. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78250. */
  78251. private _scenes;
  78252. /**
  78253. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78254. */
  78255. private _meshes;
  78256. /**
  78257. * Stores all the generated material information, which represents the appearance of each primitive
  78258. */
  78259. _materials: IMaterial[];
  78260. _materialMap: {
  78261. [materialID: number]: number;
  78262. };
  78263. /**
  78264. * Stores all the generated texture information, which is referenced by glTF materials
  78265. */
  78266. _textures: ITexture[];
  78267. /**
  78268. * Stores all the generated image information, which is referenced by glTF textures
  78269. */
  78270. _images: IImage[];
  78271. /**
  78272. * Stores all the texture samplers
  78273. */
  78274. _samplers: ISampler[];
  78275. /**
  78276. * Stores all the generated animation samplers, which is referenced by glTF animations
  78277. */
  78278. /**
  78279. * Stores the animations for glTF models
  78280. */
  78281. private _animations;
  78282. /**
  78283. * Stores the total amount of bytes stored in the glTF buffer
  78284. */
  78285. private _totalByteLength;
  78286. /**
  78287. * Stores a reference to the Babylon scene containing the source geometry and material information
  78288. */
  78289. _babylonScene: Scene;
  78290. /**
  78291. * Stores a map of the image data, where the key is the file name and the value
  78292. * is the image data
  78293. */
  78294. _imageData: {
  78295. [fileName: string]: {
  78296. data: Uint8Array;
  78297. mimeType: ImageMimeType;
  78298. };
  78299. };
  78300. /**
  78301. * Stores a map of the unique id of a node to its index in the node array
  78302. */
  78303. _nodeMap: {
  78304. [key: number]: number;
  78305. };
  78306. /**
  78307. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78308. */
  78309. _convertToRightHandedSystem: boolean;
  78310. /**
  78311. * Specifies if a Babylon node should be converted to right-handed on export
  78312. */
  78313. _convertToRightHandedSystemMap: {
  78314. [nodeId: number]: boolean;
  78315. };
  78316. _includeCoordinateSystemConversionNodes: boolean;
  78317. /**
  78318. * Baked animation sample rate
  78319. */
  78320. private _animationSampleRate;
  78321. private _options;
  78322. private _localEngine;
  78323. _glTFMaterialExporter: _GLTFMaterialExporter;
  78324. private _extensions;
  78325. private static _ExtensionNames;
  78326. private static _ExtensionFactories;
  78327. private _applyExtension;
  78328. private _applyExtensions;
  78329. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78330. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78331. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78332. [key: number]: number;
  78333. }): Promise<Nullable<INode>>;
  78334. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78335. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78336. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78337. private _forEachExtensions;
  78338. private _extensionsOnExporting;
  78339. /**
  78340. * Load glTF serializer extensions
  78341. */
  78342. private _loadExtensions;
  78343. /**
  78344. * Creates a glTF Exporter instance, which can accept optional exporter options
  78345. * @param babylonScene Babylon scene object
  78346. * @param options Options to modify the behavior of the exporter
  78347. */
  78348. constructor(babylonScene: Scene, options?: IExportOptions);
  78349. dispose(): void;
  78350. /**
  78351. * Registers a glTF exporter extension
  78352. * @param name Name of the extension to export
  78353. * @param factory The factory function that creates the exporter extension
  78354. */
  78355. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78356. /**
  78357. * Un-registers an exporter extension
  78358. * @param name The name fo the exporter extension
  78359. * @returns A boolean indicating whether the extension has been un-registered
  78360. */
  78361. static UnregisterExtension(name: string): boolean;
  78362. /**
  78363. * Lazy load a local engine
  78364. */
  78365. _getLocalEngine(): Engine;
  78366. private reorderIndicesBasedOnPrimitiveMode;
  78367. /**
  78368. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78369. * clock-wise during export to glTF
  78370. * @param submesh BabylonJS submesh
  78371. * @param primitiveMode Primitive mode of the mesh
  78372. * @param sideOrientation the winding order of the submesh
  78373. * @param vertexBufferKind The type of vertex attribute
  78374. * @param meshAttributeArray The vertex attribute data
  78375. * @param byteOffset The offset to the binary data
  78376. * @param binaryWriter The binary data for the glTF file
  78377. * @param convertToRightHandedSystem Converts the values to right-handed
  78378. */
  78379. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78380. /**
  78381. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78382. * clock-wise during export to glTF
  78383. * @param submesh BabylonJS submesh
  78384. * @param primitiveMode Primitive mode of the mesh
  78385. * @param sideOrientation the winding order of the submesh
  78386. * @param vertexBufferKind The type of vertex attribute
  78387. * @param meshAttributeArray The vertex attribute data
  78388. * @param byteOffset The offset to the binary data
  78389. * @param binaryWriter The binary data for the glTF file
  78390. * @param convertToRightHandedSystem Converts the values to right-handed
  78391. */
  78392. private reorderTriangleFillMode;
  78393. /**
  78394. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78395. * clock-wise during export to glTF
  78396. * @param submesh BabylonJS submesh
  78397. * @param primitiveMode Primitive mode of the mesh
  78398. * @param sideOrientation the winding order of the submesh
  78399. * @param vertexBufferKind The type of vertex attribute
  78400. * @param meshAttributeArray The vertex attribute data
  78401. * @param byteOffset The offset to the binary data
  78402. * @param binaryWriter The binary data for the glTF file
  78403. * @param convertToRightHandedSystem Converts the values to right-handed
  78404. */
  78405. private reorderTriangleStripDrawMode;
  78406. /**
  78407. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78408. * clock-wise during export to glTF
  78409. * @param submesh BabylonJS submesh
  78410. * @param primitiveMode Primitive mode of the mesh
  78411. * @param sideOrientation the winding order of the submesh
  78412. * @param vertexBufferKind The type of vertex attribute
  78413. * @param meshAttributeArray The vertex attribute data
  78414. * @param byteOffset The offset to the binary data
  78415. * @param binaryWriter The binary data for the glTF file
  78416. * @param convertToRightHandedSystem Converts the values to right-handed
  78417. */
  78418. private reorderTriangleFanMode;
  78419. /**
  78420. * Writes the vertex attribute data to binary
  78421. * @param vertices The vertices to write to the binary writer
  78422. * @param byteOffset The offset into the binary writer to overwrite binary data
  78423. * @param vertexAttributeKind The vertex attribute type
  78424. * @param meshAttributeArray The vertex attribute data
  78425. * @param binaryWriter The writer containing the binary data
  78426. * @param convertToRightHandedSystem Converts the values to right-handed
  78427. */
  78428. private writeVertexAttributeData;
  78429. /**
  78430. * Writes mesh attribute data to a data buffer
  78431. * Returns the bytelength of the data
  78432. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78433. * @param meshAttributeArray Array containing the attribute data
  78434. * @param binaryWriter The buffer to write the binary data to
  78435. * @param indices Used to specify the order of the vertex data
  78436. * @param convertToRightHandedSystem Converts the values to right-handed
  78437. */
  78438. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78439. /**
  78440. * Generates glTF json data
  78441. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78442. * @param glTFPrefix Text to use when prefixing a glTF file
  78443. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78444. * @returns json data as string
  78445. */
  78446. private generateJSON;
  78447. /**
  78448. * Generates data for .gltf and .bin files based on the glTF prefix string
  78449. * @param glTFPrefix Text to use when prefixing a glTF file
  78450. * @param dispose Dispose the exporter
  78451. * @returns GLTFData with glTF file data
  78452. */
  78453. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78454. /**
  78455. * Creates a binary buffer for glTF
  78456. * @returns array buffer for binary data
  78457. */
  78458. private _generateBinaryAsync;
  78459. /**
  78460. * Pads the number to a multiple of 4
  78461. * @param num number to pad
  78462. * @returns padded number
  78463. */
  78464. private _getPadding;
  78465. /**
  78466. * @hidden
  78467. */
  78468. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78469. /**
  78470. * Sets the TRS for each node
  78471. * @param node glTF Node for storing the transformation data
  78472. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78473. * @param convertToRightHandedSystem Converts the values to right-handed
  78474. */
  78475. private setNodeTransformation;
  78476. private getVertexBufferFromMesh;
  78477. /**
  78478. * Creates a bufferview based on the vertices type for the Babylon mesh
  78479. * @param kind Indicates the type of vertices data
  78480. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78481. * @param binaryWriter The buffer to write the bufferview data to
  78482. * @param convertToRightHandedSystem Converts the values to right-handed
  78483. */
  78484. private createBufferViewKind;
  78485. /**
  78486. * The primitive mode of the Babylon mesh
  78487. * @param babylonMesh The BabylonJS mesh
  78488. */
  78489. private getMeshPrimitiveMode;
  78490. /**
  78491. * Sets the primitive mode of the glTF mesh primitive
  78492. * @param meshPrimitive glTF mesh primitive
  78493. * @param primitiveMode The primitive mode
  78494. */
  78495. private setPrimitiveMode;
  78496. /**
  78497. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78498. * @param meshPrimitive glTF mesh primitive
  78499. * @param attributeKind vertex attribute
  78500. * @returns boolean specifying if uv coordinates are present
  78501. */
  78502. private setAttributeKind;
  78503. /**
  78504. * Sets data for the primitive attributes of each submesh
  78505. * @param mesh glTF Mesh object to store the primitive attribute information
  78506. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78507. * @param binaryWriter Buffer to write the attribute data to
  78508. * @param convertToRightHandedSystem Converts the values to right-handed
  78509. */
  78510. private setPrimitiveAttributesAsync;
  78511. /**
  78512. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78513. * @param node The node to check
  78514. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78515. */
  78516. private isBabylonCoordinateSystemConvertingNode;
  78517. /**
  78518. * Creates a glTF scene based on the array of meshes
  78519. * Returns the the total byte offset
  78520. * @param babylonScene Babylon scene to get the mesh data from
  78521. * @param binaryWriter Buffer to write binary data to
  78522. */
  78523. private createSceneAsync;
  78524. /**
  78525. * Creates a mapping of Node unique id to node index and handles animations
  78526. * @param babylonScene Babylon Scene
  78527. * @param nodes Babylon transform nodes
  78528. * @param binaryWriter Buffer to write binary data to
  78529. * @returns Node mapping of unique id to index
  78530. */
  78531. private createNodeMapAndAnimationsAsync;
  78532. /**
  78533. * Creates a glTF node from a Babylon mesh
  78534. * @param babylonMesh Source Babylon mesh
  78535. * @param binaryWriter Buffer for storing geometry data
  78536. * @param convertToRightHandedSystem Converts the values to right-handed
  78537. * @param nodeMap Node mapping of unique id to glTF node index
  78538. * @returns glTF node
  78539. */
  78540. private createNodeAsync;
  78541. }
  78542. /**
  78543. * @hidden
  78544. *
  78545. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78546. */
  78547. export class _BinaryWriter {
  78548. /**
  78549. * Array buffer which stores all binary data
  78550. */
  78551. private _arrayBuffer;
  78552. /**
  78553. * View of the array buffer
  78554. */
  78555. private _dataView;
  78556. /**
  78557. * byte offset of data in array buffer
  78558. */
  78559. private _byteOffset;
  78560. /**
  78561. * Initialize binary writer with an initial byte length
  78562. * @param byteLength Initial byte length of the array buffer
  78563. */
  78564. constructor(byteLength: number);
  78565. /**
  78566. * Resize the array buffer to the specified byte length
  78567. * @param byteLength
  78568. */
  78569. private resizeBuffer;
  78570. /**
  78571. * Get an array buffer with the length of the byte offset
  78572. * @returns ArrayBuffer resized to the byte offset
  78573. */
  78574. getArrayBuffer(): ArrayBuffer;
  78575. /**
  78576. * Get the byte offset of the array buffer
  78577. * @returns byte offset
  78578. */
  78579. getByteOffset(): number;
  78580. /**
  78581. * Stores an UInt8 in the array buffer
  78582. * @param entry
  78583. * @param byteOffset If defined, specifies where to set the value as an offset.
  78584. */
  78585. setUInt8(entry: number, byteOffset?: number): void;
  78586. /**
  78587. * Gets an UInt32 in the array buffer
  78588. * @param entry
  78589. * @param byteOffset If defined, specifies where to set the value as an offset.
  78590. */
  78591. getUInt32(byteOffset: number): number;
  78592. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78593. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78594. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78595. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78596. /**
  78597. * Stores a Float32 in the array buffer
  78598. * @param entry
  78599. */
  78600. setFloat32(entry: number, byteOffset?: number): void;
  78601. /**
  78602. * Stores an UInt32 in the array buffer
  78603. * @param entry
  78604. * @param byteOffset If defined, specifies where to set the value as an offset.
  78605. */
  78606. setUInt32(entry: number, byteOffset?: number): void;
  78607. }
  78608. }
  78609. declare module BABYLON.GLTF2.Exporter {
  78610. /**
  78611. * @hidden
  78612. * Interface to store animation data.
  78613. */
  78614. export interface _IAnimationData {
  78615. /**
  78616. * Keyframe data.
  78617. */
  78618. inputs: number[];
  78619. /**
  78620. * Value data.
  78621. */
  78622. outputs: number[][];
  78623. /**
  78624. * Animation interpolation data.
  78625. */
  78626. samplerInterpolation: AnimationSamplerInterpolation;
  78627. /**
  78628. * Minimum keyframe value.
  78629. */
  78630. inputsMin: number;
  78631. /**
  78632. * Maximum keyframe value.
  78633. */
  78634. inputsMax: number;
  78635. }
  78636. /**
  78637. * @hidden
  78638. */
  78639. export interface _IAnimationInfo {
  78640. /**
  78641. * The target channel for the animation
  78642. */
  78643. animationChannelTargetPath: AnimationChannelTargetPath;
  78644. /**
  78645. * The glTF accessor type for the data.
  78646. */
  78647. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78648. /**
  78649. * Specifies if quaternions should be used.
  78650. */
  78651. useQuaternion: boolean;
  78652. }
  78653. /**
  78654. * @hidden
  78655. * Utility class for generating glTF animation data from BabylonJS.
  78656. */
  78657. export class _GLTFAnimation {
  78658. /**
  78659. * @ignore
  78660. *
  78661. * Creates glTF channel animation from BabylonJS animation.
  78662. * @param babylonTransformNode - BabylonJS mesh.
  78663. * @param animation - animation.
  78664. * @param animationChannelTargetPath - The target animation channel.
  78665. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78666. * @param useQuaternion - Specifies if quaternions are used.
  78667. * @returns nullable IAnimationData
  78668. */
  78669. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78670. private static _DeduceAnimationInfo;
  78671. /**
  78672. * @ignore
  78673. * Create node animations from the transform node animations
  78674. * @param babylonNode
  78675. * @param runtimeGLTFAnimation
  78676. * @param idleGLTFAnimations
  78677. * @param nodeMap
  78678. * @param nodes
  78679. * @param binaryWriter
  78680. * @param bufferViews
  78681. * @param accessors
  78682. * @param convertToRightHandedSystem
  78683. * @param animationSampleRate
  78684. */
  78685. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78686. [key: number]: number;
  78687. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78688. /**
  78689. * @ignore
  78690. * Create node animations from the animation groups
  78691. * @param babylonScene
  78692. * @param glTFAnimations
  78693. * @param nodeMap
  78694. * @param nodes
  78695. * @param binaryWriter
  78696. * @param bufferViews
  78697. * @param accessors
  78698. * @param convertToRightHandedSystemMap
  78699. * @param animationSampleRate
  78700. */
  78701. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78702. [key: number]: number;
  78703. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78704. [nodeId: number]: boolean;
  78705. }, animationSampleRate: number): void;
  78706. private static AddAnimation;
  78707. /**
  78708. * Create a baked animation
  78709. * @param babylonTransformNode BabylonJS mesh
  78710. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78711. * @param animationChannelTargetPath animation target channel
  78712. * @param minFrame minimum animation frame
  78713. * @param maxFrame maximum animation frame
  78714. * @param fps frames per second of the animation
  78715. * @param inputs input key frames of the animation
  78716. * @param outputs output key frame data of the animation
  78717. * @param convertToRightHandedSystem converts the values to right-handed
  78718. * @param useQuaternion specifies if quaternions should be used
  78719. */
  78720. private static _CreateBakedAnimation;
  78721. private static _ConvertFactorToVector3OrQuaternion;
  78722. private static _SetInterpolatedValue;
  78723. /**
  78724. * Creates linear animation from the animation key frames
  78725. * @param babylonTransformNode BabylonJS mesh
  78726. * @param animation BabylonJS animation
  78727. * @param animationChannelTargetPath The target animation channel
  78728. * @param frameDelta The difference between the last and first frame of the animation
  78729. * @param inputs Array to store the key frame times
  78730. * @param outputs Array to store the key frame data
  78731. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78732. * @param useQuaternion Specifies if quaternions are used in the animation
  78733. */
  78734. private static _CreateLinearOrStepAnimation;
  78735. /**
  78736. * Creates cubic spline animation from the animation key frames
  78737. * @param babylonTransformNode BabylonJS mesh
  78738. * @param animation BabylonJS animation
  78739. * @param animationChannelTargetPath The target animation channel
  78740. * @param frameDelta The difference between the last and first frame of the animation
  78741. * @param inputs Array to store the key frame times
  78742. * @param outputs Array to store the key frame data
  78743. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78744. * @param useQuaternion Specifies if quaternions are used in the animation
  78745. */
  78746. private static _CreateCubicSplineAnimation;
  78747. private static _GetBasePositionRotationOrScale;
  78748. /**
  78749. * Adds a key frame value
  78750. * @param keyFrame
  78751. * @param animation
  78752. * @param outputs
  78753. * @param animationChannelTargetPath
  78754. * @param basePositionRotationOrScale
  78755. * @param convertToRightHandedSystem
  78756. * @param useQuaternion
  78757. */
  78758. private static _AddKeyframeValue;
  78759. /**
  78760. * Determine the interpolation based on the key frames
  78761. * @param keyFrames
  78762. * @param animationChannelTargetPath
  78763. * @param useQuaternion
  78764. */
  78765. private static _DeduceInterpolation;
  78766. /**
  78767. * Adds an input tangent or output tangent to the output data
  78768. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78769. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78770. * @param outputs The animation data by keyframe
  78771. * @param animationChannelTargetPath The target animation channel
  78772. * @param interpolation The interpolation type
  78773. * @param keyFrame The key frame with the animation data
  78774. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78775. * @param useQuaternion Specifies if quaternions are used
  78776. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78777. */
  78778. private static AddSplineTangent;
  78779. /**
  78780. * Get the minimum and maximum key frames' frame values
  78781. * @param keyFrames animation key frames
  78782. * @returns the minimum and maximum key frame value
  78783. */
  78784. private static calculateMinMaxKeyFrames;
  78785. }
  78786. }
  78787. declare module BABYLON.GLTF2.Exporter {
  78788. /** @hidden */
  78789. export var textureTransformPixelShader: {
  78790. name: string;
  78791. shader: string;
  78792. };
  78793. }
  78794. declare module BABYLON.GLTF2.Exporter.Extensions {
  78795. /**
  78796. * @hidden
  78797. */
  78798. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78799. private _recordedTextures;
  78800. /** Name of this extension */
  78801. readonly name: string;
  78802. /** Defines whether this extension is enabled */
  78803. enabled: boolean;
  78804. /** Defines whether this extension is required */
  78805. required: boolean;
  78806. /** Reference to the glTF exporter */
  78807. private _wasUsed;
  78808. constructor(exporter: _Exporter);
  78809. dispose(): void;
  78810. /** @hidden */
  78811. get wasUsed(): boolean;
  78812. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78813. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78814. /**
  78815. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78816. * @param babylonTexture
  78817. * @param offset
  78818. * @param rotation
  78819. * @param scale
  78820. * @param scene
  78821. */
  78822. private _textureTransformTextureAsync;
  78823. }
  78824. }
  78825. declare module BABYLON.GLTF2.Exporter.Extensions {
  78826. /**
  78827. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78828. */
  78829. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78830. /** The name of this extension. */
  78831. readonly name: string;
  78832. /** Defines whether this extension is enabled. */
  78833. enabled: boolean;
  78834. /** Defines whether this extension is required */
  78835. required: boolean;
  78836. /** Reference to the glTF exporter */
  78837. private _exporter;
  78838. private _lights;
  78839. /** @hidden */
  78840. constructor(exporter: _Exporter);
  78841. /** @hidden */
  78842. dispose(): void;
  78843. /** @hidden */
  78844. get wasUsed(): boolean;
  78845. /** @hidden */
  78846. onExporting(): void;
  78847. /**
  78848. * Define this method to modify the default behavior when exporting a node
  78849. * @param context The context when exporting the node
  78850. * @param node glTF node
  78851. * @param babylonNode BabylonJS node
  78852. * @param nodeMap Node mapping of unique id to glTF node index
  78853. * @returns nullable INode promise
  78854. */
  78855. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78856. [key: number]: number;
  78857. }): Promise<Nullable<INode>>;
  78858. }
  78859. }
  78860. declare module BABYLON.GLTF2.Exporter.Extensions {
  78861. /**
  78862. * @hidden
  78863. */
  78864. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78865. /** Name of this extension */
  78866. readonly name: string;
  78867. /** Defines whether this extension is enabled */
  78868. enabled: boolean;
  78869. /** Defines whether this extension is required */
  78870. required: boolean;
  78871. /** Reference to the glTF exporter */
  78872. private _textureInfos;
  78873. private _exportedTextures;
  78874. private _wasUsed;
  78875. constructor(exporter: _Exporter);
  78876. dispose(): void;
  78877. /** @hidden */
  78878. get wasUsed(): boolean;
  78879. private _getTextureIndex;
  78880. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78881. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78882. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78883. }
  78884. }
  78885. declare module BABYLON {
  78886. /**
  78887. * Class for generating STL data from a Babylon scene.
  78888. */
  78889. export class STLExport {
  78890. /**
  78891. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78892. * @param meshes list defines the mesh to serialize
  78893. * @param download triggers the automatic download of the file.
  78894. * @param fileName changes the downloads fileName.
  78895. * @param binary changes the STL to a binary type.
  78896. * @param isLittleEndian toggle for binary type exporter.
  78897. * @returns the STL as UTF8 string
  78898. */
  78899. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78900. }
  78901. }
  78902. declare module "babylonjs-gltf2interface" {
  78903. export = BABYLON.GLTF2;
  78904. }
  78905. /**
  78906. * Module for glTF 2.0 Interface
  78907. */
  78908. declare module BABYLON.GLTF2 {
  78909. /**
  78910. * The datatype of the components in the attribute
  78911. */
  78912. const enum AccessorComponentType {
  78913. /**
  78914. * Byte
  78915. */
  78916. BYTE = 5120,
  78917. /**
  78918. * Unsigned Byte
  78919. */
  78920. UNSIGNED_BYTE = 5121,
  78921. /**
  78922. * Short
  78923. */
  78924. SHORT = 5122,
  78925. /**
  78926. * Unsigned Short
  78927. */
  78928. UNSIGNED_SHORT = 5123,
  78929. /**
  78930. * Unsigned Int
  78931. */
  78932. UNSIGNED_INT = 5125,
  78933. /**
  78934. * Float
  78935. */
  78936. FLOAT = 5126,
  78937. }
  78938. /**
  78939. * Specifies if the attirbute is a scalar, vector, or matrix
  78940. */
  78941. const enum AccessorType {
  78942. /**
  78943. * Scalar
  78944. */
  78945. SCALAR = "SCALAR",
  78946. /**
  78947. * Vector2
  78948. */
  78949. VEC2 = "VEC2",
  78950. /**
  78951. * Vector3
  78952. */
  78953. VEC3 = "VEC3",
  78954. /**
  78955. * Vector4
  78956. */
  78957. VEC4 = "VEC4",
  78958. /**
  78959. * Matrix2x2
  78960. */
  78961. MAT2 = "MAT2",
  78962. /**
  78963. * Matrix3x3
  78964. */
  78965. MAT3 = "MAT3",
  78966. /**
  78967. * Matrix4x4
  78968. */
  78969. MAT4 = "MAT4",
  78970. }
  78971. /**
  78972. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78973. */
  78974. const enum AnimationChannelTargetPath {
  78975. /**
  78976. * Translation
  78977. */
  78978. TRANSLATION = "translation",
  78979. /**
  78980. * Rotation
  78981. */
  78982. ROTATION = "rotation",
  78983. /**
  78984. * Scale
  78985. */
  78986. SCALE = "scale",
  78987. /**
  78988. * Weights
  78989. */
  78990. WEIGHTS = "weights",
  78991. }
  78992. /**
  78993. * Interpolation algorithm
  78994. */
  78995. const enum AnimationSamplerInterpolation {
  78996. /**
  78997. * The animated values are linearly interpolated between keyframes
  78998. */
  78999. LINEAR = "LINEAR",
  79000. /**
  79001. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  79002. */
  79003. STEP = "STEP",
  79004. /**
  79005. * The animation's interpolation is computed using a cubic spline with specified tangents
  79006. */
  79007. CUBICSPLINE = "CUBICSPLINE",
  79008. }
  79009. /**
  79010. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79011. */
  79012. const enum CameraType {
  79013. /**
  79014. * A perspective camera containing properties to create a perspective projection matrix
  79015. */
  79016. PERSPECTIVE = "perspective",
  79017. /**
  79018. * An orthographic camera containing properties to create an orthographic projection matrix
  79019. */
  79020. ORTHOGRAPHIC = "orthographic",
  79021. }
  79022. /**
  79023. * The mime-type of the image
  79024. */
  79025. const enum ImageMimeType {
  79026. /**
  79027. * JPEG Mime-type
  79028. */
  79029. JPEG = "image/jpeg",
  79030. /**
  79031. * PNG Mime-type
  79032. */
  79033. PNG = "image/png",
  79034. }
  79035. /**
  79036. * The alpha rendering mode of the material
  79037. */
  79038. const enum MaterialAlphaMode {
  79039. /**
  79040. * The alpha value is ignored and the rendered output is fully opaque
  79041. */
  79042. OPAQUE = "OPAQUE",
  79043. /**
  79044. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  79045. */
  79046. MASK = "MASK",
  79047. /**
  79048. * 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)
  79049. */
  79050. BLEND = "BLEND",
  79051. }
  79052. /**
  79053. * The type of the primitives to render
  79054. */
  79055. const enum MeshPrimitiveMode {
  79056. /**
  79057. * Points
  79058. */
  79059. POINTS = 0,
  79060. /**
  79061. * Lines
  79062. */
  79063. LINES = 1,
  79064. /**
  79065. * Line Loop
  79066. */
  79067. LINE_LOOP = 2,
  79068. /**
  79069. * Line Strip
  79070. */
  79071. LINE_STRIP = 3,
  79072. /**
  79073. * Triangles
  79074. */
  79075. TRIANGLES = 4,
  79076. /**
  79077. * Triangle Strip
  79078. */
  79079. TRIANGLE_STRIP = 5,
  79080. /**
  79081. * Triangle Fan
  79082. */
  79083. TRIANGLE_FAN = 6,
  79084. }
  79085. /**
  79086. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79087. */
  79088. const enum TextureMagFilter {
  79089. /**
  79090. * Nearest
  79091. */
  79092. NEAREST = 9728,
  79093. /**
  79094. * Linear
  79095. */
  79096. LINEAR = 9729,
  79097. }
  79098. /**
  79099. * Minification filter. All valid values correspond to WebGL enums
  79100. */
  79101. const enum TextureMinFilter {
  79102. /**
  79103. * Nearest
  79104. */
  79105. NEAREST = 9728,
  79106. /**
  79107. * Linear
  79108. */
  79109. LINEAR = 9729,
  79110. /**
  79111. * Nearest Mip-Map Nearest
  79112. */
  79113. NEAREST_MIPMAP_NEAREST = 9984,
  79114. /**
  79115. * Linear Mipmap Nearest
  79116. */
  79117. LINEAR_MIPMAP_NEAREST = 9985,
  79118. /**
  79119. * Nearest Mipmap Linear
  79120. */
  79121. NEAREST_MIPMAP_LINEAR = 9986,
  79122. /**
  79123. * Linear Mipmap Linear
  79124. */
  79125. LINEAR_MIPMAP_LINEAR = 9987,
  79126. }
  79127. /**
  79128. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79129. */
  79130. const enum TextureWrapMode {
  79131. /**
  79132. * Clamp to Edge
  79133. */
  79134. CLAMP_TO_EDGE = 33071,
  79135. /**
  79136. * Mirrored Repeat
  79137. */
  79138. MIRRORED_REPEAT = 33648,
  79139. /**
  79140. * Repeat
  79141. */
  79142. REPEAT = 10497,
  79143. }
  79144. /**
  79145. * glTF Property
  79146. */
  79147. interface IProperty {
  79148. /**
  79149. * Dictionary object with extension-specific objects
  79150. */
  79151. extensions?: {
  79152. [key: string]: any;
  79153. };
  79154. /**
  79155. * Application-Specific data
  79156. */
  79157. extras?: any;
  79158. }
  79159. /**
  79160. * glTF Child of Root Property
  79161. */
  79162. interface IChildRootProperty extends IProperty {
  79163. /**
  79164. * The user-defined name of this object
  79165. */
  79166. name?: string;
  79167. }
  79168. /**
  79169. * Indices of those attributes that deviate from their initialization value
  79170. */
  79171. interface IAccessorSparseIndices extends IProperty {
  79172. /**
  79173. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79174. */
  79175. bufferView: number;
  79176. /**
  79177. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79178. */
  79179. byteOffset?: number;
  79180. /**
  79181. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  79182. */
  79183. componentType: AccessorComponentType;
  79184. }
  79185. /**
  79186. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  79187. */
  79188. interface IAccessorSparseValues extends IProperty {
  79189. /**
  79190. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79191. */
  79192. bufferView: number;
  79193. /**
  79194. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79195. */
  79196. byteOffset?: number;
  79197. }
  79198. /**
  79199. * Sparse storage of attributes that deviate from their initialization value
  79200. */
  79201. interface IAccessorSparse extends IProperty {
  79202. /**
  79203. * The number of attributes encoded in this sparse accessor
  79204. */
  79205. count: number;
  79206. /**
  79207. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  79208. */
  79209. indices: IAccessorSparseIndices;
  79210. /**
  79211. * 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
  79212. */
  79213. values: IAccessorSparseValues;
  79214. }
  79215. /**
  79216. * 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
  79217. */
  79218. interface IAccessor extends IChildRootProperty {
  79219. /**
  79220. * The index of the bufferview
  79221. */
  79222. bufferView?: number;
  79223. /**
  79224. * The offset relative to the start of the bufferView in bytes
  79225. */
  79226. byteOffset?: number;
  79227. /**
  79228. * The datatype of components in the attribute
  79229. */
  79230. componentType: AccessorComponentType;
  79231. /**
  79232. * Specifies whether integer data values should be normalized
  79233. */
  79234. normalized?: boolean;
  79235. /**
  79236. * The number of attributes referenced by this accessor
  79237. */
  79238. count: number;
  79239. /**
  79240. * Specifies if the attribute is a scalar, vector, or matrix
  79241. */
  79242. type: AccessorType;
  79243. /**
  79244. * Maximum value of each component in this attribute
  79245. */
  79246. max?: number[];
  79247. /**
  79248. * Minimum value of each component in this attribute
  79249. */
  79250. min?: number[];
  79251. /**
  79252. * Sparse storage of attributes that deviate from their initialization value
  79253. */
  79254. sparse?: IAccessorSparse;
  79255. }
  79256. /**
  79257. * Targets an animation's sampler at a node's property
  79258. */
  79259. interface IAnimationChannel extends IProperty {
  79260. /**
  79261. * The index of a sampler in this animation used to compute the value for the target
  79262. */
  79263. sampler: number;
  79264. /**
  79265. * The index of the node and TRS property to target
  79266. */
  79267. target: IAnimationChannelTarget;
  79268. }
  79269. /**
  79270. * The index of the node and TRS property that an animation channel targets
  79271. */
  79272. interface IAnimationChannelTarget extends IProperty {
  79273. /**
  79274. * The index of the node to target
  79275. */
  79276. node: number;
  79277. /**
  79278. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79279. */
  79280. path: AnimationChannelTargetPath;
  79281. }
  79282. /**
  79283. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79284. */
  79285. interface IAnimationSampler extends IProperty {
  79286. /**
  79287. * The index of an accessor containing keyframe input values, e.g., time
  79288. */
  79289. input: number;
  79290. /**
  79291. * Interpolation algorithm
  79292. */
  79293. interpolation?: AnimationSamplerInterpolation;
  79294. /**
  79295. * The index of an accessor, containing keyframe output values
  79296. */
  79297. output: number;
  79298. }
  79299. /**
  79300. * A keyframe animation
  79301. */
  79302. interface IAnimation extends IChildRootProperty {
  79303. /**
  79304. * An array of channels, each of which targets an animation's sampler at a node's property
  79305. */
  79306. channels: IAnimationChannel[];
  79307. /**
  79308. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79309. */
  79310. samplers: IAnimationSampler[];
  79311. }
  79312. /**
  79313. * Metadata about the glTF asset
  79314. */
  79315. interface IAsset extends IChildRootProperty {
  79316. /**
  79317. * A copyright message suitable for display to credit the content creator
  79318. */
  79319. copyright?: string;
  79320. /**
  79321. * Tool that generated this glTF model. Useful for debugging
  79322. */
  79323. generator?: string;
  79324. /**
  79325. * The glTF version that this asset targets
  79326. */
  79327. version: string;
  79328. /**
  79329. * The minimum glTF version that this asset targets
  79330. */
  79331. minVersion?: string;
  79332. }
  79333. /**
  79334. * A buffer points to binary geometry, animation, or skins
  79335. */
  79336. interface IBuffer extends IChildRootProperty {
  79337. /**
  79338. * 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
  79339. */
  79340. uri?: string;
  79341. /**
  79342. * The length of the buffer in bytes
  79343. */
  79344. byteLength: number;
  79345. }
  79346. /**
  79347. * A view into a buffer generally representing a subset of the buffer
  79348. */
  79349. interface IBufferView extends IChildRootProperty {
  79350. /**
  79351. * The index of the buffer
  79352. */
  79353. buffer: number;
  79354. /**
  79355. * The offset into the buffer in bytes
  79356. */
  79357. byteOffset?: number;
  79358. /**
  79359. * The lenth of the bufferView in bytes
  79360. */
  79361. byteLength: number;
  79362. /**
  79363. * The stride, in bytes
  79364. */
  79365. byteStride?: number;
  79366. }
  79367. /**
  79368. * An orthographic camera containing properties to create an orthographic projection matrix
  79369. */
  79370. interface ICameraOrthographic extends IProperty {
  79371. /**
  79372. * The floating-point horizontal magnification of the view. Must not be zero
  79373. */
  79374. xmag: number;
  79375. /**
  79376. * The floating-point vertical magnification of the view. Must not be zero
  79377. */
  79378. ymag: number;
  79379. /**
  79380. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79381. */
  79382. zfar: number;
  79383. /**
  79384. * The floating-point distance to the near clipping plane
  79385. */
  79386. znear: number;
  79387. }
  79388. /**
  79389. * A perspective camera containing properties to create a perspective projection matrix
  79390. */
  79391. interface ICameraPerspective extends IProperty {
  79392. /**
  79393. * The floating-point aspect ratio of the field of view
  79394. */
  79395. aspectRatio?: number;
  79396. /**
  79397. * The floating-point vertical field of view in radians
  79398. */
  79399. yfov: number;
  79400. /**
  79401. * The floating-point distance to the far clipping plane
  79402. */
  79403. zfar?: number;
  79404. /**
  79405. * The floating-point distance to the near clipping plane
  79406. */
  79407. znear: number;
  79408. }
  79409. /**
  79410. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79411. */
  79412. interface ICamera extends IChildRootProperty {
  79413. /**
  79414. * An orthographic camera containing properties to create an orthographic projection matrix
  79415. */
  79416. orthographic?: ICameraOrthographic;
  79417. /**
  79418. * A perspective camera containing properties to create a perspective projection matrix
  79419. */
  79420. perspective?: ICameraPerspective;
  79421. /**
  79422. * Specifies if the camera uses a perspective or orthographic projection
  79423. */
  79424. type: CameraType;
  79425. }
  79426. /**
  79427. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79428. */
  79429. interface IImage extends IChildRootProperty {
  79430. /**
  79431. * 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
  79432. */
  79433. uri?: string;
  79434. /**
  79435. * The image's MIME type
  79436. */
  79437. mimeType?: ImageMimeType;
  79438. /**
  79439. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79440. */
  79441. bufferView?: number;
  79442. }
  79443. /**
  79444. * Material Normal Texture Info
  79445. */
  79446. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79447. /**
  79448. * The scalar multiplier applied to each normal vector of the normal texture
  79449. */
  79450. scale?: number;
  79451. }
  79452. /**
  79453. * Material Occlusion Texture Info
  79454. */
  79455. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79456. /**
  79457. * A scalar multiplier controlling the amount of occlusion applied
  79458. */
  79459. strength?: number;
  79460. }
  79461. /**
  79462. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79463. */
  79464. interface IMaterialPbrMetallicRoughness {
  79465. /**
  79466. * The material's base color factor
  79467. */
  79468. baseColorFactor?: number[];
  79469. /**
  79470. * The base color texture
  79471. */
  79472. baseColorTexture?: ITextureInfo;
  79473. /**
  79474. * The metalness of the material
  79475. */
  79476. metallicFactor?: number;
  79477. /**
  79478. * The roughness of the material
  79479. */
  79480. roughnessFactor?: number;
  79481. /**
  79482. * The metallic-roughness texture
  79483. */
  79484. metallicRoughnessTexture?: ITextureInfo;
  79485. }
  79486. /**
  79487. * The material appearance of a primitive
  79488. */
  79489. interface IMaterial extends IChildRootProperty {
  79490. /**
  79491. * 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
  79492. */
  79493. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79494. /**
  79495. * The normal map texture
  79496. */
  79497. normalTexture?: IMaterialNormalTextureInfo;
  79498. /**
  79499. * The occlusion map texture
  79500. */
  79501. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79502. /**
  79503. * The emissive map texture
  79504. */
  79505. emissiveTexture?: ITextureInfo;
  79506. /**
  79507. * 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
  79508. */
  79509. emissiveFactor?: number[];
  79510. /**
  79511. * The alpha rendering mode of the material
  79512. */
  79513. alphaMode?: MaterialAlphaMode;
  79514. /**
  79515. * The alpha cutoff value of the material
  79516. */
  79517. alphaCutoff?: number;
  79518. /**
  79519. * Specifies whether the material is double sided
  79520. */
  79521. doubleSided?: boolean;
  79522. }
  79523. /**
  79524. * Geometry to be rendered with the given material
  79525. */
  79526. interface IMeshPrimitive extends IProperty {
  79527. /**
  79528. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79529. */
  79530. attributes: {
  79531. [name: string]: number;
  79532. };
  79533. /**
  79534. * The index of the accessor that contains the indices
  79535. */
  79536. indices?: number;
  79537. /**
  79538. * The index of the material to apply to this primitive when rendering
  79539. */
  79540. material?: number;
  79541. /**
  79542. * The type of primitives to render. All valid values correspond to WebGL enums
  79543. */
  79544. mode?: MeshPrimitiveMode;
  79545. /**
  79546. * 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
  79547. */
  79548. targets?: {
  79549. [name: string]: number;
  79550. }[];
  79551. }
  79552. /**
  79553. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79554. */
  79555. interface IMesh extends IChildRootProperty {
  79556. /**
  79557. * An array of primitives, each defining geometry to be rendered with a material
  79558. */
  79559. primitives: IMeshPrimitive[];
  79560. /**
  79561. * Array of weights to be applied to the Morph Targets
  79562. */
  79563. weights?: number[];
  79564. }
  79565. /**
  79566. * A node in the node hierarchy
  79567. */
  79568. interface INode extends IChildRootProperty {
  79569. /**
  79570. * The index of the camera referenced by this node
  79571. */
  79572. camera?: number;
  79573. /**
  79574. * The indices of this node's children
  79575. */
  79576. children?: number[];
  79577. /**
  79578. * The index of the skin referenced by this node
  79579. */
  79580. skin?: number;
  79581. /**
  79582. * A floating-point 4x4 transformation matrix stored in column-major order
  79583. */
  79584. matrix?: number[];
  79585. /**
  79586. * The index of the mesh in this node
  79587. */
  79588. mesh?: number;
  79589. /**
  79590. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79591. */
  79592. rotation?: number[];
  79593. /**
  79594. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79595. */
  79596. scale?: number[];
  79597. /**
  79598. * The node's translation along the x, y, and z axes
  79599. */
  79600. translation?: number[];
  79601. /**
  79602. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79603. */
  79604. weights?: number[];
  79605. }
  79606. /**
  79607. * Texture sampler properties for filtering and wrapping modes
  79608. */
  79609. interface ISampler extends IChildRootProperty {
  79610. /**
  79611. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79612. */
  79613. magFilter?: TextureMagFilter;
  79614. /**
  79615. * Minification filter. All valid values correspond to WebGL enums
  79616. */
  79617. minFilter?: TextureMinFilter;
  79618. /**
  79619. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79620. */
  79621. wrapS?: TextureWrapMode;
  79622. /**
  79623. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79624. */
  79625. wrapT?: TextureWrapMode;
  79626. }
  79627. /**
  79628. * The root nodes of a scene
  79629. */
  79630. interface IScene extends IChildRootProperty {
  79631. /**
  79632. * The indices of each root node
  79633. */
  79634. nodes: number[];
  79635. }
  79636. /**
  79637. * Joints and matrices defining a skin
  79638. */
  79639. interface ISkin extends IChildRootProperty {
  79640. /**
  79641. * 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
  79642. */
  79643. inverseBindMatrices?: number;
  79644. /**
  79645. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79646. */
  79647. skeleton?: number;
  79648. /**
  79649. * 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)
  79650. */
  79651. joints: number[];
  79652. }
  79653. /**
  79654. * A texture and its sampler
  79655. */
  79656. interface ITexture extends IChildRootProperty {
  79657. /**
  79658. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79659. */
  79660. sampler?: number;
  79661. /**
  79662. * The index of the image used by this texture
  79663. */
  79664. source: number;
  79665. }
  79666. /**
  79667. * Reference to a texture
  79668. */
  79669. interface ITextureInfo extends IProperty {
  79670. /**
  79671. * The index of the texture
  79672. */
  79673. index: number;
  79674. /**
  79675. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79676. */
  79677. texCoord?: number;
  79678. }
  79679. /**
  79680. * The root object for a glTF asset
  79681. */
  79682. interface IGLTF extends IProperty {
  79683. /**
  79684. * An array of accessors. An accessor is a typed view into a bufferView
  79685. */
  79686. accessors?: IAccessor[];
  79687. /**
  79688. * An array of keyframe animations
  79689. */
  79690. animations?: IAnimation[];
  79691. /**
  79692. * Metadata about the glTF asset
  79693. */
  79694. asset: IAsset;
  79695. /**
  79696. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79697. */
  79698. buffers?: IBuffer[];
  79699. /**
  79700. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79701. */
  79702. bufferViews?: IBufferView[];
  79703. /**
  79704. * An array of cameras
  79705. */
  79706. cameras?: ICamera[];
  79707. /**
  79708. * Names of glTF extensions used somewhere in this asset
  79709. */
  79710. extensionsUsed?: string[];
  79711. /**
  79712. * Names of glTF extensions required to properly load this asset
  79713. */
  79714. extensionsRequired?: string[];
  79715. /**
  79716. * An array of images. An image defines data used to create a texture
  79717. */
  79718. images?: IImage[];
  79719. /**
  79720. * An array of materials. A material defines the appearance of a primitive
  79721. */
  79722. materials?: IMaterial[];
  79723. /**
  79724. * An array of meshes. A mesh is a set of primitives to be rendered
  79725. */
  79726. meshes?: IMesh[];
  79727. /**
  79728. * An array of nodes
  79729. */
  79730. nodes?: INode[];
  79731. /**
  79732. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79733. */
  79734. samplers?: ISampler[];
  79735. /**
  79736. * The index of the default scene
  79737. */
  79738. scene?: number;
  79739. /**
  79740. * An array of scenes
  79741. */
  79742. scenes?: IScene[];
  79743. /**
  79744. * An array of skins. A skin is defined by joints and matrices
  79745. */
  79746. skins?: ISkin[];
  79747. /**
  79748. * An array of textures
  79749. */
  79750. textures?: ITexture[];
  79751. }
  79752. /**
  79753. * The glTF validation results
  79754. * @ignore
  79755. */
  79756. interface IGLTFValidationResults {
  79757. info: {
  79758. generator: string;
  79759. hasAnimations: boolean;
  79760. hasDefaultScene: boolean;
  79761. hasMaterials: boolean;
  79762. hasMorphTargets: boolean;
  79763. hasSkins: boolean;
  79764. hasTextures: boolean;
  79765. maxAttributesUsed: number;
  79766. primitivesCount: number
  79767. };
  79768. issues: {
  79769. messages: Array<string>;
  79770. numErrors: number;
  79771. numHints: number;
  79772. numInfos: number;
  79773. numWarnings: number;
  79774. truncated: boolean
  79775. };
  79776. mimeType: string;
  79777. uri: string;
  79778. validatedAt: string;
  79779. validatorVersion: string;
  79780. }
  79781. /**
  79782. * The glTF validation options
  79783. */
  79784. interface IGLTFValidationOptions {
  79785. /** Uri to use */
  79786. uri?: string;
  79787. /** Function used to load external resources */
  79788. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79789. /** Boolean indicating that we need to validate accessor data */
  79790. validateAccessorData?: boolean;
  79791. /** max number of issues allowed */
  79792. maxIssues?: number;
  79793. /** Ignored issues */
  79794. ignoredIssues?: Array<string>;
  79795. /** Value to override severy settings */
  79796. severityOverrides?: Object;
  79797. }
  79798. /**
  79799. * The glTF validator object
  79800. * @ignore
  79801. */
  79802. interface IGLTFValidator {
  79803. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79804. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79805. }
  79806. }
  79807. declare module BABYLON {
  79808. /** @hidden */
  79809. export var cellPixelShader: {
  79810. name: string;
  79811. shader: string;
  79812. };
  79813. }
  79814. declare module BABYLON {
  79815. /** @hidden */
  79816. export var cellVertexShader: {
  79817. name: string;
  79818. shader: string;
  79819. };
  79820. }
  79821. declare module BABYLON {
  79822. export class CellMaterial extends BABYLON.PushMaterial {
  79823. private _diffuseTexture;
  79824. diffuseTexture: BABYLON.BaseTexture;
  79825. diffuseColor: BABYLON.Color3;
  79826. _computeHighLevel: boolean;
  79827. computeHighLevel: boolean;
  79828. private _disableLighting;
  79829. disableLighting: boolean;
  79830. private _maxSimultaneousLights;
  79831. maxSimultaneousLights: number;
  79832. constructor(name: string, scene: BABYLON.Scene);
  79833. needAlphaBlending(): boolean;
  79834. needAlphaTesting(): boolean;
  79835. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79836. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79837. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79838. getAnimatables(): BABYLON.IAnimatable[];
  79839. getActiveTextures(): BABYLON.BaseTexture[];
  79840. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79841. dispose(forceDisposeEffect?: boolean): void;
  79842. getClassName(): string;
  79843. clone(name: string): CellMaterial;
  79844. serialize(): any;
  79845. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79846. }
  79847. }
  79848. declare module BABYLON {
  79849. export class CustomShaderStructure {
  79850. FragmentStore: string;
  79851. VertexStore: string;
  79852. constructor();
  79853. }
  79854. export class ShaderSpecialParts {
  79855. constructor();
  79856. Fragment_Begin: string;
  79857. Fragment_Definitions: string;
  79858. Fragment_MainBegin: string;
  79859. Fragment_Custom_Diffuse: string;
  79860. Fragment_Before_Lights: string;
  79861. Fragment_Before_Fog: string;
  79862. Fragment_Custom_Alpha: string;
  79863. Fragment_Before_FragColor: string;
  79864. Vertex_Begin: string;
  79865. Vertex_Definitions: string;
  79866. Vertex_MainBegin: string;
  79867. Vertex_Before_PositionUpdated: string;
  79868. Vertex_Before_NormalUpdated: string;
  79869. Vertex_After_WorldPosComputed: string;
  79870. Vertex_MainEnd: string;
  79871. }
  79872. export class CustomMaterial extends BABYLON.StandardMaterial {
  79873. static ShaderIndexer: number;
  79874. CustomParts: ShaderSpecialParts;
  79875. _isCreatedShader: boolean;
  79876. _createdShaderName: string;
  79877. _customUniform: string[];
  79878. _newUniforms: string[];
  79879. _newUniformInstances: {
  79880. [name: string]: any;
  79881. };
  79882. _newSamplerInstances: {
  79883. [name: string]: BABYLON.Texture;
  79884. };
  79885. _customAttributes: string[];
  79886. FragmentShader: string;
  79887. VertexShader: string;
  79888. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79889. ReviewUniform(name: string, arr: string[]): string[];
  79890. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79891. constructor(name: string, scene: BABYLON.Scene);
  79892. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79893. AddAttribute(name: string): CustomMaterial;
  79894. Fragment_Begin(shaderPart: string): CustomMaterial;
  79895. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79896. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79897. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79898. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79899. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79900. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79901. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79902. Vertex_Begin(shaderPart: string): CustomMaterial;
  79903. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79904. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79905. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79906. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79907. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  79908. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79909. }
  79910. }
  79911. declare module BABYLON {
  79912. export class ShaderAlebdoParts {
  79913. constructor();
  79914. Fragment_Begin: string;
  79915. Fragment_Definitions: string;
  79916. Fragment_MainBegin: string;
  79917. Fragment_Custom_Albedo: string;
  79918. Fragment_Before_Lights: string;
  79919. Fragment_Custom_MetallicRoughness: string;
  79920. Fragment_Custom_MicroSurface: string;
  79921. Fragment_Before_Fog: string;
  79922. Fragment_Custom_Alpha: string;
  79923. Fragment_Before_FragColor: string;
  79924. Vertex_Begin: string;
  79925. Vertex_Definitions: string;
  79926. Vertex_MainBegin: string;
  79927. Vertex_Before_PositionUpdated: string;
  79928. Vertex_Before_NormalUpdated: string;
  79929. Vertex_After_WorldPosComputed: string;
  79930. Vertex_MainEnd: string;
  79931. }
  79932. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79933. static ShaderIndexer: number;
  79934. CustomParts: ShaderAlebdoParts;
  79935. _isCreatedShader: boolean;
  79936. _createdShaderName: string;
  79937. _customUniform: string[];
  79938. _newUniforms: string[];
  79939. _newUniformInstances: {
  79940. [name: string]: any;
  79941. };
  79942. _newSamplerInstances: {
  79943. [name: string]: BABYLON.Texture;
  79944. };
  79945. _customAttributes: string[];
  79946. FragmentShader: string;
  79947. VertexShader: string;
  79948. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79949. ReviewUniform(name: string, arr: string[]): string[];
  79950. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79951. constructor(name: string, scene: BABYLON.Scene);
  79952. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79953. AddAttribute(name: string): PBRCustomMaterial;
  79954. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79955. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79956. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79957. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79958. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79959. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79960. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79961. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79962. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79963. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79964. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79965. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79966. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79967. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79968. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79969. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  79970. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79971. }
  79972. }
  79973. declare module BABYLON {
  79974. /** @hidden */
  79975. export var firePixelShader: {
  79976. name: string;
  79977. shader: string;
  79978. };
  79979. }
  79980. declare module BABYLON {
  79981. /** @hidden */
  79982. export var fireVertexShader: {
  79983. name: string;
  79984. shader: string;
  79985. };
  79986. }
  79987. declare module BABYLON {
  79988. export class FireMaterial extends BABYLON.PushMaterial {
  79989. private _diffuseTexture;
  79990. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79991. private _distortionTexture;
  79992. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79993. private _opacityTexture;
  79994. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79995. diffuseColor: BABYLON.Color3;
  79996. speed: number;
  79997. private _scaledDiffuse;
  79998. private _lastTime;
  79999. constructor(name: string, scene: BABYLON.Scene);
  80000. needAlphaBlending(): boolean;
  80001. needAlphaTesting(): boolean;
  80002. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80003. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80004. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80005. getAnimatables(): BABYLON.IAnimatable[];
  80006. getActiveTextures(): BABYLON.BaseTexture[];
  80007. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80008. getClassName(): string;
  80009. dispose(forceDisposeEffect?: boolean): void;
  80010. clone(name: string): FireMaterial;
  80011. serialize(): any;
  80012. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  80013. }
  80014. }
  80015. declare module BABYLON {
  80016. /** @hidden */
  80017. export var furPixelShader: {
  80018. name: string;
  80019. shader: string;
  80020. };
  80021. }
  80022. declare module BABYLON {
  80023. /** @hidden */
  80024. export var furVertexShader: {
  80025. name: string;
  80026. shader: string;
  80027. };
  80028. }
  80029. declare module BABYLON {
  80030. export class FurMaterial extends BABYLON.PushMaterial {
  80031. private _diffuseTexture;
  80032. diffuseTexture: BABYLON.BaseTexture;
  80033. private _heightTexture;
  80034. heightTexture: BABYLON.BaseTexture;
  80035. diffuseColor: BABYLON.Color3;
  80036. furLength: number;
  80037. furAngle: number;
  80038. furColor: BABYLON.Color3;
  80039. furOffset: number;
  80040. furSpacing: number;
  80041. furGravity: BABYLON.Vector3;
  80042. furSpeed: number;
  80043. furDensity: number;
  80044. furOcclusion: number;
  80045. furTexture: BABYLON.DynamicTexture;
  80046. private _disableLighting;
  80047. disableLighting: boolean;
  80048. private _maxSimultaneousLights;
  80049. maxSimultaneousLights: number;
  80050. highLevelFur: boolean;
  80051. _meshes: BABYLON.AbstractMesh[];
  80052. private _furTime;
  80053. constructor(name: string, scene: BABYLON.Scene);
  80054. get furTime(): number;
  80055. set furTime(furTime: number);
  80056. needAlphaBlending(): boolean;
  80057. needAlphaTesting(): boolean;
  80058. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80059. updateFur(): void;
  80060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80061. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80062. getAnimatables(): BABYLON.IAnimatable[];
  80063. getActiveTextures(): BABYLON.BaseTexture[];
  80064. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80065. dispose(forceDisposeEffect?: boolean): void;
  80066. clone(name: string): FurMaterial;
  80067. serialize(): any;
  80068. getClassName(): string;
  80069. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  80070. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  80071. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  80072. }
  80073. }
  80074. declare module BABYLON {
  80075. /** @hidden */
  80076. export var gradientPixelShader: {
  80077. name: string;
  80078. shader: string;
  80079. };
  80080. }
  80081. declare module BABYLON {
  80082. /** @hidden */
  80083. export var gradientVertexShader: {
  80084. name: string;
  80085. shader: string;
  80086. };
  80087. }
  80088. declare module BABYLON {
  80089. export class GradientMaterial extends BABYLON.PushMaterial {
  80090. private _maxSimultaneousLights;
  80091. maxSimultaneousLights: number;
  80092. topColor: BABYLON.Color3;
  80093. topColorAlpha: number;
  80094. bottomColor: BABYLON.Color3;
  80095. bottomColorAlpha: number;
  80096. offset: number;
  80097. scale: number;
  80098. smoothness: number;
  80099. private _disableLighting;
  80100. disableLighting: boolean;
  80101. constructor(name: string, scene: BABYLON.Scene);
  80102. needAlphaBlending(): boolean;
  80103. needAlphaTesting(): boolean;
  80104. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80105. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80106. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80107. getAnimatables(): BABYLON.IAnimatable[];
  80108. dispose(forceDisposeEffect?: boolean): void;
  80109. clone(name: string): GradientMaterial;
  80110. serialize(): any;
  80111. getClassName(): string;
  80112. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  80113. }
  80114. }
  80115. declare module BABYLON {
  80116. /** @hidden */
  80117. export var gridPixelShader: {
  80118. name: string;
  80119. shader: string;
  80120. };
  80121. }
  80122. declare module BABYLON {
  80123. /** @hidden */
  80124. export var gridVertexShader: {
  80125. name: string;
  80126. shader: string;
  80127. };
  80128. }
  80129. declare module BABYLON {
  80130. /**
  80131. * The grid materials allows you to wrap any shape with a grid.
  80132. * Colors are customizable.
  80133. */
  80134. export class GridMaterial extends BABYLON.PushMaterial {
  80135. /**
  80136. * Main color of the grid (e.g. between lines)
  80137. */
  80138. mainColor: BABYLON.Color3;
  80139. /**
  80140. * Color of the grid lines.
  80141. */
  80142. lineColor: BABYLON.Color3;
  80143. /**
  80144. * The scale of the grid compared to unit.
  80145. */
  80146. gridRatio: number;
  80147. /**
  80148. * Allows setting an offset for the grid lines.
  80149. */
  80150. gridOffset: BABYLON.Vector3;
  80151. /**
  80152. * The frequency of thicker lines.
  80153. */
  80154. majorUnitFrequency: number;
  80155. /**
  80156. * The visibility of minor units in the grid.
  80157. */
  80158. minorUnitVisibility: number;
  80159. /**
  80160. * The grid opacity outside of the lines.
  80161. */
  80162. opacity: number;
  80163. /**
  80164. * Determine RBG output is premultiplied by alpha value.
  80165. */
  80166. preMultiplyAlpha: boolean;
  80167. private _opacityTexture;
  80168. opacityTexture: BABYLON.BaseTexture;
  80169. private _gridControl;
  80170. /**
  80171. * constructor
  80172. * @param name The name given to the material in order to identify it afterwards.
  80173. * @param scene The scene the material is used in.
  80174. */
  80175. constructor(name: string, scene: BABYLON.Scene);
  80176. /**
  80177. * Returns wehter or not the grid requires alpha blending.
  80178. */
  80179. needAlphaBlending(): boolean;
  80180. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80181. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80182. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80183. /**
  80184. * Dispose the material and its associated resources.
  80185. * @param forceDisposeEffect will also dispose the used effect when true
  80186. */
  80187. dispose(forceDisposeEffect?: boolean): void;
  80188. clone(name: string): GridMaterial;
  80189. serialize(): any;
  80190. getClassName(): string;
  80191. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  80192. }
  80193. }
  80194. declare module BABYLON {
  80195. /** @hidden */
  80196. export var lavaPixelShader: {
  80197. name: string;
  80198. shader: string;
  80199. };
  80200. }
  80201. declare module BABYLON {
  80202. /** @hidden */
  80203. export var lavaVertexShader: {
  80204. name: string;
  80205. shader: string;
  80206. };
  80207. }
  80208. declare module BABYLON {
  80209. export class LavaMaterial extends BABYLON.PushMaterial {
  80210. private _diffuseTexture;
  80211. diffuseTexture: BABYLON.BaseTexture;
  80212. noiseTexture: BABYLON.BaseTexture;
  80213. fogColor: BABYLON.Color3;
  80214. speed: number;
  80215. movingSpeed: number;
  80216. lowFrequencySpeed: number;
  80217. fogDensity: number;
  80218. private _lastTime;
  80219. diffuseColor: BABYLON.Color3;
  80220. private _disableLighting;
  80221. disableLighting: boolean;
  80222. private _unlit;
  80223. unlit: boolean;
  80224. private _maxSimultaneousLights;
  80225. maxSimultaneousLights: number;
  80226. private _scaledDiffuse;
  80227. constructor(name: string, scene: BABYLON.Scene);
  80228. needAlphaBlending(): boolean;
  80229. needAlphaTesting(): boolean;
  80230. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80231. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80232. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80233. getAnimatables(): BABYLON.IAnimatable[];
  80234. getActiveTextures(): BABYLON.BaseTexture[];
  80235. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80236. dispose(forceDisposeEffect?: boolean): void;
  80237. clone(name: string): LavaMaterial;
  80238. serialize(): any;
  80239. getClassName(): string;
  80240. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80241. }
  80242. }
  80243. declare module BABYLON {
  80244. /** @hidden */
  80245. export var mixPixelShader: {
  80246. name: string;
  80247. shader: string;
  80248. };
  80249. }
  80250. declare module BABYLON {
  80251. /** @hidden */
  80252. export var mixVertexShader: {
  80253. name: string;
  80254. shader: string;
  80255. };
  80256. }
  80257. declare module BABYLON {
  80258. export class MixMaterial extends BABYLON.PushMaterial {
  80259. /**
  80260. * Mix textures
  80261. */
  80262. private _mixTexture1;
  80263. mixTexture1: BABYLON.BaseTexture;
  80264. private _mixTexture2;
  80265. mixTexture2: BABYLON.BaseTexture;
  80266. /**
  80267. * Diffuse textures
  80268. */
  80269. private _diffuseTexture1;
  80270. diffuseTexture1: BABYLON.Texture;
  80271. private _diffuseTexture2;
  80272. diffuseTexture2: BABYLON.Texture;
  80273. private _diffuseTexture3;
  80274. diffuseTexture3: BABYLON.Texture;
  80275. private _diffuseTexture4;
  80276. diffuseTexture4: BABYLON.Texture;
  80277. private _diffuseTexture5;
  80278. diffuseTexture5: BABYLON.Texture;
  80279. private _diffuseTexture6;
  80280. diffuseTexture6: BABYLON.Texture;
  80281. private _diffuseTexture7;
  80282. diffuseTexture7: BABYLON.Texture;
  80283. private _diffuseTexture8;
  80284. diffuseTexture8: BABYLON.Texture;
  80285. /**
  80286. * Uniforms
  80287. */
  80288. diffuseColor: BABYLON.Color3;
  80289. specularColor: BABYLON.Color3;
  80290. specularPower: number;
  80291. private _disableLighting;
  80292. disableLighting: boolean;
  80293. private _maxSimultaneousLights;
  80294. maxSimultaneousLights: number;
  80295. constructor(name: string, scene: BABYLON.Scene);
  80296. needAlphaBlending(): boolean;
  80297. needAlphaTesting(): boolean;
  80298. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80299. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80300. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80301. getAnimatables(): BABYLON.IAnimatable[];
  80302. getActiveTextures(): BABYLON.BaseTexture[];
  80303. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80304. dispose(forceDisposeEffect?: boolean): void;
  80305. clone(name: string): MixMaterial;
  80306. serialize(): any;
  80307. getClassName(): string;
  80308. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80309. }
  80310. }
  80311. declare module BABYLON {
  80312. /** @hidden */
  80313. export var normalPixelShader: {
  80314. name: string;
  80315. shader: string;
  80316. };
  80317. }
  80318. declare module BABYLON {
  80319. /** @hidden */
  80320. export var normalVertexShader: {
  80321. name: string;
  80322. shader: string;
  80323. };
  80324. }
  80325. declare module BABYLON {
  80326. export class NormalMaterial extends BABYLON.PushMaterial {
  80327. private _diffuseTexture;
  80328. diffuseTexture: BABYLON.BaseTexture;
  80329. diffuseColor: BABYLON.Color3;
  80330. private _disableLighting;
  80331. disableLighting: boolean;
  80332. private _maxSimultaneousLights;
  80333. maxSimultaneousLights: number;
  80334. constructor(name: string, scene: BABYLON.Scene);
  80335. needAlphaBlending(): boolean;
  80336. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80337. needAlphaTesting(): boolean;
  80338. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80339. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80340. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80341. getAnimatables(): BABYLON.IAnimatable[];
  80342. getActiveTextures(): BABYLON.BaseTexture[];
  80343. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80344. dispose(forceDisposeEffect?: boolean): void;
  80345. clone(name: string): NormalMaterial;
  80346. serialize(): any;
  80347. getClassName(): string;
  80348. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80349. }
  80350. }
  80351. declare module BABYLON {
  80352. /** @hidden */
  80353. export var shadowOnlyPixelShader: {
  80354. name: string;
  80355. shader: string;
  80356. };
  80357. }
  80358. declare module BABYLON {
  80359. /** @hidden */
  80360. export var shadowOnlyVertexShader: {
  80361. name: string;
  80362. shader: string;
  80363. };
  80364. }
  80365. declare module BABYLON {
  80366. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80367. private _activeLight;
  80368. constructor(name: string, scene: BABYLON.Scene);
  80369. shadowColor: BABYLON.Color3;
  80370. needAlphaBlending(): boolean;
  80371. needAlphaTesting(): boolean;
  80372. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80373. get activeLight(): BABYLON.IShadowLight;
  80374. set activeLight(light: BABYLON.IShadowLight);
  80375. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80376. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80377. clone(name: string): ShadowOnlyMaterial;
  80378. serialize(): any;
  80379. getClassName(): string;
  80380. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80381. }
  80382. }
  80383. declare module BABYLON {
  80384. /** @hidden */
  80385. export var simplePixelShader: {
  80386. name: string;
  80387. shader: string;
  80388. };
  80389. }
  80390. declare module BABYLON {
  80391. /** @hidden */
  80392. export var simpleVertexShader: {
  80393. name: string;
  80394. shader: string;
  80395. };
  80396. }
  80397. declare module BABYLON {
  80398. export class SimpleMaterial extends BABYLON.PushMaterial {
  80399. private _diffuseTexture;
  80400. diffuseTexture: BABYLON.BaseTexture;
  80401. diffuseColor: BABYLON.Color3;
  80402. private _disableLighting;
  80403. disableLighting: boolean;
  80404. private _maxSimultaneousLights;
  80405. maxSimultaneousLights: number;
  80406. constructor(name: string, scene: BABYLON.Scene);
  80407. needAlphaBlending(): boolean;
  80408. needAlphaTesting(): boolean;
  80409. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80410. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80411. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80412. getAnimatables(): BABYLON.IAnimatable[];
  80413. getActiveTextures(): BABYLON.BaseTexture[];
  80414. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80415. dispose(forceDisposeEffect?: boolean): void;
  80416. clone(name: string): SimpleMaterial;
  80417. serialize(): any;
  80418. getClassName(): string;
  80419. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80420. }
  80421. }
  80422. declare module BABYLON {
  80423. /** @hidden */
  80424. export var skyPixelShader: {
  80425. name: string;
  80426. shader: string;
  80427. };
  80428. }
  80429. declare module BABYLON {
  80430. /** @hidden */
  80431. export var skyVertexShader: {
  80432. name: string;
  80433. shader: string;
  80434. };
  80435. }
  80436. declare module BABYLON {
  80437. /**
  80438. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80439. * @see https://doc.babylonjs.com/extensions/sky
  80440. */
  80441. export class SkyMaterial extends BABYLON.PushMaterial {
  80442. /**
  80443. * Defines the overall luminance of sky in interval ]0, 1[.
  80444. */
  80445. luminance: number;
  80446. /**
  80447. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80448. */
  80449. turbidity: number;
  80450. /**
  80451. * Defines the sky appearance (light intensity).
  80452. */
  80453. rayleigh: number;
  80454. /**
  80455. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80456. */
  80457. mieCoefficient: number;
  80458. /**
  80459. * Defines the amount of haze particles following the Mie scattering theory.
  80460. */
  80461. mieDirectionalG: number;
  80462. /**
  80463. * Defines the distance of the sun according to the active scene camera.
  80464. */
  80465. distance: number;
  80466. /**
  80467. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80468. * "inclined".
  80469. */
  80470. inclination: number;
  80471. /**
  80472. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80473. * an object direction and a reference direction.
  80474. */
  80475. azimuth: number;
  80476. /**
  80477. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80478. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80479. */
  80480. sunPosition: BABYLON.Vector3;
  80481. /**
  80482. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80483. * .sunPosition property.
  80484. */
  80485. useSunPosition: boolean;
  80486. /**
  80487. * Defines an offset vector used to get a horizon offset.
  80488. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80489. */
  80490. cameraOffset: BABYLON.Vector3;
  80491. private _cameraPosition;
  80492. /**
  80493. * Instantiates a new sky material.
  80494. * This material allows to create dynamic and texture free
  80495. * effects for skyboxes by taking care of the atmosphere state.
  80496. * @see https://doc.babylonjs.com/extensions/sky
  80497. * @param name Define the name of the material in the scene
  80498. * @param scene Define the scene the material belong to
  80499. */
  80500. constructor(name: string, scene: BABYLON.Scene);
  80501. /**
  80502. * Specifies if the material will require alpha blending
  80503. * @returns a boolean specifying if alpha blending is needed
  80504. */
  80505. needAlphaBlending(): boolean;
  80506. /**
  80507. * Specifies if this material should be rendered in alpha test mode
  80508. * @returns false as the sky material doesn't need alpha testing.
  80509. */
  80510. needAlphaTesting(): boolean;
  80511. /**
  80512. * Get the texture used for alpha test purpose.
  80513. * @returns null as the sky material has no texture.
  80514. */
  80515. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80516. /**
  80517. * Get if the submesh is ready to be used and all its information available.
  80518. * Child classes can use it to update shaders
  80519. * @param mesh defines the mesh to check
  80520. * @param subMesh defines which submesh to check
  80521. * @param useInstances specifies that instances should be used
  80522. * @returns a boolean indicating that the submesh is ready or not
  80523. */
  80524. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80525. /**
  80526. * Binds the submesh to this material by preparing the effect and shader to draw
  80527. * @param world defines the world transformation matrix
  80528. * @param mesh defines the mesh containing the submesh
  80529. * @param subMesh defines the submesh to bind the material to
  80530. */
  80531. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80532. /**
  80533. * Get the list of animatables in the material.
  80534. * @returns the list of animatables object used in the material
  80535. */
  80536. getAnimatables(): BABYLON.IAnimatable[];
  80537. /**
  80538. * Disposes the material
  80539. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80540. */
  80541. dispose(forceDisposeEffect?: boolean): void;
  80542. /**
  80543. * Makes a duplicate of the material, and gives it a new name
  80544. * @param name defines the new name for the duplicated material
  80545. * @returns the cloned material
  80546. */
  80547. clone(name: string): SkyMaterial;
  80548. /**
  80549. * Serializes this material in a JSON representation
  80550. * @returns the serialized material object
  80551. */
  80552. serialize(): any;
  80553. /**
  80554. * Gets the current class name of the material e.g. "SkyMaterial"
  80555. * Mainly use in serialization.
  80556. * @returns the class name
  80557. */
  80558. getClassName(): string;
  80559. /**
  80560. * Creates a sky material from parsed material data
  80561. * @param source defines the JSON representation of the material
  80562. * @param scene defines the hosting scene
  80563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80564. * @returns a new sky material
  80565. */
  80566. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80567. }
  80568. }
  80569. declare module BABYLON {
  80570. /** @hidden */
  80571. export var terrainPixelShader: {
  80572. name: string;
  80573. shader: string;
  80574. };
  80575. }
  80576. declare module BABYLON {
  80577. /** @hidden */
  80578. export var terrainVertexShader: {
  80579. name: string;
  80580. shader: string;
  80581. };
  80582. }
  80583. declare module BABYLON {
  80584. export class TerrainMaterial extends BABYLON.PushMaterial {
  80585. private _mixTexture;
  80586. mixTexture: BABYLON.BaseTexture;
  80587. private _diffuseTexture1;
  80588. diffuseTexture1: BABYLON.Texture;
  80589. private _diffuseTexture2;
  80590. diffuseTexture2: BABYLON.Texture;
  80591. private _diffuseTexture3;
  80592. diffuseTexture3: BABYLON.Texture;
  80593. private _bumpTexture1;
  80594. bumpTexture1: BABYLON.Texture;
  80595. private _bumpTexture2;
  80596. bumpTexture2: BABYLON.Texture;
  80597. private _bumpTexture3;
  80598. bumpTexture3: BABYLON.Texture;
  80599. diffuseColor: BABYLON.Color3;
  80600. specularColor: BABYLON.Color3;
  80601. specularPower: number;
  80602. private _disableLighting;
  80603. disableLighting: boolean;
  80604. private _maxSimultaneousLights;
  80605. maxSimultaneousLights: number;
  80606. constructor(name: string, scene: BABYLON.Scene);
  80607. needAlphaBlending(): boolean;
  80608. needAlphaTesting(): boolean;
  80609. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80610. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80611. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80612. getAnimatables(): BABYLON.IAnimatable[];
  80613. getActiveTextures(): BABYLON.BaseTexture[];
  80614. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80615. dispose(forceDisposeEffect?: boolean): void;
  80616. clone(name: string): TerrainMaterial;
  80617. serialize(): any;
  80618. getClassName(): string;
  80619. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80620. }
  80621. }
  80622. declare module BABYLON {
  80623. /** @hidden */
  80624. export var triplanarPixelShader: {
  80625. name: string;
  80626. shader: string;
  80627. };
  80628. }
  80629. declare module BABYLON {
  80630. /** @hidden */
  80631. export var triplanarVertexShader: {
  80632. name: string;
  80633. shader: string;
  80634. };
  80635. }
  80636. declare module BABYLON {
  80637. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80638. mixTexture: BABYLON.BaseTexture;
  80639. private _diffuseTextureX;
  80640. diffuseTextureX: BABYLON.BaseTexture;
  80641. private _diffuseTextureY;
  80642. diffuseTextureY: BABYLON.BaseTexture;
  80643. private _diffuseTextureZ;
  80644. diffuseTextureZ: BABYLON.BaseTexture;
  80645. private _normalTextureX;
  80646. normalTextureX: BABYLON.BaseTexture;
  80647. private _normalTextureY;
  80648. normalTextureY: BABYLON.BaseTexture;
  80649. private _normalTextureZ;
  80650. normalTextureZ: BABYLON.BaseTexture;
  80651. tileSize: number;
  80652. diffuseColor: BABYLON.Color3;
  80653. specularColor: BABYLON.Color3;
  80654. specularPower: number;
  80655. private _disableLighting;
  80656. disableLighting: boolean;
  80657. private _maxSimultaneousLights;
  80658. maxSimultaneousLights: number;
  80659. constructor(name: string, scene: BABYLON.Scene);
  80660. needAlphaBlending(): boolean;
  80661. needAlphaTesting(): boolean;
  80662. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80663. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80664. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80665. getAnimatables(): BABYLON.IAnimatable[];
  80666. getActiveTextures(): BABYLON.BaseTexture[];
  80667. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80668. dispose(forceDisposeEffect?: boolean): void;
  80669. clone(name: string): TriPlanarMaterial;
  80670. serialize(): any;
  80671. getClassName(): string;
  80672. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80673. }
  80674. }
  80675. declare module BABYLON {
  80676. /** @hidden */
  80677. export var waterPixelShader: {
  80678. name: string;
  80679. shader: string;
  80680. };
  80681. }
  80682. declare module BABYLON {
  80683. /** @hidden */
  80684. export var waterVertexShader: {
  80685. name: string;
  80686. shader: string;
  80687. };
  80688. }
  80689. declare module BABYLON {
  80690. export class WaterMaterial extends BABYLON.PushMaterial {
  80691. renderTargetSize: BABYLON.Vector2;
  80692. private _bumpTexture;
  80693. bumpTexture: BABYLON.BaseTexture;
  80694. diffuseColor: BABYLON.Color3;
  80695. specularColor: BABYLON.Color3;
  80696. specularPower: number;
  80697. private _disableLighting;
  80698. disableLighting: boolean;
  80699. private _maxSimultaneousLights;
  80700. maxSimultaneousLights: number;
  80701. /**
  80702. * @param {number}: Represents the wind force
  80703. */
  80704. windForce: number;
  80705. /**
  80706. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80707. */
  80708. windDirection: BABYLON.Vector2;
  80709. /**
  80710. * @param {number}: Wave height, represents the height of the waves
  80711. */
  80712. waveHeight: number;
  80713. /**
  80714. * @param {number}: Bump height, represents the bump height related to the bump map
  80715. */
  80716. bumpHeight: number;
  80717. /**
  80718. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80719. */
  80720. private _bumpSuperimpose;
  80721. bumpSuperimpose: boolean;
  80722. /**
  80723. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80724. */
  80725. private _fresnelSeparate;
  80726. fresnelSeparate: boolean;
  80727. /**
  80728. * @param {boolean}: bump Waves modify the reflection.
  80729. */
  80730. private _bumpAffectsReflection;
  80731. bumpAffectsReflection: boolean;
  80732. /**
  80733. * @param {number}: The water color blended with the refraction (near)
  80734. */
  80735. waterColor: BABYLON.Color3;
  80736. /**
  80737. * @param {number}: The blend factor related to the water color
  80738. */
  80739. colorBlendFactor: number;
  80740. /**
  80741. * @param {number}: The water color blended with the reflection (far)
  80742. */
  80743. waterColor2: BABYLON.Color3;
  80744. /**
  80745. * @param {number}: The blend factor related to the water color (reflection, far)
  80746. */
  80747. colorBlendFactor2: number;
  80748. /**
  80749. * @param {number}: Represents the maximum length of a wave
  80750. */
  80751. waveLength: number;
  80752. /**
  80753. * @param {number}: Defines the waves speed
  80754. */
  80755. waveSpeed: number;
  80756. /**
  80757. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80758. * will avoid calculating useless pixels in the pixel shader of the water material.
  80759. */
  80760. disableClipPlane: boolean;
  80761. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80762. private _mesh;
  80763. private _refractionRTT;
  80764. private _reflectionRTT;
  80765. private _reflectionTransform;
  80766. private _lastTime;
  80767. private _lastDeltaTime;
  80768. private _useLogarithmicDepth;
  80769. private _waitingRenderList;
  80770. private _imageProcessingConfiguration;
  80771. private _imageProcessingObserver;
  80772. /**
  80773. * Gets a boolean indicating that current material needs to register RTT
  80774. */
  80775. get hasRenderTargetTextures(): boolean;
  80776. /**
  80777. * Constructor
  80778. */
  80779. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80780. get useLogarithmicDepth(): boolean;
  80781. set useLogarithmicDepth(value: boolean);
  80782. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80783. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80784. addToRenderList(node: any): void;
  80785. enableRenderTargets(enable: boolean): void;
  80786. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80787. get renderTargetsEnabled(): boolean;
  80788. needAlphaBlending(): boolean;
  80789. needAlphaTesting(): boolean;
  80790. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80791. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80792. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80793. private _createRenderTargets;
  80794. getAnimatables(): BABYLON.IAnimatable[];
  80795. getActiveTextures(): BABYLON.BaseTexture[];
  80796. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80797. dispose(forceDisposeEffect?: boolean): void;
  80798. clone(name: string): WaterMaterial;
  80799. serialize(): any;
  80800. getClassName(): string;
  80801. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80802. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80803. }
  80804. }
  80805. declare module BABYLON {
  80806. /** @hidden */
  80807. export var asciiartPixelShader: {
  80808. name: string;
  80809. shader: string;
  80810. };
  80811. }
  80812. declare module BABYLON {
  80813. /**
  80814. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80815. *
  80816. * It basically takes care rendering the font front the given font size to a texture.
  80817. * This is used later on in the postprocess.
  80818. */
  80819. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80820. private _font;
  80821. private _text;
  80822. private _charSize;
  80823. /**
  80824. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80825. */
  80826. get charSize(): number;
  80827. /**
  80828. * Create a new instance of the Ascii Art FontTexture class
  80829. * @param name the name of the texture
  80830. * @param font the font to use, use the W3C CSS notation
  80831. * @param text the caracter set to use in the rendering.
  80832. * @param scene the scene that owns the texture
  80833. */
  80834. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80835. /**
  80836. * Gets the max char width of a font.
  80837. * @param font the font to use, use the W3C CSS notation
  80838. * @return the max char width
  80839. */
  80840. private getFontWidth;
  80841. /**
  80842. * Gets the max char height of a font.
  80843. * @param font the font to use, use the W3C CSS notation
  80844. * @return the max char height
  80845. */
  80846. private getFontHeight;
  80847. /**
  80848. * Clones the current AsciiArtTexture.
  80849. * @return the clone of the texture.
  80850. */
  80851. clone(): AsciiArtFontTexture;
  80852. /**
  80853. * Parses a json object representing the texture and returns an instance of it.
  80854. * @param source the source JSON representation
  80855. * @param scene the scene to create the texture for
  80856. * @return the parsed texture
  80857. */
  80858. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80859. }
  80860. /**
  80861. * Option available in the Ascii Art Post Process.
  80862. */
  80863. export interface IAsciiArtPostProcessOptions {
  80864. /**
  80865. * The font to use following the w3c font definition.
  80866. */
  80867. font?: string;
  80868. /**
  80869. * The character set to use in the postprocess.
  80870. */
  80871. characterSet?: string;
  80872. /**
  80873. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80874. * This number is defined between 0 and 1;
  80875. */
  80876. mixToTile?: number;
  80877. /**
  80878. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80879. * This number is defined between 0 and 1;
  80880. */
  80881. mixToNormal?: number;
  80882. }
  80883. /**
  80884. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80885. *
  80886. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80887. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80888. */
  80889. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80890. /**
  80891. * The font texture used to render the char in the post process.
  80892. */
  80893. private _asciiArtFontTexture;
  80894. /**
  80895. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80896. * This number is defined between 0 and 1;
  80897. */
  80898. mixToTile: number;
  80899. /**
  80900. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80901. * This number is defined between 0 and 1;
  80902. */
  80903. mixToNormal: number;
  80904. /**
  80905. * Instantiates a new Ascii Art Post Process.
  80906. * @param name the name to give to the postprocess
  80907. * @camera the camera to apply the post process to.
  80908. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80909. */
  80910. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80911. }
  80912. }
  80913. declare module BABYLON {
  80914. /** @hidden */
  80915. export var digitalrainPixelShader: {
  80916. name: string;
  80917. shader: string;
  80918. };
  80919. }
  80920. declare module BABYLON {
  80921. /**
  80922. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80923. *
  80924. * It basically takes care rendering the font front the given font size to a texture.
  80925. * This is used later on in the postprocess.
  80926. */
  80927. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80928. private _font;
  80929. private _text;
  80930. private _charSize;
  80931. /**
  80932. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80933. */
  80934. get charSize(): number;
  80935. /**
  80936. * Create a new instance of the Digital Rain FontTexture class
  80937. * @param name the name of the texture
  80938. * @param font the font to use, use the W3C CSS notation
  80939. * @param text the caracter set to use in the rendering.
  80940. * @param scene the scene that owns the texture
  80941. */
  80942. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80943. /**
  80944. * Gets the max char width of a font.
  80945. * @param font the font to use, use the W3C CSS notation
  80946. * @return the max char width
  80947. */
  80948. private getFontWidth;
  80949. /**
  80950. * Gets the max char height of a font.
  80951. * @param font the font to use, use the W3C CSS notation
  80952. * @return the max char height
  80953. */
  80954. private getFontHeight;
  80955. /**
  80956. * Clones the current DigitalRainFontTexture.
  80957. * @return the clone of the texture.
  80958. */
  80959. clone(): DigitalRainFontTexture;
  80960. /**
  80961. * Parses a json object representing the texture and returns an instance of it.
  80962. * @param source the source JSON representation
  80963. * @param scene the scene to create the texture for
  80964. * @return the parsed texture
  80965. */
  80966. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80967. }
  80968. /**
  80969. * Option available in the Digital Rain Post Process.
  80970. */
  80971. export interface IDigitalRainPostProcessOptions {
  80972. /**
  80973. * The font to use following the w3c font definition.
  80974. */
  80975. font?: string;
  80976. /**
  80977. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80978. * This number is defined between 0 and 1;
  80979. */
  80980. mixToTile?: number;
  80981. /**
  80982. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80983. * This number is defined between 0 and 1;
  80984. */
  80985. mixToNormal?: number;
  80986. }
  80987. /**
  80988. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80989. *
  80990. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80991. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80992. */
  80993. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80994. /**
  80995. * The font texture used to render the char in the post process.
  80996. */
  80997. private _digitalRainFontTexture;
  80998. /**
  80999. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  81000. * This number is defined between 0 and 1;
  81001. */
  81002. mixToTile: number;
  81003. /**
  81004. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  81005. * This number is defined between 0 and 1;
  81006. */
  81007. mixToNormal: number;
  81008. /**
  81009. * Instantiates a new Digital Rain Post Process.
  81010. * @param name the name to give to the postprocess
  81011. * @camera the camera to apply the post process to.
  81012. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  81013. */
  81014. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  81015. }
  81016. }
  81017. declare module BABYLON {
  81018. /** @hidden */
  81019. export var brickProceduralTexturePixelShader: {
  81020. name: string;
  81021. shader: string;
  81022. };
  81023. }
  81024. declare module BABYLON {
  81025. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  81026. private _numberOfBricksHeight;
  81027. private _numberOfBricksWidth;
  81028. private _jointColor;
  81029. private _brickColor;
  81030. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81031. updateShaderUniforms(): void;
  81032. get numberOfBricksHeight(): number;
  81033. set numberOfBricksHeight(value: number);
  81034. get numberOfBricksWidth(): number;
  81035. set numberOfBricksWidth(value: number);
  81036. get jointColor(): BABYLON.Color3;
  81037. set jointColor(value: BABYLON.Color3);
  81038. get brickColor(): BABYLON.Color3;
  81039. set brickColor(value: BABYLON.Color3);
  81040. /**
  81041. * Serializes this brick procedural texture
  81042. * @returns a serialized brick procedural texture object
  81043. */
  81044. serialize(): any;
  81045. /**
  81046. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  81047. * @param parsedTexture defines parsed texture data
  81048. * @param scene defines the current scene
  81049. * @param rootUrl defines the root URL containing brick procedural texture information
  81050. * @returns a parsed Brick Procedural BABYLON.Texture
  81051. */
  81052. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  81053. }
  81054. }
  81055. declare module BABYLON {
  81056. /** @hidden */
  81057. export var cloudProceduralTexturePixelShader: {
  81058. name: string;
  81059. shader: string;
  81060. };
  81061. }
  81062. declare module BABYLON {
  81063. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  81064. private _skyColor;
  81065. private _cloudColor;
  81066. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81067. updateShaderUniforms(): void;
  81068. get skyColor(): BABYLON.Color4;
  81069. set skyColor(value: BABYLON.Color4);
  81070. get cloudColor(): BABYLON.Color4;
  81071. set cloudColor(value: BABYLON.Color4);
  81072. /**
  81073. * Serializes this cloud procedural texture
  81074. * @returns a serialized cloud procedural texture object
  81075. */
  81076. serialize(): any;
  81077. /**
  81078. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  81079. * @param parsedTexture defines parsed texture data
  81080. * @param scene defines the current scene
  81081. * @param rootUrl defines the root URL containing cloud procedural texture information
  81082. * @returns a parsed Cloud Procedural BABYLON.Texture
  81083. */
  81084. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  81085. }
  81086. }
  81087. declare module BABYLON {
  81088. /** @hidden */
  81089. export var fireProceduralTexturePixelShader: {
  81090. name: string;
  81091. shader: string;
  81092. };
  81093. }
  81094. declare module BABYLON {
  81095. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  81096. private _time;
  81097. private _speed;
  81098. private _autoGenerateTime;
  81099. private _fireColors;
  81100. private _alphaThreshold;
  81101. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81102. updateShaderUniforms(): void;
  81103. render(useCameraPostProcess?: boolean): void;
  81104. static get PurpleFireColors(): BABYLON.Color3[];
  81105. static get GreenFireColors(): BABYLON.Color3[];
  81106. static get RedFireColors(): BABYLON.Color3[];
  81107. static get BlueFireColors(): BABYLON.Color3[];
  81108. get autoGenerateTime(): boolean;
  81109. set autoGenerateTime(value: boolean);
  81110. get fireColors(): BABYLON.Color3[];
  81111. set fireColors(value: BABYLON.Color3[]);
  81112. get time(): number;
  81113. set time(value: number);
  81114. get speed(): BABYLON.Vector2;
  81115. set speed(value: BABYLON.Vector2);
  81116. get alphaThreshold(): number;
  81117. set alphaThreshold(value: number);
  81118. /**
  81119. * Serializes this fire procedural texture
  81120. * @returns a serialized fire procedural texture object
  81121. */
  81122. serialize(): any;
  81123. /**
  81124. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  81125. * @param parsedTexture defines parsed texture data
  81126. * @param scene defines the current scene
  81127. * @param rootUrl defines the root URL containing fire procedural texture information
  81128. * @returns a parsed Fire Procedural BABYLON.Texture
  81129. */
  81130. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  81131. }
  81132. }
  81133. declare module BABYLON {
  81134. /** @hidden */
  81135. export var grassProceduralTexturePixelShader: {
  81136. name: string;
  81137. shader: string;
  81138. };
  81139. }
  81140. declare module BABYLON {
  81141. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  81142. private _grassColors;
  81143. private _groundColor;
  81144. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81145. updateShaderUniforms(): void;
  81146. get grassColors(): BABYLON.Color3[];
  81147. set grassColors(value: BABYLON.Color3[]);
  81148. get groundColor(): BABYLON.Color3;
  81149. set groundColor(value: BABYLON.Color3);
  81150. /**
  81151. * Serializes this grass procedural texture
  81152. * @returns a serialized grass procedural texture object
  81153. */
  81154. serialize(): any;
  81155. /**
  81156. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  81157. * @param parsedTexture defines parsed texture data
  81158. * @param scene defines the current scene
  81159. * @param rootUrl defines the root URL containing grass procedural texture information
  81160. * @returns a parsed Grass Procedural BABYLON.Texture
  81161. */
  81162. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  81163. }
  81164. }
  81165. declare module BABYLON {
  81166. /** @hidden */
  81167. export var marbleProceduralTexturePixelShader: {
  81168. name: string;
  81169. shader: string;
  81170. };
  81171. }
  81172. declare module BABYLON {
  81173. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  81174. private _numberOfTilesHeight;
  81175. private _numberOfTilesWidth;
  81176. private _amplitude;
  81177. private _jointColor;
  81178. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81179. updateShaderUniforms(): void;
  81180. get numberOfTilesHeight(): number;
  81181. set numberOfTilesHeight(value: number);
  81182. get amplitude(): number;
  81183. set amplitude(value: number);
  81184. get numberOfTilesWidth(): number;
  81185. set numberOfTilesWidth(value: number);
  81186. get jointColor(): BABYLON.Color3;
  81187. set jointColor(value: BABYLON.Color3);
  81188. /**
  81189. * Serializes this marble procedural texture
  81190. * @returns a serialized marble procedural texture object
  81191. */
  81192. serialize(): any;
  81193. /**
  81194. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  81195. * @param parsedTexture defines parsed texture data
  81196. * @param scene defines the current scene
  81197. * @param rootUrl defines the root URL containing marble procedural texture information
  81198. * @returns a parsed Marble Procedural BABYLON.Texture
  81199. */
  81200. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  81201. }
  81202. }
  81203. declare module BABYLON {
  81204. /** @hidden */
  81205. export var normalMapProceduralTexturePixelShader: {
  81206. name: string;
  81207. shader: string;
  81208. };
  81209. }
  81210. declare module BABYLON {
  81211. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  81212. private _baseTexture;
  81213. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81214. updateShaderUniforms(): void;
  81215. render(useCameraPostProcess?: boolean): void;
  81216. resize(size: any, generateMipMaps: any): void;
  81217. get baseTexture(): BABYLON.Texture;
  81218. set baseTexture(texture: BABYLON.Texture);
  81219. /**
  81220. * Serializes this normal map procedural texture
  81221. * @returns a serialized normal map procedural texture object
  81222. */
  81223. serialize(): any;
  81224. /**
  81225. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  81226. * @param parsedTexture defines parsed texture data
  81227. * @param scene defines the current scene
  81228. * @param rootUrl defines the root URL containing normal map procedural texture information
  81229. * @returns a parsed Normal Map Procedural BABYLON.Texture
  81230. */
  81231. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  81232. }
  81233. }
  81234. declare module BABYLON {
  81235. /** @hidden */
  81236. export var perlinNoiseProceduralTexturePixelShader: {
  81237. name: string;
  81238. shader: string;
  81239. };
  81240. }
  81241. declare module BABYLON {
  81242. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81243. time: number;
  81244. timeScale: number;
  81245. translationSpeed: number;
  81246. private _currentTranslation;
  81247. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81248. updateShaderUniforms(): void;
  81249. render(useCameraPostProcess?: boolean): void;
  81250. resize(size: any, generateMipMaps: any): void;
  81251. /**
  81252. * Serializes this perlin noise procedural texture
  81253. * @returns a serialized perlin noise procedural texture object
  81254. */
  81255. serialize(): any;
  81256. /**
  81257. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81258. * @param parsedTexture defines parsed texture data
  81259. * @param scene defines the current scene
  81260. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81261. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81262. */
  81263. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81264. }
  81265. }
  81266. declare module BABYLON {
  81267. /** @hidden */
  81268. export var roadProceduralTexturePixelShader: {
  81269. name: string;
  81270. shader: string;
  81271. };
  81272. }
  81273. declare module BABYLON {
  81274. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81275. private _roadColor;
  81276. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81277. updateShaderUniforms(): void;
  81278. get roadColor(): BABYLON.Color3;
  81279. set roadColor(value: BABYLON.Color3);
  81280. /**
  81281. * Serializes this road procedural texture
  81282. * @returns a serialized road procedural texture object
  81283. */
  81284. serialize(): any;
  81285. /**
  81286. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81287. * @param parsedTexture defines parsed texture data
  81288. * @param scene defines the current scene
  81289. * @param rootUrl defines the root URL containing road procedural texture information
  81290. * @returns a parsed Road Procedural BABYLON.Texture
  81291. */
  81292. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81293. }
  81294. }
  81295. declare module BABYLON {
  81296. /** @hidden */
  81297. export var starfieldProceduralTexturePixelShader: {
  81298. name: string;
  81299. shader: string;
  81300. };
  81301. }
  81302. declare module BABYLON {
  81303. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81304. private _time;
  81305. private _alpha;
  81306. private _beta;
  81307. private _zoom;
  81308. private _formuparam;
  81309. private _stepsize;
  81310. private _tile;
  81311. private _brightness;
  81312. private _darkmatter;
  81313. private _distfading;
  81314. private _saturation;
  81315. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81316. updateShaderUniforms(): void;
  81317. get time(): number;
  81318. set time(value: number);
  81319. get alpha(): number;
  81320. set alpha(value: number);
  81321. get beta(): number;
  81322. set beta(value: number);
  81323. get formuparam(): number;
  81324. set formuparam(value: number);
  81325. get stepsize(): number;
  81326. set stepsize(value: number);
  81327. get zoom(): number;
  81328. set zoom(value: number);
  81329. get tile(): number;
  81330. set tile(value: number);
  81331. get brightness(): number;
  81332. set brightness(value: number);
  81333. get darkmatter(): number;
  81334. set darkmatter(value: number);
  81335. get distfading(): number;
  81336. set distfading(value: number);
  81337. get saturation(): number;
  81338. set saturation(value: number);
  81339. /**
  81340. * Serializes this starfield procedural texture
  81341. * @returns a serialized starfield procedural texture object
  81342. */
  81343. serialize(): any;
  81344. /**
  81345. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81346. * @param parsedTexture defines parsed texture data
  81347. * @param scene defines the current scene
  81348. * @param rootUrl defines the root URL containing startfield procedural texture information
  81349. * @returns a parsed Starfield Procedural BABYLON.Texture
  81350. */
  81351. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81352. }
  81353. }
  81354. declare module BABYLON {
  81355. /** @hidden */
  81356. export var woodProceduralTexturePixelShader: {
  81357. name: string;
  81358. shader: string;
  81359. };
  81360. }
  81361. declare module BABYLON {
  81362. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81363. private _ampScale;
  81364. private _woodColor;
  81365. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81366. updateShaderUniforms(): void;
  81367. get ampScale(): number;
  81368. set ampScale(value: number);
  81369. get woodColor(): BABYLON.Color3;
  81370. set woodColor(value: BABYLON.Color3);
  81371. /**
  81372. * Serializes this wood procedural texture
  81373. * @returns a serialized wood procedural texture object
  81374. */
  81375. serialize(): any;
  81376. /**
  81377. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81378. * @param parsedTexture defines parsed texture data
  81379. * @param scene defines the current scene
  81380. * @param rootUrl defines the root URL containing wood procedural texture information
  81381. * @returns a parsed Wood Procedural BABYLON.Texture
  81382. */
  81383. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81384. }
  81385. }