documentation.d.ts 3.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516
  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. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  20638. * @param postProcesses An array of post processes to be run.
  20639. * @param targetTexture The target texture to render to.
  20640. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20641. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20642. * @param lodLevel defines which lod of the texture to render to
  20643. */
  20644. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20645. /**
  20646. * Finalize the result of the output of the postprocesses.
  20647. * @param doNotPresent If true the result will not be displayed to the screen.
  20648. * @param targetTexture The target texture to render to.
  20649. * @param faceIndex The index of the face to bind the target texture to.
  20650. * @param postProcesses The array of post processes to render.
  20651. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20652. * @hidden
  20653. */
  20654. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20655. /**
  20656. * Disposes of the post process manager.
  20657. */
  20658. dispose(): void;
  20659. }
  20660. }
  20661. declare module BABYLON {
  20662. /**
  20663. * This Helps creating a texture that will be created from a camera in your scene.
  20664. * It is basically a dynamic texture that could be used to create special effects for instance.
  20665. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20666. */
  20667. export class RenderTargetTexture extends Texture {
  20668. isCube: boolean;
  20669. /**
  20670. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20671. */
  20672. static readonly REFRESHRATE_RENDER_ONCE: number;
  20673. /**
  20674. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20675. */
  20676. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20677. /**
  20678. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20679. * the central point of your effect and can save a lot of performances.
  20680. */
  20681. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20682. /**
  20683. * Use this predicate to dynamically define the list of mesh you want to render.
  20684. * If set, the renderList property will be overwritten.
  20685. */
  20686. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20687. private _renderList;
  20688. /**
  20689. * Use this list to define the list of mesh you want to render.
  20690. */
  20691. get renderList(): Nullable<Array<AbstractMesh>>;
  20692. set renderList(value: Nullable<Array<AbstractMesh>>);
  20693. /**
  20694. * Use this function to overload the renderList array at rendering time.
  20695. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20696. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20697. * the cube (if the RTT is a cube, else layerOrFace=0).
  20698. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20699. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20700. * hold dummy elements!
  20701. */
  20702. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20703. private _hookArray;
  20704. /**
  20705. * Define if particles should be rendered in your texture.
  20706. */
  20707. renderParticles: boolean;
  20708. /**
  20709. * Define if sprites should be rendered in your texture.
  20710. */
  20711. renderSprites: boolean;
  20712. /**
  20713. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20714. */
  20715. coordinatesMode: number;
  20716. /**
  20717. * Define the camera used to render the texture.
  20718. */
  20719. activeCamera: Nullable<Camera>;
  20720. /**
  20721. * Override the mesh isReady function with your own one.
  20722. */
  20723. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20724. /**
  20725. * Override the render function of the texture with your own one.
  20726. */
  20727. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20728. /**
  20729. * Define if camera post processes should be use while rendering the texture.
  20730. */
  20731. useCameraPostProcesses: boolean;
  20732. /**
  20733. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20734. */
  20735. ignoreCameraViewport: boolean;
  20736. private _postProcessManager;
  20737. private _postProcesses;
  20738. private _resizeObserver;
  20739. /**
  20740. * An event triggered when the texture is unbind.
  20741. */
  20742. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20743. /**
  20744. * An event triggered when the texture is unbind.
  20745. */
  20746. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20747. private _onAfterUnbindObserver;
  20748. /**
  20749. * Set a after unbind callback in the texture.
  20750. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20751. */
  20752. set onAfterUnbind(callback: () => void);
  20753. /**
  20754. * An event triggered before rendering the texture
  20755. */
  20756. onBeforeRenderObservable: Observable<number>;
  20757. private _onBeforeRenderObserver;
  20758. /**
  20759. * Set a before render callback in the texture.
  20760. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20761. */
  20762. set onBeforeRender(callback: (faceIndex: number) => void);
  20763. /**
  20764. * An event triggered after rendering the texture
  20765. */
  20766. onAfterRenderObservable: Observable<number>;
  20767. private _onAfterRenderObserver;
  20768. /**
  20769. * Set a after render callback in the texture.
  20770. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20771. */
  20772. set onAfterRender(callback: (faceIndex: number) => void);
  20773. /**
  20774. * An event triggered after the texture clear
  20775. */
  20776. onClearObservable: Observable<Engine>;
  20777. private _onClearObserver;
  20778. /**
  20779. * Set a clear callback in the texture.
  20780. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20781. */
  20782. set onClear(callback: (Engine: Engine) => void);
  20783. /**
  20784. * An event triggered when the texture is resized.
  20785. */
  20786. onResizeObservable: Observable<RenderTargetTexture>;
  20787. /**
  20788. * Define the clear color of the Render Target if it should be different from the scene.
  20789. */
  20790. clearColor: Color4;
  20791. protected _size: number | {
  20792. width: number;
  20793. height: number;
  20794. layers?: number;
  20795. };
  20796. protected _initialSizeParameter: number | {
  20797. width: number;
  20798. height: number;
  20799. } | {
  20800. ratio: number;
  20801. };
  20802. protected _sizeRatio: Nullable<number>;
  20803. /** @hidden */
  20804. _generateMipMaps: boolean;
  20805. protected _renderingManager: RenderingManager;
  20806. /** @hidden */
  20807. _waitingRenderList: string[];
  20808. protected _doNotChangeAspectRatio: boolean;
  20809. protected _currentRefreshId: number;
  20810. protected _refreshRate: number;
  20811. protected _textureMatrix: Matrix;
  20812. protected _samples: number;
  20813. protected _renderTargetOptions: RenderTargetCreationOptions;
  20814. /**
  20815. * Gets render target creation options that were used.
  20816. */
  20817. get renderTargetOptions(): RenderTargetCreationOptions;
  20818. protected _engine: Engine;
  20819. protected _onRatioRescale(): void;
  20820. /**
  20821. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20822. * It must define where the camera used to render the texture is set
  20823. */
  20824. boundingBoxPosition: Vector3;
  20825. private _boundingBoxSize;
  20826. /**
  20827. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20828. * When defined, the cubemap will switch to local mode
  20829. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20830. * @example https://www.babylonjs-playground.com/#RNASML
  20831. */
  20832. set boundingBoxSize(value: Vector3);
  20833. get boundingBoxSize(): Vector3;
  20834. /**
  20835. * In case the RTT has been created with a depth texture, get the associated
  20836. * depth texture.
  20837. * Otherwise, return null.
  20838. */
  20839. get depthStencilTexture(): Nullable<InternalTexture>;
  20840. /**
  20841. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20842. * or used a shadow, depth texture...
  20843. * @param name The friendly name of the texture
  20844. * @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)
  20845. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20846. * @param generateMipMaps True if mip maps need to be generated after render.
  20847. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20848. * @param type The type of the buffer in the RTT (int, half float, float...)
  20849. * @param isCube True if a cube texture needs to be created
  20850. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20851. * @param generateDepthBuffer True to generate a depth buffer
  20852. * @param generateStencilBuffer True to generate a stencil buffer
  20853. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20854. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20855. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20856. */
  20857. constructor(name: string, size: number | {
  20858. width: number;
  20859. height: number;
  20860. layers?: number;
  20861. } | {
  20862. ratio: number;
  20863. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20864. /**
  20865. * Creates a depth stencil texture.
  20866. * This is only available in WebGL 2 or with the depth texture extension available.
  20867. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20868. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20869. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20870. */
  20871. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20872. private _processSizeParameter;
  20873. /**
  20874. * Define the number of samples to use in case of MSAA.
  20875. * It defaults to one meaning no MSAA has been enabled.
  20876. */
  20877. get samples(): number;
  20878. set samples(value: number);
  20879. /**
  20880. * Resets the refresh counter of the texture and start bak from scratch.
  20881. * Could be useful to regenerate the texture if it is setup to render only once.
  20882. */
  20883. resetRefreshCounter(): void;
  20884. /**
  20885. * Define the refresh rate of the texture or the rendering frequency.
  20886. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20887. */
  20888. get refreshRate(): number;
  20889. set refreshRate(value: number);
  20890. /**
  20891. * Adds a post process to the render target rendering passes.
  20892. * @param postProcess define the post process to add
  20893. */
  20894. addPostProcess(postProcess: PostProcess): void;
  20895. /**
  20896. * Clear all the post processes attached to the render target
  20897. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20898. */
  20899. clearPostProcesses(dispose?: boolean): void;
  20900. /**
  20901. * Remove one of the post process from the list of attached post processes to the texture
  20902. * @param postProcess define the post process to remove from the list
  20903. */
  20904. removePostProcess(postProcess: PostProcess): void;
  20905. /** @hidden */
  20906. _shouldRender(): boolean;
  20907. /**
  20908. * Gets the actual render size of the texture.
  20909. * @returns the width of the render size
  20910. */
  20911. getRenderSize(): number;
  20912. /**
  20913. * Gets the actual render width of the texture.
  20914. * @returns the width of the render size
  20915. */
  20916. getRenderWidth(): number;
  20917. /**
  20918. * Gets the actual render height of the texture.
  20919. * @returns the height of the render size
  20920. */
  20921. getRenderHeight(): number;
  20922. /**
  20923. * Gets the actual number of layers of the texture.
  20924. * @returns the number of layers
  20925. */
  20926. getRenderLayers(): number;
  20927. /**
  20928. * Get if the texture can be rescaled or not.
  20929. */
  20930. get canRescale(): boolean;
  20931. /**
  20932. * Resize the texture using a ratio.
  20933. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20934. */
  20935. scale(ratio: number): void;
  20936. /**
  20937. * Get the texture reflection matrix used to rotate/transform the reflection.
  20938. * @returns the reflection matrix
  20939. */
  20940. getReflectionTextureMatrix(): Matrix;
  20941. /**
  20942. * Resize the texture to a new desired size.
  20943. * Be carrefull as it will recreate all the data in the new texture.
  20944. * @param size Define the new size. It can be:
  20945. * - a number for squared texture,
  20946. * - an object containing { width: number, height: number }
  20947. * - or an object containing a ratio { ratio: number }
  20948. */
  20949. resize(size: number | {
  20950. width: number;
  20951. height: number;
  20952. } | {
  20953. ratio: number;
  20954. }): void;
  20955. private _defaultRenderListPrepared;
  20956. /**
  20957. * Renders all the objects from the render list into the texture.
  20958. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20959. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20960. */
  20961. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20962. private _bestReflectionRenderTargetDimension;
  20963. private _prepareRenderingManager;
  20964. /**
  20965. * @hidden
  20966. * @param faceIndex face index to bind to if this is a cubetexture
  20967. * @param layer defines the index of the texture to bind in the array
  20968. */
  20969. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20970. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20971. private renderToTarget;
  20972. /**
  20973. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20974. * This allowed control for front to back rendering or reversly depending of the special needs.
  20975. *
  20976. * @param renderingGroupId The rendering group id corresponding to its index
  20977. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20978. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20979. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20980. */
  20981. 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;
  20982. /**
  20983. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20984. *
  20985. * @param renderingGroupId The rendering group id corresponding to its index
  20986. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20987. */
  20988. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20989. /**
  20990. * Clones the texture.
  20991. * @returns the cloned texture
  20992. */
  20993. clone(): RenderTargetTexture;
  20994. /**
  20995. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20996. * @returns The JSON representation of the texture
  20997. */
  20998. serialize(): any;
  20999. /**
  21000. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21001. */
  21002. disposeFramebufferObjects(): void;
  21003. /**
  21004. * Dispose the texture and release its associated resources.
  21005. */
  21006. dispose(): void;
  21007. /** @hidden */
  21008. _rebuild(): void;
  21009. /**
  21010. * Clear the info related to rendering groups preventing retention point in material dispose.
  21011. */
  21012. freeRenderingGroups(): void;
  21013. /**
  21014. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21015. * @returns the view count
  21016. */
  21017. getViewCount(): number;
  21018. }
  21019. }
  21020. declare module BABYLON {
  21021. /**
  21022. * Class used to manipulate GUIDs
  21023. */
  21024. export class GUID {
  21025. /**
  21026. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21027. * Be aware Math.random() could cause collisions, but:
  21028. * "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"
  21029. * @returns a pseudo random id
  21030. */
  21031. static RandomId(): string;
  21032. }
  21033. }
  21034. declare module BABYLON {
  21035. /**
  21036. * Options to be used when creating a shadow depth material
  21037. */
  21038. export interface IIOptionShadowDepthMaterial {
  21039. /** Variables in the vertex shader code that need to have their names remapped.
  21040. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21041. * "var_name" should be either: worldPos or vNormalW
  21042. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21043. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21044. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21045. */
  21046. remappedVariables?: string[];
  21047. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21048. standalone?: boolean;
  21049. }
  21050. /**
  21051. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21052. */
  21053. export class ShadowDepthWrapper {
  21054. private _scene;
  21055. private _options?;
  21056. private _baseMaterial;
  21057. private _onEffectCreatedObserver;
  21058. private _subMeshToEffect;
  21059. private _subMeshToDepthEffect;
  21060. private _meshes;
  21061. /** @hidden */
  21062. _matriceNames: any;
  21063. /** Gets the standalone status of the wrapper */
  21064. get standalone(): boolean;
  21065. /** Gets the base material the wrapper is built upon */
  21066. get baseMaterial(): Material;
  21067. /**
  21068. * Instantiate a new shadow depth wrapper.
  21069. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21070. * generate the shadow depth map. For more information, please refer to the documentation:
  21071. * https://doc.babylonjs.com/babylon101/shadows
  21072. * @param baseMaterial Material to wrap
  21073. * @param scene Define the scene the material belongs to
  21074. * @param options Options used to create the wrapper
  21075. */
  21076. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21077. /**
  21078. * Gets the effect to use to generate the depth map
  21079. * @param subMesh subMesh to get the effect for
  21080. * @param shadowGenerator shadow generator to get the effect for
  21081. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21082. */
  21083. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21084. /**
  21085. * Specifies that the submesh is ready to be used for depth rendering
  21086. * @param subMesh submesh to check
  21087. * @param defines the list of defines to take into account when checking the effect
  21088. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21089. * @param useInstances specifies that instances should be used
  21090. * @returns a boolean indicating that the submesh is ready or not
  21091. */
  21092. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21093. /**
  21094. * Disposes the resources
  21095. */
  21096. dispose(): void;
  21097. private _makeEffect;
  21098. }
  21099. }
  21100. declare module BABYLON {
  21101. /**
  21102. * Options for compiling materials.
  21103. */
  21104. export interface IMaterialCompilationOptions {
  21105. /**
  21106. * Defines whether clip planes are enabled.
  21107. */
  21108. clipPlane: boolean;
  21109. /**
  21110. * Defines whether instances are enabled.
  21111. */
  21112. useInstances: boolean;
  21113. }
  21114. /**
  21115. * Base class for the main features of a material in Babylon.js
  21116. */
  21117. export class Material implements IAnimatable {
  21118. /**
  21119. * Returns the triangle fill mode
  21120. */
  21121. static readonly TriangleFillMode: number;
  21122. /**
  21123. * Returns the wireframe mode
  21124. */
  21125. static readonly WireFrameFillMode: number;
  21126. /**
  21127. * Returns the point fill mode
  21128. */
  21129. static readonly PointFillMode: number;
  21130. /**
  21131. * Returns the point list draw mode
  21132. */
  21133. static readonly PointListDrawMode: number;
  21134. /**
  21135. * Returns the line list draw mode
  21136. */
  21137. static readonly LineListDrawMode: number;
  21138. /**
  21139. * Returns the line loop draw mode
  21140. */
  21141. static readonly LineLoopDrawMode: number;
  21142. /**
  21143. * Returns the line strip draw mode
  21144. */
  21145. static readonly LineStripDrawMode: number;
  21146. /**
  21147. * Returns the triangle strip draw mode
  21148. */
  21149. static readonly TriangleStripDrawMode: number;
  21150. /**
  21151. * Returns the triangle fan draw mode
  21152. */
  21153. static readonly TriangleFanDrawMode: number;
  21154. /**
  21155. * Stores the clock-wise side orientation
  21156. */
  21157. static readonly ClockWiseSideOrientation: number;
  21158. /**
  21159. * Stores the counter clock-wise side orientation
  21160. */
  21161. static readonly CounterClockWiseSideOrientation: number;
  21162. /**
  21163. * The dirty texture flag value
  21164. */
  21165. static readonly TextureDirtyFlag: number;
  21166. /**
  21167. * The dirty light flag value
  21168. */
  21169. static readonly LightDirtyFlag: number;
  21170. /**
  21171. * The dirty fresnel flag value
  21172. */
  21173. static readonly FresnelDirtyFlag: number;
  21174. /**
  21175. * The dirty attribute flag value
  21176. */
  21177. static readonly AttributesDirtyFlag: number;
  21178. /**
  21179. * The dirty misc flag value
  21180. */
  21181. static readonly MiscDirtyFlag: number;
  21182. /**
  21183. * The all dirty flag value
  21184. */
  21185. static readonly AllDirtyFlag: number;
  21186. /**
  21187. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21188. */
  21189. static readonly MATERIAL_OPAQUE: number;
  21190. /**
  21191. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21192. */
  21193. static readonly MATERIAL_ALPHATEST: number;
  21194. /**
  21195. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21196. */
  21197. static readonly MATERIAL_ALPHABLEND: number;
  21198. /**
  21199. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21200. * They are also discarded below the alpha cutoff threshold to improve performances.
  21201. */
  21202. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21203. /**
  21204. * Custom callback helping to override the default shader used in the material.
  21205. */
  21206. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21207. /**
  21208. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21209. */
  21210. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21211. /**
  21212. * The ID of the material
  21213. */
  21214. id: string;
  21215. /**
  21216. * Gets or sets the unique id of the material
  21217. */
  21218. uniqueId: number;
  21219. /**
  21220. * The name of the material
  21221. */
  21222. name: string;
  21223. /**
  21224. * Gets or sets user defined metadata
  21225. */
  21226. metadata: any;
  21227. /**
  21228. * For internal use only. Please do not use.
  21229. */
  21230. reservedDataStore: any;
  21231. /**
  21232. * Specifies if the ready state should be checked on each call
  21233. */
  21234. checkReadyOnEveryCall: boolean;
  21235. /**
  21236. * Specifies if the ready state should be checked once
  21237. */
  21238. checkReadyOnlyOnce: boolean;
  21239. /**
  21240. * The state of the material
  21241. */
  21242. state: string;
  21243. /**
  21244. * The alpha value of the material
  21245. */
  21246. protected _alpha: number;
  21247. /**
  21248. * List of inspectable custom properties (used by the Inspector)
  21249. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21250. */
  21251. inspectableCustomProperties: IInspectable[];
  21252. /**
  21253. * Sets the alpha value of the material
  21254. */
  21255. set alpha(value: number);
  21256. /**
  21257. * Gets the alpha value of the material
  21258. */
  21259. get alpha(): number;
  21260. /**
  21261. * Specifies if back face culling is enabled
  21262. */
  21263. protected _backFaceCulling: boolean;
  21264. /**
  21265. * Sets the back-face culling state
  21266. */
  21267. set backFaceCulling(value: boolean);
  21268. /**
  21269. * Gets the back-face culling state
  21270. */
  21271. get backFaceCulling(): boolean;
  21272. /**
  21273. * Stores the value for side orientation
  21274. */
  21275. sideOrientation: number;
  21276. /**
  21277. * Callback triggered when the material is compiled
  21278. */
  21279. onCompiled: Nullable<(effect: Effect) => void>;
  21280. /**
  21281. * Callback triggered when an error occurs
  21282. */
  21283. onError: Nullable<(effect: Effect, errors: string) => void>;
  21284. /**
  21285. * Callback triggered to get the render target textures
  21286. */
  21287. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21288. /**
  21289. * Gets a boolean indicating that current material needs to register RTT
  21290. */
  21291. get hasRenderTargetTextures(): boolean;
  21292. /**
  21293. * Specifies if the material should be serialized
  21294. */
  21295. doNotSerialize: boolean;
  21296. /**
  21297. * @hidden
  21298. */
  21299. _storeEffectOnSubMeshes: boolean;
  21300. /**
  21301. * Stores the animations for the material
  21302. */
  21303. animations: Nullable<Array<Animation>>;
  21304. /**
  21305. * An event triggered when the material is disposed
  21306. */
  21307. onDisposeObservable: Observable<Material>;
  21308. /**
  21309. * An observer which watches for dispose events
  21310. */
  21311. private _onDisposeObserver;
  21312. private _onUnBindObservable;
  21313. /**
  21314. * Called during a dispose event
  21315. */
  21316. set onDispose(callback: () => void);
  21317. private _onBindObservable;
  21318. /**
  21319. * An event triggered when the material is bound
  21320. */
  21321. get onBindObservable(): Observable<AbstractMesh>;
  21322. /**
  21323. * An observer which watches for bind events
  21324. */
  21325. private _onBindObserver;
  21326. /**
  21327. * Called during a bind event
  21328. */
  21329. set onBind(callback: (Mesh: AbstractMesh) => void);
  21330. /**
  21331. * An event triggered when the material is unbound
  21332. */
  21333. get onUnBindObservable(): Observable<Material>;
  21334. protected _onEffectCreatedObservable: Nullable<Observable<{
  21335. effect: Effect;
  21336. subMesh: Nullable<SubMesh>;
  21337. }>>;
  21338. /**
  21339. * An event triggered when the effect is (re)created
  21340. */
  21341. get onEffectCreatedObservable(): Observable<{
  21342. effect: Effect;
  21343. subMesh: Nullable<SubMesh>;
  21344. }>;
  21345. /**
  21346. * Stores the value of the alpha mode
  21347. */
  21348. private _alphaMode;
  21349. /**
  21350. * Sets the value of the alpha mode.
  21351. *
  21352. * | Value | Type | Description |
  21353. * | --- | --- | --- |
  21354. * | 0 | ALPHA_DISABLE | |
  21355. * | 1 | ALPHA_ADD | |
  21356. * | 2 | ALPHA_COMBINE | |
  21357. * | 3 | ALPHA_SUBTRACT | |
  21358. * | 4 | ALPHA_MULTIPLY | |
  21359. * | 5 | ALPHA_MAXIMIZED | |
  21360. * | 6 | ALPHA_ONEONE | |
  21361. * | 7 | ALPHA_PREMULTIPLIED | |
  21362. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21363. * | 9 | ALPHA_INTERPOLATE | |
  21364. * | 10 | ALPHA_SCREENMODE | |
  21365. *
  21366. */
  21367. set alphaMode(value: number);
  21368. /**
  21369. * Gets the value of the alpha mode
  21370. */
  21371. get alphaMode(): number;
  21372. /**
  21373. * Stores the state of the need depth pre-pass value
  21374. */
  21375. private _needDepthPrePass;
  21376. /**
  21377. * Sets the need depth pre-pass value
  21378. */
  21379. set needDepthPrePass(value: boolean);
  21380. /**
  21381. * Gets the depth pre-pass value
  21382. */
  21383. get needDepthPrePass(): boolean;
  21384. /**
  21385. * Specifies if depth writing should be disabled
  21386. */
  21387. disableDepthWrite: boolean;
  21388. /**
  21389. * Specifies if color writing should be disabled
  21390. */
  21391. disableColorWrite: boolean;
  21392. /**
  21393. * Specifies if depth writing should be forced
  21394. */
  21395. forceDepthWrite: boolean;
  21396. /**
  21397. * Specifies the depth function that should be used. 0 means the default engine function
  21398. */
  21399. depthFunction: number;
  21400. /**
  21401. * Specifies if there should be a separate pass for culling
  21402. */
  21403. separateCullingPass: boolean;
  21404. /**
  21405. * Stores the state specifing if fog should be enabled
  21406. */
  21407. private _fogEnabled;
  21408. /**
  21409. * Sets the state for enabling fog
  21410. */
  21411. set fogEnabled(value: boolean);
  21412. /**
  21413. * Gets the value of the fog enabled state
  21414. */
  21415. get fogEnabled(): boolean;
  21416. /**
  21417. * Stores the size of points
  21418. */
  21419. pointSize: number;
  21420. /**
  21421. * Stores the z offset value
  21422. */
  21423. zOffset: number;
  21424. get wireframe(): boolean;
  21425. /**
  21426. * Sets the state of wireframe mode
  21427. */
  21428. set wireframe(value: boolean);
  21429. /**
  21430. * Gets the value specifying if point clouds are enabled
  21431. */
  21432. get pointsCloud(): boolean;
  21433. /**
  21434. * Sets the state of point cloud mode
  21435. */
  21436. set pointsCloud(value: boolean);
  21437. /**
  21438. * Gets the material fill mode
  21439. */
  21440. get fillMode(): number;
  21441. /**
  21442. * Sets the material fill mode
  21443. */
  21444. set fillMode(value: number);
  21445. /**
  21446. * @hidden
  21447. * Stores the effects for the material
  21448. */
  21449. _effect: Nullable<Effect>;
  21450. /**
  21451. * Specifies if uniform buffers should be used
  21452. */
  21453. private _useUBO;
  21454. /**
  21455. * Stores a reference to the scene
  21456. */
  21457. private _scene;
  21458. /**
  21459. * Stores the fill mode state
  21460. */
  21461. private _fillMode;
  21462. /**
  21463. * Specifies if the depth write state should be cached
  21464. */
  21465. private _cachedDepthWriteState;
  21466. /**
  21467. * Specifies if the color write state should be cached
  21468. */
  21469. private _cachedColorWriteState;
  21470. /**
  21471. * Specifies if the depth function state should be cached
  21472. */
  21473. private _cachedDepthFunctionState;
  21474. /**
  21475. * Stores the uniform buffer
  21476. */
  21477. protected _uniformBuffer: UniformBuffer;
  21478. /** @hidden */
  21479. _indexInSceneMaterialArray: number;
  21480. /** @hidden */
  21481. meshMap: Nullable<{
  21482. [id: string]: AbstractMesh | undefined;
  21483. }>;
  21484. /**
  21485. * Creates a material instance
  21486. * @param name defines the name of the material
  21487. * @param scene defines the scene to reference
  21488. * @param doNotAdd specifies if the material should be added to the scene
  21489. */
  21490. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21491. /**
  21492. * Returns a string representation of the current material
  21493. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21494. * @returns a string with material information
  21495. */
  21496. toString(fullDetails?: boolean): string;
  21497. /**
  21498. * Gets the class name of the material
  21499. * @returns a string with the class name of the material
  21500. */
  21501. getClassName(): string;
  21502. /**
  21503. * Specifies if updates for the material been locked
  21504. */
  21505. get isFrozen(): boolean;
  21506. /**
  21507. * Locks updates for the material
  21508. */
  21509. freeze(): void;
  21510. /**
  21511. * Unlocks updates for the material
  21512. */
  21513. unfreeze(): void;
  21514. /**
  21515. * Specifies if the material is ready to be used
  21516. * @param mesh defines the mesh to check
  21517. * @param useInstances specifies if instances should be used
  21518. * @returns a boolean indicating if the material is ready to be used
  21519. */
  21520. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21521. /**
  21522. * Specifies that the submesh is ready to be used
  21523. * @param mesh defines the mesh to check
  21524. * @param subMesh defines which submesh to check
  21525. * @param useInstances specifies that instances should be used
  21526. * @returns a boolean indicating that the submesh is ready or not
  21527. */
  21528. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21529. /**
  21530. * Returns the material effect
  21531. * @returns the effect associated with the material
  21532. */
  21533. getEffect(): Nullable<Effect>;
  21534. /**
  21535. * Returns the current scene
  21536. * @returns a Scene
  21537. */
  21538. getScene(): Scene;
  21539. /**
  21540. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21541. */
  21542. protected _forceAlphaTest: boolean;
  21543. /**
  21544. * The transparency mode of the material.
  21545. */
  21546. protected _transparencyMode: Nullable<number>;
  21547. /**
  21548. * Gets the current transparency mode.
  21549. */
  21550. get transparencyMode(): Nullable<number>;
  21551. /**
  21552. * Sets the transparency mode of the material.
  21553. *
  21554. * | Value | Type | Description |
  21555. * | ----- | ----------------------------------- | ----------- |
  21556. * | 0 | OPAQUE | |
  21557. * | 1 | ALPHATEST | |
  21558. * | 2 | ALPHABLEND | |
  21559. * | 3 | ALPHATESTANDBLEND | |
  21560. *
  21561. */
  21562. set transparencyMode(value: Nullable<number>);
  21563. /**
  21564. * Returns true if alpha blending should be disabled.
  21565. */
  21566. protected get _disableAlphaBlending(): boolean;
  21567. /**
  21568. * Specifies whether or not this material should be rendered in alpha blend mode.
  21569. * @returns a boolean specifying if alpha blending is needed
  21570. */
  21571. needAlphaBlending(): boolean;
  21572. /**
  21573. * Specifies if the mesh will require alpha blending
  21574. * @param mesh defines the mesh to check
  21575. * @returns a boolean specifying if alpha blending is needed for the mesh
  21576. */
  21577. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21578. /**
  21579. * Specifies whether or not this material should be rendered in alpha test mode.
  21580. * @returns a boolean specifying if an alpha test is needed.
  21581. */
  21582. needAlphaTesting(): boolean;
  21583. /**
  21584. * Specifies if material alpha testing should be turned on for the mesh
  21585. * @param mesh defines the mesh to check
  21586. */
  21587. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21588. /**
  21589. * Gets the texture used for the alpha test
  21590. * @returns the texture to use for alpha testing
  21591. */
  21592. getAlphaTestTexture(): Nullable<BaseTexture>;
  21593. /**
  21594. * Marks the material to indicate that it needs to be re-calculated
  21595. */
  21596. markDirty(): void;
  21597. /** @hidden */
  21598. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21599. /**
  21600. * Binds the material to the mesh
  21601. * @param world defines the world transformation matrix
  21602. * @param mesh defines the mesh to bind the material to
  21603. */
  21604. bind(world: Matrix, mesh?: Mesh): void;
  21605. /**
  21606. * Binds the submesh to the material
  21607. * @param world defines the world transformation matrix
  21608. * @param mesh defines the mesh containing the submesh
  21609. * @param subMesh defines the submesh to bind the material to
  21610. */
  21611. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21612. /**
  21613. * Binds the world matrix to the material
  21614. * @param world defines the world transformation matrix
  21615. */
  21616. bindOnlyWorldMatrix(world: Matrix): void;
  21617. /**
  21618. * Binds the scene's uniform buffer to the effect.
  21619. * @param effect defines the effect to bind to the scene uniform buffer
  21620. * @param sceneUbo defines the uniform buffer storing scene data
  21621. */
  21622. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21623. /**
  21624. * Binds the view matrix to the effect
  21625. * @param effect defines the effect to bind the view matrix to
  21626. */
  21627. bindView(effect: Effect): void;
  21628. /**
  21629. * Binds the view projection matrix to the effect
  21630. * @param effect defines the effect to bind the view projection matrix to
  21631. */
  21632. bindViewProjection(effect: Effect): void;
  21633. /**
  21634. * Processes to execute after binding the material to a mesh
  21635. * @param mesh defines the rendered mesh
  21636. */
  21637. protected _afterBind(mesh?: Mesh): void;
  21638. /**
  21639. * Unbinds the material from the mesh
  21640. */
  21641. unbind(): void;
  21642. /**
  21643. * Gets the active textures from the material
  21644. * @returns an array of textures
  21645. */
  21646. getActiveTextures(): BaseTexture[];
  21647. /**
  21648. * Specifies if the material uses a texture
  21649. * @param texture defines the texture to check against the material
  21650. * @returns a boolean specifying if the material uses the texture
  21651. */
  21652. hasTexture(texture: BaseTexture): boolean;
  21653. /**
  21654. * Makes a duplicate of the material, and gives it a new name
  21655. * @param name defines the new name for the duplicated material
  21656. * @returns the cloned material
  21657. */
  21658. clone(name: string): Nullable<Material>;
  21659. /**
  21660. * Gets the meshes bound to the material
  21661. * @returns an array of meshes bound to the material
  21662. */
  21663. getBindedMeshes(): AbstractMesh[];
  21664. /**
  21665. * Force shader compilation
  21666. * @param mesh defines the mesh associated with this material
  21667. * @param onCompiled defines a function to execute once the material is compiled
  21668. * @param options defines the options to configure the compilation
  21669. * @param onError defines a function to execute if the material fails compiling
  21670. */
  21671. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21672. /**
  21673. * Force shader compilation
  21674. * @param mesh defines the mesh that will use this material
  21675. * @param options defines additional options for compiling the shaders
  21676. * @returns a promise that resolves when the compilation completes
  21677. */
  21678. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21679. private static readonly _AllDirtyCallBack;
  21680. private static readonly _ImageProcessingDirtyCallBack;
  21681. private static readonly _TextureDirtyCallBack;
  21682. private static readonly _FresnelDirtyCallBack;
  21683. private static readonly _MiscDirtyCallBack;
  21684. private static readonly _LightsDirtyCallBack;
  21685. private static readonly _AttributeDirtyCallBack;
  21686. private static _FresnelAndMiscDirtyCallBack;
  21687. private static _TextureAndMiscDirtyCallBack;
  21688. private static readonly _DirtyCallbackArray;
  21689. private static readonly _RunDirtyCallBacks;
  21690. /**
  21691. * Marks a define in the material to indicate that it needs to be re-computed
  21692. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21693. */
  21694. markAsDirty(flag: number): void;
  21695. /**
  21696. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21697. * @param func defines a function which checks material defines against the submeshes
  21698. */
  21699. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21700. /**
  21701. * Indicates that we need to re-calculated for all submeshes
  21702. */
  21703. protected _markAllSubMeshesAsAllDirty(): void;
  21704. /**
  21705. * Indicates that image processing needs to be re-calculated for all submeshes
  21706. */
  21707. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21708. /**
  21709. * Indicates that textures need to be re-calculated for all submeshes
  21710. */
  21711. protected _markAllSubMeshesAsTexturesDirty(): void;
  21712. /**
  21713. * Indicates that fresnel needs to be re-calculated for all submeshes
  21714. */
  21715. protected _markAllSubMeshesAsFresnelDirty(): void;
  21716. /**
  21717. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21718. */
  21719. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21720. /**
  21721. * Indicates that lights need to be re-calculated for all submeshes
  21722. */
  21723. protected _markAllSubMeshesAsLightsDirty(): void;
  21724. /**
  21725. * Indicates that attributes need to be re-calculated for all submeshes
  21726. */
  21727. protected _markAllSubMeshesAsAttributesDirty(): void;
  21728. /**
  21729. * Indicates that misc needs to be re-calculated for all submeshes
  21730. */
  21731. protected _markAllSubMeshesAsMiscDirty(): void;
  21732. /**
  21733. * Indicates that textures and misc need to be re-calculated for all submeshes
  21734. */
  21735. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21736. /**
  21737. * Disposes the material
  21738. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21739. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21740. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21741. */
  21742. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21743. /** @hidden */
  21744. private releaseVertexArrayObject;
  21745. /**
  21746. * Serializes this material
  21747. * @returns the serialized material object
  21748. */
  21749. serialize(): any;
  21750. /**
  21751. * Creates a material from parsed material data
  21752. * @param parsedMaterial defines parsed material data
  21753. * @param scene defines the hosting scene
  21754. * @param rootUrl defines the root URL to use to load textures
  21755. * @returns a new material
  21756. */
  21757. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21758. }
  21759. }
  21760. declare module BABYLON {
  21761. /**
  21762. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21763. * separate meshes. This can be use to improve performances.
  21764. * @see http://doc.babylonjs.com/how_to/multi_materials
  21765. */
  21766. export class MultiMaterial extends Material {
  21767. private _subMaterials;
  21768. /**
  21769. * Gets or Sets the list of Materials used within the multi material.
  21770. * They need to be ordered according to the submeshes order in the associated mesh
  21771. */
  21772. get subMaterials(): Nullable<Material>[];
  21773. set subMaterials(value: Nullable<Material>[]);
  21774. /**
  21775. * Function used to align with Node.getChildren()
  21776. * @returns the list of Materials used within the multi material
  21777. */
  21778. getChildren(): Nullable<Material>[];
  21779. /**
  21780. * Instantiates a new Multi Material
  21781. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21782. * separate meshes. This can be use to improve performances.
  21783. * @see http://doc.babylonjs.com/how_to/multi_materials
  21784. * @param name Define the name in the scene
  21785. * @param scene Define the scene the material belongs to
  21786. */
  21787. constructor(name: string, scene: Scene);
  21788. private _hookArray;
  21789. /**
  21790. * Get one of the submaterial by its index in the submaterials array
  21791. * @param index The index to look the sub material at
  21792. * @returns The Material if the index has been defined
  21793. */
  21794. getSubMaterial(index: number): Nullable<Material>;
  21795. /**
  21796. * Get the list of active textures for the whole sub materials list.
  21797. * @returns All the textures that will be used during the rendering
  21798. */
  21799. getActiveTextures(): BaseTexture[];
  21800. /**
  21801. * Gets the current class name of the material e.g. "MultiMaterial"
  21802. * Mainly use in serialization.
  21803. * @returns the class name
  21804. */
  21805. getClassName(): string;
  21806. /**
  21807. * Checks if the material is ready to render the requested sub mesh
  21808. * @param mesh Define the mesh the submesh belongs to
  21809. * @param subMesh Define the sub mesh to look readyness for
  21810. * @param useInstances Define whether or not the material is used with instances
  21811. * @returns true if ready, otherwise false
  21812. */
  21813. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21814. /**
  21815. * Clones the current material and its related sub materials
  21816. * @param name Define the name of the newly cloned material
  21817. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21818. * @returns the cloned material
  21819. */
  21820. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21821. /**
  21822. * Serializes the materials into a JSON representation.
  21823. * @returns the JSON representation
  21824. */
  21825. serialize(): any;
  21826. /**
  21827. * Dispose the material and release its associated resources
  21828. * @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)
  21829. * @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)
  21830. * @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)
  21831. */
  21832. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21833. /**
  21834. * Creates a MultiMaterial from parsed MultiMaterial data.
  21835. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21836. * @param scene defines the hosting scene
  21837. * @returns a new MultiMaterial
  21838. */
  21839. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21840. }
  21841. }
  21842. declare module BABYLON {
  21843. /**
  21844. * Base class for submeshes
  21845. */
  21846. export class BaseSubMesh {
  21847. /** @hidden */
  21848. _materialDefines: Nullable<MaterialDefines>;
  21849. /** @hidden */
  21850. _materialEffect: Nullable<Effect>;
  21851. /** @hidden */
  21852. _effectOverride: Nullable<Effect>;
  21853. /**
  21854. * Gets material defines used by the effect associated to the sub mesh
  21855. */
  21856. get materialDefines(): Nullable<MaterialDefines>;
  21857. /**
  21858. * Sets material defines used by the effect associated to the sub mesh
  21859. */
  21860. set materialDefines(defines: Nullable<MaterialDefines>);
  21861. /**
  21862. * Gets associated effect
  21863. */
  21864. get effect(): Nullable<Effect>;
  21865. /**
  21866. * Sets associated effect (effect used to render this submesh)
  21867. * @param effect defines the effect to associate with
  21868. * @param defines defines the set of defines used to compile this effect
  21869. */
  21870. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21871. }
  21872. /**
  21873. * Defines a subdivision inside a mesh
  21874. */
  21875. export class SubMesh extends BaseSubMesh implements ICullable {
  21876. /** the material index to use */
  21877. materialIndex: number;
  21878. /** vertex index start */
  21879. verticesStart: number;
  21880. /** vertices count */
  21881. verticesCount: number;
  21882. /** index start */
  21883. indexStart: number;
  21884. /** indices count */
  21885. indexCount: number;
  21886. /** @hidden */
  21887. _linesIndexCount: number;
  21888. private _mesh;
  21889. private _renderingMesh;
  21890. private _boundingInfo;
  21891. private _linesIndexBuffer;
  21892. /** @hidden */
  21893. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21894. /** @hidden */
  21895. _trianglePlanes: Plane[];
  21896. /** @hidden */
  21897. _lastColliderTransformMatrix: Nullable<Matrix>;
  21898. /** @hidden */
  21899. _renderId: number;
  21900. /** @hidden */
  21901. _alphaIndex: number;
  21902. /** @hidden */
  21903. _distanceToCamera: number;
  21904. /** @hidden */
  21905. _id: number;
  21906. private _currentMaterial;
  21907. /**
  21908. * Add a new submesh to a mesh
  21909. * @param materialIndex defines the material index to use
  21910. * @param verticesStart defines vertex index start
  21911. * @param verticesCount defines vertices count
  21912. * @param indexStart defines index start
  21913. * @param indexCount defines indices count
  21914. * @param mesh defines the parent mesh
  21915. * @param renderingMesh defines an optional rendering mesh
  21916. * @param createBoundingBox defines if bounding box should be created for this submesh
  21917. * @returns the new submesh
  21918. */
  21919. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21920. /**
  21921. * Creates a new submesh
  21922. * @param materialIndex defines the material index to use
  21923. * @param verticesStart defines vertex index start
  21924. * @param verticesCount defines vertices count
  21925. * @param indexStart defines index start
  21926. * @param indexCount defines indices count
  21927. * @param mesh defines the parent mesh
  21928. * @param renderingMesh defines an optional rendering mesh
  21929. * @param createBoundingBox defines if bounding box should be created for this submesh
  21930. */
  21931. constructor(
  21932. /** the material index to use */
  21933. materialIndex: number,
  21934. /** vertex index start */
  21935. verticesStart: number,
  21936. /** vertices count */
  21937. verticesCount: number,
  21938. /** index start */
  21939. indexStart: number,
  21940. /** indices count */
  21941. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21942. /**
  21943. * Returns true if this submesh covers the entire parent mesh
  21944. * @ignorenaming
  21945. */
  21946. get IsGlobal(): boolean;
  21947. /**
  21948. * Returns the submesh BoudingInfo object
  21949. * @returns current bounding info (or mesh's one if the submesh is global)
  21950. */
  21951. getBoundingInfo(): BoundingInfo;
  21952. /**
  21953. * Sets the submesh BoundingInfo
  21954. * @param boundingInfo defines the new bounding info to use
  21955. * @returns the SubMesh
  21956. */
  21957. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21958. /**
  21959. * Returns the mesh of the current submesh
  21960. * @return the parent mesh
  21961. */
  21962. getMesh(): AbstractMesh;
  21963. /**
  21964. * Returns the rendering mesh of the submesh
  21965. * @returns the rendering mesh (could be different from parent mesh)
  21966. */
  21967. getRenderingMesh(): Mesh;
  21968. /**
  21969. * Returns the submesh material
  21970. * @returns null or the current material
  21971. */
  21972. getMaterial(): Nullable<Material>;
  21973. /**
  21974. * Sets a new updated BoundingInfo object to the submesh
  21975. * @param data defines an optional position array to use to determine the bounding info
  21976. * @returns the SubMesh
  21977. */
  21978. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21979. /** @hidden */
  21980. _checkCollision(collider: Collider): boolean;
  21981. /**
  21982. * Updates the submesh BoundingInfo
  21983. * @param world defines the world matrix to use to update the bounding info
  21984. * @returns the submesh
  21985. */
  21986. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21987. /**
  21988. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21989. * @param frustumPlanes defines the frustum planes
  21990. * @returns true if the submesh is intersecting with the frustum
  21991. */
  21992. isInFrustum(frustumPlanes: Plane[]): boolean;
  21993. /**
  21994. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21995. * @param frustumPlanes defines the frustum planes
  21996. * @returns true if the submesh is inside the frustum
  21997. */
  21998. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21999. /**
  22000. * Renders the submesh
  22001. * @param enableAlphaMode defines if alpha needs to be used
  22002. * @returns the submesh
  22003. */
  22004. render(enableAlphaMode: boolean): SubMesh;
  22005. /**
  22006. * @hidden
  22007. */
  22008. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22009. /**
  22010. * Checks if the submesh intersects with a ray
  22011. * @param ray defines the ray to test
  22012. * @returns true is the passed ray intersects the submesh bounding box
  22013. */
  22014. canIntersects(ray: Ray): boolean;
  22015. /**
  22016. * Intersects current submesh with a ray
  22017. * @param ray defines the ray to test
  22018. * @param positions defines mesh's positions array
  22019. * @param indices defines mesh's indices array
  22020. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22021. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22022. * @returns intersection info or null if no intersection
  22023. */
  22024. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22025. /** @hidden */
  22026. private _intersectLines;
  22027. /** @hidden */
  22028. private _intersectUnIndexedLines;
  22029. /** @hidden */
  22030. private _intersectTriangles;
  22031. /** @hidden */
  22032. private _intersectUnIndexedTriangles;
  22033. /** @hidden */
  22034. _rebuild(): void;
  22035. /**
  22036. * Creates a new submesh from the passed mesh
  22037. * @param newMesh defines the new hosting mesh
  22038. * @param newRenderingMesh defines an optional rendering mesh
  22039. * @returns the new submesh
  22040. */
  22041. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22042. /**
  22043. * Release associated resources
  22044. */
  22045. dispose(): void;
  22046. /**
  22047. * Gets the class name
  22048. * @returns the string "SubMesh".
  22049. */
  22050. getClassName(): string;
  22051. /**
  22052. * Creates a new submesh from indices data
  22053. * @param materialIndex the index of the main mesh material
  22054. * @param startIndex the index where to start the copy in the mesh indices array
  22055. * @param indexCount the number of indices to copy then from the startIndex
  22056. * @param mesh the main mesh to create the submesh from
  22057. * @param renderingMesh the optional rendering mesh
  22058. * @returns a new submesh
  22059. */
  22060. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22061. }
  22062. }
  22063. declare module BABYLON {
  22064. /**
  22065. * Class used to represent data loading progression
  22066. */
  22067. export class SceneLoaderFlags {
  22068. private static _ForceFullSceneLoadingForIncremental;
  22069. private static _ShowLoadingScreen;
  22070. private static _CleanBoneMatrixWeights;
  22071. private static _loggingLevel;
  22072. /**
  22073. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22074. */
  22075. static get ForceFullSceneLoadingForIncremental(): boolean;
  22076. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22077. /**
  22078. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22079. */
  22080. static get ShowLoadingScreen(): boolean;
  22081. static set ShowLoadingScreen(value: boolean);
  22082. /**
  22083. * Defines the current logging level (while loading the scene)
  22084. * @ignorenaming
  22085. */
  22086. static get loggingLevel(): number;
  22087. static set loggingLevel(value: number);
  22088. /**
  22089. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22090. */
  22091. static get CleanBoneMatrixWeights(): boolean;
  22092. static set CleanBoneMatrixWeights(value: boolean);
  22093. }
  22094. }
  22095. declare module BABYLON {
  22096. /**
  22097. * Class used to store geometry data (vertex buffers + index buffer)
  22098. */
  22099. export class Geometry implements IGetSetVerticesData {
  22100. /**
  22101. * Gets or sets the ID of the geometry
  22102. */
  22103. id: string;
  22104. /**
  22105. * Gets or sets the unique ID of the geometry
  22106. */
  22107. uniqueId: number;
  22108. /**
  22109. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22110. */
  22111. delayLoadState: number;
  22112. /**
  22113. * Gets the file containing the data to load when running in delay load state
  22114. */
  22115. delayLoadingFile: Nullable<string>;
  22116. /**
  22117. * Callback called when the geometry is updated
  22118. */
  22119. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22120. private _scene;
  22121. private _engine;
  22122. private _meshes;
  22123. private _totalVertices;
  22124. /** @hidden */
  22125. _indices: IndicesArray;
  22126. /** @hidden */
  22127. _vertexBuffers: {
  22128. [key: string]: VertexBuffer;
  22129. };
  22130. private _isDisposed;
  22131. private _extend;
  22132. private _boundingBias;
  22133. /** @hidden */
  22134. _delayInfo: Array<string>;
  22135. private _indexBuffer;
  22136. private _indexBufferIsUpdatable;
  22137. /** @hidden */
  22138. _boundingInfo: Nullable<BoundingInfo>;
  22139. /** @hidden */
  22140. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22141. /** @hidden */
  22142. _softwareSkinningFrameId: number;
  22143. private _vertexArrayObjects;
  22144. private _updatable;
  22145. /** @hidden */
  22146. _positions: Nullable<Vector3[]>;
  22147. /**
  22148. * 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
  22149. */
  22150. get boundingBias(): Vector2;
  22151. /**
  22152. * 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
  22153. */
  22154. set boundingBias(value: Vector2);
  22155. /**
  22156. * Static function used to attach a new empty geometry to a mesh
  22157. * @param mesh defines the mesh to attach the geometry to
  22158. * @returns the new Geometry
  22159. */
  22160. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22161. /** Get the list of meshes using this geometry */
  22162. get meshes(): Mesh[];
  22163. /**
  22164. * Creates a new geometry
  22165. * @param id defines the unique ID
  22166. * @param scene defines the hosting scene
  22167. * @param vertexData defines the VertexData used to get geometry data
  22168. * @param updatable defines if geometry must be updatable (false by default)
  22169. * @param mesh defines the mesh that will be associated with the geometry
  22170. */
  22171. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22172. /**
  22173. * Gets the current extend of the geometry
  22174. */
  22175. get extend(): {
  22176. minimum: Vector3;
  22177. maximum: Vector3;
  22178. };
  22179. /**
  22180. * Gets the hosting scene
  22181. * @returns the hosting Scene
  22182. */
  22183. getScene(): Scene;
  22184. /**
  22185. * Gets the hosting engine
  22186. * @returns the hosting Engine
  22187. */
  22188. getEngine(): Engine;
  22189. /**
  22190. * Defines if the geometry is ready to use
  22191. * @returns true if the geometry is ready to be used
  22192. */
  22193. isReady(): boolean;
  22194. /**
  22195. * Gets a value indicating that the geometry should not be serialized
  22196. */
  22197. get doNotSerialize(): boolean;
  22198. /** @hidden */
  22199. _rebuild(): void;
  22200. /**
  22201. * Affects all geometry data in one call
  22202. * @param vertexData defines the geometry data
  22203. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22204. */
  22205. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22206. /**
  22207. * Set specific vertex data
  22208. * @param kind defines the data kind (Position, normal, etc...)
  22209. * @param data defines the vertex data to use
  22210. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22211. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22212. */
  22213. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22214. /**
  22215. * Removes a specific vertex data
  22216. * @param kind defines the data kind (Position, normal, etc...)
  22217. */
  22218. removeVerticesData(kind: string): void;
  22219. /**
  22220. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22221. * @param buffer defines the vertex buffer to use
  22222. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22223. */
  22224. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22225. /**
  22226. * Update a specific vertex buffer
  22227. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22228. * It will do nothing if the buffer is not updatable
  22229. * @param kind defines the data kind (Position, normal, etc...)
  22230. * @param data defines the data to use
  22231. * @param offset defines the offset in the target buffer where to store the data
  22232. * @param useBytes set to true if the offset is in bytes
  22233. */
  22234. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22235. /**
  22236. * Update a specific vertex buffer
  22237. * This function will create a new buffer if the current one is not updatable
  22238. * @param kind defines the data kind (Position, normal, etc...)
  22239. * @param data defines the data to use
  22240. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22241. */
  22242. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22243. private _updateBoundingInfo;
  22244. /** @hidden */
  22245. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22246. /**
  22247. * Gets total number of vertices
  22248. * @returns the total number of vertices
  22249. */
  22250. getTotalVertices(): number;
  22251. /**
  22252. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22253. * @param kind defines the data kind (Position, normal, etc...)
  22254. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22255. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22256. * @returns a float array containing vertex data
  22257. */
  22258. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22259. /**
  22260. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22261. * @param kind defines the data kind (Position, normal, etc...)
  22262. * @returns true if the vertex buffer with the specified kind is updatable
  22263. */
  22264. isVertexBufferUpdatable(kind: string): boolean;
  22265. /**
  22266. * Gets a specific vertex buffer
  22267. * @param kind defines the data kind (Position, normal, etc...)
  22268. * @returns a VertexBuffer
  22269. */
  22270. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22271. /**
  22272. * Returns all vertex buffers
  22273. * @return an object holding all vertex buffers indexed by kind
  22274. */
  22275. getVertexBuffers(): Nullable<{
  22276. [key: string]: VertexBuffer;
  22277. }>;
  22278. /**
  22279. * Gets a boolean indicating if specific vertex buffer is present
  22280. * @param kind defines the data kind (Position, normal, etc...)
  22281. * @returns true if data is present
  22282. */
  22283. isVerticesDataPresent(kind: string): boolean;
  22284. /**
  22285. * Gets a list of all attached data kinds (Position, normal, etc...)
  22286. * @returns a list of string containing all kinds
  22287. */
  22288. getVerticesDataKinds(): string[];
  22289. /**
  22290. * Update index buffer
  22291. * @param indices defines the indices to store in the index buffer
  22292. * @param offset defines the offset in the target buffer where to store the data
  22293. * @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)
  22294. */
  22295. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22296. /**
  22297. * Creates a new index buffer
  22298. * @param indices defines the indices to store in the index buffer
  22299. * @param totalVertices defines the total number of vertices (could be null)
  22300. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22301. */
  22302. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22303. /**
  22304. * Return the total number of indices
  22305. * @returns the total number of indices
  22306. */
  22307. getTotalIndices(): number;
  22308. /**
  22309. * Gets the index buffer array
  22310. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22311. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22312. * @returns the index buffer array
  22313. */
  22314. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22315. /**
  22316. * Gets the index buffer
  22317. * @return the index buffer
  22318. */
  22319. getIndexBuffer(): Nullable<DataBuffer>;
  22320. /** @hidden */
  22321. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22322. /**
  22323. * Release the associated resources for a specific mesh
  22324. * @param mesh defines the source mesh
  22325. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22326. */
  22327. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22328. /**
  22329. * Apply current geometry to a given mesh
  22330. * @param mesh defines the mesh to apply geometry to
  22331. */
  22332. applyToMesh(mesh: Mesh): void;
  22333. private _updateExtend;
  22334. private _applyToMesh;
  22335. private notifyUpdate;
  22336. /**
  22337. * Load the geometry if it was flagged as delay loaded
  22338. * @param scene defines the hosting scene
  22339. * @param onLoaded defines a callback called when the geometry is loaded
  22340. */
  22341. load(scene: Scene, onLoaded?: () => void): void;
  22342. private _queueLoad;
  22343. /**
  22344. * Invert the geometry to move from a right handed system to a left handed one.
  22345. */
  22346. toLeftHanded(): void;
  22347. /** @hidden */
  22348. _resetPointsArrayCache(): void;
  22349. /** @hidden */
  22350. _generatePointsArray(): boolean;
  22351. /**
  22352. * Gets a value indicating if the geometry is disposed
  22353. * @returns true if the geometry was disposed
  22354. */
  22355. isDisposed(): boolean;
  22356. private _disposeVertexArrayObjects;
  22357. /**
  22358. * Free all associated resources
  22359. */
  22360. dispose(): void;
  22361. /**
  22362. * Clone the current geometry into a new geometry
  22363. * @param id defines the unique ID of the new geometry
  22364. * @returns a new geometry object
  22365. */
  22366. copy(id: string): Geometry;
  22367. /**
  22368. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22369. * @return a JSON representation of the current geometry data (without the vertices data)
  22370. */
  22371. serialize(): any;
  22372. private toNumberArray;
  22373. /**
  22374. * Serialize all vertices data into a JSON oject
  22375. * @returns a JSON representation of the current geometry data
  22376. */
  22377. serializeVerticeData(): any;
  22378. /**
  22379. * Extracts a clone of a mesh geometry
  22380. * @param mesh defines the source mesh
  22381. * @param id defines the unique ID of the new geometry object
  22382. * @returns the new geometry object
  22383. */
  22384. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22385. /**
  22386. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22387. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22388. * Be aware Math.random() could cause collisions, but:
  22389. * "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"
  22390. * @returns a string containing a new GUID
  22391. */
  22392. static RandomId(): string;
  22393. /** @hidden */
  22394. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22395. private static _CleanMatricesWeights;
  22396. /**
  22397. * Create a new geometry from persisted data (Using .babylon file format)
  22398. * @param parsedVertexData defines the persisted data
  22399. * @param scene defines the hosting scene
  22400. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22401. * @returns the new geometry object
  22402. */
  22403. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22404. }
  22405. }
  22406. declare module BABYLON {
  22407. /**
  22408. * Define an interface for all classes that will get and set the data on vertices
  22409. */
  22410. export interface IGetSetVerticesData {
  22411. /**
  22412. * Gets a boolean indicating if specific vertex data is present
  22413. * @param kind defines the vertex data kind to use
  22414. * @returns true is data kind is present
  22415. */
  22416. isVerticesDataPresent(kind: string): boolean;
  22417. /**
  22418. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22419. * @param kind defines the data kind (Position, normal, etc...)
  22420. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22421. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22422. * @returns a float array containing vertex data
  22423. */
  22424. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22425. /**
  22426. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22427. * @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.
  22428. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22429. * @returns the indices array or an empty array if the mesh has no geometry
  22430. */
  22431. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22432. /**
  22433. * Set specific vertex data
  22434. * @param kind defines the data kind (Position, normal, etc...)
  22435. * @param data defines the vertex data to use
  22436. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22437. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22438. */
  22439. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22440. /**
  22441. * Update a specific associated vertex buffer
  22442. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22443. * - VertexBuffer.PositionKind
  22444. * - VertexBuffer.UVKind
  22445. * - VertexBuffer.UV2Kind
  22446. * - VertexBuffer.UV3Kind
  22447. * - VertexBuffer.UV4Kind
  22448. * - VertexBuffer.UV5Kind
  22449. * - VertexBuffer.UV6Kind
  22450. * - VertexBuffer.ColorKind
  22451. * - VertexBuffer.MatricesIndicesKind
  22452. * - VertexBuffer.MatricesIndicesExtraKind
  22453. * - VertexBuffer.MatricesWeightsKind
  22454. * - VertexBuffer.MatricesWeightsExtraKind
  22455. * @param data defines the data source
  22456. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22457. * @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)
  22458. */
  22459. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22460. /**
  22461. * Creates a new index buffer
  22462. * @param indices defines the indices to store in the index buffer
  22463. * @param totalVertices defines the total number of vertices (could be null)
  22464. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22465. */
  22466. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22467. }
  22468. /**
  22469. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22470. */
  22471. export class VertexData {
  22472. /**
  22473. * Mesh side orientation : usually the external or front surface
  22474. */
  22475. static readonly FRONTSIDE: number;
  22476. /**
  22477. * Mesh side orientation : usually the internal or back surface
  22478. */
  22479. static readonly BACKSIDE: number;
  22480. /**
  22481. * Mesh side orientation : both internal and external or front and back surfaces
  22482. */
  22483. static readonly DOUBLESIDE: number;
  22484. /**
  22485. * Mesh side orientation : by default, `FRONTSIDE`
  22486. */
  22487. static readonly DEFAULTSIDE: number;
  22488. /**
  22489. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22490. */
  22491. positions: Nullable<FloatArray>;
  22492. /**
  22493. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22494. */
  22495. normals: Nullable<FloatArray>;
  22496. /**
  22497. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22498. */
  22499. tangents: Nullable<FloatArray>;
  22500. /**
  22501. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22502. */
  22503. uvs: Nullable<FloatArray>;
  22504. /**
  22505. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22506. */
  22507. uvs2: Nullable<FloatArray>;
  22508. /**
  22509. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22510. */
  22511. uvs3: Nullable<FloatArray>;
  22512. /**
  22513. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22514. */
  22515. uvs4: Nullable<FloatArray>;
  22516. /**
  22517. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22518. */
  22519. uvs5: Nullable<FloatArray>;
  22520. /**
  22521. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22522. */
  22523. uvs6: Nullable<FloatArray>;
  22524. /**
  22525. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22526. */
  22527. colors: Nullable<FloatArray>;
  22528. /**
  22529. * 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).
  22530. */
  22531. matricesIndices: Nullable<FloatArray>;
  22532. /**
  22533. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22534. */
  22535. matricesWeights: Nullable<FloatArray>;
  22536. /**
  22537. * An array extending the number of possible indices
  22538. */
  22539. matricesIndicesExtra: Nullable<FloatArray>;
  22540. /**
  22541. * An array extending the number of possible weights when the number of indices is extended
  22542. */
  22543. matricesWeightsExtra: Nullable<FloatArray>;
  22544. /**
  22545. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22546. */
  22547. indices: Nullable<IndicesArray>;
  22548. /**
  22549. * Uses the passed data array to set the set the values for the specified kind of data
  22550. * @param data a linear array of floating numbers
  22551. * @param kind the type of data that is being set, eg positions, colors etc
  22552. */
  22553. set(data: FloatArray, kind: string): void;
  22554. /**
  22555. * Associates the vertexData to the passed Mesh.
  22556. * Sets it as updatable or not (default `false`)
  22557. * @param mesh the mesh the vertexData is applied to
  22558. * @param updatable when used and having the value true allows new data to update the vertexData
  22559. * @returns the VertexData
  22560. */
  22561. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22562. /**
  22563. * Associates the vertexData to the passed Geometry.
  22564. * Sets it as updatable or not (default `false`)
  22565. * @param geometry the geometry the vertexData is applied to
  22566. * @param updatable when used and having the value true allows new data to update the vertexData
  22567. * @returns VertexData
  22568. */
  22569. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22570. /**
  22571. * Updates the associated mesh
  22572. * @param mesh the mesh to be updated
  22573. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22574. * @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
  22575. * @returns VertexData
  22576. */
  22577. updateMesh(mesh: Mesh): VertexData;
  22578. /**
  22579. * Updates the associated geometry
  22580. * @param geometry the geometry to be updated
  22581. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22582. * @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
  22583. * @returns VertexData.
  22584. */
  22585. updateGeometry(geometry: Geometry): VertexData;
  22586. private _applyTo;
  22587. private _update;
  22588. /**
  22589. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22590. * @param matrix the transforming matrix
  22591. * @returns the VertexData
  22592. */
  22593. transform(matrix: Matrix): VertexData;
  22594. /**
  22595. * Merges the passed VertexData into the current one
  22596. * @param other the VertexData to be merged into the current one
  22597. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22598. * @returns the modified VertexData
  22599. */
  22600. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22601. private _mergeElement;
  22602. private _validate;
  22603. /**
  22604. * Serializes the VertexData
  22605. * @returns a serialized object
  22606. */
  22607. serialize(): any;
  22608. /**
  22609. * Extracts the vertexData from a mesh
  22610. * @param mesh the mesh from which to extract the VertexData
  22611. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22612. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22613. * @returns the object VertexData associated to the passed mesh
  22614. */
  22615. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22616. /**
  22617. * Extracts the vertexData from the geometry
  22618. * @param geometry the geometry from which to extract the VertexData
  22619. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22620. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22621. * @returns the object VertexData associated to the passed mesh
  22622. */
  22623. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22624. private static _ExtractFrom;
  22625. /**
  22626. * Creates the VertexData for a Ribbon
  22627. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22628. * * pathArray array of paths, each of which an array of successive Vector3
  22629. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22630. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22631. * * 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
  22632. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22633. * * 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)
  22634. * * 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)
  22635. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22636. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22637. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22638. * @returns the VertexData of the ribbon
  22639. */
  22640. static CreateRibbon(options: {
  22641. pathArray: Vector3[][];
  22642. closeArray?: boolean;
  22643. closePath?: boolean;
  22644. offset?: number;
  22645. sideOrientation?: number;
  22646. frontUVs?: Vector4;
  22647. backUVs?: Vector4;
  22648. invertUV?: boolean;
  22649. uvs?: Vector2[];
  22650. colors?: Color4[];
  22651. }): VertexData;
  22652. /**
  22653. * Creates the VertexData for a box
  22654. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22655. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22656. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22657. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22658. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22659. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22660. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22661. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22662. * * 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)
  22663. * * 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)
  22664. * @returns the VertexData of the box
  22665. */
  22666. static CreateBox(options: {
  22667. size?: number;
  22668. width?: number;
  22669. height?: number;
  22670. depth?: number;
  22671. faceUV?: Vector4[];
  22672. faceColors?: Color4[];
  22673. sideOrientation?: number;
  22674. frontUVs?: Vector4;
  22675. backUVs?: Vector4;
  22676. }): VertexData;
  22677. /**
  22678. * Creates the VertexData for a tiled box
  22679. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22680. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22681. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22682. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22683. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22684. * @returns the VertexData of the box
  22685. */
  22686. static CreateTiledBox(options: {
  22687. pattern?: number;
  22688. width?: number;
  22689. height?: number;
  22690. depth?: number;
  22691. tileSize?: number;
  22692. tileWidth?: number;
  22693. tileHeight?: number;
  22694. alignHorizontal?: number;
  22695. alignVertical?: number;
  22696. faceUV?: Vector4[];
  22697. faceColors?: Color4[];
  22698. sideOrientation?: number;
  22699. }): VertexData;
  22700. /**
  22701. * Creates the VertexData for a tiled plane
  22702. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22703. * * pattern a limited pattern arrangement depending on the number
  22704. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22705. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22706. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22708. * * 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)
  22709. * * 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)
  22710. * @returns the VertexData of the tiled plane
  22711. */
  22712. static CreateTiledPlane(options: {
  22713. pattern?: number;
  22714. tileSize?: number;
  22715. tileWidth?: number;
  22716. tileHeight?: number;
  22717. size?: number;
  22718. width?: number;
  22719. height?: number;
  22720. alignHorizontal?: number;
  22721. alignVertical?: number;
  22722. sideOrientation?: number;
  22723. frontUVs?: Vector4;
  22724. backUVs?: Vector4;
  22725. }): VertexData;
  22726. /**
  22727. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22728. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22729. * * segments sets the number of horizontal strips optional, default 32
  22730. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22731. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22732. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22733. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22734. * * 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
  22735. * * 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
  22736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22737. * * 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)
  22738. * * 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)
  22739. * @returns the VertexData of the ellipsoid
  22740. */
  22741. static CreateSphere(options: {
  22742. segments?: number;
  22743. diameter?: number;
  22744. diameterX?: number;
  22745. diameterY?: number;
  22746. diameterZ?: number;
  22747. arc?: number;
  22748. slice?: number;
  22749. sideOrientation?: number;
  22750. frontUVs?: Vector4;
  22751. backUVs?: Vector4;
  22752. }): VertexData;
  22753. /**
  22754. * Creates the VertexData for a cylinder, cone or prism
  22755. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22756. * * height sets the height (y direction) of the cylinder, optional, default 2
  22757. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22758. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22759. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22760. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22761. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22762. * * 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
  22763. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22764. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22765. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22766. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22768. * * 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)
  22769. * * 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)
  22770. * @returns the VertexData of the cylinder, cone or prism
  22771. */
  22772. static CreateCylinder(options: {
  22773. height?: number;
  22774. diameterTop?: number;
  22775. diameterBottom?: number;
  22776. diameter?: number;
  22777. tessellation?: number;
  22778. subdivisions?: number;
  22779. arc?: number;
  22780. faceColors?: Color4[];
  22781. faceUV?: Vector4[];
  22782. hasRings?: boolean;
  22783. enclose?: boolean;
  22784. sideOrientation?: number;
  22785. frontUVs?: Vector4;
  22786. backUVs?: Vector4;
  22787. }): VertexData;
  22788. /**
  22789. * Creates the VertexData for a torus
  22790. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22791. * * diameter the diameter of the torus, optional default 1
  22792. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22793. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22795. * * 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)
  22796. * * 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)
  22797. * @returns the VertexData of the torus
  22798. */
  22799. static CreateTorus(options: {
  22800. diameter?: number;
  22801. thickness?: number;
  22802. tessellation?: number;
  22803. sideOrientation?: number;
  22804. frontUVs?: Vector4;
  22805. backUVs?: Vector4;
  22806. }): VertexData;
  22807. /**
  22808. * Creates the VertexData of the LineSystem
  22809. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22810. * - lines an array of lines, each line being an array of successive Vector3
  22811. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22812. * @returns the VertexData of the LineSystem
  22813. */
  22814. static CreateLineSystem(options: {
  22815. lines: Vector3[][];
  22816. colors?: Nullable<Color4[][]>;
  22817. }): VertexData;
  22818. /**
  22819. * Create the VertexData for a DashedLines
  22820. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22821. * - points an array successive Vector3
  22822. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22823. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22824. * - dashNb the intended total number of dashes, optional, default 200
  22825. * @returns the VertexData for the DashedLines
  22826. */
  22827. static CreateDashedLines(options: {
  22828. points: Vector3[];
  22829. dashSize?: number;
  22830. gapSize?: number;
  22831. dashNb?: number;
  22832. }): VertexData;
  22833. /**
  22834. * Creates the VertexData for a Ground
  22835. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22836. * - width the width (x direction) of the ground, optional, default 1
  22837. * - height the height (z direction) of the ground, optional, default 1
  22838. * - subdivisions the number of subdivisions per side, optional, default 1
  22839. * @returns the VertexData of the Ground
  22840. */
  22841. static CreateGround(options: {
  22842. width?: number;
  22843. height?: number;
  22844. subdivisions?: number;
  22845. subdivisionsX?: number;
  22846. subdivisionsY?: number;
  22847. }): VertexData;
  22848. /**
  22849. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22850. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22851. * * xmin the ground minimum X coordinate, optional, default -1
  22852. * * zmin the ground minimum Z coordinate, optional, default -1
  22853. * * xmax the ground maximum X coordinate, optional, default 1
  22854. * * zmax the ground maximum Z coordinate, optional, default 1
  22855. * * 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}
  22856. * * 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}
  22857. * @returns the VertexData of the TiledGround
  22858. */
  22859. static CreateTiledGround(options: {
  22860. xmin: number;
  22861. zmin: number;
  22862. xmax: number;
  22863. zmax: number;
  22864. subdivisions?: {
  22865. w: number;
  22866. h: number;
  22867. };
  22868. precision?: {
  22869. w: number;
  22870. h: number;
  22871. };
  22872. }): VertexData;
  22873. /**
  22874. * Creates the VertexData of the Ground designed from a heightmap
  22875. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22876. * * width the width (x direction) of the ground
  22877. * * height the height (z direction) of the ground
  22878. * * subdivisions the number of subdivisions per side
  22879. * * minHeight the minimum altitude on the ground, optional, default 0
  22880. * * maxHeight the maximum altitude on the ground, optional default 1
  22881. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22882. * * buffer the array holding the image color data
  22883. * * bufferWidth the width of image
  22884. * * bufferHeight the height of image
  22885. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22886. * @returns the VertexData of the Ground designed from a heightmap
  22887. */
  22888. static CreateGroundFromHeightMap(options: {
  22889. width: number;
  22890. height: number;
  22891. subdivisions: number;
  22892. minHeight: number;
  22893. maxHeight: number;
  22894. colorFilter: Color3;
  22895. buffer: Uint8Array;
  22896. bufferWidth: number;
  22897. bufferHeight: number;
  22898. alphaFilter: number;
  22899. }): VertexData;
  22900. /**
  22901. * Creates the VertexData for a Plane
  22902. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22903. * * size sets the width and height of the plane to the value of size, optional default 1
  22904. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22905. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22907. * * 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)
  22908. * * 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)
  22909. * @returns the VertexData of the box
  22910. */
  22911. static CreatePlane(options: {
  22912. size?: number;
  22913. width?: number;
  22914. height?: number;
  22915. sideOrientation?: number;
  22916. frontUVs?: Vector4;
  22917. backUVs?: Vector4;
  22918. }): VertexData;
  22919. /**
  22920. * Creates the VertexData of the Disc or regular Polygon
  22921. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22922. * * radius the radius of the disc, optional default 0.5
  22923. * * tessellation the number of polygon sides, optional, default 64
  22924. * * 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
  22925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22926. * * 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)
  22927. * * 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)
  22928. * @returns the VertexData of the box
  22929. */
  22930. static CreateDisc(options: {
  22931. radius?: number;
  22932. tessellation?: number;
  22933. arc?: number;
  22934. sideOrientation?: number;
  22935. frontUVs?: Vector4;
  22936. backUVs?: Vector4;
  22937. }): VertexData;
  22938. /**
  22939. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22940. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22941. * @param polygon a mesh built from polygonTriangulation.build()
  22942. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22943. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22944. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22945. * @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)
  22946. * @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)
  22947. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  22948. * @returns the VertexData of the Polygon
  22949. */
  22950. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  22951. /**
  22952. * Creates the VertexData of the IcoSphere
  22953. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22954. * * radius the radius of the IcoSphere, optional default 1
  22955. * * radiusX allows stretching in the x direction, optional, default radius
  22956. * * radiusY allows stretching in the y direction, optional, default radius
  22957. * * radiusZ allows stretching in the z direction, optional, default radius
  22958. * * flat when true creates a flat shaded mesh, optional, default true
  22959. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22960. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22961. * * 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)
  22962. * * 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)
  22963. * @returns the VertexData of the IcoSphere
  22964. */
  22965. static CreateIcoSphere(options: {
  22966. radius?: number;
  22967. radiusX?: number;
  22968. radiusY?: number;
  22969. radiusZ?: number;
  22970. flat?: boolean;
  22971. subdivisions?: number;
  22972. sideOrientation?: number;
  22973. frontUVs?: Vector4;
  22974. backUVs?: Vector4;
  22975. }): VertexData;
  22976. /**
  22977. * Creates the VertexData for a Polyhedron
  22978. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22979. * * type provided types are:
  22980. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22981. * * 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)
  22982. * * size the size of the IcoSphere, optional default 1
  22983. * * sizeX allows stretching in the x direction, optional, default size
  22984. * * sizeY allows stretching in the y direction, optional, default size
  22985. * * sizeZ allows stretching in the z direction, optional, default size
  22986. * * 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
  22987. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22988. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22989. * * flat when true creates a flat shaded mesh, optional, default true
  22990. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22992. * * 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)
  22993. * * 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)
  22994. * @returns the VertexData of the Polyhedron
  22995. */
  22996. static CreatePolyhedron(options: {
  22997. type?: number;
  22998. size?: number;
  22999. sizeX?: number;
  23000. sizeY?: number;
  23001. sizeZ?: number;
  23002. custom?: any;
  23003. faceUV?: Vector4[];
  23004. faceColors?: Color4[];
  23005. flat?: boolean;
  23006. sideOrientation?: number;
  23007. frontUVs?: Vector4;
  23008. backUVs?: Vector4;
  23009. }): VertexData;
  23010. /**
  23011. * Creates the VertexData for a TorusKnot
  23012. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23013. * * radius the radius of the torus knot, optional, default 2
  23014. * * tube the thickness of the tube, optional, default 0.5
  23015. * * radialSegments the number of sides on each tube segments, optional, default 32
  23016. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23017. * * p the number of windings around the z axis, optional, default 2
  23018. * * q the number of windings around the x axis, optional, default 3
  23019. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23020. * * 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)
  23021. * * 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)
  23022. * @returns the VertexData of the Torus Knot
  23023. */
  23024. static CreateTorusKnot(options: {
  23025. radius?: number;
  23026. tube?: number;
  23027. radialSegments?: number;
  23028. tubularSegments?: number;
  23029. p?: number;
  23030. q?: number;
  23031. sideOrientation?: number;
  23032. frontUVs?: Vector4;
  23033. backUVs?: Vector4;
  23034. }): VertexData;
  23035. /**
  23036. * Compute normals for given positions and indices
  23037. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23038. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23039. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23040. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23041. * * facetNormals : optional array of facet normals (vector3)
  23042. * * facetPositions : optional array of facet positions (vector3)
  23043. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23044. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23045. * * bInfo : optional bounding info, required for facetPartitioning computation
  23046. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23047. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23048. * * useRightHandedSystem: optional boolean to for right handed system computation
  23049. * * depthSort : optional boolean to enable the facet depth sort computation
  23050. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23051. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23052. */
  23053. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23054. facetNormals?: any;
  23055. facetPositions?: any;
  23056. facetPartitioning?: any;
  23057. ratio?: number;
  23058. bInfo?: any;
  23059. bbSize?: Vector3;
  23060. subDiv?: any;
  23061. useRightHandedSystem?: boolean;
  23062. depthSort?: boolean;
  23063. distanceTo?: Vector3;
  23064. depthSortedFacets?: any;
  23065. }): void;
  23066. /** @hidden */
  23067. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23068. /**
  23069. * Applies VertexData created from the imported parameters to the geometry
  23070. * @param parsedVertexData the parsed data from an imported file
  23071. * @param geometry the geometry to apply the VertexData to
  23072. */
  23073. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23074. }
  23075. }
  23076. declare module BABYLON {
  23077. /**
  23078. * Defines a target to use with MorphTargetManager
  23079. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23080. */
  23081. export class MorphTarget implements IAnimatable {
  23082. /** defines the name of the target */
  23083. name: string;
  23084. /**
  23085. * Gets or sets the list of animations
  23086. */
  23087. animations: Animation[];
  23088. private _scene;
  23089. private _positions;
  23090. private _normals;
  23091. private _tangents;
  23092. private _uvs;
  23093. private _influence;
  23094. private _uniqueId;
  23095. /**
  23096. * Observable raised when the influence changes
  23097. */
  23098. onInfluenceChanged: Observable<boolean>;
  23099. /** @hidden */
  23100. _onDataLayoutChanged: Observable<void>;
  23101. /**
  23102. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23103. */
  23104. get influence(): number;
  23105. set influence(influence: number);
  23106. /**
  23107. * Gets or sets the id of the morph Target
  23108. */
  23109. id: string;
  23110. private _animationPropertiesOverride;
  23111. /**
  23112. * Gets or sets the animation properties override
  23113. */
  23114. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23115. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23116. /**
  23117. * Creates a new MorphTarget
  23118. * @param name defines the name of the target
  23119. * @param influence defines the influence to use
  23120. * @param scene defines the scene the morphtarget belongs to
  23121. */
  23122. constructor(
  23123. /** defines the name of the target */
  23124. name: string, influence?: number, scene?: Nullable<Scene>);
  23125. /**
  23126. * Gets the unique ID of this manager
  23127. */
  23128. get uniqueId(): number;
  23129. /**
  23130. * Gets a boolean defining if the target contains position data
  23131. */
  23132. get hasPositions(): boolean;
  23133. /**
  23134. * Gets a boolean defining if the target contains normal data
  23135. */
  23136. get hasNormals(): boolean;
  23137. /**
  23138. * Gets a boolean defining if the target contains tangent data
  23139. */
  23140. get hasTangents(): boolean;
  23141. /**
  23142. * Gets a boolean defining if the target contains texture coordinates data
  23143. */
  23144. get hasUVs(): boolean;
  23145. /**
  23146. * Affects position data to this target
  23147. * @param data defines the position data to use
  23148. */
  23149. setPositions(data: Nullable<FloatArray>): void;
  23150. /**
  23151. * Gets the position data stored in this target
  23152. * @returns a FloatArray containing the position data (or null if not present)
  23153. */
  23154. getPositions(): Nullable<FloatArray>;
  23155. /**
  23156. * Affects normal data to this target
  23157. * @param data defines the normal data to use
  23158. */
  23159. setNormals(data: Nullable<FloatArray>): void;
  23160. /**
  23161. * Gets the normal data stored in this target
  23162. * @returns a FloatArray containing the normal data (or null if not present)
  23163. */
  23164. getNormals(): Nullable<FloatArray>;
  23165. /**
  23166. * Affects tangent data to this target
  23167. * @param data defines the tangent data to use
  23168. */
  23169. setTangents(data: Nullable<FloatArray>): void;
  23170. /**
  23171. * Gets the tangent data stored in this target
  23172. * @returns a FloatArray containing the tangent data (or null if not present)
  23173. */
  23174. getTangents(): Nullable<FloatArray>;
  23175. /**
  23176. * Affects texture coordinates data to this target
  23177. * @param data defines the texture coordinates data to use
  23178. */
  23179. setUVs(data: Nullable<FloatArray>): void;
  23180. /**
  23181. * Gets the texture coordinates data stored in this target
  23182. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23183. */
  23184. getUVs(): Nullable<FloatArray>;
  23185. /**
  23186. * Clone the current target
  23187. * @returns a new MorphTarget
  23188. */
  23189. clone(): MorphTarget;
  23190. /**
  23191. * Serializes the current target into a Serialization object
  23192. * @returns the serialized object
  23193. */
  23194. serialize(): any;
  23195. /**
  23196. * Returns the string "MorphTarget"
  23197. * @returns "MorphTarget"
  23198. */
  23199. getClassName(): string;
  23200. /**
  23201. * Creates a new target from serialized data
  23202. * @param serializationObject defines the serialized data to use
  23203. * @returns a new MorphTarget
  23204. */
  23205. static Parse(serializationObject: any): MorphTarget;
  23206. /**
  23207. * Creates a MorphTarget from mesh data
  23208. * @param mesh defines the source mesh
  23209. * @param name defines the name to use for the new target
  23210. * @param influence defines the influence to attach to the target
  23211. * @returns a new MorphTarget
  23212. */
  23213. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23214. }
  23215. }
  23216. declare module BABYLON {
  23217. /**
  23218. * This class is used to deform meshes using morphing between different targets
  23219. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23220. */
  23221. export class MorphTargetManager {
  23222. private _targets;
  23223. private _targetInfluenceChangedObservers;
  23224. private _targetDataLayoutChangedObservers;
  23225. private _activeTargets;
  23226. private _scene;
  23227. private _influences;
  23228. private _supportsNormals;
  23229. private _supportsTangents;
  23230. private _supportsUVs;
  23231. private _vertexCount;
  23232. private _uniqueId;
  23233. private _tempInfluences;
  23234. /**
  23235. * Gets or sets a boolean indicating if normals must be morphed
  23236. */
  23237. enableNormalMorphing: boolean;
  23238. /**
  23239. * Gets or sets a boolean indicating if tangents must be morphed
  23240. */
  23241. enableTangentMorphing: boolean;
  23242. /**
  23243. * Gets or sets a boolean indicating if UV must be morphed
  23244. */
  23245. enableUVMorphing: boolean;
  23246. /**
  23247. * Creates a new MorphTargetManager
  23248. * @param scene defines the current scene
  23249. */
  23250. constructor(scene?: Nullable<Scene>);
  23251. /**
  23252. * Gets the unique ID of this manager
  23253. */
  23254. get uniqueId(): number;
  23255. /**
  23256. * Gets the number of vertices handled by this manager
  23257. */
  23258. get vertexCount(): number;
  23259. /**
  23260. * Gets a boolean indicating if this manager supports morphing of normals
  23261. */
  23262. get supportsNormals(): boolean;
  23263. /**
  23264. * Gets a boolean indicating if this manager supports morphing of tangents
  23265. */
  23266. get supportsTangents(): boolean;
  23267. /**
  23268. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23269. */
  23270. get supportsUVs(): boolean;
  23271. /**
  23272. * Gets the number of targets stored in this manager
  23273. */
  23274. get numTargets(): number;
  23275. /**
  23276. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23277. */
  23278. get numInfluencers(): number;
  23279. /**
  23280. * Gets the list of influences (one per target)
  23281. */
  23282. get influences(): Float32Array;
  23283. /**
  23284. * Gets the active target at specified index. An active target is a target with an influence > 0
  23285. * @param index defines the index to check
  23286. * @returns the requested target
  23287. */
  23288. getActiveTarget(index: number): MorphTarget;
  23289. /**
  23290. * Gets the target at specified index
  23291. * @param index defines the index to check
  23292. * @returns the requested target
  23293. */
  23294. getTarget(index: number): MorphTarget;
  23295. /**
  23296. * Add a new target to this manager
  23297. * @param target defines the target to add
  23298. */
  23299. addTarget(target: MorphTarget): void;
  23300. /**
  23301. * Removes a target from the manager
  23302. * @param target defines the target to remove
  23303. */
  23304. removeTarget(target: MorphTarget): void;
  23305. /**
  23306. * Clone the current manager
  23307. * @returns a new MorphTargetManager
  23308. */
  23309. clone(): MorphTargetManager;
  23310. /**
  23311. * Serializes the current manager into a Serialization object
  23312. * @returns the serialized object
  23313. */
  23314. serialize(): any;
  23315. private _syncActiveTargets;
  23316. /**
  23317. * Syncrhonize the targets with all the meshes using this morph target manager
  23318. */
  23319. synchronize(): void;
  23320. /**
  23321. * Creates a new MorphTargetManager from serialized data
  23322. * @param serializationObject defines the serialized data
  23323. * @param scene defines the hosting scene
  23324. * @returns the new MorphTargetManager
  23325. */
  23326. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23327. }
  23328. }
  23329. declare module BABYLON {
  23330. /**
  23331. * Class used to represent a specific level of detail of a mesh
  23332. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23333. */
  23334. export class MeshLODLevel {
  23335. /** Defines the distance where this level should start being displayed */
  23336. distance: number;
  23337. /** Defines the mesh to use to render this level */
  23338. mesh: Nullable<Mesh>;
  23339. /**
  23340. * Creates a new LOD level
  23341. * @param distance defines the distance where this level should star being displayed
  23342. * @param mesh defines the mesh to use to render this level
  23343. */
  23344. constructor(
  23345. /** Defines the distance where this level should start being displayed */
  23346. distance: number,
  23347. /** Defines the mesh to use to render this level */
  23348. mesh: Nullable<Mesh>);
  23349. }
  23350. }
  23351. declare module BABYLON {
  23352. /**
  23353. * Mesh representing the gorund
  23354. */
  23355. export class GroundMesh extends Mesh {
  23356. /** If octree should be generated */
  23357. generateOctree: boolean;
  23358. private _heightQuads;
  23359. /** @hidden */
  23360. _subdivisionsX: number;
  23361. /** @hidden */
  23362. _subdivisionsY: number;
  23363. /** @hidden */
  23364. _width: number;
  23365. /** @hidden */
  23366. _height: number;
  23367. /** @hidden */
  23368. _minX: number;
  23369. /** @hidden */
  23370. _maxX: number;
  23371. /** @hidden */
  23372. _minZ: number;
  23373. /** @hidden */
  23374. _maxZ: number;
  23375. constructor(name: string, scene: Scene);
  23376. /**
  23377. * "GroundMesh"
  23378. * @returns "GroundMesh"
  23379. */
  23380. getClassName(): string;
  23381. /**
  23382. * The minimum of x and y subdivisions
  23383. */
  23384. get subdivisions(): number;
  23385. /**
  23386. * X subdivisions
  23387. */
  23388. get subdivisionsX(): number;
  23389. /**
  23390. * Y subdivisions
  23391. */
  23392. get subdivisionsY(): number;
  23393. /**
  23394. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23395. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23396. * @param chunksCount the number of subdivisions for x and y
  23397. * @param octreeBlocksSize (Default: 32)
  23398. */
  23399. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23400. /**
  23401. * Returns a height (y) value in the Worl system :
  23402. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23403. * @param x x coordinate
  23404. * @param z z coordinate
  23405. * @returns the ground y position if (x, z) are outside the ground surface.
  23406. */
  23407. getHeightAtCoordinates(x: number, z: number): number;
  23408. /**
  23409. * Returns a normalized vector (Vector3) orthogonal to the ground
  23410. * at the ground coordinates (x, z) expressed in the World system.
  23411. * @param x x coordinate
  23412. * @param z z coordinate
  23413. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23414. */
  23415. getNormalAtCoordinates(x: number, z: number): Vector3;
  23416. /**
  23417. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23418. * at the ground coordinates (x, z) expressed in the World system.
  23419. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23420. * @param x x coordinate
  23421. * @param z z coordinate
  23422. * @param ref vector to store the result
  23423. * @returns the GroundMesh.
  23424. */
  23425. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23426. /**
  23427. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23428. * if the ground has been updated.
  23429. * This can be used in the render loop.
  23430. * @returns the GroundMesh.
  23431. */
  23432. updateCoordinateHeights(): GroundMesh;
  23433. private _getFacetAt;
  23434. private _initHeightQuads;
  23435. private _computeHeightQuads;
  23436. /**
  23437. * Serializes this ground mesh
  23438. * @param serializationObject object to write serialization to
  23439. */
  23440. serialize(serializationObject: any): void;
  23441. /**
  23442. * Parses a serialized ground mesh
  23443. * @param parsedMesh the serialized mesh
  23444. * @param scene the scene to create the ground mesh in
  23445. * @returns the created ground mesh
  23446. */
  23447. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23448. }
  23449. }
  23450. declare module BABYLON {
  23451. /**
  23452. * Interface for Physics-Joint data
  23453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23454. */
  23455. export interface PhysicsJointData {
  23456. /**
  23457. * The main pivot of the joint
  23458. */
  23459. mainPivot?: Vector3;
  23460. /**
  23461. * The connected pivot of the joint
  23462. */
  23463. connectedPivot?: Vector3;
  23464. /**
  23465. * The main axis of the joint
  23466. */
  23467. mainAxis?: Vector3;
  23468. /**
  23469. * The connected axis of the joint
  23470. */
  23471. connectedAxis?: Vector3;
  23472. /**
  23473. * The collision of the joint
  23474. */
  23475. collision?: boolean;
  23476. /**
  23477. * Native Oimo/Cannon/Energy data
  23478. */
  23479. nativeParams?: any;
  23480. }
  23481. /**
  23482. * This is a holder class for the physics joint created by the physics plugin
  23483. * It holds a set of functions to control the underlying joint
  23484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23485. */
  23486. export class PhysicsJoint {
  23487. /**
  23488. * The type of the physics joint
  23489. */
  23490. type: number;
  23491. /**
  23492. * The data for the physics joint
  23493. */
  23494. jointData: PhysicsJointData;
  23495. private _physicsJoint;
  23496. protected _physicsPlugin: IPhysicsEnginePlugin;
  23497. /**
  23498. * Initializes the physics joint
  23499. * @param type The type of the physics joint
  23500. * @param jointData The data for the physics joint
  23501. */
  23502. constructor(
  23503. /**
  23504. * The type of the physics joint
  23505. */
  23506. type: number,
  23507. /**
  23508. * The data for the physics joint
  23509. */
  23510. jointData: PhysicsJointData);
  23511. /**
  23512. * Gets the physics joint
  23513. */
  23514. get physicsJoint(): any;
  23515. /**
  23516. * Sets the physics joint
  23517. */
  23518. set physicsJoint(newJoint: any);
  23519. /**
  23520. * Sets the physics plugin
  23521. */
  23522. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23523. /**
  23524. * Execute a function that is physics-plugin specific.
  23525. * @param {Function} func the function that will be executed.
  23526. * It accepts two parameters: the physics world and the physics joint
  23527. */
  23528. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23529. /**
  23530. * Distance-Joint type
  23531. */
  23532. static DistanceJoint: number;
  23533. /**
  23534. * Hinge-Joint type
  23535. */
  23536. static HingeJoint: number;
  23537. /**
  23538. * Ball-and-Socket joint type
  23539. */
  23540. static BallAndSocketJoint: number;
  23541. /**
  23542. * Wheel-Joint type
  23543. */
  23544. static WheelJoint: number;
  23545. /**
  23546. * Slider-Joint type
  23547. */
  23548. static SliderJoint: number;
  23549. /**
  23550. * Prismatic-Joint type
  23551. */
  23552. static PrismaticJoint: number;
  23553. /**
  23554. * Universal-Joint type
  23555. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23556. */
  23557. static UniversalJoint: number;
  23558. /**
  23559. * Hinge-Joint 2 type
  23560. */
  23561. static Hinge2Joint: number;
  23562. /**
  23563. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23564. */
  23565. static PointToPointJoint: number;
  23566. /**
  23567. * Spring-Joint type
  23568. */
  23569. static SpringJoint: number;
  23570. /**
  23571. * Lock-Joint type
  23572. */
  23573. static LockJoint: number;
  23574. }
  23575. /**
  23576. * A class representing a physics distance joint
  23577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23578. */
  23579. export class DistanceJoint extends PhysicsJoint {
  23580. /**
  23581. *
  23582. * @param jointData The data for the Distance-Joint
  23583. */
  23584. constructor(jointData: DistanceJointData);
  23585. /**
  23586. * Update the predefined distance.
  23587. * @param maxDistance The maximum preferred distance
  23588. * @param minDistance The minimum preferred distance
  23589. */
  23590. updateDistance(maxDistance: number, minDistance?: number): void;
  23591. }
  23592. /**
  23593. * Represents a Motor-Enabled Joint
  23594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23595. */
  23596. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23597. /**
  23598. * Initializes the Motor-Enabled Joint
  23599. * @param type The type of the joint
  23600. * @param jointData The physica joint data for the joint
  23601. */
  23602. constructor(type: number, jointData: PhysicsJointData);
  23603. /**
  23604. * Set the motor values.
  23605. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23606. * @param force the force to apply
  23607. * @param maxForce max force for this motor.
  23608. */
  23609. setMotor(force?: number, maxForce?: number): void;
  23610. /**
  23611. * Set the motor's limits.
  23612. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23613. * @param upperLimit The upper limit of the motor
  23614. * @param lowerLimit The lower limit of the motor
  23615. */
  23616. setLimit(upperLimit: number, lowerLimit?: number): void;
  23617. }
  23618. /**
  23619. * This class represents a single physics Hinge-Joint
  23620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23621. */
  23622. export class HingeJoint extends MotorEnabledJoint {
  23623. /**
  23624. * Initializes the Hinge-Joint
  23625. * @param jointData The joint data for the Hinge-Joint
  23626. */
  23627. constructor(jointData: PhysicsJointData);
  23628. /**
  23629. * Set the motor values.
  23630. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23631. * @param {number} force the force to apply
  23632. * @param {number} maxForce max force for this motor.
  23633. */
  23634. setMotor(force?: number, maxForce?: number): void;
  23635. /**
  23636. * Set the motor's limits.
  23637. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23638. * @param upperLimit The upper limit of the motor
  23639. * @param lowerLimit The lower limit of the motor
  23640. */
  23641. setLimit(upperLimit: number, lowerLimit?: number): void;
  23642. }
  23643. /**
  23644. * This class represents a dual hinge physics joint (same as wheel joint)
  23645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23646. */
  23647. export class Hinge2Joint extends MotorEnabledJoint {
  23648. /**
  23649. * Initializes the Hinge2-Joint
  23650. * @param jointData The joint data for the Hinge2-Joint
  23651. */
  23652. constructor(jointData: PhysicsJointData);
  23653. /**
  23654. * Set the motor values.
  23655. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23656. * @param {number} targetSpeed the speed the motor is to reach
  23657. * @param {number} maxForce max force for this motor.
  23658. * @param {motorIndex} the motor's index, 0 or 1.
  23659. */
  23660. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23661. /**
  23662. * Set the motor limits.
  23663. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23664. * @param {number} upperLimit the upper limit
  23665. * @param {number} lowerLimit lower limit
  23666. * @param {motorIndex} the motor's index, 0 or 1.
  23667. */
  23668. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23669. }
  23670. /**
  23671. * Interface for a motor enabled joint
  23672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23673. */
  23674. export interface IMotorEnabledJoint {
  23675. /**
  23676. * Physics joint
  23677. */
  23678. physicsJoint: any;
  23679. /**
  23680. * Sets the motor of the motor-enabled joint
  23681. * @param force The force of the motor
  23682. * @param maxForce The maximum force of the motor
  23683. * @param motorIndex The index of the motor
  23684. */
  23685. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23686. /**
  23687. * Sets the limit of the motor
  23688. * @param upperLimit The upper limit of the motor
  23689. * @param lowerLimit The lower limit of the motor
  23690. * @param motorIndex The index of the motor
  23691. */
  23692. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23693. }
  23694. /**
  23695. * Joint data for a Distance-Joint
  23696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23697. */
  23698. export interface DistanceJointData extends PhysicsJointData {
  23699. /**
  23700. * Max distance the 2 joint objects can be apart
  23701. */
  23702. maxDistance: number;
  23703. }
  23704. /**
  23705. * Joint data from a spring joint
  23706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23707. */
  23708. export interface SpringJointData extends PhysicsJointData {
  23709. /**
  23710. * Length of the spring
  23711. */
  23712. length: number;
  23713. /**
  23714. * Stiffness of the spring
  23715. */
  23716. stiffness: number;
  23717. /**
  23718. * Damping of the spring
  23719. */
  23720. damping: number;
  23721. /** this callback will be called when applying the force to the impostors. */
  23722. forceApplicationCallback: () => void;
  23723. }
  23724. }
  23725. declare module BABYLON {
  23726. /**
  23727. * Holds the data for the raycast result
  23728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23729. */
  23730. export class PhysicsRaycastResult {
  23731. private _hasHit;
  23732. private _hitDistance;
  23733. private _hitNormalWorld;
  23734. private _hitPointWorld;
  23735. private _rayFromWorld;
  23736. private _rayToWorld;
  23737. /**
  23738. * Gets if there was a hit
  23739. */
  23740. get hasHit(): boolean;
  23741. /**
  23742. * Gets the distance from the hit
  23743. */
  23744. get hitDistance(): number;
  23745. /**
  23746. * Gets the hit normal/direction in the world
  23747. */
  23748. get hitNormalWorld(): Vector3;
  23749. /**
  23750. * Gets the hit point in the world
  23751. */
  23752. get hitPointWorld(): Vector3;
  23753. /**
  23754. * Gets the ray "start point" of the ray in the world
  23755. */
  23756. get rayFromWorld(): Vector3;
  23757. /**
  23758. * Gets the ray "end point" of the ray in the world
  23759. */
  23760. get rayToWorld(): Vector3;
  23761. /**
  23762. * Sets the hit data (normal & point in world space)
  23763. * @param hitNormalWorld defines the normal in world space
  23764. * @param hitPointWorld defines the point in world space
  23765. */
  23766. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23767. /**
  23768. * Sets the distance from the start point to the hit point
  23769. * @param distance
  23770. */
  23771. setHitDistance(distance: number): void;
  23772. /**
  23773. * Calculates the distance manually
  23774. */
  23775. calculateHitDistance(): void;
  23776. /**
  23777. * Resets all the values to default
  23778. * @param from The from point on world space
  23779. * @param to The to point on world space
  23780. */
  23781. reset(from?: Vector3, to?: Vector3): void;
  23782. }
  23783. /**
  23784. * Interface for the size containing width and height
  23785. */
  23786. interface IXYZ {
  23787. /**
  23788. * X
  23789. */
  23790. x: number;
  23791. /**
  23792. * Y
  23793. */
  23794. y: number;
  23795. /**
  23796. * Z
  23797. */
  23798. z: number;
  23799. }
  23800. }
  23801. declare module BABYLON {
  23802. /**
  23803. * Interface used to describe a physics joint
  23804. */
  23805. export interface PhysicsImpostorJoint {
  23806. /** Defines the main impostor to which the joint is linked */
  23807. mainImpostor: PhysicsImpostor;
  23808. /** Defines the impostor that is connected to the main impostor using this joint */
  23809. connectedImpostor: PhysicsImpostor;
  23810. /** Defines the joint itself */
  23811. joint: PhysicsJoint;
  23812. }
  23813. /** @hidden */
  23814. export interface IPhysicsEnginePlugin {
  23815. world: any;
  23816. name: string;
  23817. setGravity(gravity: Vector3): void;
  23818. setTimeStep(timeStep: number): void;
  23819. getTimeStep(): number;
  23820. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23821. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23822. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23823. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23824. removePhysicsBody(impostor: PhysicsImpostor): void;
  23825. generateJoint(joint: PhysicsImpostorJoint): void;
  23826. removeJoint(joint: PhysicsImpostorJoint): void;
  23827. isSupported(): boolean;
  23828. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23829. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23830. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23831. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23832. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23833. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23834. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23835. getBodyMass(impostor: PhysicsImpostor): number;
  23836. getBodyFriction(impostor: PhysicsImpostor): number;
  23837. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23838. getBodyRestitution(impostor: PhysicsImpostor): number;
  23839. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23840. getBodyPressure?(impostor: PhysicsImpostor): number;
  23841. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23842. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23843. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23844. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23845. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23846. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23847. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23848. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23849. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23850. sleepBody(impostor: PhysicsImpostor): void;
  23851. wakeUpBody(impostor: PhysicsImpostor): void;
  23852. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23853. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23854. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23855. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23856. getRadius(impostor: PhysicsImpostor): number;
  23857. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23858. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23859. dispose(): void;
  23860. }
  23861. /**
  23862. * Interface used to define a physics engine
  23863. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23864. */
  23865. export interface IPhysicsEngine {
  23866. /**
  23867. * Gets the gravity vector used by the simulation
  23868. */
  23869. gravity: Vector3;
  23870. /**
  23871. * Sets the gravity vector used by the simulation
  23872. * @param gravity defines the gravity vector to use
  23873. */
  23874. setGravity(gravity: Vector3): void;
  23875. /**
  23876. * Set the time step of the physics engine.
  23877. * Default is 1/60.
  23878. * To slow it down, enter 1/600 for example.
  23879. * To speed it up, 1/30
  23880. * @param newTimeStep the new timestep to apply to this world.
  23881. */
  23882. setTimeStep(newTimeStep: number): void;
  23883. /**
  23884. * Get the time step of the physics engine.
  23885. * @returns the current time step
  23886. */
  23887. getTimeStep(): number;
  23888. /**
  23889. * Set the sub time step of the physics engine.
  23890. * Default is 0 meaning there is no sub steps
  23891. * To increase physics resolution precision, set a small value (like 1 ms)
  23892. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23893. */
  23894. setSubTimeStep(subTimeStep: number): void;
  23895. /**
  23896. * Get the sub time step of the physics engine.
  23897. * @returns the current sub time step
  23898. */
  23899. getSubTimeStep(): number;
  23900. /**
  23901. * Release all resources
  23902. */
  23903. dispose(): void;
  23904. /**
  23905. * Gets the name of the current physics plugin
  23906. * @returns the name of the plugin
  23907. */
  23908. getPhysicsPluginName(): string;
  23909. /**
  23910. * Adding a new impostor for the impostor tracking.
  23911. * This will be done by the impostor itself.
  23912. * @param impostor the impostor to add
  23913. */
  23914. addImpostor(impostor: PhysicsImpostor): void;
  23915. /**
  23916. * Remove an impostor from the engine.
  23917. * This impostor and its mesh will not longer be updated by the physics engine.
  23918. * @param impostor the impostor to remove
  23919. */
  23920. removeImpostor(impostor: PhysicsImpostor): void;
  23921. /**
  23922. * Add a joint to the physics engine
  23923. * @param mainImpostor defines the main impostor to which the joint is added.
  23924. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23925. * @param joint defines the joint that will connect both impostors.
  23926. */
  23927. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23928. /**
  23929. * Removes a joint from the simulation
  23930. * @param mainImpostor defines the impostor used with the joint
  23931. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23932. * @param joint defines the joint to remove
  23933. */
  23934. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23935. /**
  23936. * Gets the current plugin used to run the simulation
  23937. * @returns current plugin
  23938. */
  23939. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23940. /**
  23941. * Gets the list of physic impostors
  23942. * @returns an array of PhysicsImpostor
  23943. */
  23944. getImpostors(): Array<PhysicsImpostor>;
  23945. /**
  23946. * Gets the impostor for a physics enabled object
  23947. * @param object defines the object impersonated by the impostor
  23948. * @returns the PhysicsImpostor or null if not found
  23949. */
  23950. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23951. /**
  23952. * Gets the impostor for a physics body object
  23953. * @param body defines physics body used by the impostor
  23954. * @returns the PhysicsImpostor or null if not found
  23955. */
  23956. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23957. /**
  23958. * Does a raycast in the physics world
  23959. * @param from when should the ray start?
  23960. * @param to when should the ray end?
  23961. * @returns PhysicsRaycastResult
  23962. */
  23963. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23964. /**
  23965. * Called by the scene. No need to call it.
  23966. * @param delta defines the timespam between frames
  23967. */
  23968. _step(delta: number): void;
  23969. }
  23970. }
  23971. declare module BABYLON {
  23972. /**
  23973. * The interface for the physics imposter parameters
  23974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23975. */
  23976. export interface PhysicsImpostorParameters {
  23977. /**
  23978. * The mass of the physics imposter
  23979. */
  23980. mass: number;
  23981. /**
  23982. * The friction of the physics imposter
  23983. */
  23984. friction?: number;
  23985. /**
  23986. * The coefficient of restitution of the physics imposter
  23987. */
  23988. restitution?: number;
  23989. /**
  23990. * The native options of the physics imposter
  23991. */
  23992. nativeOptions?: any;
  23993. /**
  23994. * Specifies if the parent should be ignored
  23995. */
  23996. ignoreParent?: boolean;
  23997. /**
  23998. * Specifies if bi-directional transformations should be disabled
  23999. */
  24000. disableBidirectionalTransformation?: boolean;
  24001. /**
  24002. * The pressure inside the physics imposter, soft object only
  24003. */
  24004. pressure?: number;
  24005. /**
  24006. * The stiffness the physics imposter, soft object only
  24007. */
  24008. stiffness?: number;
  24009. /**
  24010. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24011. */
  24012. velocityIterations?: number;
  24013. /**
  24014. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24015. */
  24016. positionIterations?: number;
  24017. /**
  24018. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24019. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24020. * Add to fix multiple points
  24021. */
  24022. fixedPoints?: number;
  24023. /**
  24024. * The collision margin around a soft object
  24025. */
  24026. margin?: number;
  24027. /**
  24028. * The collision margin around a soft object
  24029. */
  24030. damping?: number;
  24031. /**
  24032. * The path for a rope based on an extrusion
  24033. */
  24034. path?: any;
  24035. /**
  24036. * The shape of an extrusion used for a rope based on an extrusion
  24037. */
  24038. shape?: any;
  24039. }
  24040. /**
  24041. * Interface for a physics-enabled object
  24042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24043. */
  24044. export interface IPhysicsEnabledObject {
  24045. /**
  24046. * The position of the physics-enabled object
  24047. */
  24048. position: Vector3;
  24049. /**
  24050. * The rotation of the physics-enabled object
  24051. */
  24052. rotationQuaternion: Nullable<Quaternion>;
  24053. /**
  24054. * The scale of the physics-enabled object
  24055. */
  24056. scaling: Vector3;
  24057. /**
  24058. * The rotation of the physics-enabled object
  24059. */
  24060. rotation?: Vector3;
  24061. /**
  24062. * The parent of the physics-enabled object
  24063. */
  24064. parent?: any;
  24065. /**
  24066. * The bounding info of the physics-enabled object
  24067. * @returns The bounding info of the physics-enabled object
  24068. */
  24069. getBoundingInfo(): BoundingInfo;
  24070. /**
  24071. * Computes the world matrix
  24072. * @param force Specifies if the world matrix should be computed by force
  24073. * @returns A world matrix
  24074. */
  24075. computeWorldMatrix(force: boolean): Matrix;
  24076. /**
  24077. * Gets the world matrix
  24078. * @returns A world matrix
  24079. */
  24080. getWorldMatrix?(): Matrix;
  24081. /**
  24082. * Gets the child meshes
  24083. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24084. * @returns An array of abstract meshes
  24085. */
  24086. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24087. /**
  24088. * Gets the vertex data
  24089. * @param kind The type of vertex data
  24090. * @returns A nullable array of numbers, or a float32 array
  24091. */
  24092. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24093. /**
  24094. * Gets the indices from the mesh
  24095. * @returns A nullable array of index arrays
  24096. */
  24097. getIndices?(): Nullable<IndicesArray>;
  24098. /**
  24099. * Gets the scene from the mesh
  24100. * @returns the indices array or null
  24101. */
  24102. getScene?(): Scene;
  24103. /**
  24104. * Gets the absolute position from the mesh
  24105. * @returns the absolute position
  24106. */
  24107. getAbsolutePosition(): Vector3;
  24108. /**
  24109. * Gets the absolute pivot point from the mesh
  24110. * @returns the absolute pivot point
  24111. */
  24112. getAbsolutePivotPoint(): Vector3;
  24113. /**
  24114. * Rotates the mesh
  24115. * @param axis The axis of rotation
  24116. * @param amount The amount of rotation
  24117. * @param space The space of the rotation
  24118. * @returns The rotation transform node
  24119. */
  24120. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24121. /**
  24122. * Translates the mesh
  24123. * @param axis The axis of translation
  24124. * @param distance The distance of translation
  24125. * @param space The space of the translation
  24126. * @returns The transform node
  24127. */
  24128. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24129. /**
  24130. * Sets the absolute position of the mesh
  24131. * @param absolutePosition The absolute position of the mesh
  24132. * @returns The transform node
  24133. */
  24134. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24135. /**
  24136. * Gets the class name of the mesh
  24137. * @returns The class name
  24138. */
  24139. getClassName(): string;
  24140. }
  24141. /**
  24142. * Represents a physics imposter
  24143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24144. */
  24145. export class PhysicsImpostor {
  24146. /**
  24147. * The physics-enabled object used as the physics imposter
  24148. */
  24149. object: IPhysicsEnabledObject;
  24150. /**
  24151. * The type of the physics imposter
  24152. */
  24153. type: number;
  24154. private _options;
  24155. private _scene?;
  24156. /**
  24157. * The default object size of the imposter
  24158. */
  24159. static DEFAULT_OBJECT_SIZE: Vector3;
  24160. /**
  24161. * The identity quaternion of the imposter
  24162. */
  24163. static IDENTITY_QUATERNION: Quaternion;
  24164. /** @hidden */
  24165. _pluginData: any;
  24166. private _physicsEngine;
  24167. private _physicsBody;
  24168. private _bodyUpdateRequired;
  24169. private _onBeforePhysicsStepCallbacks;
  24170. private _onAfterPhysicsStepCallbacks;
  24171. /** @hidden */
  24172. _onPhysicsCollideCallbacks: Array<{
  24173. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24174. otherImpostors: Array<PhysicsImpostor>;
  24175. }>;
  24176. private _deltaPosition;
  24177. private _deltaRotation;
  24178. private _deltaRotationConjugated;
  24179. /** @hidden */
  24180. _isFromLine: boolean;
  24181. private _parent;
  24182. private _isDisposed;
  24183. private static _tmpVecs;
  24184. private static _tmpQuat;
  24185. /**
  24186. * Specifies if the physics imposter is disposed
  24187. */
  24188. get isDisposed(): boolean;
  24189. /**
  24190. * Gets the mass of the physics imposter
  24191. */
  24192. get mass(): number;
  24193. set mass(value: number);
  24194. /**
  24195. * Gets the coefficient of friction
  24196. */
  24197. get friction(): number;
  24198. /**
  24199. * Sets the coefficient of friction
  24200. */
  24201. set friction(value: number);
  24202. /**
  24203. * Gets the coefficient of restitution
  24204. */
  24205. get restitution(): number;
  24206. /**
  24207. * Sets the coefficient of restitution
  24208. */
  24209. set restitution(value: number);
  24210. /**
  24211. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24212. */
  24213. get pressure(): number;
  24214. /**
  24215. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24216. */
  24217. set pressure(value: number);
  24218. /**
  24219. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24220. */
  24221. get stiffness(): number;
  24222. /**
  24223. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24224. */
  24225. set stiffness(value: number);
  24226. /**
  24227. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24228. */
  24229. get velocityIterations(): number;
  24230. /**
  24231. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24232. */
  24233. set velocityIterations(value: number);
  24234. /**
  24235. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24236. */
  24237. get positionIterations(): number;
  24238. /**
  24239. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24240. */
  24241. set positionIterations(value: number);
  24242. /**
  24243. * The unique id of the physics imposter
  24244. * set by the physics engine when adding this impostor to the array
  24245. */
  24246. uniqueId: number;
  24247. /**
  24248. * @hidden
  24249. */
  24250. soft: boolean;
  24251. /**
  24252. * @hidden
  24253. */
  24254. segments: number;
  24255. private _joints;
  24256. /**
  24257. * Initializes the physics imposter
  24258. * @param object The physics-enabled object used as the physics imposter
  24259. * @param type The type of the physics imposter
  24260. * @param _options The options for the physics imposter
  24261. * @param _scene The Babylon scene
  24262. */
  24263. constructor(
  24264. /**
  24265. * The physics-enabled object used as the physics imposter
  24266. */
  24267. object: IPhysicsEnabledObject,
  24268. /**
  24269. * The type of the physics imposter
  24270. */
  24271. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24272. /**
  24273. * This function will completly initialize this impostor.
  24274. * It will create a new body - but only if this mesh has no parent.
  24275. * If it has, this impostor will not be used other than to define the impostor
  24276. * of the child mesh.
  24277. * @hidden
  24278. */
  24279. _init(): void;
  24280. private _getPhysicsParent;
  24281. /**
  24282. * Should a new body be generated.
  24283. * @returns boolean specifying if body initialization is required
  24284. */
  24285. isBodyInitRequired(): boolean;
  24286. /**
  24287. * Sets the updated scaling
  24288. * @param updated Specifies if the scaling is updated
  24289. */
  24290. setScalingUpdated(): void;
  24291. /**
  24292. * Force a regeneration of this or the parent's impostor's body.
  24293. * Use under cautious - This will remove all joints already implemented.
  24294. */
  24295. forceUpdate(): void;
  24296. /**
  24297. * Gets the body that holds this impostor. Either its own, or its parent.
  24298. */
  24299. get physicsBody(): any;
  24300. /**
  24301. * Get the parent of the physics imposter
  24302. * @returns Physics imposter or null
  24303. */
  24304. get parent(): Nullable<PhysicsImpostor>;
  24305. /**
  24306. * Sets the parent of the physics imposter
  24307. */
  24308. set parent(value: Nullable<PhysicsImpostor>);
  24309. /**
  24310. * Set the physics body. Used mainly by the physics engine/plugin
  24311. */
  24312. set physicsBody(physicsBody: any);
  24313. /**
  24314. * Resets the update flags
  24315. */
  24316. resetUpdateFlags(): void;
  24317. /**
  24318. * Gets the object extend size
  24319. * @returns the object extend size
  24320. */
  24321. getObjectExtendSize(): Vector3;
  24322. /**
  24323. * Gets the object center
  24324. * @returns The object center
  24325. */
  24326. getObjectCenter(): Vector3;
  24327. /**
  24328. * Get a specific parameter from the options parameters
  24329. * @param paramName The object parameter name
  24330. * @returns The object parameter
  24331. */
  24332. getParam(paramName: string): any;
  24333. /**
  24334. * Sets a specific parameter in the options given to the physics plugin
  24335. * @param paramName The parameter name
  24336. * @param value The value of the parameter
  24337. */
  24338. setParam(paramName: string, value: number): void;
  24339. /**
  24340. * Specifically change the body's mass option. Won't recreate the physics body object
  24341. * @param mass The mass of the physics imposter
  24342. */
  24343. setMass(mass: number): void;
  24344. /**
  24345. * Gets the linear velocity
  24346. * @returns linear velocity or null
  24347. */
  24348. getLinearVelocity(): Nullable<Vector3>;
  24349. /**
  24350. * Sets the linear velocity
  24351. * @param velocity linear velocity or null
  24352. */
  24353. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24354. /**
  24355. * Gets the angular velocity
  24356. * @returns angular velocity or null
  24357. */
  24358. getAngularVelocity(): Nullable<Vector3>;
  24359. /**
  24360. * Sets the angular velocity
  24361. * @param velocity The velocity or null
  24362. */
  24363. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24364. /**
  24365. * Execute a function with the physics plugin native code
  24366. * Provide a function the will have two variables - the world object and the physics body object
  24367. * @param func The function to execute with the physics plugin native code
  24368. */
  24369. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24370. /**
  24371. * Register a function that will be executed before the physics world is stepping forward
  24372. * @param func The function to execute before the physics world is stepped forward
  24373. */
  24374. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24375. /**
  24376. * Unregister a function that will be executed before the physics world is stepping forward
  24377. * @param func The function to execute before the physics world is stepped forward
  24378. */
  24379. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24380. /**
  24381. * Register a function that will be executed after the physics step
  24382. * @param func The function to execute after physics step
  24383. */
  24384. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24385. /**
  24386. * Unregisters a function that will be executed after the physics step
  24387. * @param func The function to execute after physics step
  24388. */
  24389. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24390. /**
  24391. * register a function that will be executed when this impostor collides against a different body
  24392. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24393. * @param func Callback that is executed on collision
  24394. */
  24395. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24396. /**
  24397. * Unregisters the physics imposter on contact
  24398. * @param collideAgainst The physics object to collide against
  24399. * @param func Callback to execute on collision
  24400. */
  24401. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24402. private _tmpQuat;
  24403. private _tmpQuat2;
  24404. /**
  24405. * Get the parent rotation
  24406. * @returns The parent rotation
  24407. */
  24408. getParentsRotation(): Quaternion;
  24409. /**
  24410. * this function is executed by the physics engine.
  24411. */
  24412. beforeStep: () => void;
  24413. /**
  24414. * this function is executed by the physics engine
  24415. */
  24416. afterStep: () => void;
  24417. /**
  24418. * Legacy collision detection event support
  24419. */
  24420. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24421. /**
  24422. * event and body object due to cannon's event-based architecture.
  24423. */
  24424. onCollide: (e: {
  24425. body: any;
  24426. }) => void;
  24427. /**
  24428. * Apply a force
  24429. * @param force The force to apply
  24430. * @param contactPoint The contact point for the force
  24431. * @returns The physics imposter
  24432. */
  24433. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24434. /**
  24435. * Apply an impulse
  24436. * @param force The impulse force
  24437. * @param contactPoint The contact point for the impulse force
  24438. * @returns The physics imposter
  24439. */
  24440. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24441. /**
  24442. * A help function to create a joint
  24443. * @param otherImpostor A physics imposter used to create a joint
  24444. * @param jointType The type of joint
  24445. * @param jointData The data for the joint
  24446. * @returns The physics imposter
  24447. */
  24448. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24449. /**
  24450. * Add a joint to this impostor with a different impostor
  24451. * @param otherImpostor A physics imposter used to add a joint
  24452. * @param joint The joint to add
  24453. * @returns The physics imposter
  24454. */
  24455. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24456. /**
  24457. * Add an anchor to a cloth impostor
  24458. * @param otherImpostor rigid impostor to anchor to
  24459. * @param width ratio across width from 0 to 1
  24460. * @param height ratio up height from 0 to 1
  24461. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24462. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24463. * @returns impostor the soft imposter
  24464. */
  24465. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24466. /**
  24467. * Add a hook to a rope impostor
  24468. * @param otherImpostor rigid impostor to anchor to
  24469. * @param length ratio across rope from 0 to 1
  24470. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24471. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24472. * @returns impostor the rope imposter
  24473. */
  24474. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24475. /**
  24476. * Will keep this body still, in a sleep mode.
  24477. * @returns the physics imposter
  24478. */
  24479. sleep(): PhysicsImpostor;
  24480. /**
  24481. * Wake the body up.
  24482. * @returns The physics imposter
  24483. */
  24484. wakeUp(): PhysicsImpostor;
  24485. /**
  24486. * Clones the physics imposter
  24487. * @param newObject The physics imposter clones to this physics-enabled object
  24488. * @returns A nullable physics imposter
  24489. */
  24490. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24491. /**
  24492. * Disposes the physics imposter
  24493. */
  24494. dispose(): void;
  24495. /**
  24496. * Sets the delta position
  24497. * @param position The delta position amount
  24498. */
  24499. setDeltaPosition(position: Vector3): void;
  24500. /**
  24501. * Sets the delta rotation
  24502. * @param rotation The delta rotation amount
  24503. */
  24504. setDeltaRotation(rotation: Quaternion): void;
  24505. /**
  24506. * Gets the box size of the physics imposter and stores the result in the input parameter
  24507. * @param result Stores the box size
  24508. * @returns The physics imposter
  24509. */
  24510. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24511. /**
  24512. * Gets the radius of the physics imposter
  24513. * @returns Radius of the physics imposter
  24514. */
  24515. getRadius(): number;
  24516. /**
  24517. * Sync a bone with this impostor
  24518. * @param bone The bone to sync to the impostor.
  24519. * @param boneMesh The mesh that the bone is influencing.
  24520. * @param jointPivot The pivot of the joint / bone in local space.
  24521. * @param distToJoint Optional distance from the impostor to the joint.
  24522. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24523. */
  24524. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24525. /**
  24526. * Sync impostor to a bone
  24527. * @param bone The bone that the impostor will be synced to.
  24528. * @param boneMesh The mesh that the bone is influencing.
  24529. * @param jointPivot The pivot of the joint / bone in local space.
  24530. * @param distToJoint Optional distance from the impostor to the joint.
  24531. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24532. * @param boneAxis Optional vector3 axis the bone is aligned with
  24533. */
  24534. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24535. /**
  24536. * No-Imposter type
  24537. */
  24538. static NoImpostor: number;
  24539. /**
  24540. * Sphere-Imposter type
  24541. */
  24542. static SphereImpostor: number;
  24543. /**
  24544. * Box-Imposter type
  24545. */
  24546. static BoxImpostor: number;
  24547. /**
  24548. * Plane-Imposter type
  24549. */
  24550. static PlaneImpostor: number;
  24551. /**
  24552. * Mesh-imposter type
  24553. */
  24554. static MeshImpostor: number;
  24555. /**
  24556. * Capsule-Impostor type (Ammo.js plugin only)
  24557. */
  24558. static CapsuleImpostor: number;
  24559. /**
  24560. * Cylinder-Imposter type
  24561. */
  24562. static CylinderImpostor: number;
  24563. /**
  24564. * Particle-Imposter type
  24565. */
  24566. static ParticleImpostor: number;
  24567. /**
  24568. * Heightmap-Imposter type
  24569. */
  24570. static HeightmapImpostor: number;
  24571. /**
  24572. * ConvexHull-Impostor type (Ammo.js plugin only)
  24573. */
  24574. static ConvexHullImpostor: number;
  24575. /**
  24576. * Custom-Imposter type (Ammo.js plugin only)
  24577. */
  24578. static CustomImpostor: number;
  24579. /**
  24580. * Rope-Imposter type
  24581. */
  24582. static RopeImpostor: number;
  24583. /**
  24584. * Cloth-Imposter type
  24585. */
  24586. static ClothImpostor: number;
  24587. /**
  24588. * Softbody-Imposter type
  24589. */
  24590. static SoftbodyImpostor: number;
  24591. }
  24592. }
  24593. declare module BABYLON {
  24594. /**
  24595. * @hidden
  24596. **/
  24597. export class _CreationDataStorage {
  24598. closePath?: boolean;
  24599. closeArray?: boolean;
  24600. idx: number[];
  24601. dashSize: number;
  24602. gapSize: number;
  24603. path3D: Path3D;
  24604. pathArray: Vector3[][];
  24605. arc: number;
  24606. radius: number;
  24607. cap: number;
  24608. tessellation: number;
  24609. }
  24610. /**
  24611. * @hidden
  24612. **/
  24613. class _InstanceDataStorage {
  24614. visibleInstances: any;
  24615. batchCache: _InstancesBatch;
  24616. instancesBufferSize: number;
  24617. instancesBuffer: Nullable<Buffer>;
  24618. instancesData: Float32Array;
  24619. overridenInstanceCount: number;
  24620. isFrozen: boolean;
  24621. previousBatch: Nullable<_InstancesBatch>;
  24622. hardwareInstancedRendering: boolean;
  24623. sideOrientation: number;
  24624. manualUpdate: boolean;
  24625. }
  24626. /**
  24627. * @hidden
  24628. **/
  24629. export class _InstancesBatch {
  24630. mustReturn: boolean;
  24631. visibleInstances: Nullable<InstancedMesh[]>[];
  24632. renderSelf: boolean[];
  24633. hardwareInstancedRendering: boolean[];
  24634. }
  24635. /**
  24636. * Class used to represent renderable models
  24637. */
  24638. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24639. /**
  24640. * Mesh side orientation : usually the external or front surface
  24641. */
  24642. static readonly FRONTSIDE: number;
  24643. /**
  24644. * Mesh side orientation : usually the internal or back surface
  24645. */
  24646. static readonly BACKSIDE: number;
  24647. /**
  24648. * Mesh side orientation : both internal and external or front and back surfaces
  24649. */
  24650. static readonly DOUBLESIDE: number;
  24651. /**
  24652. * Mesh side orientation : by default, `FRONTSIDE`
  24653. */
  24654. static readonly DEFAULTSIDE: number;
  24655. /**
  24656. * Mesh cap setting : no cap
  24657. */
  24658. static readonly NO_CAP: number;
  24659. /**
  24660. * Mesh cap setting : one cap at the beginning of the mesh
  24661. */
  24662. static readonly CAP_START: number;
  24663. /**
  24664. * Mesh cap setting : one cap at the end of the mesh
  24665. */
  24666. static readonly CAP_END: number;
  24667. /**
  24668. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24669. */
  24670. static readonly CAP_ALL: number;
  24671. /**
  24672. * Mesh pattern setting : no flip or rotate
  24673. */
  24674. static readonly NO_FLIP: number;
  24675. /**
  24676. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24677. */
  24678. static readonly FLIP_TILE: number;
  24679. /**
  24680. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24681. */
  24682. static readonly ROTATE_TILE: number;
  24683. /**
  24684. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24685. */
  24686. static readonly FLIP_ROW: number;
  24687. /**
  24688. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24689. */
  24690. static readonly ROTATE_ROW: number;
  24691. /**
  24692. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24693. */
  24694. static readonly FLIP_N_ROTATE_TILE: number;
  24695. /**
  24696. * Mesh pattern setting : rotate pattern and rotate
  24697. */
  24698. static readonly FLIP_N_ROTATE_ROW: number;
  24699. /**
  24700. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24701. */
  24702. static readonly CENTER: number;
  24703. /**
  24704. * Mesh tile positioning : part tiles on left
  24705. */
  24706. static readonly LEFT: number;
  24707. /**
  24708. * Mesh tile positioning : part tiles on right
  24709. */
  24710. static readonly RIGHT: number;
  24711. /**
  24712. * Mesh tile positioning : part tiles on top
  24713. */
  24714. static readonly TOP: number;
  24715. /**
  24716. * Mesh tile positioning : part tiles on bottom
  24717. */
  24718. static readonly BOTTOM: number;
  24719. /**
  24720. * Gets the default side orientation.
  24721. * @param orientation the orientation to value to attempt to get
  24722. * @returns the default orientation
  24723. * @hidden
  24724. */
  24725. static _GetDefaultSideOrientation(orientation?: number): number;
  24726. private _internalMeshDataInfo;
  24727. /**
  24728. * An event triggered before rendering the mesh
  24729. */
  24730. get onBeforeRenderObservable(): Observable<Mesh>;
  24731. /**
  24732. * An event triggered before binding the mesh
  24733. */
  24734. get onBeforeBindObservable(): Observable<Mesh>;
  24735. /**
  24736. * An event triggered after rendering the mesh
  24737. */
  24738. get onAfterRenderObservable(): Observable<Mesh>;
  24739. /**
  24740. * An event triggered before drawing the mesh
  24741. */
  24742. get onBeforeDrawObservable(): Observable<Mesh>;
  24743. private _onBeforeDrawObserver;
  24744. /**
  24745. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24746. */
  24747. set onBeforeDraw(callback: () => void);
  24748. get hasInstances(): boolean;
  24749. /**
  24750. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24751. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24752. */
  24753. delayLoadState: number;
  24754. /**
  24755. * Gets the list of instances created from this mesh
  24756. * it is not supposed to be modified manually.
  24757. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24758. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24759. */
  24760. instances: InstancedMesh[];
  24761. /**
  24762. * Gets the file containing delay loading data for this mesh
  24763. */
  24764. delayLoadingFile: string;
  24765. /** @hidden */
  24766. _binaryInfo: any;
  24767. /**
  24768. * User defined function used to change how LOD level selection is done
  24769. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24770. */
  24771. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24772. /**
  24773. * Gets or sets the morph target manager
  24774. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24775. */
  24776. get morphTargetManager(): Nullable<MorphTargetManager>;
  24777. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24778. /** @hidden */
  24779. _creationDataStorage: Nullable<_CreationDataStorage>;
  24780. /** @hidden */
  24781. _geometry: Nullable<Geometry>;
  24782. /** @hidden */
  24783. _delayInfo: Array<string>;
  24784. /** @hidden */
  24785. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24786. /** @hidden */
  24787. _instanceDataStorage: _InstanceDataStorage;
  24788. private _effectiveMaterial;
  24789. /** @hidden */
  24790. _shouldGenerateFlatShading: boolean;
  24791. /** @hidden */
  24792. _originalBuilderSideOrientation: number;
  24793. /**
  24794. * Use this property to change the original side orientation defined at construction time
  24795. */
  24796. overrideMaterialSideOrientation: Nullable<number>;
  24797. /**
  24798. * Gets the source mesh (the one used to clone this one from)
  24799. */
  24800. get source(): Nullable<Mesh>;
  24801. /**
  24802. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24803. */
  24804. get isUnIndexed(): boolean;
  24805. set isUnIndexed(value: boolean);
  24806. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24807. get worldMatrixInstancedBuffer(): Float32Array;
  24808. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24809. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24810. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24811. /**
  24812. * @constructor
  24813. * @param name The value used by scene.getMeshByName() to do a lookup.
  24814. * @param scene The scene to add this mesh to.
  24815. * @param parent The parent of this mesh, if it has one
  24816. * @param source An optional Mesh from which geometry is shared, cloned.
  24817. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24818. * When false, achieved by calling a clone(), also passing False.
  24819. * This will make creation of children, recursive.
  24820. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24821. */
  24822. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24823. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24824. doNotInstantiate: boolean;
  24825. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24826. /**
  24827. * Gets the class name
  24828. * @returns the string "Mesh".
  24829. */
  24830. getClassName(): string;
  24831. /** @hidden */
  24832. get _isMesh(): boolean;
  24833. /**
  24834. * Returns a description of this mesh
  24835. * @param fullDetails define if full details about this mesh must be used
  24836. * @returns a descriptive string representing this mesh
  24837. */
  24838. toString(fullDetails?: boolean): string;
  24839. /** @hidden */
  24840. _unBindEffect(): void;
  24841. /**
  24842. * Gets a boolean indicating if this mesh has LOD
  24843. */
  24844. get hasLODLevels(): boolean;
  24845. /**
  24846. * Gets the list of MeshLODLevel associated with the current mesh
  24847. * @returns an array of MeshLODLevel
  24848. */
  24849. getLODLevels(): MeshLODLevel[];
  24850. private _sortLODLevels;
  24851. /**
  24852. * Add a mesh as LOD level triggered at the given distance.
  24853. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24854. * @param distance The distance from the center of the object to show this level
  24855. * @param mesh The mesh to be added as LOD level (can be null)
  24856. * @return This mesh (for chaining)
  24857. */
  24858. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24859. /**
  24860. * Returns the LOD level mesh at the passed distance or null if not found.
  24861. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24862. * @param distance The distance from the center of the object to show this level
  24863. * @returns a Mesh or `null`
  24864. */
  24865. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24866. /**
  24867. * Remove a mesh from the LOD array
  24868. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24869. * @param mesh defines the mesh to be removed
  24870. * @return This mesh (for chaining)
  24871. */
  24872. removeLODLevel(mesh: Mesh): Mesh;
  24873. /**
  24874. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24875. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24876. * @param camera defines the camera to use to compute distance
  24877. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24878. * @return This mesh (for chaining)
  24879. */
  24880. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24881. /**
  24882. * Gets the mesh internal Geometry object
  24883. */
  24884. get geometry(): Nullable<Geometry>;
  24885. /**
  24886. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24887. * @returns the total number of vertices
  24888. */
  24889. getTotalVertices(): number;
  24890. /**
  24891. * Returns the content of an associated vertex buffer
  24892. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24893. * - VertexBuffer.PositionKind
  24894. * - VertexBuffer.UVKind
  24895. * - VertexBuffer.UV2Kind
  24896. * - VertexBuffer.UV3Kind
  24897. * - VertexBuffer.UV4Kind
  24898. * - VertexBuffer.UV5Kind
  24899. * - VertexBuffer.UV6Kind
  24900. * - VertexBuffer.ColorKind
  24901. * - VertexBuffer.MatricesIndicesKind
  24902. * - VertexBuffer.MatricesIndicesExtraKind
  24903. * - VertexBuffer.MatricesWeightsKind
  24904. * - VertexBuffer.MatricesWeightsExtraKind
  24905. * @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
  24906. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24907. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24908. */
  24909. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24910. /**
  24911. * Returns the mesh VertexBuffer object from the requested `kind`
  24912. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24913. * - VertexBuffer.PositionKind
  24914. * - VertexBuffer.NormalKind
  24915. * - VertexBuffer.UVKind
  24916. * - VertexBuffer.UV2Kind
  24917. * - VertexBuffer.UV3Kind
  24918. * - VertexBuffer.UV4Kind
  24919. * - VertexBuffer.UV5Kind
  24920. * - VertexBuffer.UV6Kind
  24921. * - VertexBuffer.ColorKind
  24922. * - VertexBuffer.MatricesIndicesKind
  24923. * - VertexBuffer.MatricesIndicesExtraKind
  24924. * - VertexBuffer.MatricesWeightsKind
  24925. * - VertexBuffer.MatricesWeightsExtraKind
  24926. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24927. */
  24928. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24929. /**
  24930. * Tests if a specific vertex buffer is associated with this mesh
  24931. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24932. * - VertexBuffer.PositionKind
  24933. * - VertexBuffer.NormalKind
  24934. * - VertexBuffer.UVKind
  24935. * - VertexBuffer.UV2Kind
  24936. * - VertexBuffer.UV3Kind
  24937. * - VertexBuffer.UV4Kind
  24938. * - VertexBuffer.UV5Kind
  24939. * - VertexBuffer.UV6Kind
  24940. * - VertexBuffer.ColorKind
  24941. * - VertexBuffer.MatricesIndicesKind
  24942. * - VertexBuffer.MatricesIndicesExtraKind
  24943. * - VertexBuffer.MatricesWeightsKind
  24944. * - VertexBuffer.MatricesWeightsExtraKind
  24945. * @returns a boolean
  24946. */
  24947. isVerticesDataPresent(kind: string): boolean;
  24948. /**
  24949. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24950. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24951. * - VertexBuffer.PositionKind
  24952. * - VertexBuffer.UVKind
  24953. * - VertexBuffer.UV2Kind
  24954. * - VertexBuffer.UV3Kind
  24955. * - VertexBuffer.UV4Kind
  24956. * - VertexBuffer.UV5Kind
  24957. * - VertexBuffer.UV6Kind
  24958. * - VertexBuffer.ColorKind
  24959. * - VertexBuffer.MatricesIndicesKind
  24960. * - VertexBuffer.MatricesIndicesExtraKind
  24961. * - VertexBuffer.MatricesWeightsKind
  24962. * - VertexBuffer.MatricesWeightsExtraKind
  24963. * @returns a boolean
  24964. */
  24965. isVertexBufferUpdatable(kind: string): boolean;
  24966. /**
  24967. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24968. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24969. * - VertexBuffer.PositionKind
  24970. * - VertexBuffer.NormalKind
  24971. * - VertexBuffer.UVKind
  24972. * - VertexBuffer.UV2Kind
  24973. * - VertexBuffer.UV3Kind
  24974. * - VertexBuffer.UV4Kind
  24975. * - VertexBuffer.UV5Kind
  24976. * - VertexBuffer.UV6Kind
  24977. * - VertexBuffer.ColorKind
  24978. * - VertexBuffer.MatricesIndicesKind
  24979. * - VertexBuffer.MatricesIndicesExtraKind
  24980. * - VertexBuffer.MatricesWeightsKind
  24981. * - VertexBuffer.MatricesWeightsExtraKind
  24982. * @returns an array of strings
  24983. */
  24984. getVerticesDataKinds(): string[];
  24985. /**
  24986. * Returns a positive integer : the total number of indices in this mesh geometry.
  24987. * @returns the numner of indices or zero if the mesh has no geometry.
  24988. */
  24989. getTotalIndices(): number;
  24990. /**
  24991. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24992. * @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.
  24993. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24994. * @returns the indices array or an empty array if the mesh has no geometry
  24995. */
  24996. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24997. get isBlocked(): boolean;
  24998. /**
  24999. * Determine if the current mesh is ready to be rendered
  25000. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25001. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25002. * @returns true if all associated assets are ready (material, textures, shaders)
  25003. */
  25004. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25005. /**
  25006. * 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.
  25007. */
  25008. get areNormalsFrozen(): boolean;
  25009. /**
  25010. * 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.
  25011. * @returns the current mesh
  25012. */
  25013. freezeNormals(): Mesh;
  25014. /**
  25015. * 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
  25016. * @returns the current mesh
  25017. */
  25018. unfreezeNormals(): Mesh;
  25019. /**
  25020. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25021. */
  25022. set overridenInstanceCount(count: number);
  25023. /** @hidden */
  25024. _preActivate(): Mesh;
  25025. /** @hidden */
  25026. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25027. /** @hidden */
  25028. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25029. /**
  25030. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25031. * This means the mesh underlying bounding box and sphere are recomputed.
  25032. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25033. * @returns the current mesh
  25034. */
  25035. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25036. /** @hidden */
  25037. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25038. /**
  25039. * This function will subdivide the mesh into multiple submeshes
  25040. * @param count defines the expected number of submeshes
  25041. */
  25042. subdivide(count: number): void;
  25043. /**
  25044. * Copy a FloatArray into a specific associated vertex buffer
  25045. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25046. * - VertexBuffer.PositionKind
  25047. * - VertexBuffer.UVKind
  25048. * - VertexBuffer.UV2Kind
  25049. * - VertexBuffer.UV3Kind
  25050. * - VertexBuffer.UV4Kind
  25051. * - VertexBuffer.UV5Kind
  25052. * - VertexBuffer.UV6Kind
  25053. * - VertexBuffer.ColorKind
  25054. * - VertexBuffer.MatricesIndicesKind
  25055. * - VertexBuffer.MatricesIndicesExtraKind
  25056. * - VertexBuffer.MatricesWeightsKind
  25057. * - VertexBuffer.MatricesWeightsExtraKind
  25058. * @param data defines the data source
  25059. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25060. * @param stride defines the data stride size (can be null)
  25061. * @returns the current mesh
  25062. */
  25063. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25064. /**
  25065. * Delete a vertex buffer associated with this mesh
  25066. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25067. * - VertexBuffer.PositionKind
  25068. * - VertexBuffer.UVKind
  25069. * - VertexBuffer.UV2Kind
  25070. * - VertexBuffer.UV3Kind
  25071. * - VertexBuffer.UV4Kind
  25072. * - VertexBuffer.UV5Kind
  25073. * - VertexBuffer.UV6Kind
  25074. * - VertexBuffer.ColorKind
  25075. * - VertexBuffer.MatricesIndicesKind
  25076. * - VertexBuffer.MatricesIndicesExtraKind
  25077. * - VertexBuffer.MatricesWeightsKind
  25078. * - VertexBuffer.MatricesWeightsExtraKind
  25079. */
  25080. removeVerticesData(kind: string): void;
  25081. /**
  25082. * Flags an associated vertex buffer as updatable
  25083. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25084. * - VertexBuffer.PositionKind
  25085. * - VertexBuffer.UVKind
  25086. * - VertexBuffer.UV2Kind
  25087. * - VertexBuffer.UV3Kind
  25088. * - VertexBuffer.UV4Kind
  25089. * - VertexBuffer.UV5Kind
  25090. * - VertexBuffer.UV6Kind
  25091. * - VertexBuffer.ColorKind
  25092. * - VertexBuffer.MatricesIndicesKind
  25093. * - VertexBuffer.MatricesIndicesExtraKind
  25094. * - VertexBuffer.MatricesWeightsKind
  25095. * - VertexBuffer.MatricesWeightsExtraKind
  25096. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25097. */
  25098. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25099. /**
  25100. * Sets the mesh global Vertex Buffer
  25101. * @param buffer defines the buffer to use
  25102. * @returns the current mesh
  25103. */
  25104. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25105. /**
  25106. * Update a specific associated vertex buffer
  25107. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25108. * - VertexBuffer.PositionKind
  25109. * - VertexBuffer.UVKind
  25110. * - VertexBuffer.UV2Kind
  25111. * - VertexBuffer.UV3Kind
  25112. * - VertexBuffer.UV4Kind
  25113. * - VertexBuffer.UV5Kind
  25114. * - VertexBuffer.UV6Kind
  25115. * - VertexBuffer.ColorKind
  25116. * - VertexBuffer.MatricesIndicesKind
  25117. * - VertexBuffer.MatricesIndicesExtraKind
  25118. * - VertexBuffer.MatricesWeightsKind
  25119. * - VertexBuffer.MatricesWeightsExtraKind
  25120. * @param data defines the data source
  25121. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25122. * @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)
  25123. * @returns the current mesh
  25124. */
  25125. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25126. /**
  25127. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25128. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25129. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25130. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25131. * @returns the current mesh
  25132. */
  25133. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25134. /**
  25135. * Creates a un-shared specific occurence of the geometry for the mesh.
  25136. * @returns the current mesh
  25137. */
  25138. makeGeometryUnique(): Mesh;
  25139. /**
  25140. * Set the index buffer of this mesh
  25141. * @param indices defines the source data
  25142. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25143. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25144. * @returns the current mesh
  25145. */
  25146. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25147. /**
  25148. * Update the current index buffer
  25149. * @param indices defines the source data
  25150. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25151. * @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)
  25152. * @returns the current mesh
  25153. */
  25154. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25155. /**
  25156. * Invert the geometry to move from a right handed system to a left handed one.
  25157. * @returns the current mesh
  25158. */
  25159. toLeftHanded(): Mesh;
  25160. /** @hidden */
  25161. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25162. /** @hidden */
  25163. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25164. /**
  25165. * Registers for this mesh a javascript function called just before the rendering process
  25166. * @param func defines the function to call before rendering this mesh
  25167. * @returns the current mesh
  25168. */
  25169. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25170. /**
  25171. * Disposes a previously registered javascript function called before the rendering
  25172. * @param func defines the function to remove
  25173. * @returns the current mesh
  25174. */
  25175. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25176. /**
  25177. * Registers for this mesh a javascript function called just after the rendering is complete
  25178. * @param func defines the function to call after rendering this mesh
  25179. * @returns the current mesh
  25180. */
  25181. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25182. /**
  25183. * Disposes a previously registered javascript function called after the rendering.
  25184. * @param func defines the function to remove
  25185. * @returns the current mesh
  25186. */
  25187. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25188. /** @hidden */
  25189. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25190. /** @hidden */
  25191. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25192. /** @hidden */
  25193. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25194. /** @hidden */
  25195. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25196. /** @hidden */
  25197. _rebuild(): void;
  25198. /** @hidden */
  25199. _freeze(): void;
  25200. /** @hidden */
  25201. _unFreeze(): void;
  25202. /**
  25203. * 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
  25204. * @param subMesh defines the subMesh to render
  25205. * @param enableAlphaMode defines if alpha mode can be changed
  25206. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25207. * @returns the current mesh
  25208. */
  25209. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25210. private _onBeforeDraw;
  25211. /**
  25212. * Renormalize the mesh and patch it up if there are no weights
  25213. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25214. * However in the case of zero weights then we set just a single influence to 1.
  25215. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25216. */
  25217. cleanMatrixWeights(): void;
  25218. private normalizeSkinFourWeights;
  25219. private normalizeSkinWeightsAndExtra;
  25220. /**
  25221. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25222. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25223. * the user know there was an issue with importing the mesh
  25224. * @returns a validation object with skinned, valid and report string
  25225. */
  25226. validateSkinning(): {
  25227. skinned: boolean;
  25228. valid: boolean;
  25229. report: string;
  25230. };
  25231. /** @hidden */
  25232. _checkDelayState(): Mesh;
  25233. private _queueLoad;
  25234. /**
  25235. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25236. * A mesh is in the frustum if its bounding box intersects the frustum
  25237. * @param frustumPlanes defines the frustum to test
  25238. * @returns true if the mesh is in the frustum planes
  25239. */
  25240. isInFrustum(frustumPlanes: Plane[]): boolean;
  25241. /**
  25242. * Sets the mesh material by the material or multiMaterial `id` property
  25243. * @param id is a string identifying the material or the multiMaterial
  25244. * @returns the current mesh
  25245. */
  25246. setMaterialByID(id: string): Mesh;
  25247. /**
  25248. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25249. * @returns an array of IAnimatable
  25250. */
  25251. getAnimatables(): IAnimatable[];
  25252. /**
  25253. * Modifies the mesh geometry according to the passed transformation matrix.
  25254. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25255. * The mesh normals are modified using the same transformation.
  25256. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25257. * @param transform defines the transform matrix to use
  25258. * @see http://doc.babylonjs.com/resources/baking_transformations
  25259. * @returns the current mesh
  25260. */
  25261. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25262. /**
  25263. * Modifies the mesh geometry according to its own current World Matrix.
  25264. * The mesh World Matrix is then reset.
  25265. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25266. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25267. * @see http://doc.babylonjs.com/resources/baking_transformations
  25268. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25269. * @returns the current mesh
  25270. */
  25271. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25272. /** @hidden */
  25273. get _positions(): Nullable<Vector3[]>;
  25274. /** @hidden */
  25275. _resetPointsArrayCache(): Mesh;
  25276. /** @hidden */
  25277. _generatePointsArray(): boolean;
  25278. /**
  25279. * Returns a new Mesh object generated from the current mesh properties.
  25280. * This method must not get confused with createInstance()
  25281. * @param name is a string, the name given to the new mesh
  25282. * @param newParent can be any Node object (default `null`)
  25283. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25284. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25285. * @returns a new mesh
  25286. */
  25287. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25288. /**
  25289. * Releases resources associated with this mesh.
  25290. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25291. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25292. */
  25293. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25294. /** @hidden */
  25295. _disposeInstanceSpecificData(): void;
  25296. /**
  25297. * Modifies the mesh geometry according to a displacement map.
  25298. * 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.
  25299. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25300. * @param url is a string, the URL from the image file is to be downloaded.
  25301. * @param minHeight is the lower limit of the displacement.
  25302. * @param maxHeight is the upper limit of the displacement.
  25303. * @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.
  25304. * @param uvOffset is an optional vector2 used to offset UV.
  25305. * @param uvScale is an optional vector2 used to scale UV.
  25306. * @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.
  25307. * @returns the Mesh.
  25308. */
  25309. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25310. /**
  25311. * Modifies the mesh geometry according to a displacementMap buffer.
  25312. * 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.
  25313. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25314. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25315. * @param heightMapWidth is the width of the buffer image.
  25316. * @param heightMapHeight is the height of the buffer image.
  25317. * @param minHeight is the lower limit of the displacement.
  25318. * @param maxHeight is the upper limit of the displacement.
  25319. * @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.
  25320. * @param uvOffset is an optional vector2 used to offset UV.
  25321. * @param uvScale is an optional vector2 used to scale UV.
  25322. * @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.
  25323. * @returns the Mesh.
  25324. */
  25325. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25326. /**
  25327. * Modify the mesh to get a flat shading rendering.
  25328. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25329. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25330. * @returns current mesh
  25331. */
  25332. convertToFlatShadedMesh(): Mesh;
  25333. /**
  25334. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25335. * In other words, more vertices, no more indices and a single bigger VBO.
  25336. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25337. * @returns current mesh
  25338. */
  25339. convertToUnIndexedMesh(): Mesh;
  25340. /**
  25341. * Inverses facet orientations.
  25342. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25343. * @param flipNormals will also inverts the normals
  25344. * @returns current mesh
  25345. */
  25346. flipFaces(flipNormals?: boolean): Mesh;
  25347. /**
  25348. * Increase the number of facets and hence vertices in a mesh
  25349. * Vertex normals are interpolated from existing vertex normals
  25350. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25351. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25352. */
  25353. increaseVertices(numberPerEdge: number): void;
  25354. /**
  25355. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25356. * This will undo any application of covertToFlatShadedMesh
  25357. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25358. */
  25359. forceSharedVertices(): void;
  25360. /** @hidden */
  25361. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25362. /** @hidden */
  25363. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25364. /**
  25365. * Creates a new InstancedMesh object from the mesh model.
  25366. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25367. * @param name defines the name of the new instance
  25368. * @returns a new InstancedMesh
  25369. */
  25370. createInstance(name: string): InstancedMesh;
  25371. /**
  25372. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25373. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25374. * @returns the current mesh
  25375. */
  25376. synchronizeInstances(): Mesh;
  25377. /**
  25378. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25379. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25380. * This should be used together with the simplification to avoid disappearing triangles.
  25381. * @param successCallback an optional success callback to be called after the optimization finished.
  25382. * @returns the current mesh
  25383. */
  25384. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25385. /**
  25386. * Serialize current mesh
  25387. * @param serializationObject defines the object which will receive the serialization data
  25388. */
  25389. serialize(serializationObject: any): void;
  25390. /** @hidden */
  25391. _syncGeometryWithMorphTargetManager(): void;
  25392. /** @hidden */
  25393. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25394. /**
  25395. * Returns a new Mesh object parsed from the source provided.
  25396. * @param parsedMesh is the source
  25397. * @param scene defines the hosting scene
  25398. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25399. * @returns a new Mesh
  25400. */
  25401. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25402. /**
  25403. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25404. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25405. * @param name defines the name of the mesh to create
  25406. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25407. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25408. * @param closePath creates a seam between the first and the last points of each path of the path array
  25409. * @param offset is taken in account only if the `pathArray` is containing a single path
  25410. * @param scene defines the hosting scene
  25411. * @param updatable defines if the mesh must be flagged as updatable
  25412. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25413. * @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)
  25414. * @returns a new Mesh
  25415. */
  25416. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25417. /**
  25418. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25419. * @param name defines the name of the mesh to create
  25420. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25421. * @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
  25422. * @param scene defines the hosting scene
  25423. * @param updatable defines if the mesh must be flagged as updatable
  25424. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25425. * @returns a new Mesh
  25426. */
  25427. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25428. /**
  25429. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25430. * @param name defines the name of the mesh to create
  25431. * @param size sets the size (float) of each box side (default 1)
  25432. * @param scene defines the hosting scene
  25433. * @param updatable defines if the mesh must be flagged as updatable
  25434. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25435. * @returns a new Mesh
  25436. */
  25437. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25438. /**
  25439. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25440. * @param name defines the name of the mesh to create
  25441. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25442. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25443. * @param scene defines the hosting scene
  25444. * @param updatable defines if the mesh must be flagged as updatable
  25445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25446. * @returns a new Mesh
  25447. */
  25448. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25449. /**
  25450. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25451. * @param name defines the name of the mesh to create
  25452. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25453. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25454. * @param scene defines the hosting scene
  25455. * @returns a new Mesh
  25456. */
  25457. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25458. /**
  25459. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25460. * @param name defines the name of the mesh to create
  25461. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25462. * @param diameterTop set the top cap diameter (floats, default 1)
  25463. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25464. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25465. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25466. * @param scene defines the hosting scene
  25467. * @param updatable defines if the mesh must be flagged as updatable
  25468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25469. * @returns a new Mesh
  25470. */
  25471. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25472. /**
  25473. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25474. * @param name defines the name of the mesh to create
  25475. * @param diameter sets the diameter size (float) of the torus (default 1)
  25476. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25477. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25478. * @param scene defines the hosting scene
  25479. * @param updatable defines if the mesh must be flagged as updatable
  25480. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25481. * @returns a new Mesh
  25482. */
  25483. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25484. /**
  25485. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25486. * @param name defines the name of the mesh to create
  25487. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25488. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25489. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25490. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25491. * @param p the number of windings on X axis (positive integers, default 2)
  25492. * @param q the number of windings on Y axis (positive integers, default 3)
  25493. * @param scene defines the hosting scene
  25494. * @param updatable defines if the mesh must be flagged as updatable
  25495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25496. * @returns a new Mesh
  25497. */
  25498. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25499. /**
  25500. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25501. * @param name defines the name of the mesh to create
  25502. * @param points is an array successive Vector3
  25503. * @param scene defines the hosting scene
  25504. * @param updatable defines if the mesh must be flagged as updatable
  25505. * @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).
  25506. * @returns a new Mesh
  25507. */
  25508. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25509. /**
  25510. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25511. * @param name defines the name of the mesh to create
  25512. * @param points is an array successive Vector3
  25513. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25514. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25515. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25516. * @param scene defines the hosting scene
  25517. * @param updatable defines if the mesh must be flagged as updatable
  25518. * @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)
  25519. * @returns a new Mesh
  25520. */
  25521. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25522. /**
  25523. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25524. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25525. * 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.
  25526. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25527. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25528. * Remember you can only change the shape positions, not their number when updating a polygon.
  25529. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25530. * @param name defines the name of the mesh to create
  25531. * @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
  25532. * @param scene defines the hosting scene
  25533. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25534. * @param updatable defines if the mesh must be flagged as updatable
  25535. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25536. * @param earcutInjection can be used to inject your own earcut reference
  25537. * @returns a new Mesh
  25538. */
  25539. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25540. /**
  25541. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25542. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25543. * @param name defines the name of the mesh to create
  25544. * @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
  25545. * @param depth defines the height of extrusion
  25546. * @param scene defines the hosting scene
  25547. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25548. * @param updatable defines if the mesh must be flagged as updatable
  25549. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25550. * @param earcutInjection can be used to inject your own earcut reference
  25551. * @returns a new Mesh
  25552. */
  25553. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25554. /**
  25555. * Creates an extruded shape mesh.
  25556. * 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
  25557. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25558. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25559. * @param name defines the name of the mesh to create
  25560. * @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
  25561. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25562. * @param scale is the value to scale the shape
  25563. * @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
  25564. * @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
  25565. * @param scene defines the hosting scene
  25566. * @param updatable defines if the mesh must be flagged as updatable
  25567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25568. * @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)
  25569. * @returns a new Mesh
  25570. */
  25571. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25572. /**
  25573. * Creates an custom extruded shape mesh.
  25574. * The custom extrusion is a parametric shape.
  25575. * It has no predefined shape. Its final shape will depend on the input parameters.
  25576. * Please consider using the same method from the MeshBuilder class instead
  25577. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25578. * @param name defines the name of the mesh to create
  25579. * @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
  25580. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25581. * @param scaleFunction is a custom Javascript function called on each path point
  25582. * @param rotationFunction is a custom Javascript function called on each path point
  25583. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25584. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25585. * @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
  25586. * @param scene defines the hosting scene
  25587. * @param updatable defines if the mesh must be flagged as updatable
  25588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25589. * @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)
  25590. * @returns a new Mesh
  25591. */
  25592. 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;
  25593. /**
  25594. * Creates lathe mesh.
  25595. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25596. * Please consider using the same method from the MeshBuilder class instead
  25597. * @param name defines the name of the mesh to create
  25598. * @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
  25599. * @param radius is the radius value of the lathe
  25600. * @param tessellation is the side number of the lathe.
  25601. * @param scene defines the hosting scene
  25602. * @param updatable defines if the mesh must be flagged as updatable
  25603. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25604. * @returns a new Mesh
  25605. */
  25606. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25607. /**
  25608. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25609. * @param name defines the name of the mesh to create
  25610. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25611. * @param scene defines the hosting scene
  25612. * @param updatable defines if the mesh must be flagged as updatable
  25613. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25614. * @returns a new Mesh
  25615. */
  25616. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25617. /**
  25618. * Creates a ground mesh.
  25619. * Please consider using the same method from the MeshBuilder class instead
  25620. * @param name defines the name of the mesh to create
  25621. * @param width set the width of the ground
  25622. * @param height set the height of the ground
  25623. * @param subdivisions sets the number of subdivisions per side
  25624. * @param scene defines the hosting scene
  25625. * @param updatable defines if the mesh must be flagged as updatable
  25626. * @returns a new Mesh
  25627. */
  25628. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25629. /**
  25630. * Creates a tiled ground mesh.
  25631. * Please consider using the same method from the MeshBuilder class instead
  25632. * @param name defines the name of the mesh to create
  25633. * @param xmin set the ground minimum X coordinate
  25634. * @param zmin set the ground minimum Y coordinate
  25635. * @param xmax set the ground maximum X coordinate
  25636. * @param zmax set the ground maximum Z coordinate
  25637. * @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
  25638. * @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
  25639. * @param scene defines the hosting scene
  25640. * @param updatable defines if the mesh must be flagged as updatable
  25641. * @returns a new Mesh
  25642. */
  25643. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25644. w: number;
  25645. h: number;
  25646. }, precision: {
  25647. w: number;
  25648. h: number;
  25649. }, scene: Scene, updatable?: boolean): Mesh;
  25650. /**
  25651. * Creates a ground mesh from a height map.
  25652. * Please consider using the same method from the MeshBuilder class instead
  25653. * @see http://doc.babylonjs.com/babylon101/height_map
  25654. * @param name defines the name of the mesh to create
  25655. * @param url sets the URL of the height map image resource
  25656. * @param width set the ground width size
  25657. * @param height set the ground height size
  25658. * @param subdivisions sets the number of subdivision per side
  25659. * @param minHeight is the minimum altitude on the ground
  25660. * @param maxHeight is the maximum altitude on the ground
  25661. * @param scene defines the hosting scene
  25662. * @param updatable defines if the mesh must be flagged as updatable
  25663. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25664. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25665. * @returns a new Mesh
  25666. */
  25667. 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;
  25668. /**
  25669. * Creates a tube mesh.
  25670. * The tube is a parametric shape.
  25671. * It has no predefined shape. Its final shape will depend on the input parameters.
  25672. * Please consider using the same method from the MeshBuilder class instead
  25673. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25674. * @param name defines the name of the mesh to create
  25675. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25676. * @param radius sets the tube radius size
  25677. * @param tessellation is the number of sides on the tubular surface
  25678. * @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
  25679. * @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
  25680. * @param scene defines the hosting scene
  25681. * @param updatable defines if the mesh must be flagged as updatable
  25682. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25683. * @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)
  25684. * @returns a new Mesh
  25685. */
  25686. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25687. (i: number, distance: number): number;
  25688. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25689. /**
  25690. * Creates a polyhedron mesh.
  25691. * Please consider using the same method from the MeshBuilder class instead.
  25692. * * 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
  25693. * * The parameter `size` (positive float, default 1) sets the polygon size
  25694. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25695. * * 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`
  25696. * * 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
  25697. * * 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)`)
  25698. * * 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
  25699. * * 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
  25700. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25701. * * 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
  25702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25703. * @param name defines the name of the mesh to create
  25704. * @param options defines the options used to create the mesh
  25705. * @param scene defines the hosting scene
  25706. * @returns a new Mesh
  25707. */
  25708. static CreatePolyhedron(name: string, options: {
  25709. type?: number;
  25710. size?: number;
  25711. sizeX?: number;
  25712. sizeY?: number;
  25713. sizeZ?: number;
  25714. custom?: any;
  25715. faceUV?: Vector4[];
  25716. faceColors?: Color4[];
  25717. updatable?: boolean;
  25718. sideOrientation?: number;
  25719. }, scene: Scene): Mesh;
  25720. /**
  25721. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25722. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25723. * * 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`)
  25724. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25725. * * 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
  25726. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25727. * * 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
  25728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25729. * @param name defines the name of the mesh
  25730. * @param options defines the options used to create the mesh
  25731. * @param scene defines the hosting scene
  25732. * @returns a new Mesh
  25733. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25734. */
  25735. static CreateIcoSphere(name: string, options: {
  25736. radius?: number;
  25737. flat?: boolean;
  25738. subdivisions?: number;
  25739. sideOrientation?: number;
  25740. updatable?: boolean;
  25741. }, scene: Scene): Mesh;
  25742. /**
  25743. * Creates a decal mesh.
  25744. * Please consider using the same method from the MeshBuilder class instead.
  25745. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25746. * @param name defines the name of the mesh
  25747. * @param sourceMesh defines the mesh receiving the decal
  25748. * @param position sets the position of the decal in world coordinates
  25749. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25750. * @param size sets the decal scaling
  25751. * @param angle sets the angle to rotate the decal
  25752. * @returns a new Mesh
  25753. */
  25754. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25755. /**
  25756. * Prepare internal position array for software CPU skinning
  25757. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25758. */
  25759. setPositionsForCPUSkinning(): Float32Array;
  25760. /**
  25761. * Prepare internal normal array for software CPU skinning
  25762. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25763. */
  25764. setNormalsForCPUSkinning(): Float32Array;
  25765. /**
  25766. * Updates the vertex buffer by applying transformation from the bones
  25767. * @param skeleton defines the skeleton to apply to current mesh
  25768. * @returns the current mesh
  25769. */
  25770. applySkeleton(skeleton: Skeleton): Mesh;
  25771. /**
  25772. * 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
  25773. * @param meshes defines the list of meshes to scan
  25774. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25775. */
  25776. static MinMax(meshes: AbstractMesh[]): {
  25777. min: Vector3;
  25778. max: Vector3;
  25779. };
  25780. /**
  25781. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25782. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25783. * @returns a vector3
  25784. */
  25785. static Center(meshesOrMinMaxVector: {
  25786. min: Vector3;
  25787. max: Vector3;
  25788. } | AbstractMesh[]): Vector3;
  25789. /**
  25790. * Merge the array of meshes into a single mesh for performance reasons.
  25791. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25792. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25793. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25794. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25795. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25796. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25797. * @returns a new mesh
  25798. */
  25799. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25800. /** @hidden */
  25801. addInstance(instance: InstancedMesh): void;
  25802. /** @hidden */
  25803. removeInstance(instance: InstancedMesh): void;
  25804. }
  25805. }
  25806. declare module BABYLON {
  25807. /**
  25808. * This is the base class of all the camera used in the application.
  25809. * @see http://doc.babylonjs.com/features/cameras
  25810. */
  25811. export class Camera extends Node {
  25812. /** @hidden */
  25813. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25814. /**
  25815. * This is the default projection mode used by the cameras.
  25816. * It helps recreating a feeling of perspective and better appreciate depth.
  25817. * This is the best way to simulate real life cameras.
  25818. */
  25819. static readonly PERSPECTIVE_CAMERA: number;
  25820. /**
  25821. * This helps creating camera with an orthographic mode.
  25822. * 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.
  25823. */
  25824. static readonly ORTHOGRAPHIC_CAMERA: number;
  25825. /**
  25826. * This is the default FOV mode for perspective cameras.
  25827. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25828. */
  25829. static readonly FOVMODE_VERTICAL_FIXED: number;
  25830. /**
  25831. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25832. */
  25833. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25834. /**
  25835. * This specifies ther is no need for a camera rig.
  25836. * Basically only one eye is rendered corresponding to the camera.
  25837. */
  25838. static readonly RIG_MODE_NONE: number;
  25839. /**
  25840. * Simulates a camera Rig with one blue eye and one red eye.
  25841. * This can be use with 3d blue and red glasses.
  25842. */
  25843. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25844. /**
  25845. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25846. */
  25847. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25848. /**
  25849. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25850. */
  25851. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25852. /**
  25853. * Defines that both eyes of the camera will be rendered over under each other.
  25854. */
  25855. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25856. /**
  25857. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25858. */
  25859. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25860. /**
  25861. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25862. */
  25863. static readonly RIG_MODE_VR: number;
  25864. /**
  25865. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25866. */
  25867. static readonly RIG_MODE_WEBVR: number;
  25868. /**
  25869. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25870. */
  25871. static readonly RIG_MODE_CUSTOM: number;
  25872. /**
  25873. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25874. */
  25875. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25876. /**
  25877. * Define the input manager associated with the camera.
  25878. */
  25879. inputs: CameraInputsManager<Camera>;
  25880. /** @hidden */
  25881. _position: Vector3;
  25882. /**
  25883. * Define the current local position of the camera in the scene
  25884. */
  25885. get position(): Vector3;
  25886. set position(newPosition: Vector3);
  25887. /**
  25888. * The vector the camera should consider as up.
  25889. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25890. */
  25891. upVector: Vector3;
  25892. /**
  25893. * Define the current limit on the left side for an orthographic camera
  25894. * In scene unit
  25895. */
  25896. orthoLeft: Nullable<number>;
  25897. /**
  25898. * Define the current limit on the right side for an orthographic camera
  25899. * In scene unit
  25900. */
  25901. orthoRight: Nullable<number>;
  25902. /**
  25903. * Define the current limit on the bottom side for an orthographic camera
  25904. * In scene unit
  25905. */
  25906. orthoBottom: Nullable<number>;
  25907. /**
  25908. * Define the current limit on the top side for an orthographic camera
  25909. * In scene unit
  25910. */
  25911. orthoTop: Nullable<number>;
  25912. /**
  25913. * Field Of View is set in Radians. (default is 0.8)
  25914. */
  25915. fov: number;
  25916. /**
  25917. * Define the minimum distance the camera can see from.
  25918. * This is important to note that the depth buffer are not infinite and the closer it starts
  25919. * the more your scene might encounter depth fighting issue.
  25920. */
  25921. minZ: number;
  25922. /**
  25923. * Define the maximum distance the camera can see to.
  25924. * This is important to note that the depth buffer are not infinite and the further it end
  25925. * the more your scene might encounter depth fighting issue.
  25926. */
  25927. maxZ: number;
  25928. /**
  25929. * Define the default inertia of the camera.
  25930. * This helps giving a smooth feeling to the camera movement.
  25931. */
  25932. inertia: number;
  25933. /**
  25934. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25935. */
  25936. mode: number;
  25937. /**
  25938. * Define whether the camera is intermediate.
  25939. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25940. */
  25941. isIntermediate: boolean;
  25942. /**
  25943. * Define the viewport of the camera.
  25944. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25945. */
  25946. viewport: Viewport;
  25947. /**
  25948. * Restricts the camera to viewing objects with the same layerMask.
  25949. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25950. */
  25951. layerMask: number;
  25952. /**
  25953. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25954. */
  25955. fovMode: number;
  25956. /**
  25957. * Rig mode of the camera.
  25958. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25959. * This is normally controlled byt the camera themselves as internal use.
  25960. */
  25961. cameraRigMode: number;
  25962. /**
  25963. * Defines the distance between both "eyes" in case of a RIG
  25964. */
  25965. interaxialDistance: number;
  25966. /**
  25967. * Defines if stereoscopic rendering is done side by side or over under.
  25968. */
  25969. isStereoscopicSideBySide: boolean;
  25970. /**
  25971. * 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
  25972. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25973. * else in the scene. (Eg. security camera)
  25974. *
  25975. * 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)
  25976. */
  25977. customRenderTargets: RenderTargetTexture[];
  25978. /**
  25979. * When set, the camera will render to this render target instead of the default canvas
  25980. *
  25981. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25982. */
  25983. outputRenderTarget: Nullable<RenderTargetTexture>;
  25984. /**
  25985. * Observable triggered when the camera view matrix has changed.
  25986. */
  25987. onViewMatrixChangedObservable: Observable<Camera>;
  25988. /**
  25989. * Observable triggered when the camera Projection matrix has changed.
  25990. */
  25991. onProjectionMatrixChangedObservable: Observable<Camera>;
  25992. /**
  25993. * Observable triggered when the inputs have been processed.
  25994. */
  25995. onAfterCheckInputsObservable: Observable<Camera>;
  25996. /**
  25997. * Observable triggered when reset has been called and applied to the camera.
  25998. */
  25999. onRestoreStateObservable: Observable<Camera>;
  26000. /**
  26001. * Is this camera a part of a rig system?
  26002. */
  26003. isRigCamera: boolean;
  26004. /**
  26005. * If isRigCamera set to true this will be set with the parent camera.
  26006. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26007. */
  26008. rigParent?: Camera;
  26009. /** @hidden */
  26010. _cameraRigParams: any;
  26011. /** @hidden */
  26012. _rigCameras: Camera[];
  26013. /** @hidden */
  26014. _rigPostProcess: Nullable<PostProcess>;
  26015. protected _webvrViewMatrix: Matrix;
  26016. /** @hidden */
  26017. _skipRendering: boolean;
  26018. /** @hidden */
  26019. _projectionMatrix: Matrix;
  26020. /** @hidden */
  26021. _postProcesses: Nullable<PostProcess>[];
  26022. /** @hidden */
  26023. _activeMeshes: SmartArray<AbstractMesh>;
  26024. protected _globalPosition: Vector3;
  26025. /** @hidden */
  26026. _computedViewMatrix: Matrix;
  26027. private _doNotComputeProjectionMatrix;
  26028. private _transformMatrix;
  26029. private _frustumPlanes;
  26030. private _refreshFrustumPlanes;
  26031. private _storedFov;
  26032. private _stateStored;
  26033. /**
  26034. * Instantiates a new camera object.
  26035. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26036. * @see http://doc.babylonjs.com/features/cameras
  26037. * @param name Defines the name of the camera in the scene
  26038. * @param position Defines the position of the camera
  26039. * @param scene Defines the scene the camera belongs too
  26040. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26041. */
  26042. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26043. /**
  26044. * Store current camera state (fov, position, etc..)
  26045. * @returns the camera
  26046. */
  26047. storeState(): Camera;
  26048. /**
  26049. * Restores the camera state values if it has been stored. You must call storeState() first
  26050. */
  26051. protected _restoreStateValues(): boolean;
  26052. /**
  26053. * Restored camera state. You must call storeState() first.
  26054. * @returns true if restored and false otherwise
  26055. */
  26056. restoreState(): boolean;
  26057. /**
  26058. * Gets the class name of the camera.
  26059. * @returns the class name
  26060. */
  26061. getClassName(): string;
  26062. /** @hidden */
  26063. readonly _isCamera: boolean;
  26064. /**
  26065. * Gets a string representation of the camera useful for debug purpose.
  26066. * @param fullDetails Defines that a more verboe level of logging is required
  26067. * @returns the string representation
  26068. */
  26069. toString(fullDetails?: boolean): string;
  26070. /**
  26071. * Gets the current world space position of the camera.
  26072. */
  26073. get globalPosition(): Vector3;
  26074. /**
  26075. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26076. * @returns the active meshe list
  26077. */
  26078. getActiveMeshes(): SmartArray<AbstractMesh>;
  26079. /**
  26080. * Check whether a mesh is part of the current active mesh list of the camera
  26081. * @param mesh Defines the mesh to check
  26082. * @returns true if active, false otherwise
  26083. */
  26084. isActiveMesh(mesh: Mesh): boolean;
  26085. /**
  26086. * Is this camera ready to be used/rendered
  26087. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26088. * @return true if the camera is ready
  26089. */
  26090. isReady(completeCheck?: boolean): boolean;
  26091. /** @hidden */
  26092. _initCache(): void;
  26093. /** @hidden */
  26094. _updateCache(ignoreParentClass?: boolean): void;
  26095. /** @hidden */
  26096. _isSynchronized(): boolean;
  26097. /** @hidden */
  26098. _isSynchronizedViewMatrix(): boolean;
  26099. /** @hidden */
  26100. _isSynchronizedProjectionMatrix(): boolean;
  26101. /**
  26102. * Attach the input controls to a specific dom element to get the input from.
  26103. * @param element Defines the element the controls should be listened from
  26104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26105. */
  26106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26107. /**
  26108. * Detach the current controls from the specified dom element.
  26109. * @param element Defines the element to stop listening the inputs from
  26110. */
  26111. detachControl(element: HTMLElement): void;
  26112. /**
  26113. * Update the camera state according to the different inputs gathered during the frame.
  26114. */
  26115. update(): void;
  26116. /** @hidden */
  26117. _checkInputs(): void;
  26118. /** @hidden */
  26119. get rigCameras(): Camera[];
  26120. /**
  26121. * Gets the post process used by the rig cameras
  26122. */
  26123. get rigPostProcess(): Nullable<PostProcess>;
  26124. /**
  26125. * Internal, gets the first post proces.
  26126. * @returns the first post process to be run on this camera.
  26127. */
  26128. _getFirstPostProcess(): Nullable<PostProcess>;
  26129. private _cascadePostProcessesToRigCams;
  26130. /**
  26131. * Attach a post process to the camera.
  26132. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26133. * @param postProcess The post process to attach to the camera
  26134. * @param insertAt The position of the post process in case several of them are in use in the scene
  26135. * @returns the position the post process has been inserted at
  26136. */
  26137. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26138. /**
  26139. * Detach a post process to the camera.
  26140. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26141. * @param postProcess The post process to detach from the camera
  26142. */
  26143. detachPostProcess(postProcess: PostProcess): void;
  26144. /**
  26145. * Gets the current world matrix of the camera
  26146. */
  26147. getWorldMatrix(): Matrix;
  26148. /** @hidden */
  26149. _getViewMatrix(): Matrix;
  26150. /**
  26151. * Gets the current view matrix of the camera.
  26152. * @param force forces the camera to recompute the matrix without looking at the cached state
  26153. * @returns the view matrix
  26154. */
  26155. getViewMatrix(force?: boolean): Matrix;
  26156. /**
  26157. * Freeze the projection matrix.
  26158. * It will prevent the cache check of the camera projection compute and can speed up perf
  26159. * if no parameter of the camera are meant to change
  26160. * @param projection Defines manually a projection if necessary
  26161. */
  26162. freezeProjectionMatrix(projection?: Matrix): void;
  26163. /**
  26164. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26165. */
  26166. unfreezeProjectionMatrix(): void;
  26167. /**
  26168. * Gets the current projection matrix of the camera.
  26169. * @param force forces the camera to recompute the matrix without looking at the cached state
  26170. * @returns the projection matrix
  26171. */
  26172. getProjectionMatrix(force?: boolean): Matrix;
  26173. /**
  26174. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26175. * @returns a Matrix
  26176. */
  26177. getTransformationMatrix(): Matrix;
  26178. private _updateFrustumPlanes;
  26179. /**
  26180. * Checks if a cullable object (mesh...) is in the camera frustum
  26181. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26182. * @param target The object to check
  26183. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26184. * @returns true if the object is in frustum otherwise false
  26185. */
  26186. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26187. /**
  26188. * Checks if a cullable object (mesh...) is in the camera frustum
  26189. * Unlike isInFrustum this cheks the full bounding box
  26190. * @param target The object to check
  26191. * @returns true if the object is in frustum otherwise false
  26192. */
  26193. isCompletelyInFrustum(target: ICullable): boolean;
  26194. /**
  26195. * Gets a ray in the forward direction from the camera.
  26196. * @param length Defines the length of the ray to create
  26197. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26198. * @param origin Defines the start point of the ray which defaults to the camera position
  26199. * @returns the forward ray
  26200. */
  26201. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26202. /**
  26203. * Releases resources associated with this node.
  26204. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26205. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26206. */
  26207. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26208. /** @hidden */
  26209. _isLeftCamera: boolean;
  26210. /**
  26211. * Gets the left camera of a rig setup in case of Rigged Camera
  26212. */
  26213. get isLeftCamera(): boolean;
  26214. /** @hidden */
  26215. _isRightCamera: boolean;
  26216. /**
  26217. * Gets the right camera of a rig setup in case of Rigged Camera
  26218. */
  26219. get isRightCamera(): boolean;
  26220. /**
  26221. * Gets the left camera of a rig setup in case of Rigged Camera
  26222. */
  26223. get leftCamera(): Nullable<FreeCamera>;
  26224. /**
  26225. * Gets the right camera of a rig setup in case of Rigged Camera
  26226. */
  26227. get rightCamera(): Nullable<FreeCamera>;
  26228. /**
  26229. * Gets the left camera target of a rig setup in case of Rigged Camera
  26230. * @returns the target position
  26231. */
  26232. getLeftTarget(): Nullable<Vector3>;
  26233. /**
  26234. * Gets the right camera target of a rig setup in case of Rigged Camera
  26235. * @returns the target position
  26236. */
  26237. getRightTarget(): Nullable<Vector3>;
  26238. /**
  26239. * @hidden
  26240. */
  26241. setCameraRigMode(mode: number, rigParams: any): void;
  26242. /** @hidden */
  26243. static _setStereoscopicRigMode(camera: Camera): void;
  26244. /** @hidden */
  26245. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26246. /** @hidden */
  26247. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26248. /** @hidden */
  26249. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26250. /** @hidden */
  26251. _getVRProjectionMatrix(): Matrix;
  26252. protected _updateCameraRotationMatrix(): void;
  26253. protected _updateWebVRCameraRotationMatrix(): void;
  26254. /**
  26255. * This function MUST be overwritten by the different WebVR cameras available.
  26256. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26257. * @hidden
  26258. */
  26259. _getWebVRProjectionMatrix(): Matrix;
  26260. /**
  26261. * This function MUST be overwritten by the different WebVR cameras available.
  26262. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26263. * @hidden
  26264. */
  26265. _getWebVRViewMatrix(): Matrix;
  26266. /** @hidden */
  26267. setCameraRigParameter(name: string, value: any): void;
  26268. /**
  26269. * needs to be overridden by children so sub has required properties to be copied
  26270. * @hidden
  26271. */
  26272. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26273. /**
  26274. * May need to be overridden by children
  26275. * @hidden
  26276. */
  26277. _updateRigCameras(): void;
  26278. /** @hidden */
  26279. _setupInputs(): void;
  26280. /**
  26281. * Serialiaze the camera setup to a json represention
  26282. * @returns the JSON representation
  26283. */
  26284. serialize(): any;
  26285. /**
  26286. * Clones the current camera.
  26287. * @param name The cloned camera name
  26288. * @returns the cloned camera
  26289. */
  26290. clone(name: string): Camera;
  26291. /**
  26292. * Gets the direction of the camera relative to a given local axis.
  26293. * @param localAxis Defines the reference axis to provide a relative direction.
  26294. * @return the direction
  26295. */
  26296. getDirection(localAxis: Vector3): Vector3;
  26297. /**
  26298. * Returns the current camera absolute rotation
  26299. */
  26300. get absoluteRotation(): Quaternion;
  26301. /**
  26302. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26303. * @param localAxis Defines the reference axis to provide a relative direction.
  26304. * @param result Defines the vector to store the result in
  26305. */
  26306. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26307. /**
  26308. * Gets a camera constructor for a given camera type
  26309. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26310. * @param name The name of the camera the result will be able to instantiate
  26311. * @param scene The scene the result will construct the camera in
  26312. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26313. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26314. * @returns a factory method to construc the camera
  26315. */
  26316. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26317. /**
  26318. * Compute the world matrix of the camera.
  26319. * @returns the camera world matrix
  26320. */
  26321. computeWorldMatrix(): Matrix;
  26322. /**
  26323. * Parse a JSON and creates the camera from the parsed information
  26324. * @param parsedCamera The JSON to parse
  26325. * @param scene The scene to instantiate the camera in
  26326. * @returns the newly constructed camera
  26327. */
  26328. static Parse(parsedCamera: any, scene: Scene): Camera;
  26329. }
  26330. }
  26331. declare module BABYLON {
  26332. /**
  26333. * Class containing static functions to help procedurally build meshes
  26334. */
  26335. export class DiscBuilder {
  26336. /**
  26337. * Creates a plane polygonal mesh. By default, this is a disc
  26338. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26339. * * 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
  26340. * * 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
  26341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26342. * * 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
  26343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26344. * @param name defines the name of the mesh
  26345. * @param options defines the options used to create the mesh
  26346. * @param scene defines the hosting scene
  26347. * @returns the plane polygonal mesh
  26348. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26349. */
  26350. static CreateDisc(name: string, options: {
  26351. radius?: number;
  26352. tessellation?: number;
  26353. arc?: number;
  26354. updatable?: boolean;
  26355. sideOrientation?: number;
  26356. frontUVs?: Vector4;
  26357. backUVs?: Vector4;
  26358. }, scene?: Nullable<Scene>): Mesh;
  26359. }
  26360. }
  26361. declare module BABYLON {
  26362. /**
  26363. * Options to be used when creating a FresnelParameters.
  26364. */
  26365. export type IFresnelParametersCreationOptions = {
  26366. /**
  26367. * Define the color used on edges (grazing angle)
  26368. */
  26369. leftColor?: Color3;
  26370. /**
  26371. * Define the color used on center
  26372. */
  26373. rightColor?: Color3;
  26374. /**
  26375. * Define bias applied to computed fresnel term
  26376. */
  26377. bias?: number;
  26378. /**
  26379. * Defined the power exponent applied to fresnel term
  26380. */
  26381. power?: number;
  26382. /**
  26383. * Define if the fresnel effect is enable or not.
  26384. */
  26385. isEnabled?: boolean;
  26386. };
  26387. /**
  26388. * Serialized format for FresnelParameters.
  26389. */
  26390. export type IFresnelParametersSerialized = {
  26391. /**
  26392. * Define the color used on edges (grazing angle) [as an array]
  26393. */
  26394. leftColor: number[];
  26395. /**
  26396. * Define the color used on center [as an array]
  26397. */
  26398. rightColor: number[];
  26399. /**
  26400. * Define bias applied to computed fresnel term
  26401. */
  26402. bias: number;
  26403. /**
  26404. * Defined the power exponent applied to fresnel term
  26405. */
  26406. power?: number;
  26407. /**
  26408. * Define if the fresnel effect is enable or not.
  26409. */
  26410. isEnabled: boolean;
  26411. };
  26412. /**
  26413. * This represents all the required information to add a fresnel effect on a material:
  26414. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26415. */
  26416. export class FresnelParameters {
  26417. private _isEnabled;
  26418. /**
  26419. * Define if the fresnel effect is enable or not.
  26420. */
  26421. get isEnabled(): boolean;
  26422. set isEnabled(value: boolean);
  26423. /**
  26424. * Define the color used on edges (grazing angle)
  26425. */
  26426. leftColor: Color3;
  26427. /**
  26428. * Define the color used on center
  26429. */
  26430. rightColor: Color3;
  26431. /**
  26432. * Define bias applied to computed fresnel term
  26433. */
  26434. bias: number;
  26435. /**
  26436. * Defined the power exponent applied to fresnel term
  26437. */
  26438. power: number;
  26439. /**
  26440. * Creates a new FresnelParameters object.
  26441. *
  26442. * @param options provide your own settings to optionally to override defaults
  26443. */
  26444. constructor(options?: IFresnelParametersCreationOptions);
  26445. /**
  26446. * Clones the current fresnel and its valuues
  26447. * @returns a clone fresnel configuration
  26448. */
  26449. clone(): FresnelParameters;
  26450. /**
  26451. * Determines equality between FresnelParameters objects
  26452. * @param otherFresnelParameters defines the second operand
  26453. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26454. */
  26455. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26456. /**
  26457. * Serializes the current fresnel parameters to a JSON representation.
  26458. * @return the JSON serialization
  26459. */
  26460. serialize(): IFresnelParametersSerialized;
  26461. /**
  26462. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26463. * @param parsedFresnelParameters Define the JSON representation
  26464. * @returns the parsed parameters
  26465. */
  26466. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26467. }
  26468. }
  26469. declare module BABYLON {
  26470. /**
  26471. * Base class of materials working in push mode in babylon JS
  26472. * @hidden
  26473. */
  26474. export class PushMaterial extends Material {
  26475. protected _activeEffect: Effect;
  26476. protected _normalMatrix: Matrix;
  26477. /**
  26478. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26479. * This means that the material can keep using a previous shader while a new one is being compiled.
  26480. * This is mostly used when shader parallel compilation is supported (true by default)
  26481. */
  26482. allowShaderHotSwapping: boolean;
  26483. constructor(name: string, scene: Scene);
  26484. getEffect(): Effect;
  26485. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26486. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26487. /**
  26488. * Binds the given world matrix to the active effect
  26489. *
  26490. * @param world the matrix to bind
  26491. */
  26492. bindOnlyWorldMatrix(world: Matrix): void;
  26493. /**
  26494. * Binds the given normal matrix to the active effect
  26495. *
  26496. * @param normalMatrix the matrix to bind
  26497. */
  26498. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26499. bind(world: Matrix, mesh?: Mesh): void;
  26500. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26501. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26502. }
  26503. }
  26504. declare module BABYLON {
  26505. /**
  26506. * This groups all the flags used to control the materials channel.
  26507. */
  26508. export class MaterialFlags {
  26509. private static _DiffuseTextureEnabled;
  26510. /**
  26511. * Are diffuse textures enabled in the application.
  26512. */
  26513. static get DiffuseTextureEnabled(): boolean;
  26514. static set DiffuseTextureEnabled(value: boolean);
  26515. private static _AmbientTextureEnabled;
  26516. /**
  26517. * Are ambient textures enabled in the application.
  26518. */
  26519. static get AmbientTextureEnabled(): boolean;
  26520. static set AmbientTextureEnabled(value: boolean);
  26521. private static _OpacityTextureEnabled;
  26522. /**
  26523. * Are opacity textures enabled in the application.
  26524. */
  26525. static get OpacityTextureEnabled(): boolean;
  26526. static set OpacityTextureEnabled(value: boolean);
  26527. private static _ReflectionTextureEnabled;
  26528. /**
  26529. * Are reflection textures enabled in the application.
  26530. */
  26531. static get ReflectionTextureEnabled(): boolean;
  26532. static set ReflectionTextureEnabled(value: boolean);
  26533. private static _EmissiveTextureEnabled;
  26534. /**
  26535. * Are emissive textures enabled in the application.
  26536. */
  26537. static get EmissiveTextureEnabled(): boolean;
  26538. static set EmissiveTextureEnabled(value: boolean);
  26539. private static _SpecularTextureEnabled;
  26540. /**
  26541. * Are specular textures enabled in the application.
  26542. */
  26543. static get SpecularTextureEnabled(): boolean;
  26544. static set SpecularTextureEnabled(value: boolean);
  26545. private static _BumpTextureEnabled;
  26546. /**
  26547. * Are bump textures enabled in the application.
  26548. */
  26549. static get BumpTextureEnabled(): boolean;
  26550. static set BumpTextureEnabled(value: boolean);
  26551. private static _LightmapTextureEnabled;
  26552. /**
  26553. * Are lightmap textures enabled in the application.
  26554. */
  26555. static get LightmapTextureEnabled(): boolean;
  26556. static set LightmapTextureEnabled(value: boolean);
  26557. private static _RefractionTextureEnabled;
  26558. /**
  26559. * Are refraction textures enabled in the application.
  26560. */
  26561. static get RefractionTextureEnabled(): boolean;
  26562. static set RefractionTextureEnabled(value: boolean);
  26563. private static _ColorGradingTextureEnabled;
  26564. /**
  26565. * Are color grading textures enabled in the application.
  26566. */
  26567. static get ColorGradingTextureEnabled(): boolean;
  26568. static set ColorGradingTextureEnabled(value: boolean);
  26569. private static _FresnelEnabled;
  26570. /**
  26571. * Are fresnels enabled in the application.
  26572. */
  26573. static get FresnelEnabled(): boolean;
  26574. static set FresnelEnabled(value: boolean);
  26575. private static _ClearCoatTextureEnabled;
  26576. /**
  26577. * Are clear coat textures enabled in the application.
  26578. */
  26579. static get ClearCoatTextureEnabled(): boolean;
  26580. static set ClearCoatTextureEnabled(value: boolean);
  26581. private static _ClearCoatBumpTextureEnabled;
  26582. /**
  26583. * Are clear coat bump textures enabled in the application.
  26584. */
  26585. static get ClearCoatBumpTextureEnabled(): boolean;
  26586. static set ClearCoatBumpTextureEnabled(value: boolean);
  26587. private static _ClearCoatTintTextureEnabled;
  26588. /**
  26589. * Are clear coat tint textures enabled in the application.
  26590. */
  26591. static get ClearCoatTintTextureEnabled(): boolean;
  26592. static set ClearCoatTintTextureEnabled(value: boolean);
  26593. private static _SheenTextureEnabled;
  26594. /**
  26595. * Are sheen textures enabled in the application.
  26596. */
  26597. static get SheenTextureEnabled(): boolean;
  26598. static set SheenTextureEnabled(value: boolean);
  26599. private static _AnisotropicTextureEnabled;
  26600. /**
  26601. * Are anisotropic textures enabled in the application.
  26602. */
  26603. static get AnisotropicTextureEnabled(): boolean;
  26604. static set AnisotropicTextureEnabled(value: boolean);
  26605. private static _ThicknessTextureEnabled;
  26606. /**
  26607. * Are thickness textures enabled in the application.
  26608. */
  26609. static get ThicknessTextureEnabled(): boolean;
  26610. static set ThicknessTextureEnabled(value: boolean);
  26611. }
  26612. }
  26613. declare module BABYLON {
  26614. /** @hidden */
  26615. export var defaultFragmentDeclaration: {
  26616. name: string;
  26617. shader: string;
  26618. };
  26619. }
  26620. declare module BABYLON {
  26621. /** @hidden */
  26622. export var defaultUboDeclaration: {
  26623. name: string;
  26624. shader: string;
  26625. };
  26626. }
  26627. declare module BABYLON {
  26628. /** @hidden */
  26629. export var lightFragmentDeclaration: {
  26630. name: string;
  26631. shader: string;
  26632. };
  26633. }
  26634. declare module BABYLON {
  26635. /** @hidden */
  26636. export var lightUboDeclaration: {
  26637. name: string;
  26638. shader: string;
  26639. };
  26640. }
  26641. declare module BABYLON {
  26642. /** @hidden */
  26643. export var lightsFragmentFunctions: {
  26644. name: string;
  26645. shader: string;
  26646. };
  26647. }
  26648. declare module BABYLON {
  26649. /** @hidden */
  26650. export var shadowsFragmentFunctions: {
  26651. name: string;
  26652. shader: string;
  26653. };
  26654. }
  26655. declare module BABYLON {
  26656. /** @hidden */
  26657. export var fresnelFunction: {
  26658. name: string;
  26659. shader: string;
  26660. };
  26661. }
  26662. declare module BABYLON {
  26663. /** @hidden */
  26664. export var reflectionFunction: {
  26665. name: string;
  26666. shader: string;
  26667. };
  26668. }
  26669. declare module BABYLON {
  26670. /** @hidden */
  26671. export var bumpFragmentFunctions: {
  26672. name: string;
  26673. shader: string;
  26674. };
  26675. }
  26676. declare module BABYLON {
  26677. /** @hidden */
  26678. export var logDepthDeclaration: {
  26679. name: string;
  26680. shader: string;
  26681. };
  26682. }
  26683. declare module BABYLON {
  26684. /** @hidden */
  26685. export var bumpFragment: {
  26686. name: string;
  26687. shader: string;
  26688. };
  26689. }
  26690. declare module BABYLON {
  26691. /** @hidden */
  26692. export var depthPrePass: {
  26693. name: string;
  26694. shader: string;
  26695. };
  26696. }
  26697. declare module BABYLON {
  26698. /** @hidden */
  26699. export var lightFragment: {
  26700. name: string;
  26701. shader: string;
  26702. };
  26703. }
  26704. declare module BABYLON {
  26705. /** @hidden */
  26706. export var logDepthFragment: {
  26707. name: string;
  26708. shader: string;
  26709. };
  26710. }
  26711. declare module BABYLON {
  26712. /** @hidden */
  26713. export var defaultPixelShader: {
  26714. name: string;
  26715. shader: string;
  26716. };
  26717. }
  26718. declare module BABYLON {
  26719. /** @hidden */
  26720. export var defaultVertexDeclaration: {
  26721. name: string;
  26722. shader: string;
  26723. };
  26724. }
  26725. declare module BABYLON {
  26726. /** @hidden */
  26727. export var bumpVertexDeclaration: {
  26728. name: string;
  26729. shader: string;
  26730. };
  26731. }
  26732. declare module BABYLON {
  26733. /** @hidden */
  26734. export var bumpVertex: {
  26735. name: string;
  26736. shader: string;
  26737. };
  26738. }
  26739. declare module BABYLON {
  26740. /** @hidden */
  26741. export var fogVertex: {
  26742. name: string;
  26743. shader: string;
  26744. };
  26745. }
  26746. declare module BABYLON {
  26747. /** @hidden */
  26748. export var shadowsVertex: {
  26749. name: string;
  26750. shader: string;
  26751. };
  26752. }
  26753. declare module BABYLON {
  26754. /** @hidden */
  26755. export var pointCloudVertex: {
  26756. name: string;
  26757. shader: string;
  26758. };
  26759. }
  26760. declare module BABYLON {
  26761. /** @hidden */
  26762. export var logDepthVertex: {
  26763. name: string;
  26764. shader: string;
  26765. };
  26766. }
  26767. declare module BABYLON {
  26768. /** @hidden */
  26769. export var defaultVertexShader: {
  26770. name: string;
  26771. shader: string;
  26772. };
  26773. }
  26774. declare module BABYLON {
  26775. /** @hidden */
  26776. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26777. MAINUV1: boolean;
  26778. MAINUV2: boolean;
  26779. DIFFUSE: boolean;
  26780. DIFFUSEDIRECTUV: number;
  26781. AMBIENT: boolean;
  26782. AMBIENTDIRECTUV: number;
  26783. OPACITY: boolean;
  26784. OPACITYDIRECTUV: number;
  26785. OPACITYRGB: boolean;
  26786. REFLECTION: boolean;
  26787. EMISSIVE: boolean;
  26788. EMISSIVEDIRECTUV: number;
  26789. SPECULAR: boolean;
  26790. SPECULARDIRECTUV: number;
  26791. BUMP: boolean;
  26792. BUMPDIRECTUV: number;
  26793. PARALLAX: boolean;
  26794. PARALLAXOCCLUSION: boolean;
  26795. SPECULAROVERALPHA: boolean;
  26796. CLIPPLANE: boolean;
  26797. CLIPPLANE2: boolean;
  26798. CLIPPLANE3: boolean;
  26799. CLIPPLANE4: boolean;
  26800. CLIPPLANE5: boolean;
  26801. CLIPPLANE6: boolean;
  26802. ALPHATEST: boolean;
  26803. DEPTHPREPASS: boolean;
  26804. ALPHAFROMDIFFUSE: boolean;
  26805. POINTSIZE: boolean;
  26806. FOG: boolean;
  26807. SPECULARTERM: boolean;
  26808. DIFFUSEFRESNEL: boolean;
  26809. OPACITYFRESNEL: boolean;
  26810. REFLECTIONFRESNEL: boolean;
  26811. REFRACTIONFRESNEL: boolean;
  26812. EMISSIVEFRESNEL: boolean;
  26813. FRESNEL: boolean;
  26814. NORMAL: boolean;
  26815. UV1: boolean;
  26816. UV2: boolean;
  26817. VERTEXCOLOR: boolean;
  26818. VERTEXALPHA: boolean;
  26819. NUM_BONE_INFLUENCERS: number;
  26820. BonesPerMesh: number;
  26821. BONETEXTURE: boolean;
  26822. INSTANCES: boolean;
  26823. GLOSSINESS: boolean;
  26824. ROUGHNESS: boolean;
  26825. EMISSIVEASILLUMINATION: boolean;
  26826. LINKEMISSIVEWITHDIFFUSE: boolean;
  26827. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26828. LIGHTMAP: boolean;
  26829. LIGHTMAPDIRECTUV: number;
  26830. OBJECTSPACE_NORMALMAP: boolean;
  26831. USELIGHTMAPASSHADOWMAP: boolean;
  26832. REFLECTIONMAP_3D: boolean;
  26833. REFLECTIONMAP_SPHERICAL: boolean;
  26834. REFLECTIONMAP_PLANAR: boolean;
  26835. REFLECTIONMAP_CUBIC: boolean;
  26836. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26837. REFLECTIONMAP_PROJECTION: boolean;
  26838. REFLECTIONMAP_SKYBOX: boolean;
  26839. REFLECTIONMAP_EXPLICIT: boolean;
  26840. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26841. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26842. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26843. INVERTCUBICMAP: boolean;
  26844. LOGARITHMICDEPTH: boolean;
  26845. REFRACTION: boolean;
  26846. REFRACTIONMAP_3D: boolean;
  26847. REFLECTIONOVERALPHA: boolean;
  26848. TWOSIDEDLIGHTING: boolean;
  26849. SHADOWFLOAT: boolean;
  26850. MORPHTARGETS: boolean;
  26851. MORPHTARGETS_NORMAL: boolean;
  26852. MORPHTARGETS_TANGENT: boolean;
  26853. MORPHTARGETS_UV: boolean;
  26854. NUM_MORPH_INFLUENCERS: number;
  26855. NONUNIFORMSCALING: boolean;
  26856. PREMULTIPLYALPHA: boolean;
  26857. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26858. ALPHABLEND: boolean;
  26859. IMAGEPROCESSING: boolean;
  26860. VIGNETTE: boolean;
  26861. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26862. VIGNETTEBLENDMODEOPAQUE: boolean;
  26863. TONEMAPPING: boolean;
  26864. TONEMAPPING_ACES: boolean;
  26865. CONTRAST: boolean;
  26866. COLORCURVES: boolean;
  26867. COLORGRADING: boolean;
  26868. COLORGRADING3D: boolean;
  26869. SAMPLER3DGREENDEPTH: boolean;
  26870. SAMPLER3DBGRMAP: boolean;
  26871. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26872. MULTIVIEW: boolean;
  26873. /**
  26874. * If the reflection texture on this material is in linear color space
  26875. * @hidden
  26876. */
  26877. IS_REFLECTION_LINEAR: boolean;
  26878. /**
  26879. * If the refraction texture on this material is in linear color space
  26880. * @hidden
  26881. */
  26882. IS_REFRACTION_LINEAR: boolean;
  26883. EXPOSURE: boolean;
  26884. constructor();
  26885. setReflectionMode(modeToEnable: string): void;
  26886. }
  26887. /**
  26888. * This is the default material used in Babylon. It is the best trade off between quality
  26889. * and performances.
  26890. * @see http://doc.babylonjs.com/babylon101/materials
  26891. */
  26892. export class StandardMaterial extends PushMaterial {
  26893. private _diffuseTexture;
  26894. /**
  26895. * The basic texture of the material as viewed under a light.
  26896. */
  26897. diffuseTexture: Nullable<BaseTexture>;
  26898. private _ambientTexture;
  26899. /**
  26900. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26901. */
  26902. ambientTexture: Nullable<BaseTexture>;
  26903. private _opacityTexture;
  26904. /**
  26905. * Define the transparency of the material from a texture.
  26906. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26907. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26908. */
  26909. opacityTexture: Nullable<BaseTexture>;
  26910. private _reflectionTexture;
  26911. /**
  26912. * Define the texture used to display the reflection.
  26913. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26914. */
  26915. reflectionTexture: Nullable<BaseTexture>;
  26916. private _emissiveTexture;
  26917. /**
  26918. * Define texture of the material as if self lit.
  26919. * This will be mixed in the final result even in the absence of light.
  26920. */
  26921. emissiveTexture: Nullable<BaseTexture>;
  26922. private _specularTexture;
  26923. /**
  26924. * Define how the color and intensity of the highlight given by the light in the material.
  26925. */
  26926. specularTexture: Nullable<BaseTexture>;
  26927. private _bumpTexture;
  26928. /**
  26929. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26930. * 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.
  26931. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26932. */
  26933. bumpTexture: Nullable<BaseTexture>;
  26934. private _lightmapTexture;
  26935. /**
  26936. * Complex lighting can be computationally expensive to compute at runtime.
  26937. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26938. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26939. */
  26940. lightmapTexture: Nullable<BaseTexture>;
  26941. private _refractionTexture;
  26942. /**
  26943. * Define the texture used to display the refraction.
  26944. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26945. */
  26946. refractionTexture: Nullable<BaseTexture>;
  26947. /**
  26948. * The color of the material lit by the environmental background lighting.
  26949. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26950. */
  26951. ambientColor: Color3;
  26952. /**
  26953. * The basic color of the material as viewed under a light.
  26954. */
  26955. diffuseColor: Color3;
  26956. /**
  26957. * Define how the color and intensity of the highlight given by the light in the material.
  26958. */
  26959. specularColor: Color3;
  26960. /**
  26961. * Define the color of the material as if self lit.
  26962. * This will be mixed in the final result even in the absence of light.
  26963. */
  26964. emissiveColor: Color3;
  26965. /**
  26966. * Defines how sharp are the highlights in the material.
  26967. * The bigger the value the sharper giving a more glossy feeling to the result.
  26968. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26969. */
  26970. specularPower: number;
  26971. private _useAlphaFromDiffuseTexture;
  26972. /**
  26973. * Does the transparency come from the diffuse texture alpha channel.
  26974. */
  26975. useAlphaFromDiffuseTexture: boolean;
  26976. private _useEmissiveAsIllumination;
  26977. /**
  26978. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26979. */
  26980. useEmissiveAsIllumination: boolean;
  26981. private _linkEmissiveWithDiffuse;
  26982. /**
  26983. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26984. * the emissive level when the final color is close to one.
  26985. */
  26986. linkEmissiveWithDiffuse: boolean;
  26987. private _useSpecularOverAlpha;
  26988. /**
  26989. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26990. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26991. */
  26992. useSpecularOverAlpha: boolean;
  26993. private _useReflectionOverAlpha;
  26994. /**
  26995. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26996. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26997. */
  26998. useReflectionOverAlpha: boolean;
  26999. private _disableLighting;
  27000. /**
  27001. * Does lights from the scene impacts this material.
  27002. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27003. */
  27004. disableLighting: boolean;
  27005. private _useObjectSpaceNormalMap;
  27006. /**
  27007. * Allows using an object space normal map (instead of tangent space).
  27008. */
  27009. useObjectSpaceNormalMap: boolean;
  27010. private _useParallax;
  27011. /**
  27012. * Is parallax enabled or not.
  27013. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27014. */
  27015. useParallax: boolean;
  27016. private _useParallaxOcclusion;
  27017. /**
  27018. * Is parallax occlusion enabled or not.
  27019. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27020. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27021. */
  27022. useParallaxOcclusion: boolean;
  27023. /**
  27024. * 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.
  27025. */
  27026. parallaxScaleBias: number;
  27027. private _roughness;
  27028. /**
  27029. * Helps to define how blurry the reflections should appears in the material.
  27030. */
  27031. roughness: number;
  27032. /**
  27033. * In case of refraction, define the value of the index of refraction.
  27034. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27035. */
  27036. indexOfRefraction: number;
  27037. /**
  27038. * Invert the refraction texture alongside the y axis.
  27039. * It can be useful with procedural textures or probe for instance.
  27040. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27041. */
  27042. invertRefractionY: boolean;
  27043. /**
  27044. * Defines the alpha limits in alpha test mode.
  27045. */
  27046. alphaCutOff: number;
  27047. private _useLightmapAsShadowmap;
  27048. /**
  27049. * In case of light mapping, define whether the map contains light or shadow informations.
  27050. */
  27051. useLightmapAsShadowmap: boolean;
  27052. private _diffuseFresnelParameters;
  27053. /**
  27054. * Define the diffuse fresnel parameters of the material.
  27055. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27056. */
  27057. diffuseFresnelParameters: FresnelParameters;
  27058. private _opacityFresnelParameters;
  27059. /**
  27060. * Define the opacity fresnel parameters of the material.
  27061. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27062. */
  27063. opacityFresnelParameters: FresnelParameters;
  27064. private _reflectionFresnelParameters;
  27065. /**
  27066. * Define the reflection fresnel parameters of the material.
  27067. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27068. */
  27069. reflectionFresnelParameters: FresnelParameters;
  27070. private _refractionFresnelParameters;
  27071. /**
  27072. * Define the refraction fresnel parameters of the material.
  27073. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27074. */
  27075. refractionFresnelParameters: FresnelParameters;
  27076. private _emissiveFresnelParameters;
  27077. /**
  27078. * Define the emissive fresnel parameters of the material.
  27079. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27080. */
  27081. emissiveFresnelParameters: FresnelParameters;
  27082. private _useReflectionFresnelFromSpecular;
  27083. /**
  27084. * If true automatically deducts the fresnels values from the material specularity.
  27085. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27086. */
  27087. useReflectionFresnelFromSpecular: boolean;
  27088. private _useGlossinessFromSpecularMapAlpha;
  27089. /**
  27090. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27091. */
  27092. useGlossinessFromSpecularMapAlpha: boolean;
  27093. private _maxSimultaneousLights;
  27094. /**
  27095. * Defines the maximum number of lights that can be used in the material
  27096. */
  27097. maxSimultaneousLights: number;
  27098. private _invertNormalMapX;
  27099. /**
  27100. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27101. */
  27102. invertNormalMapX: boolean;
  27103. private _invertNormalMapY;
  27104. /**
  27105. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27106. */
  27107. invertNormalMapY: boolean;
  27108. private _twoSidedLighting;
  27109. /**
  27110. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27111. */
  27112. twoSidedLighting: boolean;
  27113. /**
  27114. * Default configuration related to image processing available in the standard Material.
  27115. */
  27116. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27117. /**
  27118. * Gets the image processing configuration used either in this material.
  27119. */
  27120. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27121. /**
  27122. * Sets the Default image processing configuration used either in the this material.
  27123. *
  27124. * If sets to null, the scene one is in use.
  27125. */
  27126. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27127. /**
  27128. * Keep track of the image processing observer to allow dispose and replace.
  27129. */
  27130. private _imageProcessingObserver;
  27131. /**
  27132. * Attaches a new image processing configuration to the Standard Material.
  27133. * @param configuration
  27134. */
  27135. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27136. /**
  27137. * Gets wether the color curves effect is enabled.
  27138. */
  27139. get cameraColorCurvesEnabled(): boolean;
  27140. /**
  27141. * Sets wether the color curves effect is enabled.
  27142. */
  27143. set cameraColorCurvesEnabled(value: boolean);
  27144. /**
  27145. * Gets wether the color grading effect is enabled.
  27146. */
  27147. get cameraColorGradingEnabled(): boolean;
  27148. /**
  27149. * Gets wether the color grading effect is enabled.
  27150. */
  27151. set cameraColorGradingEnabled(value: boolean);
  27152. /**
  27153. * Gets wether tonemapping is enabled or not.
  27154. */
  27155. get cameraToneMappingEnabled(): boolean;
  27156. /**
  27157. * Sets wether tonemapping is enabled or not
  27158. */
  27159. set cameraToneMappingEnabled(value: boolean);
  27160. /**
  27161. * The camera exposure used on this material.
  27162. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27163. * This corresponds to a photographic exposure.
  27164. */
  27165. get cameraExposure(): number;
  27166. /**
  27167. * The camera exposure used on this material.
  27168. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27169. * This corresponds to a photographic exposure.
  27170. */
  27171. set cameraExposure(value: number);
  27172. /**
  27173. * Gets The camera contrast used on this material.
  27174. */
  27175. get cameraContrast(): number;
  27176. /**
  27177. * Sets The camera contrast used on this material.
  27178. */
  27179. set cameraContrast(value: number);
  27180. /**
  27181. * Gets the Color Grading 2D Lookup Texture.
  27182. */
  27183. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27184. /**
  27185. * Sets the Color Grading 2D Lookup Texture.
  27186. */
  27187. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27188. /**
  27189. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27190. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27191. * 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;
  27192. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27193. */
  27194. get cameraColorCurves(): Nullable<ColorCurves>;
  27195. /**
  27196. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27197. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27198. * 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;
  27199. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27200. */
  27201. set cameraColorCurves(value: Nullable<ColorCurves>);
  27202. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27203. protected _worldViewProjectionMatrix: Matrix;
  27204. protected _globalAmbientColor: Color3;
  27205. protected _useLogarithmicDepth: boolean;
  27206. protected _rebuildInParallel: boolean;
  27207. /**
  27208. * Instantiates a new standard material.
  27209. * This is the default material used in Babylon. It is the best trade off between quality
  27210. * and performances.
  27211. * @see http://doc.babylonjs.com/babylon101/materials
  27212. * @param name Define the name of the material in the scene
  27213. * @param scene Define the scene the material belong to
  27214. */
  27215. constructor(name: string, scene: Scene);
  27216. /**
  27217. * Gets a boolean indicating that current material needs to register RTT
  27218. */
  27219. get hasRenderTargetTextures(): boolean;
  27220. /**
  27221. * Gets the current class name of the material e.g. "StandardMaterial"
  27222. * Mainly use in serialization.
  27223. * @returns the class name
  27224. */
  27225. getClassName(): string;
  27226. /**
  27227. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27228. * You can try switching to logarithmic depth.
  27229. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27230. */
  27231. get useLogarithmicDepth(): boolean;
  27232. set useLogarithmicDepth(value: boolean);
  27233. /**
  27234. * Specifies if the material will require alpha blending
  27235. * @returns a boolean specifying if alpha blending is needed
  27236. */
  27237. needAlphaBlending(): boolean;
  27238. /**
  27239. * Specifies if this material should be rendered in alpha test mode
  27240. * @returns a boolean specifying if an alpha test is needed.
  27241. */
  27242. needAlphaTesting(): boolean;
  27243. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27244. /**
  27245. * Get the texture used for alpha test purpose.
  27246. * @returns the diffuse texture in case of the standard material.
  27247. */
  27248. getAlphaTestTexture(): Nullable<BaseTexture>;
  27249. /**
  27250. * Get if the submesh is ready to be used and all its information available.
  27251. * Child classes can use it to update shaders
  27252. * @param mesh defines the mesh to check
  27253. * @param subMesh defines which submesh to check
  27254. * @param useInstances specifies that instances should be used
  27255. * @returns a boolean indicating that the submesh is ready or not
  27256. */
  27257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27258. /**
  27259. * Builds the material UBO layouts.
  27260. * Used internally during the effect preparation.
  27261. */
  27262. buildUniformLayout(): void;
  27263. /**
  27264. * Unbinds the material from the mesh
  27265. */
  27266. unbind(): void;
  27267. /**
  27268. * Binds the submesh to this material by preparing the effect and shader to draw
  27269. * @param world defines the world transformation matrix
  27270. * @param mesh defines the mesh containing the submesh
  27271. * @param subMesh defines the submesh to bind the material to
  27272. */
  27273. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27274. /**
  27275. * Get the list of animatables in the material.
  27276. * @returns the list of animatables object used in the material
  27277. */
  27278. getAnimatables(): IAnimatable[];
  27279. /**
  27280. * Gets the active textures from the material
  27281. * @returns an array of textures
  27282. */
  27283. getActiveTextures(): BaseTexture[];
  27284. /**
  27285. * Specifies if the material uses a texture
  27286. * @param texture defines the texture to check against the material
  27287. * @returns a boolean specifying if the material uses the texture
  27288. */
  27289. hasTexture(texture: BaseTexture): boolean;
  27290. /**
  27291. * Disposes the material
  27292. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27293. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27294. */
  27295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27296. /**
  27297. * Makes a duplicate of the material, and gives it a new name
  27298. * @param name defines the new name for the duplicated material
  27299. * @returns the cloned material
  27300. */
  27301. clone(name: string): StandardMaterial;
  27302. /**
  27303. * Serializes this material in a JSON representation
  27304. * @returns the serialized material object
  27305. */
  27306. serialize(): any;
  27307. /**
  27308. * Creates a standard material from parsed material data
  27309. * @param source defines the JSON representation of the material
  27310. * @param scene defines the hosting scene
  27311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27312. * @returns a new standard material
  27313. */
  27314. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27315. /**
  27316. * Are diffuse textures enabled in the application.
  27317. */
  27318. static get DiffuseTextureEnabled(): boolean;
  27319. static set DiffuseTextureEnabled(value: boolean);
  27320. /**
  27321. * Are ambient textures enabled in the application.
  27322. */
  27323. static get AmbientTextureEnabled(): boolean;
  27324. static set AmbientTextureEnabled(value: boolean);
  27325. /**
  27326. * Are opacity textures enabled in the application.
  27327. */
  27328. static get OpacityTextureEnabled(): boolean;
  27329. static set OpacityTextureEnabled(value: boolean);
  27330. /**
  27331. * Are reflection textures enabled in the application.
  27332. */
  27333. static get ReflectionTextureEnabled(): boolean;
  27334. static set ReflectionTextureEnabled(value: boolean);
  27335. /**
  27336. * Are emissive textures enabled in the application.
  27337. */
  27338. static get EmissiveTextureEnabled(): boolean;
  27339. static set EmissiveTextureEnabled(value: boolean);
  27340. /**
  27341. * Are specular textures enabled in the application.
  27342. */
  27343. static get SpecularTextureEnabled(): boolean;
  27344. static set SpecularTextureEnabled(value: boolean);
  27345. /**
  27346. * Are bump textures enabled in the application.
  27347. */
  27348. static get BumpTextureEnabled(): boolean;
  27349. static set BumpTextureEnabled(value: boolean);
  27350. /**
  27351. * Are lightmap textures enabled in the application.
  27352. */
  27353. static get LightmapTextureEnabled(): boolean;
  27354. static set LightmapTextureEnabled(value: boolean);
  27355. /**
  27356. * Are refraction textures enabled in the application.
  27357. */
  27358. static get RefractionTextureEnabled(): boolean;
  27359. static set RefractionTextureEnabled(value: boolean);
  27360. /**
  27361. * Are color grading textures enabled in the application.
  27362. */
  27363. static get ColorGradingTextureEnabled(): boolean;
  27364. static set ColorGradingTextureEnabled(value: boolean);
  27365. /**
  27366. * Are fresnels enabled in the application.
  27367. */
  27368. static get FresnelEnabled(): boolean;
  27369. static set FresnelEnabled(value: boolean);
  27370. }
  27371. }
  27372. declare module BABYLON {
  27373. /**
  27374. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27375. *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.
  27376. * The SPS is also a particle system. It provides some methods to manage the particles.
  27377. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27378. *
  27379. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27380. */
  27381. export class SolidParticleSystem implements IDisposable {
  27382. /**
  27383. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27384. * Example : var p = SPS.particles[i];
  27385. */
  27386. particles: SolidParticle[];
  27387. /**
  27388. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27389. */
  27390. nbParticles: number;
  27391. /**
  27392. * If the particles must ever face the camera (default false). Useful for planar particles.
  27393. */
  27394. billboard: boolean;
  27395. /**
  27396. * Recompute normals when adding a shape
  27397. */
  27398. recomputeNormals: boolean;
  27399. /**
  27400. * This a counter ofr your own usage. It's not set by any SPS functions.
  27401. */
  27402. counter: number;
  27403. /**
  27404. * The SPS name. This name is also given to the underlying mesh.
  27405. */
  27406. name: string;
  27407. /**
  27408. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27409. */
  27410. mesh: Mesh;
  27411. /**
  27412. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27413. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27414. */
  27415. vars: any;
  27416. /**
  27417. * This array is populated when the SPS is set as 'pickable'.
  27418. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27419. * Each element of this array is an object `{idx: int, faceId: int}`.
  27420. * `idx` is the picked particle index in the `SPS.particles` array
  27421. * `faceId` is the picked face index counted within this particle.
  27422. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27423. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27424. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27425. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27426. */
  27427. pickedParticles: {
  27428. idx: number;
  27429. faceId: number;
  27430. }[];
  27431. /**
  27432. * This array is populated when the SPS is set as 'pickable'
  27433. * Each key of this array is a submesh index.
  27434. * Each element of this array is a second array defined like this :
  27435. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27436. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27437. * `idx` is the picked particle index in the `SPS.particles` array
  27438. * `faceId` is the picked face index counted within this particle.
  27439. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27440. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27441. */
  27442. pickedBySubMesh: {
  27443. idx: number;
  27444. faceId: number;
  27445. }[][];
  27446. /**
  27447. * This array is populated when `enableDepthSort` is set to true.
  27448. * Each element of this array is an instance of the class DepthSortedParticle.
  27449. */
  27450. depthSortedParticles: DepthSortedParticle[];
  27451. /**
  27452. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27453. * @hidden
  27454. */
  27455. _bSphereOnly: boolean;
  27456. /**
  27457. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27458. * @hidden
  27459. */
  27460. _bSphereRadiusFactor: number;
  27461. private _scene;
  27462. private _positions;
  27463. private _indices;
  27464. private _normals;
  27465. private _colors;
  27466. private _uvs;
  27467. private _indices32;
  27468. private _positions32;
  27469. private _normals32;
  27470. private _fixedNormal32;
  27471. private _colors32;
  27472. private _uvs32;
  27473. private _index;
  27474. private _updatable;
  27475. private _pickable;
  27476. private _isVisibilityBoxLocked;
  27477. private _alwaysVisible;
  27478. private _depthSort;
  27479. private _expandable;
  27480. private _shapeCounter;
  27481. private _copy;
  27482. private _color;
  27483. private _computeParticleColor;
  27484. private _computeParticleTexture;
  27485. private _computeParticleRotation;
  27486. private _computeParticleVertex;
  27487. private _computeBoundingBox;
  27488. private _depthSortParticles;
  27489. private _camera;
  27490. private _mustUnrotateFixedNormals;
  27491. private _particlesIntersect;
  27492. private _needs32Bits;
  27493. private _isNotBuilt;
  27494. private _lastParticleId;
  27495. private _idxOfId;
  27496. private _multimaterialEnabled;
  27497. private _useModelMaterial;
  27498. private _indicesByMaterial;
  27499. private _materialIndexes;
  27500. private _depthSortFunction;
  27501. private _materialSortFunction;
  27502. private _materials;
  27503. private _multimaterial;
  27504. private _materialIndexesById;
  27505. private _defaultMaterial;
  27506. private _autoUpdateSubMeshes;
  27507. /**
  27508. * Creates a SPS (Solid Particle System) object.
  27509. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27510. * @param scene (Scene) is the scene in which the SPS is added.
  27511. * @param options defines the options of the sps e.g.
  27512. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27513. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27514. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27515. * * 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.
  27516. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27517. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27518. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27519. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27520. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27521. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27522. */
  27523. constructor(name: string, scene: Scene, options?: {
  27524. updatable?: boolean;
  27525. isPickable?: boolean;
  27526. enableDepthSort?: boolean;
  27527. particleIntersection?: boolean;
  27528. boundingSphereOnly?: boolean;
  27529. bSphereRadiusFactor?: number;
  27530. expandable?: boolean;
  27531. useModelMaterial?: boolean;
  27532. enableMultiMaterial?: boolean;
  27533. });
  27534. /**
  27535. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27536. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27537. * @returns the created mesh
  27538. */
  27539. buildMesh(): Mesh;
  27540. /**
  27541. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27542. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27543. * Thus the particles generated from `digest()` have their property `position` set yet.
  27544. * @param mesh ( Mesh ) is the mesh to be digested
  27545. * @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
  27546. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27547. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27548. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27549. * @returns the current SPS
  27550. */
  27551. digest(mesh: Mesh, options?: {
  27552. facetNb?: number;
  27553. number?: number;
  27554. delta?: number;
  27555. storage?: [];
  27556. }): SolidParticleSystem;
  27557. /**
  27558. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27559. * @hidden
  27560. */
  27561. private _unrotateFixedNormals;
  27562. /**
  27563. * Resets the temporary working copy particle
  27564. * @hidden
  27565. */
  27566. private _resetCopy;
  27567. /**
  27568. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27569. * @param p the current index in the positions array to be updated
  27570. * @param ind the current index in the indices array
  27571. * @param shape a Vector3 array, the shape geometry
  27572. * @param positions the positions array to be updated
  27573. * @param meshInd the shape indices array
  27574. * @param indices the indices array to be updated
  27575. * @param meshUV the shape uv array
  27576. * @param uvs the uv array to be updated
  27577. * @param meshCol the shape color array
  27578. * @param colors the color array to be updated
  27579. * @param meshNor the shape normals array
  27580. * @param normals the normals array to be updated
  27581. * @param idx the particle index
  27582. * @param idxInShape the particle index in its shape
  27583. * @param options the addShape() method passed options
  27584. * @model the particle model
  27585. * @hidden
  27586. */
  27587. private _meshBuilder;
  27588. /**
  27589. * Returns a shape Vector3 array from positions float array
  27590. * @param positions float array
  27591. * @returns a vector3 array
  27592. * @hidden
  27593. */
  27594. private _posToShape;
  27595. /**
  27596. * Returns a shapeUV array from a float uvs (array deep copy)
  27597. * @param uvs as a float array
  27598. * @returns a shapeUV array
  27599. * @hidden
  27600. */
  27601. private _uvsToShapeUV;
  27602. /**
  27603. * Adds a new particle object in the particles array
  27604. * @param idx particle index in particles array
  27605. * @param id particle id
  27606. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27607. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27608. * @param model particle ModelShape object
  27609. * @param shapeId model shape identifier
  27610. * @param idxInShape index of the particle in the current model
  27611. * @param bInfo model bounding info object
  27612. * @param storage target storage array, if any
  27613. * @hidden
  27614. */
  27615. private _addParticle;
  27616. /**
  27617. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27618. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27619. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27620. * @param nb (positive integer) the number of particles to be created from this model
  27621. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27622. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27623. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27624. * @returns the number of shapes in the system
  27625. */
  27626. addShape(mesh: Mesh, nb: number, options?: {
  27627. positionFunction?: any;
  27628. vertexFunction?: any;
  27629. storage?: [];
  27630. }): number;
  27631. /**
  27632. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27633. * @hidden
  27634. */
  27635. private _rebuildParticle;
  27636. /**
  27637. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27638. * @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.
  27639. * @returns the SPS.
  27640. */
  27641. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27642. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27643. * Returns an array with the removed particles.
  27644. * 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.
  27645. * The SPS can't be empty so at least one particle needs to remain in place.
  27646. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27647. * @param start index of the first particle to remove
  27648. * @param end index of the last particle to remove (included)
  27649. * @returns an array populated with the removed particles
  27650. */
  27651. removeParticles(start: number, end: number): SolidParticle[];
  27652. /**
  27653. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27654. * @param solidParticleArray an array populated with Solid Particles objects
  27655. * @returns the SPS
  27656. */
  27657. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27658. /**
  27659. * Creates a new particle and modifies the SPS mesh geometry :
  27660. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27661. * - calls _addParticle() to populate the particle array
  27662. * factorized code from addShape() and insertParticlesFromArray()
  27663. * @param idx particle index in the particles array
  27664. * @param i particle index in its shape
  27665. * @param modelShape particle ModelShape object
  27666. * @param shape shape vertex array
  27667. * @param meshInd shape indices array
  27668. * @param meshUV shape uv array
  27669. * @param meshCol shape color array
  27670. * @param meshNor shape normals array
  27671. * @param bbInfo shape bounding info
  27672. * @param storage target particle storage
  27673. * @options addShape() passed options
  27674. * @hidden
  27675. */
  27676. private _insertNewParticle;
  27677. /**
  27678. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27679. * This method calls `updateParticle()` for each particle of the SPS.
  27680. * For an animated SPS, it is usually called within the render loop.
  27681. * 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.
  27682. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27683. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27684. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27685. * @returns the SPS.
  27686. */
  27687. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27688. /**
  27689. * Disposes the SPS.
  27690. */
  27691. dispose(): void;
  27692. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27693. * idx is the particle index in the SPS
  27694. * faceId is the picked face index counted within this particle.
  27695. * Returns null if the pickInfo can't identify a picked particle.
  27696. * @param pickingInfo (PickingInfo object)
  27697. * @returns {idx: number, faceId: number} or null
  27698. */
  27699. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27700. idx: number;
  27701. faceId: number;
  27702. }>;
  27703. /**
  27704. * Returns a SolidParticle object from its identifier : particle.id
  27705. * @param id (integer) the particle Id
  27706. * @returns the searched particle or null if not found in the SPS.
  27707. */
  27708. getParticleById(id: number): Nullable<SolidParticle>;
  27709. /**
  27710. * Returns a new array populated with the particles having the passed shapeId.
  27711. * @param shapeId (integer) the shape identifier
  27712. * @returns a new solid particle array
  27713. */
  27714. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27715. /**
  27716. * Populates the passed array "ref" with the particles having the passed shapeId.
  27717. * @param shapeId the shape identifier
  27718. * @returns the SPS
  27719. * @param ref
  27720. */
  27721. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27722. /**
  27723. * Computes the required SubMeshes according the materials assigned to the particles.
  27724. * @returns the solid particle system.
  27725. * Does nothing if called before the SPS mesh is built.
  27726. */
  27727. computeSubMeshes(): SolidParticleSystem;
  27728. /**
  27729. * Sorts the solid particles by material when MultiMaterial is enabled.
  27730. * Updates the indices32 array.
  27731. * Updates the indicesByMaterial array.
  27732. * Updates the mesh indices array.
  27733. * @returns the SPS
  27734. * @hidden
  27735. */
  27736. private _sortParticlesByMaterial;
  27737. /**
  27738. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27739. * @hidden
  27740. */
  27741. private _setMaterialIndexesById;
  27742. /**
  27743. * Returns an array with unique values of Materials from the passed array
  27744. * @param array the material array to be checked and filtered
  27745. * @hidden
  27746. */
  27747. private _filterUniqueMaterialId;
  27748. /**
  27749. * Sets a new Standard Material as _defaultMaterial if not already set.
  27750. * @hidden
  27751. */
  27752. private _setDefaultMaterial;
  27753. /**
  27754. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27755. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27756. * @returns the SPS.
  27757. */
  27758. refreshVisibleSize(): SolidParticleSystem;
  27759. /**
  27760. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27761. * @param size the size (float) of the visibility box
  27762. * note : this doesn't lock the SPS mesh bounding box.
  27763. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27764. */
  27765. setVisibilityBox(size: number): void;
  27766. /**
  27767. * Gets whether the SPS as always visible or not
  27768. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27769. */
  27770. get isAlwaysVisible(): boolean;
  27771. /**
  27772. * Sets the SPS as always visible or not
  27773. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27774. */
  27775. set isAlwaysVisible(val: boolean);
  27776. /**
  27777. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27778. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27779. */
  27780. set isVisibilityBoxLocked(val: boolean);
  27781. /**
  27782. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27783. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27784. */
  27785. get isVisibilityBoxLocked(): boolean;
  27786. /**
  27787. * Tells to `setParticles()` to compute the particle rotations or not.
  27788. * Default value : true. The SPS is faster when it's set to false.
  27789. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27790. */
  27791. set computeParticleRotation(val: boolean);
  27792. /**
  27793. * Tells to `setParticles()` to compute the particle colors or not.
  27794. * Default value : true. The SPS is faster when it's set to false.
  27795. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27796. */
  27797. set computeParticleColor(val: boolean);
  27798. set computeParticleTexture(val: boolean);
  27799. /**
  27800. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27801. * Default value : false. The SPS is faster when it's set to false.
  27802. * Note : the particle custom vertex positions aren't stored values.
  27803. */
  27804. set computeParticleVertex(val: boolean);
  27805. /**
  27806. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27807. */
  27808. set computeBoundingBox(val: boolean);
  27809. /**
  27810. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27811. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27812. * Default : `true`
  27813. */
  27814. set depthSortParticles(val: boolean);
  27815. /**
  27816. * Gets if `setParticles()` computes the particle rotations or not.
  27817. * Default value : true. The SPS is faster when it's set to false.
  27818. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27819. */
  27820. get computeParticleRotation(): boolean;
  27821. /**
  27822. * Gets if `setParticles()` computes the particle colors or not.
  27823. * Default value : true. The SPS is faster when it's set to false.
  27824. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27825. */
  27826. get computeParticleColor(): boolean;
  27827. /**
  27828. * Gets if `setParticles()` computes the particle textures or not.
  27829. * Default value : true. The SPS is faster when it's set to false.
  27830. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27831. */
  27832. get computeParticleTexture(): boolean;
  27833. /**
  27834. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27835. * Default value : false. The SPS is faster when it's set to false.
  27836. * Note : the particle custom vertex positions aren't stored values.
  27837. */
  27838. get computeParticleVertex(): boolean;
  27839. /**
  27840. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27841. */
  27842. get computeBoundingBox(): boolean;
  27843. /**
  27844. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27845. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27846. * Default : `true`
  27847. */
  27848. get depthSortParticles(): boolean;
  27849. /**
  27850. * Gets if the SPS is created as expandable at construction time.
  27851. * Default : `false`
  27852. */
  27853. get expandable(): boolean;
  27854. /**
  27855. * Gets if the SPS supports the Multi Materials
  27856. */
  27857. get multimaterialEnabled(): boolean;
  27858. /**
  27859. * Gets if the SPS uses the model materials for its own multimaterial.
  27860. */
  27861. get useModelMaterial(): boolean;
  27862. /**
  27863. * The SPS used material array.
  27864. */
  27865. get materials(): Material[];
  27866. /**
  27867. * Sets the SPS MultiMaterial from the passed materials.
  27868. * Note : the passed array is internally copied and not used then by reference.
  27869. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27870. */
  27871. setMultiMaterial(materials: Material[]): void;
  27872. /**
  27873. * The SPS computed multimaterial object
  27874. */
  27875. get multimaterial(): MultiMaterial;
  27876. set multimaterial(mm: MultiMaterial);
  27877. /**
  27878. * If the subMeshes must be updated on the next call to setParticles()
  27879. */
  27880. get autoUpdateSubMeshes(): boolean;
  27881. set autoUpdateSubMeshes(val: boolean);
  27882. /**
  27883. * This function does nothing. It may be overwritten to set all the particle first values.
  27884. * The SPS doesn't call this function, you may have to call it by your own.
  27885. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27886. */
  27887. initParticles(): void;
  27888. /**
  27889. * This function does nothing. It may be overwritten to recycle a particle.
  27890. * The SPS doesn't call this function, you may have to call it by your own.
  27891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27892. * @param particle The particle to recycle
  27893. * @returns the recycled particle
  27894. */
  27895. recycleParticle(particle: SolidParticle): SolidParticle;
  27896. /**
  27897. * Updates a particle : this function should be overwritten by the user.
  27898. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27899. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27900. * @example : just set a particle position or velocity and recycle conditions
  27901. * @param particle The particle to update
  27902. * @returns the updated particle
  27903. */
  27904. updateParticle(particle: SolidParticle): SolidParticle;
  27905. /**
  27906. * Updates a vertex of a particle : it can be overwritten by the user.
  27907. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27908. * @param particle the current particle
  27909. * @param vertex the current index of the current particle
  27910. * @param pt the index of the current vertex in the particle shape
  27911. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27912. * @example : just set a vertex particle position
  27913. * @returns the updated vertex
  27914. */
  27915. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27916. /**
  27917. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27918. * This does nothing and may be overwritten by the user.
  27919. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27920. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27921. * @param update the boolean update value actually passed to setParticles()
  27922. */
  27923. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27924. /**
  27925. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27926. * This will be passed three parameters.
  27927. * This does nothing and may be overwritten by the user.
  27928. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27929. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27930. * @param update the boolean update value actually passed to setParticles()
  27931. */
  27932. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27933. }
  27934. }
  27935. declare module BABYLON {
  27936. /**
  27937. * Represents one particle of a solid particle system.
  27938. */
  27939. export class SolidParticle {
  27940. /**
  27941. * particle global index
  27942. */
  27943. idx: number;
  27944. /**
  27945. * particle identifier
  27946. */
  27947. id: number;
  27948. /**
  27949. * The color of the particle
  27950. */
  27951. color: Nullable<Color4>;
  27952. /**
  27953. * The world space position of the particle.
  27954. */
  27955. position: Vector3;
  27956. /**
  27957. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27958. */
  27959. rotation: Vector3;
  27960. /**
  27961. * The world space rotation quaternion of the particle.
  27962. */
  27963. rotationQuaternion: Nullable<Quaternion>;
  27964. /**
  27965. * The scaling of the particle.
  27966. */
  27967. scaling: Vector3;
  27968. /**
  27969. * The uvs of the particle.
  27970. */
  27971. uvs: Vector4;
  27972. /**
  27973. * The current speed of the particle.
  27974. */
  27975. velocity: Vector3;
  27976. /**
  27977. * The pivot point in the particle local space.
  27978. */
  27979. pivot: Vector3;
  27980. /**
  27981. * Must the particle be translated from its pivot point in its local space ?
  27982. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27983. * Default : false
  27984. */
  27985. translateFromPivot: boolean;
  27986. /**
  27987. * Is the particle active or not ?
  27988. */
  27989. alive: boolean;
  27990. /**
  27991. * Is the particle visible or not ?
  27992. */
  27993. isVisible: boolean;
  27994. /**
  27995. * Index of this particle in the global "positions" array (Internal use)
  27996. * @hidden
  27997. */
  27998. _pos: number;
  27999. /**
  28000. * @hidden Index of this particle in the global "indices" array (Internal use)
  28001. */
  28002. _ind: number;
  28003. /**
  28004. * @hidden ModelShape of this particle (Internal use)
  28005. */
  28006. _model: ModelShape;
  28007. /**
  28008. * ModelShape id of this particle
  28009. */
  28010. shapeId: number;
  28011. /**
  28012. * Index of the particle in its shape id
  28013. */
  28014. idxInShape: number;
  28015. /**
  28016. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28017. */
  28018. _modelBoundingInfo: BoundingInfo;
  28019. /**
  28020. * @hidden Particle BoundingInfo object (Internal use)
  28021. */
  28022. _boundingInfo: BoundingInfo;
  28023. /**
  28024. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28025. */
  28026. _sps: SolidParticleSystem;
  28027. /**
  28028. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28029. */
  28030. _stillInvisible: boolean;
  28031. /**
  28032. * @hidden Last computed particle rotation matrix
  28033. */
  28034. _rotationMatrix: number[];
  28035. /**
  28036. * Parent particle Id, if any.
  28037. * Default null.
  28038. */
  28039. parentId: Nullable<number>;
  28040. /**
  28041. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28042. */
  28043. materialIndex: Nullable<number>;
  28044. /**
  28045. * Custom object or properties.
  28046. */
  28047. props: Nullable<any>;
  28048. /**
  28049. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28050. * The possible values are :
  28051. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28052. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28053. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28054. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28055. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28056. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28057. * */
  28058. cullingStrategy: number;
  28059. /**
  28060. * @hidden Internal global position in the SPS.
  28061. */
  28062. _globalPosition: Vector3;
  28063. /**
  28064. * Creates a Solid Particle object.
  28065. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28066. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28067. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28068. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28069. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28070. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28071. * @param shapeId (integer) is the model shape identifier in the SPS.
  28072. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28073. * @param sps defines the sps it is associated to
  28074. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28075. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28076. */
  28077. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28078. /**
  28079. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28080. * @param target the particle target
  28081. * @returns the current particle
  28082. */
  28083. copyToRef(target: SolidParticle): SolidParticle;
  28084. /**
  28085. * Legacy support, changed scale to scaling
  28086. */
  28087. get scale(): Vector3;
  28088. /**
  28089. * Legacy support, changed scale to scaling
  28090. */
  28091. set scale(scale: Vector3);
  28092. /**
  28093. * Legacy support, changed quaternion to rotationQuaternion
  28094. */
  28095. get quaternion(): Nullable<Quaternion>;
  28096. /**
  28097. * Legacy support, changed quaternion to rotationQuaternion
  28098. */
  28099. set quaternion(q: Nullable<Quaternion>);
  28100. /**
  28101. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28102. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28103. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28104. * @returns true if it intersects
  28105. */
  28106. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28107. /**
  28108. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28109. * A particle is in the frustum if its bounding box intersects the frustum
  28110. * @param frustumPlanes defines the frustum to test
  28111. * @returns true if the particle is in the frustum planes
  28112. */
  28113. isInFrustum(frustumPlanes: Plane[]): boolean;
  28114. /**
  28115. * get the rotation matrix of the particle
  28116. * @hidden
  28117. */
  28118. getRotationMatrix(m: Matrix): void;
  28119. }
  28120. /**
  28121. * Represents the shape of the model used by one particle of a solid particle system.
  28122. * SPS internal tool, don't use it manually.
  28123. */
  28124. export class ModelShape {
  28125. /**
  28126. * The shape id
  28127. * @hidden
  28128. */
  28129. shapeID: number;
  28130. /**
  28131. * flat array of model positions (internal use)
  28132. * @hidden
  28133. */
  28134. _shape: Vector3[];
  28135. /**
  28136. * flat array of model UVs (internal use)
  28137. * @hidden
  28138. */
  28139. _shapeUV: number[];
  28140. /**
  28141. * color array of the model
  28142. * @hidden
  28143. */
  28144. _shapeColors: number[];
  28145. /**
  28146. * indices array of the model
  28147. * @hidden
  28148. */
  28149. _indices: number[];
  28150. /**
  28151. * normals array of the model
  28152. * @hidden
  28153. */
  28154. _normals: number[];
  28155. /**
  28156. * length of the shape in the model indices array (internal use)
  28157. * @hidden
  28158. */
  28159. _indicesLength: number;
  28160. /**
  28161. * Custom position function (internal use)
  28162. * @hidden
  28163. */
  28164. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28165. /**
  28166. * Custom vertex function (internal use)
  28167. * @hidden
  28168. */
  28169. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28170. /**
  28171. * Model material (internal use)
  28172. * @hidden
  28173. */
  28174. _material: Nullable<Material>;
  28175. /**
  28176. * 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.
  28177. * SPS internal tool, don't use it manually.
  28178. * @hidden
  28179. */
  28180. 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>);
  28181. }
  28182. /**
  28183. * Represents a Depth Sorted Particle in the solid particle system.
  28184. * @hidden
  28185. */
  28186. export class DepthSortedParticle {
  28187. /**
  28188. * Particle index
  28189. */
  28190. idx: number;
  28191. /**
  28192. * Index of the particle in the "indices" array
  28193. */
  28194. ind: number;
  28195. /**
  28196. * Length of the particle shape in the "indices" array
  28197. */
  28198. indicesLength: number;
  28199. /**
  28200. * Squared distance from the particle to the camera
  28201. */
  28202. sqDistance: number;
  28203. /**
  28204. * Material index when used with MultiMaterials
  28205. */
  28206. materialIndex: number;
  28207. /**
  28208. * Creates a new sorted particle
  28209. * @param materialIndex
  28210. */
  28211. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28212. }
  28213. }
  28214. declare module BABYLON {
  28215. /**
  28216. * @hidden
  28217. */
  28218. export class _MeshCollisionData {
  28219. _checkCollisions: boolean;
  28220. _collisionMask: number;
  28221. _collisionGroup: number;
  28222. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28223. _collider: Nullable<Collider>;
  28224. _oldPositionForCollisions: Vector3;
  28225. _diffPositionForCollisions: Vector3;
  28226. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28227. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28228. }
  28229. }
  28230. declare module BABYLON {
  28231. /** @hidden */
  28232. class _FacetDataStorage {
  28233. facetPositions: Vector3[];
  28234. facetNormals: Vector3[];
  28235. facetPartitioning: number[][];
  28236. facetNb: number;
  28237. partitioningSubdivisions: number;
  28238. partitioningBBoxRatio: number;
  28239. facetDataEnabled: boolean;
  28240. facetParameters: any;
  28241. bbSize: Vector3;
  28242. subDiv: {
  28243. max: number;
  28244. X: number;
  28245. Y: number;
  28246. Z: number;
  28247. };
  28248. facetDepthSort: boolean;
  28249. facetDepthSortEnabled: boolean;
  28250. depthSortedIndices: IndicesArray;
  28251. depthSortedFacets: {
  28252. ind: number;
  28253. sqDistance: number;
  28254. }[];
  28255. facetDepthSortFunction: (f1: {
  28256. ind: number;
  28257. sqDistance: number;
  28258. }, f2: {
  28259. ind: number;
  28260. sqDistance: number;
  28261. }) => number;
  28262. facetDepthSortFrom: Vector3;
  28263. facetDepthSortOrigin: Vector3;
  28264. invertedMatrix: Matrix;
  28265. }
  28266. /**
  28267. * @hidden
  28268. **/
  28269. class _InternalAbstractMeshDataInfo {
  28270. _hasVertexAlpha: boolean;
  28271. _useVertexColors: boolean;
  28272. _numBoneInfluencers: number;
  28273. _applyFog: boolean;
  28274. _receiveShadows: boolean;
  28275. _facetData: _FacetDataStorage;
  28276. _visibility: number;
  28277. _skeleton: Nullable<Skeleton>;
  28278. _layerMask: number;
  28279. _computeBonesUsingShaders: boolean;
  28280. _isActive: boolean;
  28281. _onlyForInstances: boolean;
  28282. _isActiveIntermediate: boolean;
  28283. _onlyForInstancesIntermediate: boolean;
  28284. _actAsRegularMesh: boolean;
  28285. }
  28286. /**
  28287. * Class used to store all common mesh properties
  28288. */
  28289. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28290. /** No occlusion */
  28291. static OCCLUSION_TYPE_NONE: number;
  28292. /** Occlusion set to optimisitic */
  28293. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28294. /** Occlusion set to strict */
  28295. static OCCLUSION_TYPE_STRICT: number;
  28296. /** Use an accurante occlusion algorithm */
  28297. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28298. /** Use a conservative occlusion algorithm */
  28299. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28300. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28301. * Test order :
  28302. * Is the bounding sphere outside the frustum ?
  28303. * If not, are the bounding box vertices outside the frustum ?
  28304. * It not, then the cullable object is in the frustum.
  28305. */
  28306. static readonly CULLINGSTRATEGY_STANDARD: number;
  28307. /** Culling strategy : Bounding Sphere Only.
  28308. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28309. * It's also less accurate than the standard because some not visible objects can still be selected.
  28310. * Test : is the bounding sphere outside the frustum ?
  28311. * If not, then the cullable object is in the frustum.
  28312. */
  28313. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28314. /** Culling strategy : Optimistic Inclusion.
  28315. * This in an inclusion test first, then the standard exclusion test.
  28316. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28317. * 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.
  28318. * Anyway, it's as accurate as the standard strategy.
  28319. * Test :
  28320. * Is the cullable object bounding sphere center in the frustum ?
  28321. * If not, apply the default culling strategy.
  28322. */
  28323. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28324. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28325. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28326. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28327. * 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.
  28328. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28329. * Test :
  28330. * Is the cullable object bounding sphere center in the frustum ?
  28331. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28332. */
  28333. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28334. /**
  28335. * No billboard
  28336. */
  28337. static get BILLBOARDMODE_NONE(): number;
  28338. /** Billboard on X axis */
  28339. static get BILLBOARDMODE_X(): number;
  28340. /** Billboard on Y axis */
  28341. static get BILLBOARDMODE_Y(): number;
  28342. /** Billboard on Z axis */
  28343. static get BILLBOARDMODE_Z(): number;
  28344. /** Billboard on all axes */
  28345. static get BILLBOARDMODE_ALL(): number;
  28346. /** Billboard on using position instead of orientation */
  28347. static get BILLBOARDMODE_USE_POSITION(): number;
  28348. /** @hidden */
  28349. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28350. /**
  28351. * The culling strategy to use to check whether the mesh must be rendered or not.
  28352. * This value can be changed at any time and will be used on the next render mesh selection.
  28353. * The possible values are :
  28354. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28355. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28356. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28357. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28358. * Please read each static variable documentation to get details about the culling process.
  28359. * */
  28360. cullingStrategy: number;
  28361. /**
  28362. * Gets the number of facets in the mesh
  28363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28364. */
  28365. get facetNb(): number;
  28366. /**
  28367. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28369. */
  28370. get partitioningSubdivisions(): number;
  28371. set partitioningSubdivisions(nb: number);
  28372. /**
  28373. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28374. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28376. */
  28377. get partitioningBBoxRatio(): number;
  28378. set partitioningBBoxRatio(ratio: number);
  28379. /**
  28380. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28381. * Works only for updatable meshes.
  28382. * Doesn't work with multi-materials
  28383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28384. */
  28385. get mustDepthSortFacets(): boolean;
  28386. set mustDepthSortFacets(sort: boolean);
  28387. /**
  28388. * The location (Vector3) where the facet depth sort must be computed from.
  28389. * By default, the active camera position.
  28390. * Used only when facet depth sort is enabled
  28391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28392. */
  28393. get facetDepthSortFrom(): Vector3;
  28394. set facetDepthSortFrom(location: Vector3);
  28395. /**
  28396. * gets a boolean indicating if facetData is enabled
  28397. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28398. */
  28399. get isFacetDataEnabled(): boolean;
  28400. /** @hidden */
  28401. _updateNonUniformScalingState(value: boolean): boolean;
  28402. /**
  28403. * An event triggered when this mesh collides with another one
  28404. */
  28405. onCollideObservable: Observable<AbstractMesh>;
  28406. /** Set a function to call when this mesh collides with another one */
  28407. set onCollide(callback: () => void);
  28408. /**
  28409. * An event triggered when the collision's position changes
  28410. */
  28411. onCollisionPositionChangeObservable: Observable<Vector3>;
  28412. /** Set a function to call when the collision's position changes */
  28413. set onCollisionPositionChange(callback: () => void);
  28414. /**
  28415. * An event triggered when material is changed
  28416. */
  28417. onMaterialChangedObservable: Observable<AbstractMesh>;
  28418. /**
  28419. * Gets or sets the orientation for POV movement & rotation
  28420. */
  28421. definedFacingForward: boolean;
  28422. /** @hidden */
  28423. _occlusionQuery: Nullable<WebGLQuery>;
  28424. /** @hidden */
  28425. _renderingGroup: Nullable<RenderingGroup>;
  28426. /**
  28427. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28428. */
  28429. get visibility(): number;
  28430. /**
  28431. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28432. */
  28433. set visibility(value: number);
  28434. /** Gets or sets the alpha index used to sort transparent meshes
  28435. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28436. */
  28437. alphaIndex: number;
  28438. /**
  28439. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28440. */
  28441. isVisible: boolean;
  28442. /**
  28443. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28444. */
  28445. isPickable: boolean;
  28446. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28447. showSubMeshesBoundingBox: boolean;
  28448. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28449. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28450. */
  28451. isBlocker: boolean;
  28452. /**
  28453. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28454. */
  28455. enablePointerMoveEvents: boolean;
  28456. /**
  28457. * Specifies the rendering group id for this mesh (0 by default)
  28458. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28459. */
  28460. renderingGroupId: number;
  28461. private _material;
  28462. /** Gets or sets current material */
  28463. get material(): Nullable<Material>;
  28464. set material(value: Nullable<Material>);
  28465. /**
  28466. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28467. * @see http://doc.babylonjs.com/babylon101/shadows
  28468. */
  28469. get receiveShadows(): boolean;
  28470. set receiveShadows(value: boolean);
  28471. /** Defines color to use when rendering outline */
  28472. outlineColor: Color3;
  28473. /** Define width to use when rendering outline */
  28474. outlineWidth: number;
  28475. /** Defines color to use when rendering overlay */
  28476. overlayColor: Color3;
  28477. /** Defines alpha to use when rendering overlay */
  28478. overlayAlpha: number;
  28479. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28480. get hasVertexAlpha(): boolean;
  28481. set hasVertexAlpha(value: boolean);
  28482. /** 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) */
  28483. get useVertexColors(): boolean;
  28484. set useVertexColors(value: boolean);
  28485. /**
  28486. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28487. */
  28488. get computeBonesUsingShaders(): boolean;
  28489. set computeBonesUsingShaders(value: boolean);
  28490. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28491. get numBoneInfluencers(): number;
  28492. set numBoneInfluencers(value: number);
  28493. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28494. get applyFog(): boolean;
  28495. set applyFog(value: boolean);
  28496. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28497. useOctreeForRenderingSelection: boolean;
  28498. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28499. useOctreeForPicking: boolean;
  28500. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28501. useOctreeForCollisions: boolean;
  28502. /**
  28503. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28504. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28505. */
  28506. get layerMask(): number;
  28507. set layerMask(value: number);
  28508. /**
  28509. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28510. */
  28511. alwaysSelectAsActiveMesh: boolean;
  28512. /**
  28513. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28514. */
  28515. doNotSyncBoundingInfo: boolean;
  28516. /**
  28517. * Gets or sets the current action manager
  28518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28519. */
  28520. actionManager: Nullable<AbstractActionManager>;
  28521. private _meshCollisionData;
  28522. /**
  28523. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28525. */
  28526. ellipsoid: Vector3;
  28527. /**
  28528. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28529. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28530. */
  28531. ellipsoidOffset: Vector3;
  28532. /**
  28533. * Gets or sets a collision mask used to mask collisions (default is -1).
  28534. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28535. */
  28536. get collisionMask(): number;
  28537. set collisionMask(mask: number);
  28538. /**
  28539. * Gets or sets the current collision group mask (-1 by default).
  28540. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28541. */
  28542. get collisionGroup(): number;
  28543. set collisionGroup(mask: number);
  28544. /**
  28545. * Gets or sets current surrounding meshes (null by default).
  28546. *
  28547. * By default collision detection is tested against every mesh in the scene.
  28548. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28549. * meshes will be tested for the collision.
  28550. *
  28551. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28552. */
  28553. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28554. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28555. /**
  28556. * Defines edge width used when edgesRenderer is enabled
  28557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28558. */
  28559. edgesWidth: number;
  28560. /**
  28561. * Defines edge color used when edgesRenderer is enabled
  28562. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28563. */
  28564. edgesColor: Color4;
  28565. /** @hidden */
  28566. _edgesRenderer: Nullable<IEdgesRenderer>;
  28567. /** @hidden */
  28568. _masterMesh: Nullable<AbstractMesh>;
  28569. /** @hidden */
  28570. _boundingInfo: Nullable<BoundingInfo>;
  28571. /** @hidden */
  28572. _renderId: number;
  28573. /**
  28574. * Gets or sets the list of subMeshes
  28575. * @see http://doc.babylonjs.com/how_to/multi_materials
  28576. */
  28577. subMeshes: SubMesh[];
  28578. /** @hidden */
  28579. _intersectionsInProgress: AbstractMesh[];
  28580. /** @hidden */
  28581. _unIndexed: boolean;
  28582. /** @hidden */
  28583. _lightSources: Light[];
  28584. /** Gets the list of lights affecting that mesh */
  28585. get lightSources(): Light[];
  28586. /** @hidden */
  28587. get _positions(): Nullable<Vector3[]>;
  28588. /** @hidden */
  28589. _waitingData: {
  28590. lods: Nullable<any>;
  28591. actions: Nullable<any>;
  28592. freezeWorldMatrix: Nullable<boolean>;
  28593. };
  28594. /** @hidden */
  28595. _bonesTransformMatrices: Nullable<Float32Array>;
  28596. /** @hidden */
  28597. _transformMatrixTexture: Nullable<RawTexture>;
  28598. /**
  28599. * Gets or sets a skeleton to apply skining transformations
  28600. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28601. */
  28602. set skeleton(value: Nullable<Skeleton>);
  28603. get skeleton(): Nullable<Skeleton>;
  28604. /**
  28605. * An event triggered when the mesh is rebuilt.
  28606. */
  28607. onRebuildObservable: Observable<AbstractMesh>;
  28608. /**
  28609. * Creates a new AbstractMesh
  28610. * @param name defines the name of the mesh
  28611. * @param scene defines the hosting scene
  28612. */
  28613. constructor(name: string, scene?: Nullable<Scene>);
  28614. /**
  28615. * Returns the string "AbstractMesh"
  28616. * @returns "AbstractMesh"
  28617. */
  28618. getClassName(): string;
  28619. /**
  28620. * Gets a string representation of the current mesh
  28621. * @param fullDetails defines a boolean indicating if full details must be included
  28622. * @returns a string representation of the current mesh
  28623. */
  28624. toString(fullDetails?: boolean): string;
  28625. /**
  28626. * @hidden
  28627. */
  28628. protected _getEffectiveParent(): Nullable<Node>;
  28629. /** @hidden */
  28630. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28631. /** @hidden */
  28632. _rebuild(): void;
  28633. /** @hidden */
  28634. _resyncLightSources(): void;
  28635. /** @hidden */
  28636. _resyncLightSource(light: Light): void;
  28637. /** @hidden */
  28638. _unBindEffect(): void;
  28639. /** @hidden */
  28640. _removeLightSource(light: Light, dispose: boolean): void;
  28641. private _markSubMeshesAsDirty;
  28642. /** @hidden */
  28643. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28644. /** @hidden */
  28645. _markSubMeshesAsAttributesDirty(): void;
  28646. /** @hidden */
  28647. _markSubMeshesAsMiscDirty(): void;
  28648. /**
  28649. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28650. */
  28651. get scaling(): Vector3;
  28652. set scaling(newScaling: Vector3);
  28653. /**
  28654. * Returns true if the mesh is blocked. Implemented by child classes
  28655. */
  28656. get isBlocked(): boolean;
  28657. /**
  28658. * Returns the mesh itself by default. Implemented by child classes
  28659. * @param camera defines the camera to use to pick the right LOD level
  28660. * @returns the currentAbstractMesh
  28661. */
  28662. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28663. /**
  28664. * Returns 0 by default. Implemented by child classes
  28665. * @returns an integer
  28666. */
  28667. getTotalVertices(): number;
  28668. /**
  28669. * Returns a positive integer : the total number of indices in this mesh geometry.
  28670. * @returns the numner of indices or zero if the mesh has no geometry.
  28671. */
  28672. getTotalIndices(): number;
  28673. /**
  28674. * Returns null by default. Implemented by child classes
  28675. * @returns null
  28676. */
  28677. getIndices(): Nullable<IndicesArray>;
  28678. /**
  28679. * Returns the array of the requested vertex data kind. Implemented by child classes
  28680. * @param kind defines the vertex data kind to use
  28681. * @returns null
  28682. */
  28683. getVerticesData(kind: string): Nullable<FloatArray>;
  28684. /**
  28685. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28686. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28687. * Note that a new underlying VertexBuffer object is created each call.
  28688. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28689. * @param kind defines vertex data kind:
  28690. * * VertexBuffer.PositionKind
  28691. * * VertexBuffer.UVKind
  28692. * * VertexBuffer.UV2Kind
  28693. * * VertexBuffer.UV3Kind
  28694. * * VertexBuffer.UV4Kind
  28695. * * VertexBuffer.UV5Kind
  28696. * * VertexBuffer.UV6Kind
  28697. * * VertexBuffer.ColorKind
  28698. * * VertexBuffer.MatricesIndicesKind
  28699. * * VertexBuffer.MatricesIndicesExtraKind
  28700. * * VertexBuffer.MatricesWeightsKind
  28701. * * VertexBuffer.MatricesWeightsExtraKind
  28702. * @param data defines the data source
  28703. * @param updatable defines if the data must be flagged as updatable (or static)
  28704. * @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
  28705. * @returns the current mesh
  28706. */
  28707. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28708. /**
  28709. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28710. * If the mesh has no geometry, it is simply returned as it is.
  28711. * @param kind defines vertex data kind:
  28712. * * VertexBuffer.PositionKind
  28713. * * VertexBuffer.UVKind
  28714. * * VertexBuffer.UV2Kind
  28715. * * VertexBuffer.UV3Kind
  28716. * * VertexBuffer.UV4Kind
  28717. * * VertexBuffer.UV5Kind
  28718. * * VertexBuffer.UV6Kind
  28719. * * VertexBuffer.ColorKind
  28720. * * VertexBuffer.MatricesIndicesKind
  28721. * * VertexBuffer.MatricesIndicesExtraKind
  28722. * * VertexBuffer.MatricesWeightsKind
  28723. * * VertexBuffer.MatricesWeightsExtraKind
  28724. * @param data defines the data source
  28725. * @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
  28726. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28727. * @returns the current mesh
  28728. */
  28729. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28730. /**
  28731. * Sets the mesh indices,
  28732. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28733. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28734. * @param totalVertices Defines the total number of vertices
  28735. * @returns the current mesh
  28736. */
  28737. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28738. /**
  28739. * Gets a boolean indicating if specific vertex data is present
  28740. * @param kind defines the vertex data kind to use
  28741. * @returns true is data kind is present
  28742. */
  28743. isVerticesDataPresent(kind: string): boolean;
  28744. /**
  28745. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28746. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28747. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28748. * @returns a BoundingInfo
  28749. */
  28750. getBoundingInfo(): BoundingInfo;
  28751. /**
  28752. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28753. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28754. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28755. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28756. * @returns the current mesh
  28757. */
  28758. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28759. /**
  28760. * Overwrite the current bounding info
  28761. * @param boundingInfo defines the new bounding info
  28762. * @returns the current mesh
  28763. */
  28764. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28765. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28766. get useBones(): boolean;
  28767. /** @hidden */
  28768. _preActivate(): void;
  28769. /** @hidden */
  28770. _preActivateForIntermediateRendering(renderId: number): void;
  28771. /** @hidden */
  28772. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28773. /** @hidden */
  28774. _postActivate(): void;
  28775. /** @hidden */
  28776. _freeze(): void;
  28777. /** @hidden */
  28778. _unFreeze(): void;
  28779. /**
  28780. * Gets the current world matrix
  28781. * @returns a Matrix
  28782. */
  28783. getWorldMatrix(): Matrix;
  28784. /** @hidden */
  28785. _getWorldMatrixDeterminant(): number;
  28786. /**
  28787. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28788. */
  28789. get isAnInstance(): boolean;
  28790. /**
  28791. * Gets a boolean indicating if this mesh has instances
  28792. */
  28793. get hasInstances(): boolean;
  28794. /**
  28795. * Perform relative position change from the point of view of behind the front of the mesh.
  28796. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28797. * Supports definition of mesh facing forward or backward
  28798. * @param amountRight defines the distance on the right axis
  28799. * @param amountUp defines the distance on the up axis
  28800. * @param amountForward defines the distance on the forward axis
  28801. * @returns the current mesh
  28802. */
  28803. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28804. /**
  28805. * Calculate relative position change from the point of view of behind the front of the mesh.
  28806. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28807. * Supports definition of mesh facing forward or backward
  28808. * @param amountRight defines the distance on the right axis
  28809. * @param amountUp defines the distance on the up axis
  28810. * @param amountForward defines the distance on the forward axis
  28811. * @returns the new displacement vector
  28812. */
  28813. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28814. /**
  28815. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28816. * Supports definition of mesh facing forward or backward
  28817. * @param flipBack defines the flip
  28818. * @param twirlClockwise defines the twirl
  28819. * @param tiltRight defines the tilt
  28820. * @returns the current mesh
  28821. */
  28822. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28823. /**
  28824. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28825. * Supports definition of mesh facing forward or backward.
  28826. * @param flipBack defines the flip
  28827. * @param twirlClockwise defines the twirl
  28828. * @param tiltRight defines the tilt
  28829. * @returns the new rotation vector
  28830. */
  28831. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28832. /**
  28833. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28834. * This means the mesh underlying bounding box and sphere are recomputed.
  28835. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28836. * @returns the current mesh
  28837. */
  28838. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28839. /** @hidden */
  28840. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28841. /** @hidden */
  28842. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28843. /** @hidden */
  28844. _updateBoundingInfo(): AbstractMesh;
  28845. /** @hidden */
  28846. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28847. /** @hidden */
  28848. protected _afterComputeWorldMatrix(): void;
  28849. /** @hidden */
  28850. get _effectiveMesh(): AbstractMesh;
  28851. /**
  28852. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28853. * A mesh is in the frustum if its bounding box intersects the frustum
  28854. * @param frustumPlanes defines the frustum to test
  28855. * @returns true if the mesh is in the frustum planes
  28856. */
  28857. isInFrustum(frustumPlanes: Plane[]): boolean;
  28858. /**
  28859. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28860. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28861. * @param frustumPlanes defines the frustum to test
  28862. * @returns true if the mesh is completely in the frustum planes
  28863. */
  28864. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28865. /**
  28866. * True if the mesh intersects another mesh or a SolidParticle object
  28867. * @param mesh defines a target mesh or SolidParticle to test
  28868. * @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)
  28869. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28870. * @returns true if there is an intersection
  28871. */
  28872. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28873. /**
  28874. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28875. * @param point defines the point to test
  28876. * @returns true if there is an intersection
  28877. */
  28878. intersectsPoint(point: Vector3): boolean;
  28879. /**
  28880. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28881. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28882. */
  28883. get checkCollisions(): boolean;
  28884. set checkCollisions(collisionEnabled: boolean);
  28885. /**
  28886. * Gets Collider object used to compute collisions (not physics)
  28887. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28888. */
  28889. get collider(): Nullable<Collider>;
  28890. /**
  28891. * Move the mesh using collision engine
  28892. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28893. * @param displacement defines the requested displacement vector
  28894. * @returns the current mesh
  28895. */
  28896. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28897. private _onCollisionPositionChange;
  28898. /** @hidden */
  28899. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28900. /** @hidden */
  28901. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28902. /** @hidden */
  28903. _checkCollision(collider: Collider): AbstractMesh;
  28904. /** @hidden */
  28905. _generatePointsArray(): boolean;
  28906. /**
  28907. * Checks if the passed Ray intersects with the mesh
  28908. * @param ray defines the ray to use
  28909. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28910. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28911. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  28912. * @returns the picking info
  28913. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28914. */
  28915. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  28916. /**
  28917. * Clones the current mesh
  28918. * @param name defines the mesh name
  28919. * @param newParent defines the new mesh parent
  28920. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28921. * @returns the new mesh
  28922. */
  28923. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28924. /**
  28925. * Disposes all the submeshes of the current meshnp
  28926. * @returns the current mesh
  28927. */
  28928. releaseSubMeshes(): AbstractMesh;
  28929. /**
  28930. * Releases resources associated with this abstract mesh.
  28931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28933. */
  28934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28935. /**
  28936. * Adds the passed mesh as a child to the current mesh
  28937. * @param mesh defines the child mesh
  28938. * @returns the current mesh
  28939. */
  28940. addChild(mesh: AbstractMesh): AbstractMesh;
  28941. /**
  28942. * Removes the passed mesh from the current mesh children list
  28943. * @param mesh defines the child mesh
  28944. * @returns the current mesh
  28945. */
  28946. removeChild(mesh: AbstractMesh): AbstractMesh;
  28947. /** @hidden */
  28948. private _initFacetData;
  28949. /**
  28950. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28951. * This method can be called within the render loop.
  28952. * 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
  28953. * @returns the current mesh
  28954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28955. */
  28956. updateFacetData(): AbstractMesh;
  28957. /**
  28958. * Returns the facetLocalNormals array.
  28959. * The normals are expressed in the mesh local spac
  28960. * @returns an array of Vector3
  28961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28962. */
  28963. getFacetLocalNormals(): Vector3[];
  28964. /**
  28965. * Returns the facetLocalPositions array.
  28966. * The facet positions are expressed in the mesh local space
  28967. * @returns an array of Vector3
  28968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28969. */
  28970. getFacetLocalPositions(): Vector3[];
  28971. /**
  28972. * Returns the facetLocalPartioning array
  28973. * @returns an array of array of numbers
  28974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28975. */
  28976. getFacetLocalPartitioning(): number[][];
  28977. /**
  28978. * Returns the i-th facet position in the world system.
  28979. * This method allocates a new Vector3 per call
  28980. * @param i defines the facet index
  28981. * @returns a new Vector3
  28982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28983. */
  28984. getFacetPosition(i: number): Vector3;
  28985. /**
  28986. * Sets the reference Vector3 with the i-th facet position in the world system
  28987. * @param i defines the facet index
  28988. * @param ref defines the target vector
  28989. * @returns the current mesh
  28990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28991. */
  28992. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28993. /**
  28994. * Returns the i-th facet normal in the world system.
  28995. * This method allocates a new Vector3 per call
  28996. * @param i defines the facet index
  28997. * @returns a new Vector3
  28998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28999. */
  29000. getFacetNormal(i: number): Vector3;
  29001. /**
  29002. * Sets the reference Vector3 with the i-th facet normal in the world system
  29003. * @param i defines the facet index
  29004. * @param ref defines the target vector
  29005. * @returns the current mesh
  29006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29007. */
  29008. getFacetNormalToRef(i: number, ref: Vector3): this;
  29009. /**
  29010. * 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)
  29011. * @param x defines x coordinate
  29012. * @param y defines y coordinate
  29013. * @param z defines z coordinate
  29014. * @returns the array of facet indexes
  29015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29016. */
  29017. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29018. /**
  29019. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29020. * @param projected sets as the (x,y,z) world projection on the facet
  29021. * @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
  29022. * @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
  29023. * @param x defines x coordinate
  29024. * @param y defines y coordinate
  29025. * @param z defines z coordinate
  29026. * @returns the face index if found (or null instead)
  29027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29028. */
  29029. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29030. /**
  29031. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29032. * @param projected sets as the (x,y,z) local projection on the facet
  29033. * @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
  29034. * @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
  29035. * @param x defines x coordinate
  29036. * @param y defines y coordinate
  29037. * @param z defines z coordinate
  29038. * @returns the face index if found (or null instead)
  29039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29040. */
  29041. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29042. /**
  29043. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29044. * @returns the parameters
  29045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29046. */
  29047. getFacetDataParameters(): any;
  29048. /**
  29049. * Disables the feature FacetData and frees the related memory
  29050. * @returns the current mesh
  29051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29052. */
  29053. disableFacetData(): AbstractMesh;
  29054. /**
  29055. * Updates the AbstractMesh indices array
  29056. * @param indices defines the data source
  29057. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29058. * @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)
  29059. * @returns the current mesh
  29060. */
  29061. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29062. /**
  29063. * Creates new normals data for the mesh
  29064. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29065. * @returns the current mesh
  29066. */
  29067. createNormals(updatable: boolean): AbstractMesh;
  29068. /**
  29069. * Align the mesh with a normal
  29070. * @param normal defines the normal to use
  29071. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29072. * @returns the current mesh
  29073. */
  29074. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29075. /** @hidden */
  29076. _checkOcclusionQuery(): boolean;
  29077. /**
  29078. * Disables the mesh edge rendering mode
  29079. * @returns the currentAbstractMesh
  29080. */
  29081. disableEdgesRendering(): AbstractMesh;
  29082. /**
  29083. * Enables the edge rendering mode on the mesh.
  29084. * This mode makes the mesh edges visible
  29085. * @param epsilon defines the maximal distance between two angles to detect a face
  29086. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29087. * @returns the currentAbstractMesh
  29088. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29089. */
  29090. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29091. }
  29092. }
  29093. declare module BABYLON {
  29094. /**
  29095. * Interface used to define ActionEvent
  29096. */
  29097. export interface IActionEvent {
  29098. /** The mesh or sprite that triggered the action */
  29099. source: any;
  29100. /** The X mouse cursor position at the time of the event */
  29101. pointerX: number;
  29102. /** The Y mouse cursor position at the time of the event */
  29103. pointerY: number;
  29104. /** The mesh that is currently pointed at (can be null) */
  29105. meshUnderPointer: Nullable<AbstractMesh>;
  29106. /** the original (browser) event that triggered the ActionEvent */
  29107. sourceEvent?: any;
  29108. /** additional data for the event */
  29109. additionalData?: any;
  29110. }
  29111. /**
  29112. * ActionEvent is the event being sent when an action is triggered.
  29113. */
  29114. export class ActionEvent implements IActionEvent {
  29115. /** The mesh or sprite that triggered the action */
  29116. source: any;
  29117. /** The X mouse cursor position at the time of the event */
  29118. pointerX: number;
  29119. /** The Y mouse cursor position at the time of the event */
  29120. pointerY: number;
  29121. /** The mesh that is currently pointed at (can be null) */
  29122. meshUnderPointer: Nullable<AbstractMesh>;
  29123. /** the original (browser) event that triggered the ActionEvent */
  29124. sourceEvent?: any;
  29125. /** additional data for the event */
  29126. additionalData?: any;
  29127. /**
  29128. * Creates a new ActionEvent
  29129. * @param source The mesh or sprite that triggered the action
  29130. * @param pointerX The X mouse cursor position at the time of the event
  29131. * @param pointerY The Y mouse cursor position at the time of the event
  29132. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29133. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29134. * @param additionalData additional data for the event
  29135. */
  29136. constructor(
  29137. /** The mesh or sprite that triggered the action */
  29138. source: any,
  29139. /** The X mouse cursor position at the time of the event */
  29140. pointerX: number,
  29141. /** The Y mouse cursor position at the time of the event */
  29142. pointerY: number,
  29143. /** The mesh that is currently pointed at (can be null) */
  29144. meshUnderPointer: Nullable<AbstractMesh>,
  29145. /** the original (browser) event that triggered the ActionEvent */
  29146. sourceEvent?: any,
  29147. /** additional data for the event */
  29148. additionalData?: any);
  29149. /**
  29150. * Helper function to auto-create an ActionEvent from a source mesh.
  29151. * @param source The source mesh that triggered the event
  29152. * @param evt The original (browser) event
  29153. * @param additionalData additional data for the event
  29154. * @returns the new ActionEvent
  29155. */
  29156. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29157. /**
  29158. * Helper function to auto-create an ActionEvent from a source sprite
  29159. * @param source The source sprite that triggered the event
  29160. * @param scene Scene associated with the sprite
  29161. * @param evt The original (browser) event
  29162. * @param additionalData additional data for the event
  29163. * @returns the new ActionEvent
  29164. */
  29165. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29166. /**
  29167. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29168. * @param scene the scene where the event occurred
  29169. * @param evt The original (browser) event
  29170. * @returns the new ActionEvent
  29171. */
  29172. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29173. /**
  29174. * Helper function to auto-create an ActionEvent from a primitive
  29175. * @param prim defines the target primitive
  29176. * @param pointerPos defines the pointer position
  29177. * @param evt The original (browser) event
  29178. * @param additionalData additional data for the event
  29179. * @returns the new ActionEvent
  29180. */
  29181. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29182. }
  29183. }
  29184. declare module BABYLON {
  29185. /**
  29186. * Abstract class used to decouple action Manager from scene and meshes.
  29187. * Do not instantiate.
  29188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29189. */
  29190. export abstract class AbstractActionManager implements IDisposable {
  29191. /** Gets the list of active triggers */
  29192. static Triggers: {
  29193. [key: string]: number;
  29194. };
  29195. /** Gets the cursor to use when hovering items */
  29196. hoverCursor: string;
  29197. /** Gets the list of actions */
  29198. actions: IAction[];
  29199. /**
  29200. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29201. */
  29202. isRecursive: boolean;
  29203. /**
  29204. * Releases all associated resources
  29205. */
  29206. abstract dispose(): void;
  29207. /**
  29208. * Does this action manager has pointer triggers
  29209. */
  29210. abstract get hasPointerTriggers(): boolean;
  29211. /**
  29212. * Does this action manager has pick triggers
  29213. */
  29214. abstract get hasPickTriggers(): boolean;
  29215. /**
  29216. * Process a specific trigger
  29217. * @param trigger defines the trigger to process
  29218. * @param evt defines the event details to be processed
  29219. */
  29220. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29221. /**
  29222. * Does this action manager handles actions of any of the given triggers
  29223. * @param triggers defines the triggers to be tested
  29224. * @return a boolean indicating whether one (or more) of the triggers is handled
  29225. */
  29226. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29227. /**
  29228. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29229. * speed.
  29230. * @param triggerA defines the trigger to be tested
  29231. * @param triggerB defines the trigger to be tested
  29232. * @return a boolean indicating whether one (or more) of the triggers is handled
  29233. */
  29234. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29235. /**
  29236. * Does this action manager handles actions of a given trigger
  29237. * @param trigger defines the trigger to be tested
  29238. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29239. * @return whether the trigger is handled
  29240. */
  29241. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29242. /**
  29243. * Serialize this manager to a JSON object
  29244. * @param name defines the property name to store this manager
  29245. * @returns a JSON representation of this manager
  29246. */
  29247. abstract serialize(name: string): any;
  29248. /**
  29249. * Registers an action to this action manager
  29250. * @param action defines the action to be registered
  29251. * @return the action amended (prepared) after registration
  29252. */
  29253. abstract registerAction(action: IAction): Nullable<IAction>;
  29254. /**
  29255. * Unregisters an action to this action manager
  29256. * @param action defines the action to be unregistered
  29257. * @return a boolean indicating whether the action has been unregistered
  29258. */
  29259. abstract unregisterAction(action: IAction): Boolean;
  29260. /**
  29261. * Does exist one action manager with at least one trigger
  29262. **/
  29263. static get HasTriggers(): boolean;
  29264. /**
  29265. * Does exist one action manager with at least one pick trigger
  29266. **/
  29267. static get HasPickTriggers(): boolean;
  29268. /**
  29269. * Does exist one action manager that handles actions of a given trigger
  29270. * @param trigger defines the trigger to be tested
  29271. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29272. **/
  29273. static HasSpecificTrigger(trigger: number): boolean;
  29274. }
  29275. }
  29276. declare module BABYLON {
  29277. /**
  29278. * Defines how a node can be built from a string name.
  29279. */
  29280. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29281. /**
  29282. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29283. */
  29284. export class Node implements IBehaviorAware<Node> {
  29285. /** @hidden */
  29286. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29287. private static _NodeConstructors;
  29288. /**
  29289. * Add a new node constructor
  29290. * @param type defines the type name of the node to construct
  29291. * @param constructorFunc defines the constructor function
  29292. */
  29293. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29294. /**
  29295. * Returns a node constructor based on type name
  29296. * @param type defines the type name
  29297. * @param name defines the new node name
  29298. * @param scene defines the hosting scene
  29299. * @param options defines optional options to transmit to constructors
  29300. * @returns the new constructor or null
  29301. */
  29302. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29303. /**
  29304. * Gets or sets the name of the node
  29305. */
  29306. name: string;
  29307. /**
  29308. * Gets or sets the id of the node
  29309. */
  29310. id: string;
  29311. /**
  29312. * Gets or sets the unique id of the node
  29313. */
  29314. uniqueId: number;
  29315. /**
  29316. * Gets or sets a string used to store user defined state for the node
  29317. */
  29318. state: string;
  29319. /**
  29320. * Gets or sets an object used to store user defined information for the node
  29321. */
  29322. metadata: any;
  29323. /**
  29324. * For internal use only. Please do not use.
  29325. */
  29326. reservedDataStore: any;
  29327. /**
  29328. * List of inspectable custom properties (used by the Inspector)
  29329. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29330. */
  29331. inspectableCustomProperties: IInspectable[];
  29332. private _doNotSerialize;
  29333. /**
  29334. * Gets or sets a boolean used to define if the node must be serialized
  29335. */
  29336. get doNotSerialize(): boolean;
  29337. set doNotSerialize(value: boolean);
  29338. /** @hidden */
  29339. _isDisposed: boolean;
  29340. /**
  29341. * Gets a list of Animations associated with the node
  29342. */
  29343. animations: Animation[];
  29344. protected _ranges: {
  29345. [name: string]: Nullable<AnimationRange>;
  29346. };
  29347. /**
  29348. * Callback raised when the node is ready to be used
  29349. */
  29350. onReady: Nullable<(node: Node) => void>;
  29351. private _isEnabled;
  29352. private _isParentEnabled;
  29353. private _isReady;
  29354. /** @hidden */
  29355. _currentRenderId: number;
  29356. private _parentUpdateId;
  29357. /** @hidden */
  29358. _childUpdateId: number;
  29359. /** @hidden */
  29360. _waitingParentId: Nullable<string>;
  29361. /** @hidden */
  29362. _scene: Scene;
  29363. /** @hidden */
  29364. _cache: any;
  29365. private _parentNode;
  29366. private _children;
  29367. /** @hidden */
  29368. _worldMatrix: Matrix;
  29369. /** @hidden */
  29370. _worldMatrixDeterminant: number;
  29371. /** @hidden */
  29372. _worldMatrixDeterminantIsDirty: boolean;
  29373. /** @hidden */
  29374. private _sceneRootNodesIndex;
  29375. /**
  29376. * Gets a boolean indicating if the node has been disposed
  29377. * @returns true if the node was disposed
  29378. */
  29379. isDisposed(): boolean;
  29380. /**
  29381. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29382. * @see https://doc.babylonjs.com/how_to/parenting
  29383. */
  29384. set parent(parent: Nullable<Node>);
  29385. get parent(): Nullable<Node>;
  29386. /** @hidden */
  29387. _addToSceneRootNodes(): void;
  29388. /** @hidden */
  29389. _removeFromSceneRootNodes(): void;
  29390. private _animationPropertiesOverride;
  29391. /**
  29392. * Gets or sets the animation properties override
  29393. */
  29394. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29395. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29396. /**
  29397. * Gets a string idenfifying the name of the class
  29398. * @returns "Node" string
  29399. */
  29400. getClassName(): string;
  29401. /** @hidden */
  29402. readonly _isNode: boolean;
  29403. /**
  29404. * An event triggered when the mesh is disposed
  29405. */
  29406. onDisposeObservable: Observable<Node>;
  29407. private _onDisposeObserver;
  29408. /**
  29409. * Sets a callback that will be raised when the node will be disposed
  29410. */
  29411. set onDispose(callback: () => void);
  29412. /**
  29413. * Creates a new Node
  29414. * @param name the name and id to be given to this node
  29415. * @param scene the scene this node will be added to
  29416. */
  29417. constructor(name: string, scene?: Nullable<Scene>);
  29418. /**
  29419. * Gets the scene of the node
  29420. * @returns a scene
  29421. */
  29422. getScene(): Scene;
  29423. /**
  29424. * Gets the engine of the node
  29425. * @returns a Engine
  29426. */
  29427. getEngine(): Engine;
  29428. private _behaviors;
  29429. /**
  29430. * Attach a behavior to the node
  29431. * @see http://doc.babylonjs.com/features/behaviour
  29432. * @param behavior defines the behavior to attach
  29433. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29434. * @returns the current Node
  29435. */
  29436. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29437. /**
  29438. * Remove an attached behavior
  29439. * @see http://doc.babylonjs.com/features/behaviour
  29440. * @param behavior defines the behavior to attach
  29441. * @returns the current Node
  29442. */
  29443. removeBehavior(behavior: Behavior<Node>): Node;
  29444. /**
  29445. * Gets the list of attached behaviors
  29446. * @see http://doc.babylonjs.com/features/behaviour
  29447. */
  29448. get behaviors(): Behavior<Node>[];
  29449. /**
  29450. * Gets an attached behavior by name
  29451. * @param name defines the name of the behavior to look for
  29452. * @see http://doc.babylonjs.com/features/behaviour
  29453. * @returns null if behavior was not found else the requested behavior
  29454. */
  29455. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29456. /**
  29457. * Returns the latest update of the World matrix
  29458. * @returns a Matrix
  29459. */
  29460. getWorldMatrix(): Matrix;
  29461. /** @hidden */
  29462. _getWorldMatrixDeterminant(): number;
  29463. /**
  29464. * Returns directly the latest state of the mesh World matrix.
  29465. * A Matrix is returned.
  29466. */
  29467. get worldMatrixFromCache(): Matrix;
  29468. /** @hidden */
  29469. _initCache(): void;
  29470. /** @hidden */
  29471. updateCache(force?: boolean): void;
  29472. /** @hidden */
  29473. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29474. /** @hidden */
  29475. _updateCache(ignoreParentClass?: boolean): void;
  29476. /** @hidden */
  29477. _isSynchronized(): boolean;
  29478. /** @hidden */
  29479. _markSyncedWithParent(): void;
  29480. /** @hidden */
  29481. isSynchronizedWithParent(): boolean;
  29482. /** @hidden */
  29483. isSynchronized(): boolean;
  29484. /**
  29485. * Is this node ready to be used/rendered
  29486. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29487. * @return true if the node is ready
  29488. */
  29489. isReady(completeCheck?: boolean): boolean;
  29490. /**
  29491. * Is this node enabled?
  29492. * 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
  29493. * @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
  29494. * @return whether this node (and its parent) is enabled
  29495. */
  29496. isEnabled(checkAncestors?: boolean): boolean;
  29497. /** @hidden */
  29498. protected _syncParentEnabledState(): void;
  29499. /**
  29500. * Set the enabled state of this node
  29501. * @param value defines the new enabled state
  29502. */
  29503. setEnabled(value: boolean): void;
  29504. /**
  29505. * Is this node a descendant of the given node?
  29506. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29507. * @param ancestor defines the parent node to inspect
  29508. * @returns a boolean indicating if this node is a descendant of the given node
  29509. */
  29510. isDescendantOf(ancestor: Node): boolean;
  29511. /** @hidden */
  29512. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29513. /**
  29514. * Will return all nodes that have this node as ascendant
  29515. * @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
  29516. * @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
  29517. * @return all children nodes of all types
  29518. */
  29519. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29520. /**
  29521. * Get all child-meshes of this node
  29522. * @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)
  29523. * @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
  29524. * @returns an array of AbstractMesh
  29525. */
  29526. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29527. /**
  29528. * Get all direct children of this node
  29529. * @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
  29530. * @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)
  29531. * @returns an array of Node
  29532. */
  29533. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29534. /** @hidden */
  29535. _setReady(state: boolean): void;
  29536. /**
  29537. * Get an animation by name
  29538. * @param name defines the name of the animation to look for
  29539. * @returns null if not found else the requested animation
  29540. */
  29541. getAnimationByName(name: string): Nullable<Animation>;
  29542. /**
  29543. * Creates an animation range for this node
  29544. * @param name defines the name of the range
  29545. * @param from defines the starting key
  29546. * @param to defines the end key
  29547. */
  29548. createAnimationRange(name: string, from: number, to: number): void;
  29549. /**
  29550. * Delete a specific animation range
  29551. * @param name defines the name of the range to delete
  29552. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29553. */
  29554. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29555. /**
  29556. * Get an animation range by name
  29557. * @param name defines the name of the animation range to look for
  29558. * @returns null if not found else the requested animation range
  29559. */
  29560. getAnimationRange(name: string): Nullable<AnimationRange>;
  29561. /**
  29562. * Gets the list of all animation ranges defined on this node
  29563. * @returns an array
  29564. */
  29565. getAnimationRanges(): Nullable<AnimationRange>[];
  29566. /**
  29567. * Will start the animation sequence
  29568. * @param name defines the range frames for animation sequence
  29569. * @param loop defines if the animation should loop (false by default)
  29570. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29571. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29572. * @returns the object created for this animation. If range does not exist, it will return null
  29573. */
  29574. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29575. /**
  29576. * Serialize animation ranges into a JSON compatible object
  29577. * @returns serialization object
  29578. */
  29579. serializeAnimationRanges(): any;
  29580. /**
  29581. * Computes the world matrix of the node
  29582. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29583. * @returns the world matrix
  29584. */
  29585. computeWorldMatrix(force?: boolean): Matrix;
  29586. /**
  29587. * Releases resources associated with this node.
  29588. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29589. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29590. */
  29591. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29592. /**
  29593. * Parse animation range data from a serialization object and store them into a given node
  29594. * @param node defines where to store the animation ranges
  29595. * @param parsedNode defines the serialization object to read data from
  29596. * @param scene defines the hosting scene
  29597. */
  29598. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29599. /**
  29600. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29601. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29602. * @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
  29603. * @returns the new bounding vectors
  29604. */
  29605. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29606. min: Vector3;
  29607. max: Vector3;
  29608. };
  29609. }
  29610. }
  29611. declare module BABYLON {
  29612. /**
  29613. * @hidden
  29614. */
  29615. export class _IAnimationState {
  29616. key: number;
  29617. repeatCount: number;
  29618. workValue?: any;
  29619. loopMode?: number;
  29620. offsetValue?: any;
  29621. highLimitValue?: any;
  29622. }
  29623. /**
  29624. * Class used to store any kind of animation
  29625. */
  29626. export class Animation {
  29627. /**Name of the animation */
  29628. name: string;
  29629. /**Property to animate */
  29630. targetProperty: string;
  29631. /**The frames per second of the animation */
  29632. framePerSecond: number;
  29633. /**The data type of the animation */
  29634. dataType: number;
  29635. /**The loop mode of the animation */
  29636. loopMode?: number | undefined;
  29637. /**Specifies if blending should be enabled */
  29638. enableBlending?: boolean | undefined;
  29639. /**
  29640. * Use matrix interpolation instead of using direct key value when animating matrices
  29641. */
  29642. static AllowMatricesInterpolation: boolean;
  29643. /**
  29644. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29645. */
  29646. static AllowMatrixDecomposeForInterpolation: boolean;
  29647. /**
  29648. * Stores the key frames of the animation
  29649. */
  29650. private _keys;
  29651. /**
  29652. * Stores the easing function of the animation
  29653. */
  29654. private _easingFunction;
  29655. /**
  29656. * @hidden Internal use only
  29657. */
  29658. _runtimeAnimations: RuntimeAnimation[];
  29659. /**
  29660. * The set of event that will be linked to this animation
  29661. */
  29662. private _events;
  29663. /**
  29664. * Stores an array of target property paths
  29665. */
  29666. targetPropertyPath: string[];
  29667. /**
  29668. * Stores the blending speed of the animation
  29669. */
  29670. blendingSpeed: number;
  29671. /**
  29672. * Stores the animation ranges for the animation
  29673. */
  29674. private _ranges;
  29675. /**
  29676. * @hidden Internal use
  29677. */
  29678. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29679. /**
  29680. * Sets up an animation
  29681. * @param property The property to animate
  29682. * @param animationType The animation type to apply
  29683. * @param framePerSecond The frames per second of the animation
  29684. * @param easingFunction The easing function used in the animation
  29685. * @returns The created animation
  29686. */
  29687. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29688. /**
  29689. * Create and start an animation on a node
  29690. * @param name defines the name of the global animation that will be run on all nodes
  29691. * @param node defines the root node where the animation will take place
  29692. * @param targetProperty defines property to animate
  29693. * @param framePerSecond defines the number of frame per second yo use
  29694. * @param totalFrame defines the number of frames in total
  29695. * @param from defines the initial value
  29696. * @param to defines the final value
  29697. * @param loopMode defines which loop mode you want to use (off by default)
  29698. * @param easingFunction defines the easing function to use (linear by default)
  29699. * @param onAnimationEnd defines the callback to call when animation end
  29700. * @returns the animatable created for this animation
  29701. */
  29702. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29703. /**
  29704. * Create and start an animation on a node and its descendants
  29705. * @param name defines the name of the global animation that will be run on all nodes
  29706. * @param node defines the root node where the animation will take place
  29707. * @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
  29708. * @param targetProperty defines property to animate
  29709. * @param framePerSecond defines the number of frame per second to use
  29710. * @param totalFrame defines the number of frames in total
  29711. * @param from defines the initial value
  29712. * @param to defines the final value
  29713. * @param loopMode defines which loop mode you want to use (off by default)
  29714. * @param easingFunction defines the easing function to use (linear by default)
  29715. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29716. * @returns the list of animatables created for all nodes
  29717. * @example https://www.babylonjs-playground.com/#MH0VLI
  29718. */
  29719. 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[]>;
  29720. /**
  29721. * Creates a new animation, merges it with the existing animations and starts it
  29722. * @param name Name of the animation
  29723. * @param node Node which contains the scene that begins the animations
  29724. * @param targetProperty Specifies which property to animate
  29725. * @param framePerSecond The frames per second of the animation
  29726. * @param totalFrame The total number of frames
  29727. * @param from The frame at the beginning of the animation
  29728. * @param to The frame at the end of the animation
  29729. * @param loopMode Specifies the loop mode of the animation
  29730. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29731. * @param onAnimationEnd Callback to run once the animation is complete
  29732. * @returns Nullable animation
  29733. */
  29734. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29735. /**
  29736. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29737. * @param sourceAnimation defines the Animation containing keyframes to convert
  29738. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29739. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29740. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29741. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29742. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29743. */
  29744. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29745. /**
  29746. * Transition property of an host to the target Value
  29747. * @param property The property to transition
  29748. * @param targetValue The target Value of the property
  29749. * @param host The object where the property to animate belongs
  29750. * @param scene Scene used to run the animation
  29751. * @param frameRate Framerate (in frame/s) to use
  29752. * @param transition The transition type we want to use
  29753. * @param duration The duration of the animation, in milliseconds
  29754. * @param onAnimationEnd Callback trigger at the end of the animation
  29755. * @returns Nullable animation
  29756. */
  29757. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29758. /**
  29759. * Return the array of runtime animations currently using this animation
  29760. */
  29761. get runtimeAnimations(): RuntimeAnimation[];
  29762. /**
  29763. * Specifies if any of the runtime animations are currently running
  29764. */
  29765. get hasRunningRuntimeAnimations(): boolean;
  29766. /**
  29767. * Initializes the animation
  29768. * @param name Name of the animation
  29769. * @param targetProperty Property to animate
  29770. * @param framePerSecond The frames per second of the animation
  29771. * @param dataType The data type of the animation
  29772. * @param loopMode The loop mode of the animation
  29773. * @param enableBlending Specifies if blending should be enabled
  29774. */
  29775. constructor(
  29776. /**Name of the animation */
  29777. name: string,
  29778. /**Property to animate */
  29779. targetProperty: string,
  29780. /**The frames per second of the animation */
  29781. framePerSecond: number,
  29782. /**The data type of the animation */
  29783. dataType: number,
  29784. /**The loop mode of the animation */
  29785. loopMode?: number | undefined,
  29786. /**Specifies if blending should be enabled */
  29787. enableBlending?: boolean | undefined);
  29788. /**
  29789. * Converts the animation to a string
  29790. * @param fullDetails support for multiple levels of logging within scene loading
  29791. * @returns String form of the animation
  29792. */
  29793. toString(fullDetails?: boolean): string;
  29794. /**
  29795. * Add an event to this animation
  29796. * @param event Event to add
  29797. */
  29798. addEvent(event: AnimationEvent): void;
  29799. /**
  29800. * Remove all events found at the given frame
  29801. * @param frame The frame to remove events from
  29802. */
  29803. removeEvents(frame: number): void;
  29804. /**
  29805. * Retrieves all the events from the animation
  29806. * @returns Events from the animation
  29807. */
  29808. getEvents(): AnimationEvent[];
  29809. /**
  29810. * Creates an animation range
  29811. * @param name Name of the animation range
  29812. * @param from Starting frame of the animation range
  29813. * @param to Ending frame of the animation
  29814. */
  29815. createRange(name: string, from: number, to: number): void;
  29816. /**
  29817. * Deletes an animation range by name
  29818. * @param name Name of the animation range to delete
  29819. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29820. */
  29821. deleteRange(name: string, deleteFrames?: boolean): void;
  29822. /**
  29823. * Gets the animation range by name, or null if not defined
  29824. * @param name Name of the animation range
  29825. * @returns Nullable animation range
  29826. */
  29827. getRange(name: string): Nullable<AnimationRange>;
  29828. /**
  29829. * Gets the key frames from the animation
  29830. * @returns The key frames of the animation
  29831. */
  29832. getKeys(): Array<IAnimationKey>;
  29833. /**
  29834. * Gets the highest frame rate of the animation
  29835. * @returns Highest frame rate of the animation
  29836. */
  29837. getHighestFrame(): number;
  29838. /**
  29839. * Gets the easing function of the animation
  29840. * @returns Easing function of the animation
  29841. */
  29842. getEasingFunction(): IEasingFunction;
  29843. /**
  29844. * Sets the easing function of the animation
  29845. * @param easingFunction A custom mathematical formula for animation
  29846. */
  29847. setEasingFunction(easingFunction: EasingFunction): void;
  29848. /**
  29849. * Interpolates a scalar linearly
  29850. * @param startValue Start value of the animation curve
  29851. * @param endValue End value of the animation curve
  29852. * @param gradient Scalar amount to interpolate
  29853. * @returns Interpolated scalar value
  29854. */
  29855. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29856. /**
  29857. * Interpolates a scalar cubically
  29858. * @param startValue Start value of the animation curve
  29859. * @param outTangent End tangent of the animation
  29860. * @param endValue End value of the animation curve
  29861. * @param inTangent Start tangent of the animation curve
  29862. * @param gradient Scalar amount to interpolate
  29863. * @returns Interpolated scalar value
  29864. */
  29865. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29866. /**
  29867. * Interpolates a quaternion using a spherical linear interpolation
  29868. * @param startValue Start value of the animation curve
  29869. * @param endValue End value of the animation curve
  29870. * @param gradient Scalar amount to interpolate
  29871. * @returns Interpolated quaternion value
  29872. */
  29873. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29874. /**
  29875. * Interpolates a quaternion cubically
  29876. * @param startValue Start value of the animation curve
  29877. * @param outTangent End tangent of the animation curve
  29878. * @param endValue End value of the animation curve
  29879. * @param inTangent Start tangent of the animation curve
  29880. * @param gradient Scalar amount to interpolate
  29881. * @returns Interpolated quaternion value
  29882. */
  29883. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29884. /**
  29885. * Interpolates a Vector3 linearl
  29886. * @param startValue Start value of the animation curve
  29887. * @param endValue End value of the animation curve
  29888. * @param gradient Scalar amount to interpolate
  29889. * @returns Interpolated scalar value
  29890. */
  29891. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29892. /**
  29893. * Interpolates a Vector3 cubically
  29894. * @param startValue Start value of the animation curve
  29895. * @param outTangent End tangent of the animation
  29896. * @param endValue End value of the animation curve
  29897. * @param inTangent Start tangent of the animation curve
  29898. * @param gradient Scalar amount to interpolate
  29899. * @returns InterpolatedVector3 value
  29900. */
  29901. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29902. /**
  29903. * Interpolates a Vector2 linearly
  29904. * @param startValue Start value of the animation curve
  29905. * @param endValue End value of the animation curve
  29906. * @param gradient Scalar amount to interpolate
  29907. * @returns Interpolated Vector2 value
  29908. */
  29909. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29910. /**
  29911. * Interpolates a Vector2 cubically
  29912. * @param startValue Start value of the animation curve
  29913. * @param outTangent End tangent of the animation
  29914. * @param endValue End value of the animation curve
  29915. * @param inTangent Start tangent of the animation curve
  29916. * @param gradient Scalar amount to interpolate
  29917. * @returns Interpolated Vector2 value
  29918. */
  29919. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29920. /**
  29921. * Interpolates a size linearly
  29922. * @param startValue Start value of the animation curve
  29923. * @param endValue End value of the animation curve
  29924. * @param gradient Scalar amount to interpolate
  29925. * @returns Interpolated Size value
  29926. */
  29927. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29928. /**
  29929. * Interpolates a Color3 linearly
  29930. * @param startValue Start value of the animation curve
  29931. * @param endValue End value of the animation curve
  29932. * @param gradient Scalar amount to interpolate
  29933. * @returns Interpolated Color3 value
  29934. */
  29935. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29936. /**
  29937. * Interpolates a Color4 linearly
  29938. * @param startValue Start value of the animation curve
  29939. * @param endValue End value of the animation curve
  29940. * @param gradient Scalar amount to interpolate
  29941. * @returns Interpolated Color3 value
  29942. */
  29943. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29944. /**
  29945. * @hidden Internal use only
  29946. */
  29947. _getKeyValue(value: any): any;
  29948. /**
  29949. * @hidden Internal use only
  29950. */
  29951. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29952. /**
  29953. * Defines the function to use to interpolate matrices
  29954. * @param startValue defines the start matrix
  29955. * @param endValue defines the end matrix
  29956. * @param gradient defines the gradient between both matrices
  29957. * @param result defines an optional target matrix where to store the interpolation
  29958. * @returns the interpolated matrix
  29959. */
  29960. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29961. /**
  29962. * Makes a copy of the animation
  29963. * @returns Cloned animation
  29964. */
  29965. clone(): Animation;
  29966. /**
  29967. * Sets the key frames of the animation
  29968. * @param values The animation key frames to set
  29969. */
  29970. setKeys(values: Array<IAnimationKey>): void;
  29971. /**
  29972. * Serializes the animation to an object
  29973. * @returns Serialized object
  29974. */
  29975. serialize(): any;
  29976. /**
  29977. * Float animation type
  29978. */
  29979. static readonly ANIMATIONTYPE_FLOAT: number;
  29980. /**
  29981. * Vector3 animation type
  29982. */
  29983. static readonly ANIMATIONTYPE_VECTOR3: number;
  29984. /**
  29985. * Quaternion animation type
  29986. */
  29987. static readonly ANIMATIONTYPE_QUATERNION: number;
  29988. /**
  29989. * Matrix animation type
  29990. */
  29991. static readonly ANIMATIONTYPE_MATRIX: number;
  29992. /**
  29993. * Color3 animation type
  29994. */
  29995. static readonly ANIMATIONTYPE_COLOR3: number;
  29996. /**
  29997. * Color3 animation type
  29998. */
  29999. static readonly ANIMATIONTYPE_COLOR4: number;
  30000. /**
  30001. * Vector2 animation type
  30002. */
  30003. static readonly ANIMATIONTYPE_VECTOR2: number;
  30004. /**
  30005. * Size animation type
  30006. */
  30007. static readonly ANIMATIONTYPE_SIZE: number;
  30008. /**
  30009. * Relative Loop Mode
  30010. */
  30011. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30012. /**
  30013. * Cycle Loop Mode
  30014. */
  30015. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30016. /**
  30017. * Constant Loop Mode
  30018. */
  30019. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30020. /** @hidden */
  30021. static _UniversalLerp(left: any, right: any, amount: number): any;
  30022. /**
  30023. * Parses an animation object and creates an animation
  30024. * @param parsedAnimation Parsed animation object
  30025. * @returns Animation object
  30026. */
  30027. static Parse(parsedAnimation: any): Animation;
  30028. /**
  30029. * Appends the serialized animations from the source animations
  30030. * @param source Source containing the animations
  30031. * @param destination Target to store the animations
  30032. */
  30033. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30034. }
  30035. }
  30036. declare module BABYLON {
  30037. /**
  30038. * Interface containing an array of animations
  30039. */
  30040. export interface IAnimatable {
  30041. /**
  30042. * Array of animations
  30043. */
  30044. animations: Nullable<Array<Animation>>;
  30045. }
  30046. }
  30047. declare module BABYLON {
  30048. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30049. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30050. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30051. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30052. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30053. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30054. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30055. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30056. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30057. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30058. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30059. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30060. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30061. /**
  30062. * Decorator used to define property that can be serialized as reference to a camera
  30063. * @param sourceName defines the name of the property to decorate
  30064. */
  30065. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30066. /**
  30067. * Class used to help serialization objects
  30068. */
  30069. export class SerializationHelper {
  30070. /** @hidden */
  30071. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30072. /** @hidden */
  30073. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30074. /** @hidden */
  30075. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30076. /** @hidden */
  30077. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30078. /**
  30079. * Appends the serialized animations from the source animations
  30080. * @param source Source containing the animations
  30081. * @param destination Target to store the animations
  30082. */
  30083. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30084. /**
  30085. * Static function used to serialized a specific entity
  30086. * @param entity defines the entity to serialize
  30087. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30088. * @returns a JSON compatible object representing the serialization of the entity
  30089. */
  30090. static Serialize<T>(entity: T, serializationObject?: any): any;
  30091. /**
  30092. * Creates a new entity from a serialization data object
  30093. * @param creationFunction defines a function used to instanciated the new entity
  30094. * @param source defines the source serialization data
  30095. * @param scene defines the hosting scene
  30096. * @param rootUrl defines the root url for resources
  30097. * @returns a new entity
  30098. */
  30099. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30100. /**
  30101. * Clones an object
  30102. * @param creationFunction defines the function used to instanciate the new object
  30103. * @param source defines the source object
  30104. * @returns the cloned object
  30105. */
  30106. static Clone<T>(creationFunction: () => T, source: T): T;
  30107. /**
  30108. * Instanciates a new object based on a source one (some data will be shared between both object)
  30109. * @param creationFunction defines the function used to instanciate the new object
  30110. * @param source defines the source object
  30111. * @returns the new object
  30112. */
  30113. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30114. }
  30115. }
  30116. declare module BABYLON {
  30117. /**
  30118. * Base class of all the textures in babylon.
  30119. * It groups all the common properties the materials, post process, lights... might need
  30120. * in order to make a correct use of the texture.
  30121. */
  30122. export class BaseTexture implements IAnimatable {
  30123. /**
  30124. * Default anisotropic filtering level for the application.
  30125. * It is set to 4 as a good tradeoff between perf and quality.
  30126. */
  30127. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30128. /**
  30129. * Gets or sets the unique id of the texture
  30130. */
  30131. uniqueId: number;
  30132. /**
  30133. * Define the name of the texture.
  30134. */
  30135. name: string;
  30136. /**
  30137. * Gets or sets an object used to store user defined information.
  30138. */
  30139. metadata: any;
  30140. /**
  30141. * For internal use only. Please do not use.
  30142. */
  30143. reservedDataStore: any;
  30144. private _hasAlpha;
  30145. /**
  30146. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30147. */
  30148. set hasAlpha(value: boolean);
  30149. get hasAlpha(): boolean;
  30150. /**
  30151. * Defines if the alpha value should be determined via the rgb values.
  30152. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30153. */
  30154. getAlphaFromRGB: boolean;
  30155. /**
  30156. * Intensity or strength of the texture.
  30157. * It is commonly used by materials to fine tune the intensity of the texture
  30158. */
  30159. level: number;
  30160. /**
  30161. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30162. * This is part of the texture as textures usually maps to one uv set.
  30163. */
  30164. coordinatesIndex: number;
  30165. private _coordinatesMode;
  30166. /**
  30167. * How a texture is mapped.
  30168. *
  30169. * | Value | Type | Description |
  30170. * | ----- | ----------------------------------- | ----------- |
  30171. * | 0 | EXPLICIT_MODE | |
  30172. * | 1 | SPHERICAL_MODE | |
  30173. * | 2 | PLANAR_MODE | |
  30174. * | 3 | CUBIC_MODE | |
  30175. * | 4 | PROJECTION_MODE | |
  30176. * | 5 | SKYBOX_MODE | |
  30177. * | 6 | INVCUBIC_MODE | |
  30178. * | 7 | EQUIRECTANGULAR_MODE | |
  30179. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30180. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30181. */
  30182. set coordinatesMode(value: number);
  30183. get coordinatesMode(): number;
  30184. /**
  30185. * | Value | Type | Description |
  30186. * | ----- | ------------------ | ----------- |
  30187. * | 0 | CLAMP_ADDRESSMODE | |
  30188. * | 1 | WRAP_ADDRESSMODE | |
  30189. * | 2 | MIRROR_ADDRESSMODE | |
  30190. */
  30191. wrapU: number;
  30192. /**
  30193. * | Value | Type | Description |
  30194. * | ----- | ------------------ | ----------- |
  30195. * | 0 | CLAMP_ADDRESSMODE | |
  30196. * | 1 | WRAP_ADDRESSMODE | |
  30197. * | 2 | MIRROR_ADDRESSMODE | |
  30198. */
  30199. wrapV: number;
  30200. /**
  30201. * | Value | Type | Description |
  30202. * | ----- | ------------------ | ----------- |
  30203. * | 0 | CLAMP_ADDRESSMODE | |
  30204. * | 1 | WRAP_ADDRESSMODE | |
  30205. * | 2 | MIRROR_ADDRESSMODE | |
  30206. */
  30207. wrapR: number;
  30208. /**
  30209. * With compliant hardware and browser (supporting anisotropic filtering)
  30210. * this defines the level of anisotropic filtering in the texture.
  30211. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30212. */
  30213. anisotropicFilteringLevel: number;
  30214. /**
  30215. * Define if the texture is a cube texture or if false a 2d texture.
  30216. */
  30217. get isCube(): boolean;
  30218. set isCube(value: boolean);
  30219. /**
  30220. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30221. */
  30222. get is3D(): boolean;
  30223. set is3D(value: boolean);
  30224. /**
  30225. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30226. */
  30227. get is2DArray(): boolean;
  30228. set is2DArray(value: boolean);
  30229. /**
  30230. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30231. * HDR texture are usually stored in linear space.
  30232. * This only impacts the PBR and Background materials
  30233. */
  30234. gammaSpace: boolean;
  30235. /**
  30236. * Gets or sets whether or not the texture contains RGBD data.
  30237. */
  30238. get isRGBD(): boolean;
  30239. set isRGBD(value: boolean);
  30240. /**
  30241. * Is Z inverted in the texture (useful in a cube texture).
  30242. */
  30243. invertZ: boolean;
  30244. /**
  30245. * Are mip maps generated for this texture or not.
  30246. */
  30247. get noMipmap(): boolean;
  30248. /**
  30249. * @hidden
  30250. */
  30251. lodLevelInAlpha: boolean;
  30252. /**
  30253. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30254. */
  30255. get lodGenerationOffset(): number;
  30256. set lodGenerationOffset(value: number);
  30257. /**
  30258. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30259. */
  30260. get lodGenerationScale(): number;
  30261. set lodGenerationScale(value: number);
  30262. /**
  30263. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30264. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30265. * average roughness values.
  30266. */
  30267. get linearSpecularLOD(): boolean;
  30268. set linearSpecularLOD(value: boolean);
  30269. /**
  30270. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30271. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30272. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30273. */
  30274. get irradianceTexture(): Nullable<BaseTexture>;
  30275. set irradianceTexture(value: Nullable<BaseTexture>);
  30276. /**
  30277. * Define if the texture is a render target.
  30278. */
  30279. isRenderTarget: boolean;
  30280. /**
  30281. * Define the unique id of the texture in the scene.
  30282. */
  30283. get uid(): string;
  30284. /**
  30285. * Return a string representation of the texture.
  30286. * @returns the texture as a string
  30287. */
  30288. toString(): string;
  30289. /**
  30290. * Get the class name of the texture.
  30291. * @returns "BaseTexture"
  30292. */
  30293. getClassName(): string;
  30294. /**
  30295. * Define the list of animation attached to the texture.
  30296. */
  30297. animations: Animation[];
  30298. /**
  30299. * An event triggered when the texture is disposed.
  30300. */
  30301. onDisposeObservable: Observable<BaseTexture>;
  30302. private _onDisposeObserver;
  30303. /**
  30304. * Callback triggered when the texture has been disposed.
  30305. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30306. */
  30307. set onDispose(callback: () => void);
  30308. /**
  30309. * Define the current state of the loading sequence when in delayed load mode.
  30310. */
  30311. delayLoadState: number;
  30312. private _scene;
  30313. /** @hidden */
  30314. _texture: Nullable<InternalTexture>;
  30315. private _uid;
  30316. /**
  30317. * Define if the texture is preventinga material to render or not.
  30318. * If not and the texture is not ready, the engine will use a default black texture instead.
  30319. */
  30320. get isBlocking(): boolean;
  30321. /**
  30322. * Instantiates a new BaseTexture.
  30323. * Base class of all the textures in babylon.
  30324. * It groups all the common properties the materials, post process, lights... might need
  30325. * in order to make a correct use of the texture.
  30326. * @param scene Define the scene the texture blongs to
  30327. */
  30328. constructor(scene: Nullable<Scene>);
  30329. /**
  30330. * Get the scene the texture belongs to.
  30331. * @returns the scene or null if undefined
  30332. */
  30333. getScene(): Nullable<Scene>;
  30334. /**
  30335. * Get the texture transform matrix used to offset tile the texture for istance.
  30336. * @returns the transformation matrix
  30337. */
  30338. getTextureMatrix(): Matrix;
  30339. /**
  30340. * Get the texture reflection matrix used to rotate/transform the reflection.
  30341. * @returns the reflection matrix
  30342. */
  30343. getReflectionTextureMatrix(): Matrix;
  30344. /**
  30345. * Get the underlying lower level texture from Babylon.
  30346. * @returns the insternal texture
  30347. */
  30348. getInternalTexture(): Nullable<InternalTexture>;
  30349. /**
  30350. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30351. * @returns true if ready or not blocking
  30352. */
  30353. isReadyOrNotBlocking(): boolean;
  30354. /**
  30355. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30356. * @returns true if fully ready
  30357. */
  30358. isReady(): boolean;
  30359. private _cachedSize;
  30360. /**
  30361. * Get the size of the texture.
  30362. * @returns the texture size.
  30363. */
  30364. getSize(): ISize;
  30365. /**
  30366. * Get the base size of the texture.
  30367. * It can be different from the size if the texture has been resized for POT for instance
  30368. * @returns the base size
  30369. */
  30370. getBaseSize(): ISize;
  30371. /**
  30372. * Update the sampling mode of the texture.
  30373. * Default is Trilinear mode.
  30374. *
  30375. * | Value | Type | Description |
  30376. * | ----- | ------------------ | ----------- |
  30377. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30378. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30379. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30380. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30381. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30382. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30383. * | 7 | NEAREST_LINEAR | |
  30384. * | 8 | NEAREST_NEAREST | |
  30385. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30386. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30387. * | 11 | LINEAR_LINEAR | |
  30388. * | 12 | LINEAR_NEAREST | |
  30389. *
  30390. * > _mag_: magnification filter (close to the viewer)
  30391. * > _min_: minification filter (far from the viewer)
  30392. * > _mip_: filter used between mip map levels
  30393. *@param samplingMode Define the new sampling mode of the texture
  30394. */
  30395. updateSamplingMode(samplingMode: number): void;
  30396. /**
  30397. * Scales the texture if is `canRescale()`
  30398. * @param ratio the resize factor we want to use to rescale
  30399. */
  30400. scale(ratio: number): void;
  30401. /**
  30402. * Get if the texture can rescale.
  30403. */
  30404. get canRescale(): boolean;
  30405. /** @hidden */
  30406. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30407. /** @hidden */
  30408. _rebuild(): void;
  30409. /**
  30410. * Triggers the load sequence in delayed load mode.
  30411. */
  30412. delayLoad(): void;
  30413. /**
  30414. * Clones the texture.
  30415. * @returns the cloned texture
  30416. */
  30417. clone(): Nullable<BaseTexture>;
  30418. /**
  30419. * Get the texture underlying type (INT, FLOAT...)
  30420. */
  30421. get textureType(): number;
  30422. /**
  30423. * Get the texture underlying format (RGB, RGBA...)
  30424. */
  30425. get textureFormat(): number;
  30426. /**
  30427. * Indicates that textures need to be re-calculated for all materials
  30428. */
  30429. protected _markAllSubMeshesAsTexturesDirty(): void;
  30430. /**
  30431. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30432. * This will returns an RGBA array buffer containing either in values (0-255) or
  30433. * float values (0-1) depending of the underlying buffer type.
  30434. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30435. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30436. * @param buffer defines a user defined buffer to fill with data (can be null)
  30437. * @returns The Array buffer containing the pixels data.
  30438. */
  30439. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30440. /**
  30441. * Release and destroy the underlying lower level texture aka internalTexture.
  30442. */
  30443. releaseInternalTexture(): void;
  30444. /** @hidden */
  30445. get _lodTextureHigh(): Nullable<BaseTexture>;
  30446. /** @hidden */
  30447. get _lodTextureMid(): Nullable<BaseTexture>;
  30448. /** @hidden */
  30449. get _lodTextureLow(): Nullable<BaseTexture>;
  30450. /**
  30451. * Dispose the texture and release its associated resources.
  30452. */
  30453. dispose(): void;
  30454. /**
  30455. * Serialize the texture into a JSON representation that can be parsed later on.
  30456. * @returns the JSON representation of the texture
  30457. */
  30458. serialize(): any;
  30459. /**
  30460. * Helper function to be called back once a list of texture contains only ready textures.
  30461. * @param textures Define the list of textures to wait for
  30462. * @param callback Define the callback triggered once the entire list will be ready
  30463. */
  30464. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30465. }
  30466. }
  30467. declare module BABYLON {
  30468. /**
  30469. * Options to be used when creating an effect.
  30470. */
  30471. export interface IEffectCreationOptions {
  30472. /**
  30473. * Atrributes that will be used in the shader.
  30474. */
  30475. attributes: string[];
  30476. /**
  30477. * Uniform varible names that will be set in the shader.
  30478. */
  30479. uniformsNames: string[];
  30480. /**
  30481. * Uniform buffer variable names that will be set in the shader.
  30482. */
  30483. uniformBuffersNames: string[];
  30484. /**
  30485. * Sampler texture variable names that will be set in the shader.
  30486. */
  30487. samplers: string[];
  30488. /**
  30489. * Define statements that will be set in the shader.
  30490. */
  30491. defines: any;
  30492. /**
  30493. * Possible fallbacks for this effect to improve performance when needed.
  30494. */
  30495. fallbacks: Nullable<IEffectFallbacks>;
  30496. /**
  30497. * Callback that will be called when the shader is compiled.
  30498. */
  30499. onCompiled: Nullable<(effect: Effect) => void>;
  30500. /**
  30501. * Callback that will be called if an error occurs during shader compilation.
  30502. */
  30503. onError: Nullable<(effect: Effect, errors: string) => void>;
  30504. /**
  30505. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30506. */
  30507. indexParameters?: any;
  30508. /**
  30509. * Max number of lights that can be used in the shader.
  30510. */
  30511. maxSimultaneousLights?: number;
  30512. /**
  30513. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30514. */
  30515. transformFeedbackVaryings?: Nullable<string[]>;
  30516. }
  30517. /**
  30518. * Effect containing vertex and fragment shader that can be executed on an object.
  30519. */
  30520. export class Effect implements IDisposable {
  30521. /**
  30522. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30523. */
  30524. static ShadersRepository: string;
  30525. /**
  30526. * Enable logging of the shader code when a compilation error occurs
  30527. */
  30528. static LogShaderCodeOnCompilationError: boolean;
  30529. /**
  30530. * Name of the effect.
  30531. */
  30532. name: any;
  30533. /**
  30534. * String container all the define statements that should be set on the shader.
  30535. */
  30536. defines: string;
  30537. /**
  30538. * Callback that will be called when the shader is compiled.
  30539. */
  30540. onCompiled: Nullable<(effect: Effect) => void>;
  30541. /**
  30542. * Callback that will be called if an error occurs during shader compilation.
  30543. */
  30544. onError: Nullable<(effect: Effect, errors: string) => void>;
  30545. /**
  30546. * Callback that will be called when effect is bound.
  30547. */
  30548. onBind: Nullable<(effect: Effect) => void>;
  30549. /**
  30550. * Unique ID of the effect.
  30551. */
  30552. uniqueId: number;
  30553. /**
  30554. * Observable that will be called when the shader is compiled.
  30555. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30556. */
  30557. onCompileObservable: Observable<Effect>;
  30558. /**
  30559. * Observable that will be called if an error occurs during shader compilation.
  30560. */
  30561. onErrorObservable: Observable<Effect>;
  30562. /** @hidden */
  30563. _onBindObservable: Nullable<Observable<Effect>>;
  30564. /**
  30565. * @hidden
  30566. * Specifies if the effect was previously ready
  30567. */
  30568. _wasPreviouslyReady: boolean;
  30569. /**
  30570. * Observable that will be called when effect is bound.
  30571. */
  30572. get onBindObservable(): Observable<Effect>;
  30573. /** @hidden */
  30574. _bonesComputationForcedToCPU: boolean;
  30575. private static _uniqueIdSeed;
  30576. private _engine;
  30577. private _uniformBuffersNames;
  30578. private _uniformBuffersNamesList;
  30579. private _uniformsNames;
  30580. private _samplerList;
  30581. private _samplers;
  30582. private _isReady;
  30583. private _compilationError;
  30584. private _allFallbacksProcessed;
  30585. private _attributesNames;
  30586. private _attributes;
  30587. private _attributeLocationByName;
  30588. private _uniforms;
  30589. /**
  30590. * Key for the effect.
  30591. * @hidden
  30592. */
  30593. _key: string;
  30594. private _indexParameters;
  30595. private _fallbacks;
  30596. private _vertexSourceCode;
  30597. private _fragmentSourceCode;
  30598. private _vertexSourceCodeOverride;
  30599. private _fragmentSourceCodeOverride;
  30600. private _transformFeedbackVaryings;
  30601. /**
  30602. * Compiled shader to webGL program.
  30603. * @hidden
  30604. */
  30605. _pipelineContext: Nullable<IPipelineContext>;
  30606. private _valueCache;
  30607. private static _baseCache;
  30608. /**
  30609. * Instantiates an effect.
  30610. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30611. * @param baseName Name of the effect.
  30612. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30613. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30614. * @param samplers List of sampler variables that will be passed to the shader.
  30615. * @param engine Engine to be used to render the effect
  30616. * @param defines Define statements to be added to the shader.
  30617. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30618. * @param onCompiled Callback that will be called when the shader is compiled.
  30619. * @param onError Callback that will be called if an error occurs during shader compilation.
  30620. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30621. */
  30622. 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);
  30623. private _useFinalCode;
  30624. /**
  30625. * Unique key for this effect
  30626. */
  30627. get key(): string;
  30628. /**
  30629. * If the effect has been compiled and prepared.
  30630. * @returns if the effect is compiled and prepared.
  30631. */
  30632. isReady(): boolean;
  30633. private _isReadyInternal;
  30634. /**
  30635. * The engine the effect was initialized with.
  30636. * @returns the engine.
  30637. */
  30638. getEngine(): Engine;
  30639. /**
  30640. * The pipeline context for this effect
  30641. * @returns the associated pipeline context
  30642. */
  30643. getPipelineContext(): Nullable<IPipelineContext>;
  30644. /**
  30645. * The set of names of attribute variables for the shader.
  30646. * @returns An array of attribute names.
  30647. */
  30648. getAttributesNames(): string[];
  30649. /**
  30650. * Returns the attribute at the given index.
  30651. * @param index The index of the attribute.
  30652. * @returns The location of the attribute.
  30653. */
  30654. getAttributeLocation(index: number): number;
  30655. /**
  30656. * Returns the attribute based on the name of the variable.
  30657. * @param name of the attribute to look up.
  30658. * @returns the attribute location.
  30659. */
  30660. getAttributeLocationByName(name: string): number;
  30661. /**
  30662. * The number of attributes.
  30663. * @returns the numnber of attributes.
  30664. */
  30665. getAttributesCount(): number;
  30666. /**
  30667. * Gets the index of a uniform variable.
  30668. * @param uniformName of the uniform to look up.
  30669. * @returns the index.
  30670. */
  30671. getUniformIndex(uniformName: string): number;
  30672. /**
  30673. * Returns the attribute based on the name of the variable.
  30674. * @param uniformName of the uniform to look up.
  30675. * @returns the location of the uniform.
  30676. */
  30677. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30678. /**
  30679. * Returns an array of sampler variable names
  30680. * @returns The array of sampler variable names.
  30681. */
  30682. getSamplers(): string[];
  30683. /**
  30684. * Returns an array of uniform variable names
  30685. * @returns The array of uniform variable names.
  30686. */
  30687. getUniformNames(): string[];
  30688. /**
  30689. * Returns an array of uniform buffer variable names
  30690. * @returns The array of uniform buffer variable names.
  30691. */
  30692. getUniformBuffersNames(): string[];
  30693. /**
  30694. * Returns the index parameters used to create the effect
  30695. * @returns The index parameters object
  30696. */
  30697. getIndexParameters(): any;
  30698. /**
  30699. * The error from the last compilation.
  30700. * @returns the error string.
  30701. */
  30702. getCompilationError(): string;
  30703. /**
  30704. * Gets a boolean indicating that all fallbacks were used during compilation
  30705. * @returns true if all fallbacks were used
  30706. */
  30707. allFallbacksProcessed(): boolean;
  30708. /**
  30709. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30710. * @param func The callback to be used.
  30711. */
  30712. executeWhenCompiled(func: (effect: Effect) => void): void;
  30713. private _checkIsReady;
  30714. private _loadShader;
  30715. /**
  30716. * Gets the vertex shader source code of this effect
  30717. */
  30718. get vertexSourceCode(): string;
  30719. /**
  30720. * Gets the fragment shader source code of this effect
  30721. */
  30722. get fragmentSourceCode(): string;
  30723. /**
  30724. * Recompiles the webGL program
  30725. * @param vertexSourceCode The source code for the vertex shader.
  30726. * @param fragmentSourceCode The source code for the fragment shader.
  30727. * @param onCompiled Callback called when completed.
  30728. * @param onError Callback called on error.
  30729. * @hidden
  30730. */
  30731. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30732. /**
  30733. * Prepares the effect
  30734. * @hidden
  30735. */
  30736. _prepareEffect(): void;
  30737. private _getShaderCodeAndErrorLine;
  30738. private _processCompilationErrors;
  30739. /**
  30740. * Checks if the effect is supported. (Must be called after compilation)
  30741. */
  30742. get isSupported(): boolean;
  30743. /**
  30744. * Binds a texture to the engine to be used as output of the shader.
  30745. * @param channel Name of the output variable.
  30746. * @param texture Texture to bind.
  30747. * @hidden
  30748. */
  30749. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30750. /**
  30751. * Sets a texture on the engine to be used in the shader.
  30752. * @param channel Name of the sampler variable.
  30753. * @param texture Texture to set.
  30754. */
  30755. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30756. /**
  30757. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30758. * @param channel Name of the sampler variable.
  30759. * @param texture Texture to set.
  30760. */
  30761. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30762. /**
  30763. * Sets an array of textures on the engine to be used in the shader.
  30764. * @param channel Name of the variable.
  30765. * @param textures Textures to set.
  30766. */
  30767. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30768. /**
  30769. * 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)
  30770. * @param channel Name of the sampler variable.
  30771. * @param postProcess Post process to get the input texture from.
  30772. */
  30773. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30774. /**
  30775. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30776. * 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)
  30777. * @param channel Name of the sampler variable.
  30778. * @param postProcess Post process to get the output texture from.
  30779. */
  30780. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30781. /** @hidden */
  30782. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30783. /** @hidden */
  30784. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30785. /** @hidden */
  30786. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30787. /** @hidden */
  30788. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30789. /**
  30790. * Binds a buffer to a uniform.
  30791. * @param buffer Buffer to bind.
  30792. * @param name Name of the uniform variable to bind to.
  30793. */
  30794. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30795. /**
  30796. * Binds block to a uniform.
  30797. * @param blockName Name of the block to bind.
  30798. * @param index Index to bind.
  30799. */
  30800. bindUniformBlock(blockName: string, index: number): void;
  30801. /**
  30802. * Sets an interger value on a uniform variable.
  30803. * @param uniformName Name of the variable.
  30804. * @param value Value to be set.
  30805. * @returns this effect.
  30806. */
  30807. setInt(uniformName: string, value: number): Effect;
  30808. /**
  30809. * Sets an int array on a uniform variable.
  30810. * @param uniformName Name of the variable.
  30811. * @param array array to be set.
  30812. * @returns this effect.
  30813. */
  30814. setIntArray(uniformName: string, array: Int32Array): Effect;
  30815. /**
  30816. * 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)
  30817. * @param uniformName Name of the variable.
  30818. * @param array array to be set.
  30819. * @returns this effect.
  30820. */
  30821. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30822. /**
  30823. * 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)
  30824. * @param uniformName Name of the variable.
  30825. * @param array array to be set.
  30826. * @returns this effect.
  30827. */
  30828. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30829. /**
  30830. * 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)
  30831. * @param uniformName Name of the variable.
  30832. * @param array array to be set.
  30833. * @returns this effect.
  30834. */
  30835. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30836. /**
  30837. * Sets an float array on a uniform variable.
  30838. * @param uniformName Name of the variable.
  30839. * @param array array to be set.
  30840. * @returns this effect.
  30841. */
  30842. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30843. /**
  30844. * 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)
  30845. * @param uniformName Name of the variable.
  30846. * @param array array to be set.
  30847. * @returns this effect.
  30848. */
  30849. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30850. /**
  30851. * 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)
  30852. * @param uniformName Name of the variable.
  30853. * @param array array to be set.
  30854. * @returns this effect.
  30855. */
  30856. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30857. /**
  30858. * 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)
  30859. * @param uniformName Name of the variable.
  30860. * @param array array to be set.
  30861. * @returns this effect.
  30862. */
  30863. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30864. /**
  30865. * Sets an array on a uniform variable.
  30866. * @param uniformName Name of the variable.
  30867. * @param array array to be set.
  30868. * @returns this effect.
  30869. */
  30870. setArray(uniformName: string, array: number[]): Effect;
  30871. /**
  30872. * 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)
  30873. * @param uniformName Name of the variable.
  30874. * @param array array to be set.
  30875. * @returns this effect.
  30876. */
  30877. setArray2(uniformName: string, array: number[]): Effect;
  30878. /**
  30879. * 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)
  30880. * @param uniformName Name of the variable.
  30881. * @param array array to be set.
  30882. * @returns this effect.
  30883. */
  30884. setArray3(uniformName: string, array: number[]): Effect;
  30885. /**
  30886. * 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)
  30887. * @param uniformName Name of the variable.
  30888. * @param array array to be set.
  30889. * @returns this effect.
  30890. */
  30891. setArray4(uniformName: string, array: number[]): Effect;
  30892. /**
  30893. * Sets matrices on a uniform variable.
  30894. * @param uniformName Name of the variable.
  30895. * @param matrices matrices to be set.
  30896. * @returns this effect.
  30897. */
  30898. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30899. /**
  30900. * Sets matrix on a uniform variable.
  30901. * @param uniformName Name of the variable.
  30902. * @param matrix matrix to be set.
  30903. * @returns this effect.
  30904. */
  30905. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30906. /**
  30907. * 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)
  30908. * @param uniformName Name of the variable.
  30909. * @param matrix matrix to be set.
  30910. * @returns this effect.
  30911. */
  30912. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30913. /**
  30914. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30915. * @param uniformName Name of the variable.
  30916. * @param matrix matrix to be set.
  30917. * @returns this effect.
  30918. */
  30919. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30920. /**
  30921. * Sets a float on a uniform variable.
  30922. * @param uniformName Name of the variable.
  30923. * @param value value to be set.
  30924. * @returns this effect.
  30925. */
  30926. setFloat(uniformName: string, value: number): Effect;
  30927. /**
  30928. * Sets a boolean on a uniform variable.
  30929. * @param uniformName Name of the variable.
  30930. * @param bool value to be set.
  30931. * @returns this effect.
  30932. */
  30933. setBool(uniformName: string, bool: boolean): Effect;
  30934. /**
  30935. * Sets a Vector2 on a uniform variable.
  30936. * @param uniformName Name of the variable.
  30937. * @param vector2 vector2 to be set.
  30938. * @returns this effect.
  30939. */
  30940. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30941. /**
  30942. * Sets a float2 on a uniform variable.
  30943. * @param uniformName Name of the variable.
  30944. * @param x First float in float2.
  30945. * @param y Second float in float2.
  30946. * @returns this effect.
  30947. */
  30948. setFloat2(uniformName: string, x: number, y: number): Effect;
  30949. /**
  30950. * Sets a Vector3 on a uniform variable.
  30951. * @param uniformName Name of the variable.
  30952. * @param vector3 Value to be set.
  30953. * @returns this effect.
  30954. */
  30955. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30956. /**
  30957. * Sets a float3 on a uniform variable.
  30958. * @param uniformName Name of the variable.
  30959. * @param x First float in float3.
  30960. * @param y Second float in float3.
  30961. * @param z Third float in float3.
  30962. * @returns this effect.
  30963. */
  30964. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30965. /**
  30966. * Sets a Vector4 on a uniform variable.
  30967. * @param uniformName Name of the variable.
  30968. * @param vector4 Value to be set.
  30969. * @returns this effect.
  30970. */
  30971. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30972. /**
  30973. * Sets a float4 on a uniform variable.
  30974. * @param uniformName Name of the variable.
  30975. * @param x First float in float4.
  30976. * @param y Second float in float4.
  30977. * @param z Third float in float4.
  30978. * @param w Fourth float in float4.
  30979. * @returns this effect.
  30980. */
  30981. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30982. /**
  30983. * Sets a Color3 on a uniform variable.
  30984. * @param uniformName Name of the variable.
  30985. * @param color3 Value to be set.
  30986. * @returns this effect.
  30987. */
  30988. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30989. /**
  30990. * Sets a Color4 on a uniform variable.
  30991. * @param uniformName Name of the variable.
  30992. * @param color3 Value to be set.
  30993. * @param alpha Alpha value to be set.
  30994. * @returns this effect.
  30995. */
  30996. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30997. /**
  30998. * Sets a Color4 on a uniform variable
  30999. * @param uniformName defines the name of the variable
  31000. * @param color4 defines the value to be set
  31001. * @returns this effect.
  31002. */
  31003. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31004. /** Release all associated resources */
  31005. dispose(): void;
  31006. /**
  31007. * This function will add a new shader to the shader store
  31008. * @param name the name of the shader
  31009. * @param pixelShader optional pixel shader content
  31010. * @param vertexShader optional vertex shader content
  31011. */
  31012. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31013. /**
  31014. * Store of each shader (The can be looked up using effect.key)
  31015. */
  31016. static ShadersStore: {
  31017. [key: string]: string;
  31018. };
  31019. /**
  31020. * Store of each included file for a shader (The can be looked up using effect.key)
  31021. */
  31022. static IncludesShadersStore: {
  31023. [key: string]: string;
  31024. };
  31025. /**
  31026. * Resets the cache of effects.
  31027. */
  31028. static ResetCache(): void;
  31029. }
  31030. }
  31031. declare module BABYLON {
  31032. /**
  31033. * Interface used to describe the capabilities of the engine relatively to the current browser
  31034. */
  31035. export interface EngineCapabilities {
  31036. /** Maximum textures units per fragment shader */
  31037. maxTexturesImageUnits: number;
  31038. /** Maximum texture units per vertex shader */
  31039. maxVertexTextureImageUnits: number;
  31040. /** Maximum textures units in the entire pipeline */
  31041. maxCombinedTexturesImageUnits: number;
  31042. /** Maximum texture size */
  31043. maxTextureSize: number;
  31044. /** Maximum texture samples */
  31045. maxSamples?: number;
  31046. /** Maximum cube texture size */
  31047. maxCubemapTextureSize: number;
  31048. /** Maximum render texture size */
  31049. maxRenderTextureSize: number;
  31050. /** Maximum number of vertex attributes */
  31051. maxVertexAttribs: number;
  31052. /** Maximum number of varyings */
  31053. maxVaryingVectors: number;
  31054. /** Maximum number of uniforms per vertex shader */
  31055. maxVertexUniformVectors: number;
  31056. /** Maximum number of uniforms per fragment shader */
  31057. maxFragmentUniformVectors: number;
  31058. /** Defines if standard derivates (dx/dy) are supported */
  31059. standardDerivatives: boolean;
  31060. /** Defines if s3tc texture compression is supported */
  31061. s3tc?: WEBGL_compressed_texture_s3tc;
  31062. /** Defines if pvrtc texture compression is supported */
  31063. pvrtc: any;
  31064. /** Defines if etc1 texture compression is supported */
  31065. etc1: any;
  31066. /** Defines if etc2 texture compression is supported */
  31067. etc2: any;
  31068. /** Defines if astc texture compression is supported */
  31069. astc: any;
  31070. /** Defines if float textures are supported */
  31071. textureFloat: boolean;
  31072. /** Defines if vertex array objects are supported */
  31073. vertexArrayObject: boolean;
  31074. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31075. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31076. /** Gets the maximum level of anisotropy supported */
  31077. maxAnisotropy: number;
  31078. /** Defines if instancing is supported */
  31079. instancedArrays: boolean;
  31080. /** Defines if 32 bits indices are supported */
  31081. uintIndices: boolean;
  31082. /** Defines if high precision shaders are supported */
  31083. highPrecisionShaderSupported: boolean;
  31084. /** Defines if depth reading in the fragment shader is supported */
  31085. fragmentDepthSupported: boolean;
  31086. /** Defines if float texture linear filtering is supported*/
  31087. textureFloatLinearFiltering: boolean;
  31088. /** Defines if rendering to float textures is supported */
  31089. textureFloatRender: boolean;
  31090. /** Defines if half float textures are supported*/
  31091. textureHalfFloat: boolean;
  31092. /** Defines if half float texture linear filtering is supported*/
  31093. textureHalfFloatLinearFiltering: boolean;
  31094. /** Defines if rendering to half float textures is supported */
  31095. textureHalfFloatRender: boolean;
  31096. /** Defines if textureLOD shader command is supported */
  31097. textureLOD: boolean;
  31098. /** Defines if draw buffers extension is supported */
  31099. drawBuffersExtension: boolean;
  31100. /** Defines if depth textures are supported */
  31101. depthTextureExtension: boolean;
  31102. /** Defines if float color buffer are supported */
  31103. colorBufferFloat: boolean;
  31104. /** Gets disjoint timer query extension (null if not supported) */
  31105. timerQuery?: EXT_disjoint_timer_query;
  31106. /** Defines if timestamp can be used with timer query */
  31107. canUseTimestampForTimerQuery: boolean;
  31108. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31109. multiview?: any;
  31110. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31111. oculusMultiview?: any;
  31112. /** Function used to let the system compiles shaders in background */
  31113. parallelShaderCompile?: {
  31114. COMPLETION_STATUS_KHR: number;
  31115. };
  31116. /** Max number of texture samples for MSAA */
  31117. maxMSAASamples: number;
  31118. /** Defines if the blend min max extension is supported */
  31119. blendMinMax: boolean;
  31120. }
  31121. }
  31122. declare module BABYLON {
  31123. /**
  31124. * @hidden
  31125. **/
  31126. export class DepthCullingState {
  31127. private _isDepthTestDirty;
  31128. private _isDepthMaskDirty;
  31129. private _isDepthFuncDirty;
  31130. private _isCullFaceDirty;
  31131. private _isCullDirty;
  31132. private _isZOffsetDirty;
  31133. private _isFrontFaceDirty;
  31134. private _depthTest;
  31135. private _depthMask;
  31136. private _depthFunc;
  31137. private _cull;
  31138. private _cullFace;
  31139. private _zOffset;
  31140. private _frontFace;
  31141. /**
  31142. * Initializes the state.
  31143. */
  31144. constructor();
  31145. get isDirty(): boolean;
  31146. get zOffset(): number;
  31147. set zOffset(value: number);
  31148. get cullFace(): Nullable<number>;
  31149. set cullFace(value: Nullable<number>);
  31150. get cull(): Nullable<boolean>;
  31151. set cull(value: Nullable<boolean>);
  31152. get depthFunc(): Nullable<number>;
  31153. set depthFunc(value: Nullable<number>);
  31154. get depthMask(): boolean;
  31155. set depthMask(value: boolean);
  31156. get depthTest(): boolean;
  31157. set depthTest(value: boolean);
  31158. get frontFace(): Nullable<number>;
  31159. set frontFace(value: Nullable<number>);
  31160. reset(): void;
  31161. apply(gl: WebGLRenderingContext): void;
  31162. }
  31163. }
  31164. declare module BABYLON {
  31165. /**
  31166. * @hidden
  31167. **/
  31168. export class StencilState {
  31169. /** 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 */
  31170. static readonly ALWAYS: number;
  31171. /** Passed to stencilOperation to specify that stencil value must be kept */
  31172. static readonly KEEP: number;
  31173. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31174. static readonly REPLACE: number;
  31175. private _isStencilTestDirty;
  31176. private _isStencilMaskDirty;
  31177. private _isStencilFuncDirty;
  31178. private _isStencilOpDirty;
  31179. private _stencilTest;
  31180. private _stencilMask;
  31181. private _stencilFunc;
  31182. private _stencilFuncRef;
  31183. private _stencilFuncMask;
  31184. private _stencilOpStencilFail;
  31185. private _stencilOpDepthFail;
  31186. private _stencilOpStencilDepthPass;
  31187. get isDirty(): boolean;
  31188. get stencilFunc(): number;
  31189. set stencilFunc(value: number);
  31190. get stencilFuncRef(): number;
  31191. set stencilFuncRef(value: number);
  31192. get stencilFuncMask(): number;
  31193. set stencilFuncMask(value: number);
  31194. get stencilOpStencilFail(): number;
  31195. set stencilOpStencilFail(value: number);
  31196. get stencilOpDepthFail(): number;
  31197. set stencilOpDepthFail(value: number);
  31198. get stencilOpStencilDepthPass(): number;
  31199. set stencilOpStencilDepthPass(value: number);
  31200. get stencilMask(): number;
  31201. set stencilMask(value: number);
  31202. get stencilTest(): boolean;
  31203. set stencilTest(value: boolean);
  31204. constructor();
  31205. reset(): void;
  31206. apply(gl: WebGLRenderingContext): void;
  31207. }
  31208. }
  31209. declare module BABYLON {
  31210. /**
  31211. * @hidden
  31212. **/
  31213. export class AlphaState {
  31214. private _isAlphaBlendDirty;
  31215. private _isBlendFunctionParametersDirty;
  31216. private _isBlendEquationParametersDirty;
  31217. private _isBlendConstantsDirty;
  31218. private _alphaBlend;
  31219. private _blendFunctionParameters;
  31220. private _blendEquationParameters;
  31221. private _blendConstants;
  31222. /**
  31223. * Initializes the state.
  31224. */
  31225. constructor();
  31226. get isDirty(): boolean;
  31227. get alphaBlend(): boolean;
  31228. set alphaBlend(value: boolean);
  31229. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31230. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31231. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31232. reset(): void;
  31233. apply(gl: WebGLRenderingContext): void;
  31234. }
  31235. }
  31236. declare module BABYLON {
  31237. /** @hidden */
  31238. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31239. attributeProcessor(attribute: string): string;
  31240. varyingProcessor(varying: string, isFragment: boolean): string;
  31241. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31242. }
  31243. }
  31244. declare module BABYLON {
  31245. /**
  31246. * Interface for attribute information associated with buffer instanciation
  31247. */
  31248. export interface InstancingAttributeInfo {
  31249. /**
  31250. * Name of the GLSL attribute
  31251. * if attribute index is not specified, this is used to retrieve the index from the effect
  31252. */
  31253. attributeName: string;
  31254. /**
  31255. * Index/offset of the attribute in the vertex shader
  31256. * if not specified, this will be computes from the name.
  31257. */
  31258. index?: number;
  31259. /**
  31260. * size of the attribute, 1, 2, 3 or 4
  31261. */
  31262. attributeSize: number;
  31263. /**
  31264. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31265. */
  31266. offset: number;
  31267. /**
  31268. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31269. * default to 1
  31270. */
  31271. divisor?: number;
  31272. /**
  31273. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31274. * default is FLOAT
  31275. */
  31276. attributeType?: number;
  31277. /**
  31278. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31279. */
  31280. normalized?: boolean;
  31281. }
  31282. }
  31283. declare module BABYLON {
  31284. interface ThinEngine {
  31285. /**
  31286. * Update a video texture
  31287. * @param texture defines the texture to update
  31288. * @param video defines the video element to use
  31289. * @param invertY defines if data must be stored with Y axis inverted
  31290. */
  31291. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31292. }
  31293. }
  31294. declare module BABYLON {
  31295. /**
  31296. * Settings for finer control over video usage
  31297. */
  31298. export interface VideoTextureSettings {
  31299. /**
  31300. * Applies `autoplay` to video, if specified
  31301. */
  31302. autoPlay?: boolean;
  31303. /**
  31304. * Applies `loop` to video, if specified
  31305. */
  31306. loop?: boolean;
  31307. /**
  31308. * Automatically updates internal texture from video at every frame in the render loop
  31309. */
  31310. autoUpdateTexture: boolean;
  31311. /**
  31312. * Image src displayed during the video loading or until the user interacts with the video.
  31313. */
  31314. poster?: string;
  31315. }
  31316. /**
  31317. * If you want to display a video in your scene, this is the special texture for that.
  31318. * This special texture works similar to other textures, with the exception of a few parameters.
  31319. * @see https://doc.babylonjs.com/how_to/video_texture
  31320. */
  31321. export class VideoTexture extends Texture {
  31322. /**
  31323. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31324. */
  31325. readonly autoUpdateTexture: boolean;
  31326. /**
  31327. * The video instance used by the texture internally
  31328. */
  31329. readonly video: HTMLVideoElement;
  31330. private _onUserActionRequestedObservable;
  31331. /**
  31332. * Event triggerd when a dom action is required by the user to play the video.
  31333. * This happens due to recent changes in browser policies preventing video to auto start.
  31334. */
  31335. get onUserActionRequestedObservable(): Observable<Texture>;
  31336. private _generateMipMaps;
  31337. private _engine;
  31338. private _stillImageCaptured;
  31339. private _displayingPosterTexture;
  31340. private _settings;
  31341. private _createInternalTextureOnEvent;
  31342. private _frameId;
  31343. private _currentSrc;
  31344. /**
  31345. * Creates a video texture.
  31346. * If you want to display a video in your scene, this is the special texture for that.
  31347. * This special texture works similar to other textures, with the exception of a few parameters.
  31348. * @see https://doc.babylonjs.com/how_to/video_texture
  31349. * @param name optional name, will detect from video source, if not defined
  31350. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31351. * @param scene is obviously the current scene.
  31352. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31353. * @param invertY is false by default but can be used to invert video on Y axis
  31354. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31355. * @param settings allows finer control over video usage
  31356. */
  31357. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31358. private _getName;
  31359. private _getVideo;
  31360. private _createInternalTexture;
  31361. private reset;
  31362. /**
  31363. * @hidden Internal method to initiate `update`.
  31364. */
  31365. _rebuild(): void;
  31366. /**
  31367. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31368. */
  31369. update(): void;
  31370. /**
  31371. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31372. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31373. */
  31374. updateTexture(isVisible: boolean): void;
  31375. protected _updateInternalTexture: () => void;
  31376. /**
  31377. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31378. * @param url New url.
  31379. */
  31380. updateURL(url: string): void;
  31381. /**
  31382. * Clones the texture.
  31383. * @returns the cloned texture
  31384. */
  31385. clone(): VideoTexture;
  31386. /**
  31387. * Dispose the texture and release its associated resources.
  31388. */
  31389. dispose(): void;
  31390. /**
  31391. * Creates a video texture straight from a stream.
  31392. * @param scene Define the scene the texture should be created in
  31393. * @param stream Define the stream the texture should be created from
  31394. * @returns The created video texture as a promise
  31395. */
  31396. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31397. /**
  31398. * Creates a video texture straight from your WebCam video feed.
  31399. * @param scene Define the scene the texture should be created in
  31400. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31401. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31402. * @returns The created video texture as a promise
  31403. */
  31404. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31405. minWidth: number;
  31406. maxWidth: number;
  31407. minHeight: number;
  31408. maxHeight: number;
  31409. deviceId: string;
  31410. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31411. /**
  31412. * Creates a video texture straight from your WebCam video feed.
  31413. * @param scene Define the scene the texture should be created in
  31414. * @param onReady Define a callback to triggered once the texture will be ready
  31415. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31416. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31417. */
  31418. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31419. minWidth: number;
  31420. maxWidth: number;
  31421. minHeight: number;
  31422. maxHeight: number;
  31423. deviceId: string;
  31424. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31425. }
  31426. }
  31427. declare module BABYLON {
  31428. /**
  31429. * Defines the interface used by objects working like Scene
  31430. * @hidden
  31431. */
  31432. export interface ISceneLike {
  31433. _addPendingData(data: any): void;
  31434. _removePendingData(data: any): void;
  31435. offlineProvider: IOfflineProvider;
  31436. }
  31437. /** Interface defining initialization parameters for Engine class */
  31438. export interface EngineOptions extends WebGLContextAttributes {
  31439. /**
  31440. * Defines if the engine should no exceed a specified device ratio
  31441. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31442. */
  31443. limitDeviceRatio?: number;
  31444. /**
  31445. * Defines if webvr should be enabled automatically
  31446. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31447. */
  31448. autoEnableWebVR?: boolean;
  31449. /**
  31450. * Defines if webgl2 should be turned off even if supported
  31451. * @see http://doc.babylonjs.com/features/webgl2
  31452. */
  31453. disableWebGL2Support?: boolean;
  31454. /**
  31455. * Defines if webaudio should be initialized as well
  31456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31457. */
  31458. audioEngine?: boolean;
  31459. /**
  31460. * Defines if animations should run using a deterministic lock step
  31461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31462. */
  31463. deterministicLockstep?: boolean;
  31464. /** Defines the maximum steps to use with deterministic lock step mode */
  31465. lockstepMaxSteps?: number;
  31466. /** Defines the seconds between each deterministic lock step */
  31467. timeStep?: number;
  31468. /**
  31469. * Defines that engine should ignore context lost events
  31470. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31471. */
  31472. doNotHandleContextLost?: boolean;
  31473. /**
  31474. * Defines that engine should ignore modifying touch action attribute and style
  31475. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31476. */
  31477. doNotHandleTouchAction?: boolean;
  31478. /**
  31479. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31480. */
  31481. useHighPrecisionFloats?: boolean;
  31482. }
  31483. /**
  31484. * The base engine class (root of all engines)
  31485. */
  31486. export class ThinEngine {
  31487. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31488. static ExceptionList: ({
  31489. key: string;
  31490. capture: string;
  31491. captureConstraint: number;
  31492. targets: string[];
  31493. } | {
  31494. key: string;
  31495. capture: null;
  31496. captureConstraint: null;
  31497. targets: string[];
  31498. })[];
  31499. /** @hidden */
  31500. static _TextureLoaders: IInternalTextureLoader[];
  31501. /**
  31502. * Returns the current npm package of the sdk
  31503. */
  31504. static get NpmPackage(): string;
  31505. /**
  31506. * Returns the current version of the framework
  31507. */
  31508. static get Version(): string;
  31509. /**
  31510. * Returns a string describing the current engine
  31511. */
  31512. get description(): string;
  31513. /**
  31514. * Gets or sets the epsilon value used by collision engine
  31515. */
  31516. static CollisionsEpsilon: number;
  31517. /**
  31518. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31519. */
  31520. static get ShadersRepository(): string;
  31521. static set ShadersRepository(value: string);
  31522. /** @hidden */
  31523. _shaderProcessor: IShaderProcessor;
  31524. /**
  31525. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31526. */
  31527. forcePOTTextures: boolean;
  31528. /**
  31529. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31530. */
  31531. isFullscreen: boolean;
  31532. /**
  31533. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31534. */
  31535. cullBackFaces: boolean;
  31536. /**
  31537. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31538. */
  31539. renderEvenInBackground: boolean;
  31540. /**
  31541. * Gets or sets a boolean indicating that cache can be kept between frames
  31542. */
  31543. preventCacheWipeBetweenFrames: boolean;
  31544. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31545. validateShaderPrograms: boolean;
  31546. /**
  31547. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31548. * This can provide greater z depth for distant objects.
  31549. */
  31550. useReverseDepthBuffer: boolean;
  31551. /**
  31552. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31553. */
  31554. disableUniformBuffers: boolean;
  31555. /** @hidden */
  31556. _uniformBuffers: UniformBuffer[];
  31557. /**
  31558. * Gets a boolean indicating that the engine supports uniform buffers
  31559. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31560. */
  31561. get supportsUniformBuffers(): boolean;
  31562. /** @hidden */
  31563. _gl: WebGLRenderingContext;
  31564. /** @hidden */
  31565. _webGLVersion: number;
  31566. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31567. protected _windowIsBackground: boolean;
  31568. protected _creationOptions: EngineOptions;
  31569. protected _highPrecisionShadersAllowed: boolean;
  31570. /** @hidden */
  31571. get _shouldUseHighPrecisionShader(): boolean;
  31572. /**
  31573. * Gets a boolean indicating that only power of 2 textures are supported
  31574. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31575. */
  31576. get needPOTTextures(): boolean;
  31577. /** @hidden */
  31578. _badOS: boolean;
  31579. /** @hidden */
  31580. _badDesktopOS: boolean;
  31581. private _hardwareScalingLevel;
  31582. /** @hidden */
  31583. _caps: EngineCapabilities;
  31584. private _isStencilEnable;
  31585. private _glVersion;
  31586. private _glRenderer;
  31587. private _glVendor;
  31588. /** @hidden */
  31589. _videoTextureSupported: boolean;
  31590. protected _renderingQueueLaunched: boolean;
  31591. protected _activeRenderLoops: (() => void)[];
  31592. /**
  31593. * Observable signaled when a context lost event is raised
  31594. */
  31595. onContextLostObservable: Observable<ThinEngine>;
  31596. /**
  31597. * Observable signaled when a context restored event is raised
  31598. */
  31599. onContextRestoredObservable: Observable<ThinEngine>;
  31600. private _onContextLost;
  31601. private _onContextRestored;
  31602. protected _contextWasLost: boolean;
  31603. /** @hidden */
  31604. _doNotHandleContextLost: boolean;
  31605. /**
  31606. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31608. */
  31609. get doNotHandleContextLost(): boolean;
  31610. set doNotHandleContextLost(value: boolean);
  31611. /**
  31612. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31613. */
  31614. disableVertexArrayObjects: boolean;
  31615. /** @hidden */
  31616. protected _colorWrite: boolean;
  31617. /** @hidden */
  31618. protected _colorWriteChanged: boolean;
  31619. /** @hidden */
  31620. protected _depthCullingState: DepthCullingState;
  31621. /** @hidden */
  31622. protected _stencilState: StencilState;
  31623. /** @hidden */
  31624. _alphaState: AlphaState;
  31625. /** @hidden */
  31626. _alphaMode: number;
  31627. /** @hidden */
  31628. _alphaEquation: number;
  31629. /** @hidden */
  31630. _internalTexturesCache: InternalTexture[];
  31631. /** @hidden */
  31632. protected _activeChannel: number;
  31633. private _currentTextureChannel;
  31634. /** @hidden */
  31635. protected _boundTexturesCache: {
  31636. [key: string]: Nullable<InternalTexture>;
  31637. };
  31638. /** @hidden */
  31639. protected _currentEffect: Nullable<Effect>;
  31640. /** @hidden */
  31641. protected _currentProgram: Nullable<WebGLProgram>;
  31642. private _compiledEffects;
  31643. private _vertexAttribArraysEnabled;
  31644. /** @hidden */
  31645. protected _cachedViewport: Nullable<IViewportLike>;
  31646. private _cachedVertexArrayObject;
  31647. /** @hidden */
  31648. protected _cachedVertexBuffers: any;
  31649. /** @hidden */
  31650. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31651. /** @hidden */
  31652. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31653. /** @hidden */
  31654. _currentRenderTarget: Nullable<InternalTexture>;
  31655. private _uintIndicesCurrentlySet;
  31656. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31657. /** @hidden */
  31658. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31659. private _currentBufferPointers;
  31660. private _currentInstanceLocations;
  31661. private _currentInstanceBuffers;
  31662. private _textureUnits;
  31663. /** @hidden */
  31664. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31665. /** @hidden */
  31666. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31667. /** @hidden */
  31668. _boundRenderFunction: any;
  31669. private _vaoRecordInProgress;
  31670. private _mustWipeVertexAttributes;
  31671. private _emptyTexture;
  31672. private _emptyCubeTexture;
  31673. private _emptyTexture3D;
  31674. private _emptyTexture2DArray;
  31675. /** @hidden */
  31676. _frameHandler: number;
  31677. private _nextFreeTextureSlots;
  31678. private _maxSimultaneousTextures;
  31679. private _activeRequests;
  31680. /** @hidden */
  31681. _transformTextureUrl: Nullable<(url: string) => string>;
  31682. protected get _supportsHardwareTextureRescaling(): boolean;
  31683. private _framebufferDimensionsObject;
  31684. /**
  31685. * sets the object from which width and height will be taken from when getting render width and height
  31686. * Will fallback to the gl object
  31687. * @param dimensions the framebuffer width and height that will be used.
  31688. */
  31689. set framebufferDimensionsObject(dimensions: Nullable<{
  31690. framebufferWidth: number;
  31691. framebufferHeight: number;
  31692. }>);
  31693. /**
  31694. * Gets the current viewport
  31695. */
  31696. get currentViewport(): Nullable<IViewportLike>;
  31697. /**
  31698. * Gets the default empty texture
  31699. */
  31700. get emptyTexture(): InternalTexture;
  31701. /**
  31702. * Gets the default empty 3D texture
  31703. */
  31704. get emptyTexture3D(): InternalTexture;
  31705. /**
  31706. * Gets the default empty 2D array texture
  31707. */
  31708. get emptyTexture2DArray(): InternalTexture;
  31709. /**
  31710. * Gets the default empty cube texture
  31711. */
  31712. get emptyCubeTexture(): InternalTexture;
  31713. /**
  31714. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31715. */
  31716. readonly premultipliedAlpha: boolean;
  31717. /**
  31718. * Observable event triggered before each texture is initialized
  31719. */
  31720. onBeforeTextureInitObservable: Observable<Texture>;
  31721. /**
  31722. * Creates a new engine
  31723. * @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
  31724. * @param antialias defines enable antialiasing (default: false)
  31725. * @param options defines further options to be sent to the getContext() function
  31726. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31727. */
  31728. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31729. private _rebuildInternalTextures;
  31730. private _rebuildEffects;
  31731. /**
  31732. * Gets a boolean indicating if all created effects are ready
  31733. * @returns true if all effects are ready
  31734. */
  31735. areAllEffectsReady(): boolean;
  31736. protected _rebuildBuffers(): void;
  31737. protected _initGLContext(): void;
  31738. /**
  31739. * Gets version of the current webGL context
  31740. */
  31741. get webGLVersion(): number;
  31742. /**
  31743. * Gets a string idenfifying the name of the class
  31744. * @returns "Engine" string
  31745. */
  31746. getClassName(): string;
  31747. /**
  31748. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31749. */
  31750. get isStencilEnable(): boolean;
  31751. /** @hidden */
  31752. _prepareWorkingCanvas(): void;
  31753. /**
  31754. * Reset the texture cache to empty state
  31755. */
  31756. resetTextureCache(): void;
  31757. /**
  31758. * Gets an object containing information about the current webGL context
  31759. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31760. */
  31761. getGlInfo(): {
  31762. vendor: string;
  31763. renderer: string;
  31764. version: string;
  31765. };
  31766. /**
  31767. * Defines the hardware scaling level.
  31768. * By default the hardware scaling level is computed from the window device ratio.
  31769. * 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.
  31770. * @param level defines the level to use
  31771. */
  31772. setHardwareScalingLevel(level: number): void;
  31773. /**
  31774. * Gets the current hardware scaling level.
  31775. * By default the hardware scaling level is computed from the window device ratio.
  31776. * 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.
  31777. * @returns a number indicating the current hardware scaling level
  31778. */
  31779. getHardwareScalingLevel(): number;
  31780. /**
  31781. * Gets the list of loaded textures
  31782. * @returns an array containing all loaded textures
  31783. */
  31784. getLoadedTexturesCache(): InternalTexture[];
  31785. /**
  31786. * Gets the object containing all engine capabilities
  31787. * @returns the EngineCapabilities object
  31788. */
  31789. getCaps(): EngineCapabilities;
  31790. /**
  31791. * stop executing a render loop function and remove it from the execution array
  31792. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31793. */
  31794. stopRenderLoop(renderFunction?: () => void): void;
  31795. /** @hidden */
  31796. _renderLoop(): void;
  31797. /**
  31798. * Gets the HTML canvas attached with the current webGL context
  31799. * @returns a HTML canvas
  31800. */
  31801. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31802. /**
  31803. * Gets host window
  31804. * @returns the host window object
  31805. */
  31806. getHostWindow(): Nullable<Window>;
  31807. /**
  31808. * Gets the current render width
  31809. * @param useScreen defines if screen size must be used (or the current render target if any)
  31810. * @returns a number defining the current render width
  31811. */
  31812. getRenderWidth(useScreen?: boolean): number;
  31813. /**
  31814. * Gets the current render height
  31815. * @param useScreen defines if screen size must be used (or the current render target if any)
  31816. * @returns a number defining the current render height
  31817. */
  31818. getRenderHeight(useScreen?: boolean): number;
  31819. /**
  31820. * Can be used to override the current requestAnimationFrame requester.
  31821. * @hidden
  31822. */
  31823. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31824. /**
  31825. * Register and execute a render loop. The engine can have more than one render function
  31826. * @param renderFunction defines the function to continuously execute
  31827. */
  31828. runRenderLoop(renderFunction: () => void): void;
  31829. /**
  31830. * Clear the current render buffer or the current render target (if any is set up)
  31831. * @param color defines the color to use
  31832. * @param backBuffer defines if the back buffer must be cleared
  31833. * @param depth defines if the depth buffer must be cleared
  31834. * @param stencil defines if the stencil buffer must be cleared
  31835. */
  31836. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31837. private _viewportCached;
  31838. /** @hidden */
  31839. _viewport(x: number, y: number, width: number, height: number): void;
  31840. /**
  31841. * Set the WebGL's viewport
  31842. * @param viewport defines the viewport element to be used
  31843. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31844. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31845. */
  31846. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31847. /**
  31848. * Begin a new frame
  31849. */
  31850. beginFrame(): void;
  31851. /**
  31852. * Enf the current frame
  31853. */
  31854. endFrame(): void;
  31855. /**
  31856. * Resize the view according to the canvas' size
  31857. */
  31858. resize(): void;
  31859. /**
  31860. * Force a specific size of the canvas
  31861. * @param width defines the new canvas' width
  31862. * @param height defines the new canvas' height
  31863. */
  31864. setSize(width: number, height: number): void;
  31865. /**
  31866. * Binds the frame buffer to the specified texture.
  31867. * @param texture The texture to render to or null for the default canvas
  31868. * @param faceIndex The face of the texture to render to in case of cube texture
  31869. * @param requiredWidth The width of the target to render to
  31870. * @param requiredHeight The height of the target to render to
  31871. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31872. * @param lodLevel defines the lod level to bind to the frame buffer
  31873. * @param layer defines the 2d array index to bind to frame buffer to
  31874. */
  31875. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31876. /** @hidden */
  31877. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31878. /**
  31879. * Unbind the current render target texture from the webGL context
  31880. * @param texture defines the render target texture to unbind
  31881. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31882. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31883. */
  31884. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31885. /**
  31886. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31887. */
  31888. flushFramebuffer(): void;
  31889. /**
  31890. * Unbind the current render target and bind the default framebuffer
  31891. */
  31892. restoreDefaultFramebuffer(): void;
  31893. /** @hidden */
  31894. protected _resetVertexBufferBinding(): void;
  31895. /**
  31896. * Creates a vertex buffer
  31897. * @param data the data for the vertex buffer
  31898. * @returns the new WebGL static buffer
  31899. */
  31900. createVertexBuffer(data: DataArray): DataBuffer;
  31901. private _createVertexBuffer;
  31902. /**
  31903. * Creates a dynamic vertex buffer
  31904. * @param data the data for the dynamic vertex buffer
  31905. * @returns the new WebGL dynamic buffer
  31906. */
  31907. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31908. protected _resetIndexBufferBinding(): void;
  31909. /**
  31910. * Creates a new index buffer
  31911. * @param indices defines the content of the index buffer
  31912. * @param updatable defines if the index buffer must be updatable
  31913. * @returns a new webGL buffer
  31914. */
  31915. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31916. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31917. /**
  31918. * Bind a webGL buffer to the webGL context
  31919. * @param buffer defines the buffer to bind
  31920. */
  31921. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31922. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31923. private bindBuffer;
  31924. /**
  31925. * update the bound buffer with the given data
  31926. * @param data defines the data to update
  31927. */
  31928. updateArrayBuffer(data: Float32Array): void;
  31929. private _vertexAttribPointer;
  31930. /** @hidden */
  31931. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31932. private _bindVertexBuffersAttributes;
  31933. /**
  31934. * Records a vertex array object
  31935. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31936. * @param vertexBuffers defines the list of vertex buffers to store
  31937. * @param indexBuffer defines the index buffer to store
  31938. * @param effect defines the effect to store
  31939. * @returns the new vertex array object
  31940. */
  31941. recordVertexArrayObject(vertexBuffers: {
  31942. [key: string]: VertexBuffer;
  31943. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31944. /**
  31945. * Bind a specific vertex array object
  31946. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31947. * @param vertexArrayObject defines the vertex array object to bind
  31948. * @param indexBuffer defines the index buffer to bind
  31949. */
  31950. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31951. /**
  31952. * Bind webGl buffers directly to the webGL context
  31953. * @param vertexBuffer defines the vertex buffer to bind
  31954. * @param indexBuffer defines the index buffer to bind
  31955. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31956. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31957. * @param effect defines the effect associated with the vertex buffer
  31958. */
  31959. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31960. private _unbindVertexArrayObject;
  31961. /**
  31962. * Bind a list of vertex buffers to the webGL context
  31963. * @param vertexBuffers defines the list of vertex buffers to bind
  31964. * @param indexBuffer defines the index buffer to bind
  31965. * @param effect defines the effect associated with the vertex buffers
  31966. */
  31967. bindBuffers(vertexBuffers: {
  31968. [key: string]: Nullable<VertexBuffer>;
  31969. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31970. /**
  31971. * Unbind all instance attributes
  31972. */
  31973. unbindInstanceAttributes(): void;
  31974. /**
  31975. * Release and free the memory of a vertex array object
  31976. * @param vao defines the vertex array object to delete
  31977. */
  31978. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31979. /** @hidden */
  31980. _releaseBuffer(buffer: DataBuffer): boolean;
  31981. protected _deleteBuffer(buffer: DataBuffer): void;
  31982. /**
  31983. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31984. * @param instancesBuffer defines the webGL buffer to update and bind
  31985. * @param data defines the data to store in the buffer
  31986. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31987. */
  31988. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31989. /**
  31990. * Bind the content of a webGL buffer used with instantiation
  31991. * @param instancesBuffer defines the webGL buffer to bind
  31992. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31993. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31994. */
  31995. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31996. /**
  31997. * Disable the instance attribute corresponding to the name in parameter
  31998. * @param name defines the name of the attribute to disable
  31999. */
  32000. disableInstanceAttributeByName(name: string): void;
  32001. /**
  32002. * Disable the instance attribute corresponding to the location in parameter
  32003. * @param attributeLocation defines the attribute location of the attribute to disable
  32004. */
  32005. disableInstanceAttribute(attributeLocation: number): void;
  32006. /**
  32007. * Disable the attribute corresponding to the location in parameter
  32008. * @param attributeLocation defines the attribute location of the attribute to disable
  32009. */
  32010. disableAttributeByIndex(attributeLocation: number): void;
  32011. /**
  32012. * Send a draw order
  32013. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32014. * @param indexStart defines the starting index
  32015. * @param indexCount defines the number of index to draw
  32016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32017. */
  32018. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32019. /**
  32020. * Draw a list of points
  32021. * @param verticesStart defines the index of first vertex to draw
  32022. * @param verticesCount defines the count of vertices to draw
  32023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32024. */
  32025. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32026. /**
  32027. * Draw a list of unindexed primitives
  32028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32029. * @param verticesStart defines the index of first vertex to draw
  32030. * @param verticesCount defines the count of vertices to draw
  32031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32032. */
  32033. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32034. /**
  32035. * Draw a list of indexed primitives
  32036. * @param fillMode defines the primitive to use
  32037. * @param indexStart defines the starting index
  32038. * @param indexCount defines the number of index to draw
  32039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32040. */
  32041. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32042. /**
  32043. * Draw a list of unindexed primitives
  32044. * @param fillMode defines the primitive to use
  32045. * @param verticesStart defines the index of first vertex to draw
  32046. * @param verticesCount defines the count of vertices to draw
  32047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32048. */
  32049. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32050. private _drawMode;
  32051. /** @hidden */
  32052. protected _reportDrawCall(): void;
  32053. /** @hidden */
  32054. _releaseEffect(effect: Effect): void;
  32055. /** @hidden */
  32056. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32057. /**
  32058. * Create a new effect (used to store vertex/fragment shaders)
  32059. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32060. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32061. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32062. * @param samplers defines an array of string used to represent textures
  32063. * @param defines defines the string containing the defines to use to compile the shaders
  32064. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32065. * @param onCompiled defines a function to call when the effect creation is successful
  32066. * @param onError defines a function to call when the effect creation has failed
  32067. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32068. * @returns the new Effect
  32069. */
  32070. 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;
  32071. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32072. private _compileShader;
  32073. private _compileRawShader;
  32074. /** @hidden */
  32075. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32076. /**
  32077. * Directly creates a webGL program
  32078. * @param pipelineContext defines the pipeline context to attach to
  32079. * @param vertexCode defines the vertex shader code to use
  32080. * @param fragmentCode defines the fragment shader code to use
  32081. * @param context defines the webGL context to use (if not set, the current one will be used)
  32082. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32083. * @returns the new webGL program
  32084. */
  32085. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32086. /**
  32087. * Creates a webGL program
  32088. * @param pipelineContext defines the pipeline context to attach to
  32089. * @param vertexCode defines the vertex shader code to use
  32090. * @param fragmentCode defines the fragment shader code to use
  32091. * @param defines defines the string containing the defines to use to compile the shaders
  32092. * @param context defines the webGL context to use (if not set, the current one will be used)
  32093. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32094. * @returns the new webGL program
  32095. */
  32096. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32097. /**
  32098. * Creates a new pipeline context
  32099. * @returns the new pipeline
  32100. */
  32101. createPipelineContext(): IPipelineContext;
  32102. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32103. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32104. /** @hidden */
  32105. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32106. /** @hidden */
  32107. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32108. /** @hidden */
  32109. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32110. /**
  32111. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32112. * @param pipelineContext defines the pipeline context to use
  32113. * @param uniformsNames defines the list of uniform names
  32114. * @returns an array of webGL uniform locations
  32115. */
  32116. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32117. /**
  32118. * Gets the lsit of active attributes for a given webGL program
  32119. * @param pipelineContext defines the pipeline context to use
  32120. * @param attributesNames defines the list of attribute names to get
  32121. * @returns an array of indices indicating the offset of each attribute
  32122. */
  32123. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32124. /**
  32125. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32126. * @param effect defines the effect to activate
  32127. */
  32128. enableEffect(effect: Nullable<Effect>): void;
  32129. /**
  32130. * Set the value of an uniform to a number (int)
  32131. * @param uniform defines the webGL uniform location where to store the value
  32132. * @param value defines the int number to store
  32133. */
  32134. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32135. /**
  32136. * Set the value of an uniform to an array of int32
  32137. * @param uniform defines the webGL uniform location where to store the value
  32138. * @param array defines the array of int32 to store
  32139. */
  32140. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32141. /**
  32142. * Set the value of an uniform to an array of int32 (stored as vec2)
  32143. * @param uniform defines the webGL uniform location where to store the value
  32144. * @param array defines the array of int32 to store
  32145. */
  32146. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32147. /**
  32148. * Set the value of an uniform to an array of int32 (stored as vec3)
  32149. * @param uniform defines the webGL uniform location where to store the value
  32150. * @param array defines the array of int32 to store
  32151. */
  32152. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32153. /**
  32154. * Set the value of an uniform to an array of int32 (stored as vec4)
  32155. * @param uniform defines the webGL uniform location where to store the value
  32156. * @param array defines the array of int32 to store
  32157. */
  32158. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32159. /**
  32160. * Set the value of an uniform to an array of number
  32161. * @param uniform defines the webGL uniform location where to store the value
  32162. * @param array defines the array of number to store
  32163. */
  32164. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32165. /**
  32166. * Set the value of an uniform to an array of number (stored as vec2)
  32167. * @param uniform defines the webGL uniform location where to store the value
  32168. * @param array defines the array of number to store
  32169. */
  32170. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32171. /**
  32172. * Set the value of an uniform to an array of number (stored as vec3)
  32173. * @param uniform defines the webGL uniform location where to store the value
  32174. * @param array defines the array of number to store
  32175. */
  32176. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32177. /**
  32178. * Set the value of an uniform to an array of number (stored as vec4)
  32179. * @param uniform defines the webGL uniform location where to store the value
  32180. * @param array defines the array of number to store
  32181. */
  32182. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32183. /**
  32184. * Set the value of an uniform to an array of float32 (stored as matrices)
  32185. * @param uniform defines the webGL uniform location where to store the value
  32186. * @param matrices defines the array of float32 to store
  32187. */
  32188. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32189. /**
  32190. * Set the value of an uniform to a matrix (3x3)
  32191. * @param uniform defines the webGL uniform location where to store the value
  32192. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32193. */
  32194. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32195. /**
  32196. * Set the value of an uniform to a matrix (2x2)
  32197. * @param uniform defines the webGL uniform location where to store the value
  32198. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32199. */
  32200. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32201. /**
  32202. * Set the value of an uniform to a number (float)
  32203. * @param uniform defines the webGL uniform location where to store the value
  32204. * @param value defines the float number to store
  32205. */
  32206. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32207. /**
  32208. * Set the value of an uniform to a vec2
  32209. * @param uniform defines the webGL uniform location where to store the value
  32210. * @param x defines the 1st component of the value
  32211. * @param y defines the 2nd component of the value
  32212. */
  32213. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32214. /**
  32215. * Set the value of an uniform to a vec3
  32216. * @param uniform defines the webGL uniform location where to store the value
  32217. * @param x defines the 1st component of the value
  32218. * @param y defines the 2nd component of the value
  32219. * @param z defines the 3rd component of the value
  32220. */
  32221. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32222. /**
  32223. * Set the value of an uniform to a vec4
  32224. * @param uniform defines the webGL uniform location where to store the value
  32225. * @param x defines the 1st component of the value
  32226. * @param y defines the 2nd component of the value
  32227. * @param z defines the 3rd component of the value
  32228. * @param w defines the 4th component of the value
  32229. */
  32230. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32231. /**
  32232. * Apply all cached states (depth, culling, stencil and alpha)
  32233. */
  32234. applyStates(): void;
  32235. /**
  32236. * Enable or disable color writing
  32237. * @param enable defines the state to set
  32238. */
  32239. setColorWrite(enable: boolean): void;
  32240. /**
  32241. * Gets a boolean indicating if color writing is enabled
  32242. * @returns the current color writing state
  32243. */
  32244. getColorWrite(): boolean;
  32245. /**
  32246. * Gets the depth culling state manager
  32247. */
  32248. get depthCullingState(): DepthCullingState;
  32249. /**
  32250. * Gets the alpha state manager
  32251. */
  32252. get alphaState(): AlphaState;
  32253. /**
  32254. * Gets the stencil state manager
  32255. */
  32256. get stencilState(): StencilState;
  32257. /**
  32258. * Clears the list of texture accessible through engine.
  32259. * This can help preventing texture load conflict due to name collision.
  32260. */
  32261. clearInternalTexturesCache(): void;
  32262. /**
  32263. * Force the entire cache to be cleared
  32264. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32265. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32266. */
  32267. wipeCaches(bruteForce?: boolean): void;
  32268. /** @hidden */
  32269. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32270. min: number;
  32271. mag: number;
  32272. };
  32273. /** @hidden */
  32274. _createTexture(): WebGLTexture;
  32275. /**
  32276. * Usually called from Texture.ts.
  32277. * Passed information to create a WebGLTexture
  32278. * @param url defines a value which contains one of the following:
  32279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32283. * @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)
  32284. * @param scene needed for loading to the correct scene
  32285. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32286. * @param onLoad optional callback to be called upon successful completion
  32287. * @param onError optional callback to be called upon failure
  32288. * @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
  32289. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32291. * @param forcedExtension defines the extension to use to pick the right loader
  32292. * @param mimeType defines an optional mime type
  32293. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32294. */
  32295. 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;
  32296. /**
  32297. * Loads an image as an HTMLImageElement.
  32298. * @param input url string, ArrayBuffer, or Blob to load
  32299. * @param onLoad callback called when the image successfully loads
  32300. * @param onError callback called when the image fails to load
  32301. * @param offlineProvider offline provider for caching
  32302. * @param mimeType optional mime type
  32303. * @returns the HTMLImageElement of the loaded image
  32304. * @hidden
  32305. */
  32306. 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>;
  32307. /**
  32308. * @hidden
  32309. */
  32310. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32311. private _unpackFlipYCached;
  32312. /**
  32313. * In case you are sharing the context with other applications, it might
  32314. * be interested to not cache the unpack flip y state to ensure a consistent
  32315. * value would be set.
  32316. */
  32317. enableUnpackFlipYCached: boolean;
  32318. /** @hidden */
  32319. _unpackFlipY(value: boolean): void;
  32320. /** @hidden */
  32321. _getUnpackAlignement(): number;
  32322. private _getTextureTarget;
  32323. /**
  32324. * Update the sampling mode of a given texture
  32325. * @param samplingMode defines the required sampling mode
  32326. * @param texture defines the texture to update
  32327. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32328. */
  32329. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32330. /**
  32331. * Update the sampling mode of a given texture
  32332. * @param texture defines the texture to update
  32333. * @param wrapU defines the texture wrap mode of the u coordinates
  32334. * @param wrapV defines the texture wrap mode of the v coordinates
  32335. * @param wrapR defines the texture wrap mode of the r coordinates
  32336. */
  32337. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32338. /** @hidden */
  32339. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32340. width: number;
  32341. height: number;
  32342. layers?: number;
  32343. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32344. /** @hidden */
  32345. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32346. /** @hidden */
  32347. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32348. /**
  32349. * Update a portion of an internal texture
  32350. * @param texture defines the texture to update
  32351. * @param imageData defines the data to store into the texture
  32352. * @param xOffset defines the x coordinates of the update rectangle
  32353. * @param yOffset defines the y coordinates of the update rectangle
  32354. * @param width defines the width of the update rectangle
  32355. * @param height defines the height of the update rectangle
  32356. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32357. * @param lod defines the lod level to update (0 by default)
  32358. */
  32359. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32360. /** @hidden */
  32361. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32362. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32363. private _prepareWebGLTexture;
  32364. /** @hidden */
  32365. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32366. private _getDepthStencilBuffer;
  32367. /** @hidden */
  32368. _releaseFramebufferObjects(texture: InternalTexture): void;
  32369. /** @hidden */
  32370. _releaseTexture(texture: InternalTexture): void;
  32371. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32372. protected _setProgram(program: WebGLProgram): void;
  32373. protected _boundUniforms: {
  32374. [key: number]: WebGLUniformLocation;
  32375. };
  32376. /**
  32377. * Binds an effect to the webGL context
  32378. * @param effect defines the effect to bind
  32379. */
  32380. bindSamplers(effect: Effect): void;
  32381. private _activateCurrentTexture;
  32382. /** @hidden */
  32383. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32384. /** @hidden */
  32385. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32386. /**
  32387. * Unbind all textures from the webGL context
  32388. */
  32389. unbindAllTextures(): void;
  32390. /**
  32391. * Sets a texture to the according uniform.
  32392. * @param channel The texture channel
  32393. * @param uniform The uniform to set
  32394. * @param texture The texture to apply
  32395. */
  32396. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32397. private _bindSamplerUniformToChannel;
  32398. private _getTextureWrapMode;
  32399. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32400. /**
  32401. * Sets an array of texture to the webGL context
  32402. * @param channel defines the channel where the texture array must be set
  32403. * @param uniform defines the associated uniform location
  32404. * @param textures defines the array of textures to bind
  32405. */
  32406. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32407. /** @hidden */
  32408. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32409. private _setTextureParameterFloat;
  32410. private _setTextureParameterInteger;
  32411. /**
  32412. * Unbind all vertex attributes from the webGL context
  32413. */
  32414. unbindAllAttributes(): void;
  32415. /**
  32416. * 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
  32417. */
  32418. releaseEffects(): void;
  32419. /**
  32420. * Dispose and release all associated resources
  32421. */
  32422. dispose(): void;
  32423. /**
  32424. * Attach a new callback raised when context lost event is fired
  32425. * @param callback defines the callback to call
  32426. */
  32427. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32428. /**
  32429. * Attach a new callback raised when context restored event is fired
  32430. * @param callback defines the callback to call
  32431. */
  32432. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32433. /**
  32434. * Get the current error code of the webGL context
  32435. * @returns the error code
  32436. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32437. */
  32438. getError(): number;
  32439. private _canRenderToFloatFramebuffer;
  32440. private _canRenderToHalfFloatFramebuffer;
  32441. private _canRenderToFramebuffer;
  32442. /** @hidden */
  32443. _getWebGLTextureType(type: number): number;
  32444. /** @hidden */
  32445. _getInternalFormat(format: number): number;
  32446. /** @hidden */
  32447. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32448. /** @hidden */
  32449. _getRGBAMultiSampleBufferFormat(type: number): number;
  32450. /** @hidden */
  32451. _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;
  32452. /**
  32453. * Loads a file from a url
  32454. * @param url url to load
  32455. * @param onSuccess callback called when the file successfully loads
  32456. * @param onProgress callback called while file is loading (if the server supports this mode)
  32457. * @param offlineProvider defines the offline provider for caching
  32458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32459. * @param onError callback called when the file fails to load
  32460. * @returns a file request object
  32461. * @hidden
  32462. */
  32463. 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;
  32464. /**
  32465. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32466. * @param x defines the x coordinate of the rectangle where pixels must be read
  32467. * @param y defines the y coordinate of the rectangle where pixels must be read
  32468. * @param width defines the width of the rectangle where pixels must be read
  32469. * @param height defines the height of the rectangle where pixels must be read
  32470. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32471. * @returns a Uint8Array containing RGBA colors
  32472. */
  32473. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32474. private static _isSupported;
  32475. /**
  32476. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32477. * @returns true if the engine can be created
  32478. * @ignorenaming
  32479. */
  32480. static isSupported(): boolean;
  32481. /**
  32482. * Find the next highest power of two.
  32483. * @param x Number to start search from.
  32484. * @return Next highest power of two.
  32485. */
  32486. static CeilingPOT(x: number): number;
  32487. /**
  32488. * Find the next lowest power of two.
  32489. * @param x Number to start search from.
  32490. * @return Next lowest power of two.
  32491. */
  32492. static FloorPOT(x: number): number;
  32493. /**
  32494. * Find the nearest power of two.
  32495. * @param x Number to start search from.
  32496. * @return Next nearest power of two.
  32497. */
  32498. static NearestPOT(x: number): number;
  32499. /**
  32500. * Get the closest exponent of two
  32501. * @param value defines the value to approximate
  32502. * @param max defines the maximum value to return
  32503. * @param mode defines how to define the closest value
  32504. * @returns closest exponent of two of the given value
  32505. */
  32506. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32507. /**
  32508. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32509. * @param func - the function to be called
  32510. * @param requester - the object that will request the next frame. Falls back to window.
  32511. * @returns frame number
  32512. */
  32513. static QueueNewFrame(func: () => void, requester?: any): number;
  32514. /**
  32515. * Gets host document
  32516. * @returns the host document object
  32517. */
  32518. getHostDocument(): Nullable<Document>;
  32519. }
  32520. }
  32521. declare module BABYLON {
  32522. /**
  32523. * Class representing spherical harmonics coefficients to the 3rd degree
  32524. */
  32525. export class SphericalHarmonics {
  32526. /**
  32527. * Defines whether or not the harmonics have been prescaled for rendering.
  32528. */
  32529. preScaled: boolean;
  32530. /**
  32531. * The l0,0 coefficients of the spherical harmonics
  32532. */
  32533. l00: Vector3;
  32534. /**
  32535. * The l1,-1 coefficients of the spherical harmonics
  32536. */
  32537. l1_1: Vector3;
  32538. /**
  32539. * The l1,0 coefficients of the spherical harmonics
  32540. */
  32541. l10: Vector3;
  32542. /**
  32543. * The l1,1 coefficients of the spherical harmonics
  32544. */
  32545. l11: Vector3;
  32546. /**
  32547. * The l2,-2 coefficients of the spherical harmonics
  32548. */
  32549. l2_2: Vector3;
  32550. /**
  32551. * The l2,-1 coefficients of the spherical harmonics
  32552. */
  32553. l2_1: Vector3;
  32554. /**
  32555. * The l2,0 coefficients of the spherical harmonics
  32556. */
  32557. l20: Vector3;
  32558. /**
  32559. * The l2,1 coefficients of the spherical harmonics
  32560. */
  32561. l21: Vector3;
  32562. /**
  32563. * The l2,2 coefficients of the spherical harmonics
  32564. */
  32565. l22: Vector3;
  32566. /**
  32567. * Adds a light to the spherical harmonics
  32568. * @param direction the direction of the light
  32569. * @param color the color of the light
  32570. * @param deltaSolidAngle the delta solid angle of the light
  32571. */
  32572. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32573. /**
  32574. * Scales the spherical harmonics by the given amount
  32575. * @param scale the amount to scale
  32576. */
  32577. scaleInPlace(scale: number): void;
  32578. /**
  32579. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32580. *
  32581. * ```
  32582. * E_lm = A_l * L_lm
  32583. * ```
  32584. *
  32585. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32586. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32587. * the scaling factors are given in equation 9.
  32588. */
  32589. convertIncidentRadianceToIrradiance(): void;
  32590. /**
  32591. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32592. *
  32593. * ```
  32594. * L = (1/pi) * E * rho
  32595. * ```
  32596. *
  32597. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32598. */
  32599. convertIrradianceToLambertianRadiance(): void;
  32600. /**
  32601. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32602. * required operations at run time.
  32603. *
  32604. * This is simply done by scaling back the SH with Ylm constants parameter.
  32605. * The trigonometric part being applied by the shader at run time.
  32606. */
  32607. preScaleForRendering(): void;
  32608. /**
  32609. * Constructs a spherical harmonics from an array.
  32610. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32611. * @returns the spherical harmonics
  32612. */
  32613. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32614. /**
  32615. * Gets the spherical harmonics from polynomial
  32616. * @param polynomial the spherical polynomial
  32617. * @returns the spherical harmonics
  32618. */
  32619. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32620. }
  32621. /**
  32622. * Class representing spherical polynomial coefficients to the 3rd degree
  32623. */
  32624. export class SphericalPolynomial {
  32625. private _harmonics;
  32626. /**
  32627. * The spherical harmonics used to create the polynomials.
  32628. */
  32629. get preScaledHarmonics(): SphericalHarmonics;
  32630. /**
  32631. * The x coefficients of the spherical polynomial
  32632. */
  32633. x: Vector3;
  32634. /**
  32635. * The y coefficients of the spherical polynomial
  32636. */
  32637. y: Vector3;
  32638. /**
  32639. * The z coefficients of the spherical polynomial
  32640. */
  32641. z: Vector3;
  32642. /**
  32643. * The xx coefficients of the spherical polynomial
  32644. */
  32645. xx: Vector3;
  32646. /**
  32647. * The yy coefficients of the spherical polynomial
  32648. */
  32649. yy: Vector3;
  32650. /**
  32651. * The zz coefficients of the spherical polynomial
  32652. */
  32653. zz: Vector3;
  32654. /**
  32655. * The xy coefficients of the spherical polynomial
  32656. */
  32657. xy: Vector3;
  32658. /**
  32659. * The yz coefficients of the spherical polynomial
  32660. */
  32661. yz: Vector3;
  32662. /**
  32663. * The zx coefficients of the spherical polynomial
  32664. */
  32665. zx: Vector3;
  32666. /**
  32667. * Adds an ambient color to the spherical polynomial
  32668. * @param color the color to add
  32669. */
  32670. addAmbient(color: Color3): void;
  32671. /**
  32672. * Scales the spherical polynomial by the given amount
  32673. * @param scale the amount to scale
  32674. */
  32675. scaleInPlace(scale: number): void;
  32676. /**
  32677. * Gets the spherical polynomial from harmonics
  32678. * @param harmonics the spherical harmonics
  32679. * @returns the spherical polynomial
  32680. */
  32681. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32682. /**
  32683. * Constructs a spherical polynomial from an array.
  32684. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32685. * @returns the spherical polynomial
  32686. */
  32687. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32688. }
  32689. }
  32690. declare module BABYLON {
  32691. /**
  32692. * Defines the source of the internal texture
  32693. */
  32694. export enum InternalTextureSource {
  32695. /**
  32696. * The source of the texture data is unknown
  32697. */
  32698. Unknown = 0,
  32699. /**
  32700. * Texture data comes from an URL
  32701. */
  32702. Url = 1,
  32703. /**
  32704. * Texture data is only used for temporary storage
  32705. */
  32706. Temp = 2,
  32707. /**
  32708. * Texture data comes from raw data (ArrayBuffer)
  32709. */
  32710. Raw = 3,
  32711. /**
  32712. * Texture content is dynamic (video or dynamic texture)
  32713. */
  32714. Dynamic = 4,
  32715. /**
  32716. * Texture content is generated by rendering to it
  32717. */
  32718. RenderTarget = 5,
  32719. /**
  32720. * Texture content is part of a multi render target process
  32721. */
  32722. MultiRenderTarget = 6,
  32723. /**
  32724. * Texture data comes from a cube data file
  32725. */
  32726. Cube = 7,
  32727. /**
  32728. * Texture data comes from a raw cube data
  32729. */
  32730. CubeRaw = 8,
  32731. /**
  32732. * Texture data come from a prefiltered cube data file
  32733. */
  32734. CubePrefiltered = 9,
  32735. /**
  32736. * Texture content is raw 3D data
  32737. */
  32738. Raw3D = 10,
  32739. /**
  32740. * Texture content is raw 2D array data
  32741. */
  32742. Raw2DArray = 11,
  32743. /**
  32744. * Texture content is a depth texture
  32745. */
  32746. Depth = 12,
  32747. /**
  32748. * Texture data comes from a raw cube data encoded with RGBD
  32749. */
  32750. CubeRawRGBD = 13
  32751. }
  32752. /**
  32753. * Class used to store data associated with WebGL texture data for the engine
  32754. * This class should not be used directly
  32755. */
  32756. export class InternalTexture {
  32757. /** @hidden */
  32758. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32759. /**
  32760. * Defines if the texture is ready
  32761. */
  32762. isReady: boolean;
  32763. /**
  32764. * Defines if the texture is a cube texture
  32765. */
  32766. isCube: boolean;
  32767. /**
  32768. * Defines if the texture contains 3D data
  32769. */
  32770. is3D: boolean;
  32771. /**
  32772. * Defines if the texture contains 2D array data
  32773. */
  32774. is2DArray: boolean;
  32775. /**
  32776. * Defines if the texture contains multiview data
  32777. */
  32778. isMultiview: boolean;
  32779. /**
  32780. * Gets the URL used to load this texture
  32781. */
  32782. url: string;
  32783. /**
  32784. * Gets the sampling mode of the texture
  32785. */
  32786. samplingMode: number;
  32787. /**
  32788. * Gets a boolean indicating if the texture needs mipmaps generation
  32789. */
  32790. generateMipMaps: boolean;
  32791. /**
  32792. * Gets the number of samples used by the texture (WebGL2+ only)
  32793. */
  32794. samples: number;
  32795. /**
  32796. * Gets the type of the texture (int, float...)
  32797. */
  32798. type: number;
  32799. /**
  32800. * Gets the format of the texture (RGB, RGBA...)
  32801. */
  32802. format: number;
  32803. /**
  32804. * Observable called when the texture is loaded
  32805. */
  32806. onLoadedObservable: Observable<InternalTexture>;
  32807. /**
  32808. * Gets the width of the texture
  32809. */
  32810. width: number;
  32811. /**
  32812. * Gets the height of the texture
  32813. */
  32814. height: number;
  32815. /**
  32816. * Gets the depth of the texture
  32817. */
  32818. depth: number;
  32819. /**
  32820. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32821. */
  32822. baseWidth: number;
  32823. /**
  32824. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32825. */
  32826. baseHeight: number;
  32827. /**
  32828. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32829. */
  32830. baseDepth: number;
  32831. /**
  32832. * Gets a boolean indicating if the texture is inverted on Y axis
  32833. */
  32834. invertY: boolean;
  32835. /** @hidden */
  32836. _invertVScale: boolean;
  32837. /** @hidden */
  32838. _associatedChannel: number;
  32839. /** @hidden */
  32840. _source: InternalTextureSource;
  32841. /** @hidden */
  32842. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32843. /** @hidden */
  32844. _bufferView: Nullable<ArrayBufferView>;
  32845. /** @hidden */
  32846. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32847. /** @hidden */
  32848. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32849. /** @hidden */
  32850. _size: number;
  32851. /** @hidden */
  32852. _extension: string;
  32853. /** @hidden */
  32854. _files: Nullable<string[]>;
  32855. /** @hidden */
  32856. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32857. /** @hidden */
  32858. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32859. /** @hidden */
  32860. _framebuffer: Nullable<WebGLFramebuffer>;
  32861. /** @hidden */
  32862. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32863. /** @hidden */
  32864. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32865. /** @hidden */
  32866. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32867. /** @hidden */
  32868. _attachments: Nullable<number[]>;
  32869. /** @hidden */
  32870. _cachedCoordinatesMode: Nullable<number>;
  32871. /** @hidden */
  32872. _cachedWrapU: Nullable<number>;
  32873. /** @hidden */
  32874. _cachedWrapV: Nullable<number>;
  32875. /** @hidden */
  32876. _cachedWrapR: Nullable<number>;
  32877. /** @hidden */
  32878. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32879. /** @hidden */
  32880. _isDisabled: boolean;
  32881. /** @hidden */
  32882. _compression: Nullable<string>;
  32883. /** @hidden */
  32884. _generateStencilBuffer: boolean;
  32885. /** @hidden */
  32886. _generateDepthBuffer: boolean;
  32887. /** @hidden */
  32888. _comparisonFunction: number;
  32889. /** @hidden */
  32890. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32891. /** @hidden */
  32892. _lodGenerationScale: number;
  32893. /** @hidden */
  32894. _lodGenerationOffset: number;
  32895. /** @hidden */
  32896. _depthStencilTexture: Nullable<InternalTexture>;
  32897. /** @hidden */
  32898. _colorTextureArray: Nullable<WebGLTexture>;
  32899. /** @hidden */
  32900. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32901. /** @hidden */
  32902. _lodTextureHigh: Nullable<BaseTexture>;
  32903. /** @hidden */
  32904. _lodTextureMid: Nullable<BaseTexture>;
  32905. /** @hidden */
  32906. _lodTextureLow: Nullable<BaseTexture>;
  32907. /** @hidden */
  32908. _isRGBD: boolean;
  32909. /** @hidden */
  32910. _linearSpecularLOD: boolean;
  32911. /** @hidden */
  32912. _irradianceTexture: Nullable<BaseTexture>;
  32913. /** @hidden */
  32914. _webGLTexture: Nullable<WebGLTexture>;
  32915. /** @hidden */
  32916. _references: number;
  32917. private _engine;
  32918. /**
  32919. * Gets the Engine the texture belongs to.
  32920. * @returns The babylon engine
  32921. */
  32922. getEngine(): ThinEngine;
  32923. /**
  32924. * Gets the data source type of the texture
  32925. */
  32926. get source(): InternalTextureSource;
  32927. /**
  32928. * Creates a new InternalTexture
  32929. * @param engine defines the engine to use
  32930. * @param source defines the type of data that will be used
  32931. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32932. */
  32933. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32934. /**
  32935. * Increments the number of references (ie. the number of Texture that point to it)
  32936. */
  32937. incrementReferences(): void;
  32938. /**
  32939. * Change the size of the texture (not the size of the content)
  32940. * @param width defines the new width
  32941. * @param height defines the new height
  32942. * @param depth defines the new depth (1 by default)
  32943. */
  32944. updateSize(width: int, height: int, depth?: int): void;
  32945. /** @hidden */
  32946. _rebuild(): void;
  32947. /** @hidden */
  32948. _swapAndDie(target: InternalTexture): void;
  32949. /**
  32950. * Dispose the current allocated resources
  32951. */
  32952. dispose(): void;
  32953. }
  32954. }
  32955. declare module BABYLON {
  32956. /**
  32957. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32959. */
  32960. export class Analyser {
  32961. /**
  32962. * Gets or sets the smoothing
  32963. * @ignorenaming
  32964. */
  32965. SMOOTHING: number;
  32966. /**
  32967. * Gets or sets the FFT table size
  32968. * @ignorenaming
  32969. */
  32970. FFT_SIZE: number;
  32971. /**
  32972. * Gets or sets the bar graph amplitude
  32973. * @ignorenaming
  32974. */
  32975. BARGRAPHAMPLITUDE: number;
  32976. /**
  32977. * Gets or sets the position of the debug canvas
  32978. * @ignorenaming
  32979. */
  32980. DEBUGCANVASPOS: {
  32981. x: number;
  32982. y: number;
  32983. };
  32984. /**
  32985. * Gets or sets the debug canvas size
  32986. * @ignorenaming
  32987. */
  32988. DEBUGCANVASSIZE: {
  32989. width: number;
  32990. height: number;
  32991. };
  32992. private _byteFreqs;
  32993. private _byteTime;
  32994. private _floatFreqs;
  32995. private _webAudioAnalyser;
  32996. private _debugCanvas;
  32997. private _debugCanvasContext;
  32998. private _scene;
  32999. private _registerFunc;
  33000. private _audioEngine;
  33001. /**
  33002. * Creates a new analyser
  33003. * @param scene defines hosting scene
  33004. */
  33005. constructor(scene: Scene);
  33006. /**
  33007. * Get the number of data values you will have to play with for the visualization
  33008. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33009. * @returns a number
  33010. */
  33011. getFrequencyBinCount(): number;
  33012. /**
  33013. * Gets the current frequency data as a byte array
  33014. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33015. * @returns a Uint8Array
  33016. */
  33017. getByteFrequencyData(): Uint8Array;
  33018. /**
  33019. * Gets the current waveform as a byte array
  33020. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33021. * @returns a Uint8Array
  33022. */
  33023. getByteTimeDomainData(): Uint8Array;
  33024. /**
  33025. * Gets the current frequency data as a float array
  33026. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33027. * @returns a Float32Array
  33028. */
  33029. getFloatFrequencyData(): Float32Array;
  33030. /**
  33031. * Renders the debug canvas
  33032. */
  33033. drawDebugCanvas(): void;
  33034. /**
  33035. * Stops rendering the debug canvas and removes it
  33036. */
  33037. stopDebugCanvas(): void;
  33038. /**
  33039. * Connects two audio nodes
  33040. * @param inputAudioNode defines first node to connect
  33041. * @param outputAudioNode defines second node to connect
  33042. */
  33043. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33044. /**
  33045. * Releases all associated resources
  33046. */
  33047. dispose(): void;
  33048. }
  33049. }
  33050. declare module BABYLON {
  33051. /**
  33052. * This represents an audio engine and it is responsible
  33053. * to play, synchronize and analyse sounds throughout the application.
  33054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33055. */
  33056. export interface IAudioEngine extends IDisposable {
  33057. /**
  33058. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33059. */
  33060. readonly canUseWebAudio: boolean;
  33061. /**
  33062. * Gets the current AudioContext if available.
  33063. */
  33064. readonly audioContext: Nullable<AudioContext>;
  33065. /**
  33066. * The master gain node defines the global audio volume of your audio engine.
  33067. */
  33068. readonly masterGain: GainNode;
  33069. /**
  33070. * Gets whether or not mp3 are supported by your browser.
  33071. */
  33072. readonly isMP3supported: boolean;
  33073. /**
  33074. * Gets whether or not ogg are supported by your browser.
  33075. */
  33076. readonly isOGGsupported: boolean;
  33077. /**
  33078. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33079. * @ignoreNaming
  33080. */
  33081. WarnedWebAudioUnsupported: boolean;
  33082. /**
  33083. * Defines if the audio engine relies on a custom unlocked button.
  33084. * In this case, the embedded button will not be displayed.
  33085. */
  33086. useCustomUnlockedButton: boolean;
  33087. /**
  33088. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33089. */
  33090. readonly unlocked: boolean;
  33091. /**
  33092. * Event raised when audio has been unlocked on the browser.
  33093. */
  33094. onAudioUnlockedObservable: Observable<AudioEngine>;
  33095. /**
  33096. * Event raised when audio has been locked on the browser.
  33097. */
  33098. onAudioLockedObservable: Observable<AudioEngine>;
  33099. /**
  33100. * Flags the audio engine in Locked state.
  33101. * This happens due to new browser policies preventing audio to autoplay.
  33102. */
  33103. lock(): void;
  33104. /**
  33105. * Unlocks the audio engine once a user action has been done on the dom.
  33106. * This is helpful to resume play once browser policies have been satisfied.
  33107. */
  33108. unlock(): void;
  33109. /**
  33110. * Gets the global volume sets on the master gain.
  33111. * @returns the global volume if set or -1 otherwise
  33112. */
  33113. getGlobalVolume(): number;
  33114. /**
  33115. * Sets the global volume of your experience (sets on the master gain).
  33116. * @param newVolume Defines the new global volume of the application
  33117. */
  33118. setGlobalVolume(newVolume: number): void;
  33119. /**
  33120. * Connect the audio engine to an audio analyser allowing some amazing
  33121. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33123. * @param analyser The analyser to connect to the engine
  33124. */
  33125. connectToAnalyser(analyser: Analyser): void;
  33126. }
  33127. /**
  33128. * This represents the default audio engine used in babylon.
  33129. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33131. */
  33132. export class AudioEngine implements IAudioEngine {
  33133. private _audioContext;
  33134. private _audioContextInitialized;
  33135. private _muteButton;
  33136. private _hostElement;
  33137. /**
  33138. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33139. */
  33140. canUseWebAudio: boolean;
  33141. /**
  33142. * The master gain node defines the global audio volume of your audio engine.
  33143. */
  33144. masterGain: GainNode;
  33145. /**
  33146. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33147. * @ignoreNaming
  33148. */
  33149. WarnedWebAudioUnsupported: boolean;
  33150. /**
  33151. * Gets whether or not mp3 are supported by your browser.
  33152. */
  33153. isMP3supported: boolean;
  33154. /**
  33155. * Gets whether or not ogg are supported by your browser.
  33156. */
  33157. isOGGsupported: boolean;
  33158. /**
  33159. * Gets whether audio has been unlocked on the device.
  33160. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33161. * a user interaction has happened.
  33162. */
  33163. unlocked: boolean;
  33164. /**
  33165. * Defines if the audio engine relies on a custom unlocked button.
  33166. * In this case, the embedded button will not be displayed.
  33167. */
  33168. useCustomUnlockedButton: boolean;
  33169. /**
  33170. * Event raised when audio has been unlocked on the browser.
  33171. */
  33172. onAudioUnlockedObservable: Observable<AudioEngine>;
  33173. /**
  33174. * Event raised when audio has been locked on the browser.
  33175. */
  33176. onAudioLockedObservable: Observable<AudioEngine>;
  33177. /**
  33178. * Gets the current AudioContext if available.
  33179. */
  33180. get audioContext(): Nullable<AudioContext>;
  33181. private _connectedAnalyser;
  33182. /**
  33183. * Instantiates a new audio engine.
  33184. *
  33185. * There should be only one per page as some browsers restrict the number
  33186. * of audio contexts you can create.
  33187. * @param hostElement defines the host element where to display the mute icon if necessary
  33188. */
  33189. constructor(hostElement?: Nullable<HTMLElement>);
  33190. /**
  33191. * Flags the audio engine in Locked state.
  33192. * This happens due to new browser policies preventing audio to autoplay.
  33193. */
  33194. lock(): void;
  33195. /**
  33196. * Unlocks the audio engine once a user action has been done on the dom.
  33197. * This is helpful to resume play once browser policies have been satisfied.
  33198. */
  33199. unlock(): void;
  33200. private _resumeAudioContext;
  33201. private _initializeAudioContext;
  33202. private _tryToRun;
  33203. private _triggerRunningState;
  33204. private _triggerSuspendedState;
  33205. private _displayMuteButton;
  33206. private _moveButtonToTopLeft;
  33207. private _onResize;
  33208. private _hideMuteButton;
  33209. /**
  33210. * Destroy and release the resources associated with the audio ccontext.
  33211. */
  33212. dispose(): void;
  33213. /**
  33214. * Gets the global volume sets on the master gain.
  33215. * @returns the global volume if set or -1 otherwise
  33216. */
  33217. getGlobalVolume(): number;
  33218. /**
  33219. * Sets the global volume of your experience (sets on the master gain).
  33220. * @param newVolume Defines the new global volume of the application
  33221. */
  33222. setGlobalVolume(newVolume: number): void;
  33223. /**
  33224. * Connect the audio engine to an audio analyser allowing some amazing
  33225. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33227. * @param analyser The analyser to connect to the engine
  33228. */
  33229. connectToAnalyser(analyser: Analyser): void;
  33230. }
  33231. }
  33232. declare module BABYLON {
  33233. /**
  33234. * Interface used to present a loading screen while loading a scene
  33235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33236. */
  33237. export interface ILoadingScreen {
  33238. /**
  33239. * Function called to display the loading screen
  33240. */
  33241. displayLoadingUI: () => void;
  33242. /**
  33243. * Function called to hide the loading screen
  33244. */
  33245. hideLoadingUI: () => void;
  33246. /**
  33247. * Gets or sets the color to use for the background
  33248. */
  33249. loadingUIBackgroundColor: string;
  33250. /**
  33251. * Gets or sets the text to display while loading
  33252. */
  33253. loadingUIText: string;
  33254. }
  33255. /**
  33256. * Class used for the default loading screen
  33257. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33258. */
  33259. export class DefaultLoadingScreen implements ILoadingScreen {
  33260. private _renderingCanvas;
  33261. private _loadingText;
  33262. private _loadingDivBackgroundColor;
  33263. private _loadingDiv;
  33264. private _loadingTextDiv;
  33265. /** Gets or sets the logo url to use for the default loading screen */
  33266. static DefaultLogoUrl: string;
  33267. /** Gets or sets the spinner url to use for the default loading screen */
  33268. static DefaultSpinnerUrl: string;
  33269. /**
  33270. * Creates a new default loading screen
  33271. * @param _renderingCanvas defines the canvas used to render the scene
  33272. * @param _loadingText defines the default text to display
  33273. * @param _loadingDivBackgroundColor defines the default background color
  33274. */
  33275. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33276. /**
  33277. * Function called to display the loading screen
  33278. */
  33279. displayLoadingUI(): void;
  33280. /**
  33281. * Function called to hide the loading screen
  33282. */
  33283. hideLoadingUI(): void;
  33284. /**
  33285. * Gets or sets the text to display while loading
  33286. */
  33287. set loadingUIText(text: string);
  33288. get loadingUIText(): string;
  33289. /**
  33290. * Gets or sets the color to use for the background
  33291. */
  33292. get loadingUIBackgroundColor(): string;
  33293. set loadingUIBackgroundColor(color: string);
  33294. private _resizeLoadingUI;
  33295. }
  33296. }
  33297. declare module BABYLON {
  33298. /**
  33299. * Interface for any object that can request an animation frame
  33300. */
  33301. export interface ICustomAnimationFrameRequester {
  33302. /**
  33303. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33304. */
  33305. renderFunction?: Function;
  33306. /**
  33307. * Called to request the next frame to render to
  33308. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33309. */
  33310. requestAnimationFrame: Function;
  33311. /**
  33312. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33313. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33314. */
  33315. requestID?: number;
  33316. }
  33317. }
  33318. declare module BABYLON {
  33319. /**
  33320. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33321. */
  33322. export class PerformanceMonitor {
  33323. private _enabled;
  33324. private _rollingFrameTime;
  33325. private _lastFrameTimeMs;
  33326. /**
  33327. * constructor
  33328. * @param frameSampleSize The number of samples required to saturate the sliding window
  33329. */
  33330. constructor(frameSampleSize?: number);
  33331. /**
  33332. * Samples current frame
  33333. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33334. */
  33335. sampleFrame(timeMs?: number): void;
  33336. /**
  33337. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33338. */
  33339. get averageFrameTime(): number;
  33340. /**
  33341. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33342. */
  33343. get averageFrameTimeVariance(): number;
  33344. /**
  33345. * Returns the frame time of the most recent frame
  33346. */
  33347. get instantaneousFrameTime(): number;
  33348. /**
  33349. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33350. */
  33351. get averageFPS(): number;
  33352. /**
  33353. * Returns the average framerate in frames per second using the most recent frame time
  33354. */
  33355. get instantaneousFPS(): number;
  33356. /**
  33357. * Returns true if enough samples have been taken to completely fill the sliding window
  33358. */
  33359. get isSaturated(): boolean;
  33360. /**
  33361. * Enables contributions to the sliding window sample set
  33362. */
  33363. enable(): void;
  33364. /**
  33365. * Disables contributions to the sliding window sample set
  33366. * Samples will not be interpolated over the disabled period
  33367. */
  33368. disable(): void;
  33369. /**
  33370. * Returns true if sampling is enabled
  33371. */
  33372. get isEnabled(): boolean;
  33373. /**
  33374. * Resets performance monitor
  33375. */
  33376. reset(): void;
  33377. }
  33378. /**
  33379. * RollingAverage
  33380. *
  33381. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33382. */
  33383. export class RollingAverage {
  33384. /**
  33385. * Current average
  33386. */
  33387. average: number;
  33388. /**
  33389. * Current variance
  33390. */
  33391. variance: number;
  33392. protected _samples: Array<number>;
  33393. protected _sampleCount: number;
  33394. protected _pos: number;
  33395. protected _m2: number;
  33396. /**
  33397. * constructor
  33398. * @param length The number of samples required to saturate the sliding window
  33399. */
  33400. constructor(length: number);
  33401. /**
  33402. * Adds a sample to the sample set
  33403. * @param v The sample value
  33404. */
  33405. add(v: number): void;
  33406. /**
  33407. * Returns previously added values or null if outside of history or outside the sliding window domain
  33408. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33409. * @return Value previously recorded with add() or null if outside of range
  33410. */
  33411. history(i: number): number;
  33412. /**
  33413. * Returns true if enough samples have been taken to completely fill the sliding window
  33414. * @return true if sample-set saturated
  33415. */
  33416. isSaturated(): boolean;
  33417. /**
  33418. * Resets the rolling average (equivalent to 0 samples taken so far)
  33419. */
  33420. reset(): void;
  33421. /**
  33422. * Wraps a value around the sample range boundaries
  33423. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33424. * @return Wrapped position in sample range
  33425. */
  33426. protected _wrapPosition(i: number): number;
  33427. }
  33428. }
  33429. declare module BABYLON {
  33430. /**
  33431. * This class is used to track a performance counter which is number based.
  33432. * The user has access to many properties which give statistics of different nature.
  33433. *
  33434. * The implementer can track two kinds of Performance Counter: time and count.
  33435. * 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.
  33436. * 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.
  33437. */
  33438. export class PerfCounter {
  33439. /**
  33440. * Gets or sets a global boolean to turn on and off all the counters
  33441. */
  33442. static Enabled: boolean;
  33443. /**
  33444. * Returns the smallest value ever
  33445. */
  33446. get min(): number;
  33447. /**
  33448. * Returns the biggest value ever
  33449. */
  33450. get max(): number;
  33451. /**
  33452. * Returns the average value since the performance counter is running
  33453. */
  33454. get average(): number;
  33455. /**
  33456. * Returns the average value of the last second the counter was monitored
  33457. */
  33458. get lastSecAverage(): number;
  33459. /**
  33460. * Returns the current value
  33461. */
  33462. get current(): number;
  33463. /**
  33464. * Gets the accumulated total
  33465. */
  33466. get total(): number;
  33467. /**
  33468. * Gets the total value count
  33469. */
  33470. get count(): number;
  33471. /**
  33472. * Creates a new counter
  33473. */
  33474. constructor();
  33475. /**
  33476. * Call this method to start monitoring a new frame.
  33477. * 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.
  33478. */
  33479. fetchNewFrame(): void;
  33480. /**
  33481. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33482. * @param newCount the count value to add to the monitored count
  33483. * @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.
  33484. */
  33485. addCount(newCount: number, fetchResult: boolean): void;
  33486. /**
  33487. * Start monitoring this performance counter
  33488. */
  33489. beginMonitoring(): void;
  33490. /**
  33491. * Compute the time lapsed since the previous beginMonitoring() call.
  33492. * @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
  33493. */
  33494. endMonitoring(newFrame?: boolean): void;
  33495. private _fetchResult;
  33496. private _startMonitoringTime;
  33497. private _min;
  33498. private _max;
  33499. private _average;
  33500. private _current;
  33501. private _totalValueCount;
  33502. private _totalAccumulated;
  33503. private _lastSecAverage;
  33504. private _lastSecAccumulated;
  33505. private _lastSecTime;
  33506. private _lastSecValueCount;
  33507. }
  33508. }
  33509. declare module BABYLON {
  33510. interface ThinEngine {
  33511. /**
  33512. * Sets alpha constants used by some alpha blending modes
  33513. * @param r defines the red component
  33514. * @param g defines the green component
  33515. * @param b defines the blue component
  33516. * @param a defines the alpha component
  33517. */
  33518. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33519. /**
  33520. * Sets the current alpha mode
  33521. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33522. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33523. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33524. */
  33525. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33526. /**
  33527. * Gets the current alpha mode
  33528. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33529. * @returns the current alpha mode
  33530. */
  33531. getAlphaMode(): number;
  33532. /**
  33533. * Sets the current alpha equation
  33534. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33535. */
  33536. setAlphaEquation(equation: number): void;
  33537. /**
  33538. * Gets the current alpha equation.
  33539. * @returns the current alpha equation
  33540. */
  33541. getAlphaEquation(): number;
  33542. }
  33543. }
  33544. declare module BABYLON {
  33545. /**
  33546. * Defines the interface used by display changed events
  33547. */
  33548. export interface IDisplayChangedEventArgs {
  33549. /** Gets the vrDisplay object (if any) */
  33550. vrDisplay: Nullable<any>;
  33551. /** Gets a boolean indicating if webVR is supported */
  33552. vrSupported: boolean;
  33553. }
  33554. /**
  33555. * Defines the interface used by objects containing a viewport (like a camera)
  33556. */
  33557. interface IViewportOwnerLike {
  33558. /**
  33559. * Gets or sets the viewport
  33560. */
  33561. viewport: IViewportLike;
  33562. }
  33563. /**
  33564. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33565. */
  33566. export class Engine extends ThinEngine {
  33567. /** Defines that alpha blending is disabled */
  33568. static readonly ALPHA_DISABLE: number;
  33569. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33570. static readonly ALPHA_ADD: number;
  33571. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33572. static readonly ALPHA_COMBINE: number;
  33573. /** Defines that alpha blending to DEST - SRC * DEST */
  33574. static readonly ALPHA_SUBTRACT: number;
  33575. /** Defines that alpha blending to SRC * DEST */
  33576. static readonly ALPHA_MULTIPLY: number;
  33577. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33578. static readonly ALPHA_MAXIMIZED: number;
  33579. /** Defines that alpha blending to SRC + DEST */
  33580. static readonly ALPHA_ONEONE: number;
  33581. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33582. static readonly ALPHA_PREMULTIPLIED: number;
  33583. /**
  33584. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33585. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33586. */
  33587. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33588. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33589. static readonly ALPHA_INTERPOLATE: number;
  33590. /**
  33591. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33592. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33593. */
  33594. static readonly ALPHA_SCREENMODE: number;
  33595. /** Defines that the ressource is not delayed*/
  33596. static readonly DELAYLOADSTATE_NONE: number;
  33597. /** Defines that the ressource was successfully delay loaded */
  33598. static readonly DELAYLOADSTATE_LOADED: number;
  33599. /** Defines that the ressource is currently delay loading */
  33600. static readonly DELAYLOADSTATE_LOADING: number;
  33601. /** Defines that the ressource is delayed and has not started loading */
  33602. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33603. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33604. static readonly NEVER: number;
  33605. /** 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 */
  33606. static readonly ALWAYS: number;
  33607. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33608. static readonly LESS: number;
  33609. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33610. static readonly EQUAL: number;
  33611. /** 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 */
  33612. static readonly LEQUAL: number;
  33613. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33614. static readonly GREATER: number;
  33615. /** 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 */
  33616. static readonly GEQUAL: number;
  33617. /** 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 */
  33618. static readonly NOTEQUAL: number;
  33619. /** Passed to stencilOperation to specify that stencil value must be kept */
  33620. static readonly KEEP: number;
  33621. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33622. static readonly REPLACE: number;
  33623. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33624. static readonly INCR: number;
  33625. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33626. static readonly DECR: number;
  33627. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33628. static readonly INVERT: number;
  33629. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33630. static readonly INCR_WRAP: number;
  33631. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33632. static readonly DECR_WRAP: number;
  33633. /** Texture is not repeating outside of 0..1 UVs */
  33634. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33635. /** Texture is repeating outside of 0..1 UVs */
  33636. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33637. /** Texture is repeating and mirrored */
  33638. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33639. /** ALPHA */
  33640. static readonly TEXTUREFORMAT_ALPHA: number;
  33641. /** LUMINANCE */
  33642. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33643. /** LUMINANCE_ALPHA */
  33644. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33645. /** RGB */
  33646. static readonly TEXTUREFORMAT_RGB: number;
  33647. /** RGBA */
  33648. static readonly TEXTUREFORMAT_RGBA: number;
  33649. /** RED */
  33650. static readonly TEXTUREFORMAT_RED: number;
  33651. /** RED (2nd reference) */
  33652. static readonly TEXTUREFORMAT_R: number;
  33653. /** RG */
  33654. static readonly TEXTUREFORMAT_RG: number;
  33655. /** RED_INTEGER */
  33656. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33657. /** RED_INTEGER (2nd reference) */
  33658. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33659. /** RG_INTEGER */
  33660. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33661. /** RGB_INTEGER */
  33662. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33663. /** RGBA_INTEGER */
  33664. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33665. /** UNSIGNED_BYTE */
  33666. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33667. /** UNSIGNED_BYTE (2nd reference) */
  33668. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33669. /** FLOAT */
  33670. static readonly TEXTURETYPE_FLOAT: number;
  33671. /** HALF_FLOAT */
  33672. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33673. /** BYTE */
  33674. static readonly TEXTURETYPE_BYTE: number;
  33675. /** SHORT */
  33676. static readonly TEXTURETYPE_SHORT: number;
  33677. /** UNSIGNED_SHORT */
  33678. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33679. /** INT */
  33680. static readonly TEXTURETYPE_INT: number;
  33681. /** UNSIGNED_INT */
  33682. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33683. /** UNSIGNED_SHORT_4_4_4_4 */
  33684. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33685. /** UNSIGNED_SHORT_5_5_5_1 */
  33686. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33687. /** UNSIGNED_SHORT_5_6_5 */
  33688. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33689. /** UNSIGNED_INT_2_10_10_10_REV */
  33690. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33691. /** UNSIGNED_INT_24_8 */
  33692. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33693. /** UNSIGNED_INT_10F_11F_11F_REV */
  33694. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33695. /** UNSIGNED_INT_5_9_9_9_REV */
  33696. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33697. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33698. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33699. /** nearest is mag = nearest and min = nearest and mip = linear */
  33700. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33701. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33702. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33703. /** Trilinear is mag = linear and min = linear and mip = linear */
  33704. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33705. /** nearest is mag = nearest and min = nearest and mip = linear */
  33706. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33707. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33708. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33709. /** Trilinear is mag = linear and min = linear and mip = linear */
  33710. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33711. /** mag = nearest and min = nearest and mip = nearest */
  33712. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33713. /** mag = nearest and min = linear and mip = nearest */
  33714. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33715. /** mag = nearest and min = linear and mip = linear */
  33716. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33717. /** mag = nearest and min = linear and mip = none */
  33718. static readonly TEXTURE_NEAREST_LINEAR: number;
  33719. /** mag = nearest and min = nearest and mip = none */
  33720. static readonly TEXTURE_NEAREST_NEAREST: number;
  33721. /** mag = linear and min = nearest and mip = nearest */
  33722. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33723. /** mag = linear and min = nearest and mip = linear */
  33724. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33725. /** mag = linear and min = linear and mip = none */
  33726. static readonly TEXTURE_LINEAR_LINEAR: number;
  33727. /** mag = linear and min = nearest and mip = none */
  33728. static readonly TEXTURE_LINEAR_NEAREST: number;
  33729. /** Explicit coordinates mode */
  33730. static readonly TEXTURE_EXPLICIT_MODE: number;
  33731. /** Spherical coordinates mode */
  33732. static readonly TEXTURE_SPHERICAL_MODE: number;
  33733. /** Planar coordinates mode */
  33734. static readonly TEXTURE_PLANAR_MODE: number;
  33735. /** Cubic coordinates mode */
  33736. static readonly TEXTURE_CUBIC_MODE: number;
  33737. /** Projection coordinates mode */
  33738. static readonly TEXTURE_PROJECTION_MODE: number;
  33739. /** Skybox coordinates mode */
  33740. static readonly TEXTURE_SKYBOX_MODE: number;
  33741. /** Inverse Cubic coordinates mode */
  33742. static readonly TEXTURE_INVCUBIC_MODE: number;
  33743. /** Equirectangular coordinates mode */
  33744. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33745. /** Equirectangular Fixed coordinates mode */
  33746. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33747. /** Equirectangular Fixed Mirrored coordinates mode */
  33748. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33749. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33750. static readonly SCALEMODE_FLOOR: number;
  33751. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33752. static readonly SCALEMODE_NEAREST: number;
  33753. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33754. static readonly SCALEMODE_CEILING: number;
  33755. /**
  33756. * Returns the current npm package of the sdk
  33757. */
  33758. static get NpmPackage(): string;
  33759. /**
  33760. * Returns the current version of the framework
  33761. */
  33762. static get Version(): string;
  33763. /** Gets the list of created engines */
  33764. static get Instances(): Engine[];
  33765. /**
  33766. * Gets the latest created engine
  33767. */
  33768. static get LastCreatedEngine(): Nullable<Engine>;
  33769. /**
  33770. * Gets the latest created scene
  33771. */
  33772. static get LastCreatedScene(): Nullable<Scene>;
  33773. /**
  33774. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33775. * @param flag defines which part of the materials must be marked as dirty
  33776. * @param predicate defines a predicate used to filter which materials should be affected
  33777. */
  33778. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33779. /**
  33780. * Method called to create the default loading screen.
  33781. * This can be overriden in your own app.
  33782. * @param canvas The rendering canvas element
  33783. * @returns The loading screen
  33784. */
  33785. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33786. /**
  33787. * Method called to create the default rescale post process on each engine.
  33788. */
  33789. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33790. /**
  33791. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33792. **/
  33793. enableOfflineSupport: boolean;
  33794. /**
  33795. * 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)
  33796. **/
  33797. disableManifestCheck: boolean;
  33798. /**
  33799. * Gets the list of created scenes
  33800. */
  33801. scenes: Scene[];
  33802. /**
  33803. * Event raised when a new scene is created
  33804. */
  33805. onNewSceneAddedObservable: Observable<Scene>;
  33806. /**
  33807. * Gets the list of created postprocesses
  33808. */
  33809. postProcesses: PostProcess[];
  33810. /**
  33811. * Gets a boolean indicating if the pointer is currently locked
  33812. */
  33813. isPointerLock: boolean;
  33814. /**
  33815. * Observable event triggered each time the rendering canvas is resized
  33816. */
  33817. onResizeObservable: Observable<Engine>;
  33818. /**
  33819. * Observable event triggered each time the canvas loses focus
  33820. */
  33821. onCanvasBlurObservable: Observable<Engine>;
  33822. /**
  33823. * Observable event triggered each time the canvas gains focus
  33824. */
  33825. onCanvasFocusObservable: Observable<Engine>;
  33826. /**
  33827. * Observable event triggered each time the canvas receives pointerout event
  33828. */
  33829. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33830. /**
  33831. * Observable raised when the engine begins a new frame
  33832. */
  33833. onBeginFrameObservable: Observable<Engine>;
  33834. /**
  33835. * If set, will be used to request the next animation frame for the render loop
  33836. */
  33837. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33838. /**
  33839. * Observable raised when the engine ends the current frame
  33840. */
  33841. onEndFrameObservable: Observable<Engine>;
  33842. /**
  33843. * Observable raised when the engine is about to compile a shader
  33844. */
  33845. onBeforeShaderCompilationObservable: Observable<Engine>;
  33846. /**
  33847. * Observable raised when the engine has jsut compiled a shader
  33848. */
  33849. onAfterShaderCompilationObservable: Observable<Engine>;
  33850. /**
  33851. * Gets the audio engine
  33852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33853. * @ignorenaming
  33854. */
  33855. static audioEngine: IAudioEngine;
  33856. /**
  33857. * Default AudioEngine factory responsible of creating the Audio Engine.
  33858. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33859. */
  33860. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33861. /**
  33862. * Default offline support factory responsible of creating a tool used to store data locally.
  33863. * By default, this will create a Database object if the workload has been embedded.
  33864. */
  33865. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33866. private _loadingScreen;
  33867. private _pointerLockRequested;
  33868. private _dummyFramebuffer;
  33869. private _rescalePostProcess;
  33870. private _deterministicLockstep;
  33871. private _lockstepMaxSteps;
  33872. private _timeStep;
  33873. protected get _supportsHardwareTextureRescaling(): boolean;
  33874. private _fps;
  33875. private _deltaTime;
  33876. /** @hidden */
  33877. _drawCalls: PerfCounter;
  33878. /** 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 */
  33879. canvasTabIndex: number;
  33880. /**
  33881. * Turn this value on if you want to pause FPS computation when in background
  33882. */
  33883. disablePerformanceMonitorInBackground: boolean;
  33884. private _performanceMonitor;
  33885. /**
  33886. * Gets the performance monitor attached to this engine
  33887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33888. */
  33889. get performanceMonitor(): PerformanceMonitor;
  33890. private _onFocus;
  33891. private _onBlur;
  33892. private _onCanvasPointerOut;
  33893. private _onCanvasBlur;
  33894. private _onCanvasFocus;
  33895. private _onFullscreenChange;
  33896. private _onPointerLockChange;
  33897. /**
  33898. * Gets the HTML element used to attach event listeners
  33899. * @returns a HTML element
  33900. */
  33901. getInputElement(): Nullable<HTMLElement>;
  33902. /**
  33903. * Creates a new engine
  33904. * @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
  33905. * @param antialias defines enable antialiasing (default: false)
  33906. * @param options defines further options to be sent to the getContext() function
  33907. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33908. */
  33909. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33910. /**
  33911. * Gets current aspect ratio
  33912. * @param viewportOwner defines the camera to use to get the aspect ratio
  33913. * @param useScreen defines if screen size must be used (or the current render target if any)
  33914. * @returns a number defining the aspect ratio
  33915. */
  33916. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33917. /**
  33918. * Gets current screen aspect ratio
  33919. * @returns a number defining the aspect ratio
  33920. */
  33921. getScreenAspectRatio(): number;
  33922. /**
  33923. * Gets the client rect of the HTML canvas attached with the current webGL context
  33924. * @returns a client rectanglee
  33925. */
  33926. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33927. /**
  33928. * Gets the client rect of the HTML element used for events
  33929. * @returns a client rectanglee
  33930. */
  33931. getInputElementClientRect(): Nullable<ClientRect>;
  33932. /**
  33933. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33934. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33935. * @returns true if engine is in deterministic lock step mode
  33936. */
  33937. isDeterministicLockStep(): boolean;
  33938. /**
  33939. * Gets the max steps when engine is running in deterministic lock step
  33940. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33941. * @returns the max steps
  33942. */
  33943. getLockstepMaxSteps(): number;
  33944. /**
  33945. * Returns the time in ms between steps when using deterministic lock step.
  33946. * @returns time step in (ms)
  33947. */
  33948. getTimeStep(): number;
  33949. /**
  33950. * Force the mipmap generation for the given render target texture
  33951. * @param texture defines the render target texture to use
  33952. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33953. */
  33954. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33955. /** States */
  33956. /**
  33957. * Set various states to the webGL context
  33958. * @param culling defines backface culling state
  33959. * @param zOffset defines the value to apply to zOffset (0 by default)
  33960. * @param force defines if states must be applied even if cache is up to date
  33961. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33962. */
  33963. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33964. /**
  33965. * Set the z offset to apply to current rendering
  33966. * @param value defines the offset to apply
  33967. */
  33968. setZOffset(value: number): void;
  33969. /**
  33970. * Gets the current value of the zOffset
  33971. * @returns the current zOffset state
  33972. */
  33973. getZOffset(): number;
  33974. /**
  33975. * Enable or disable depth buffering
  33976. * @param enable defines the state to set
  33977. */
  33978. setDepthBuffer(enable: boolean): void;
  33979. /**
  33980. * Gets a boolean indicating if depth writing is enabled
  33981. * @returns the current depth writing state
  33982. */
  33983. getDepthWrite(): boolean;
  33984. /**
  33985. * Enable or disable depth writing
  33986. * @param enable defines the state to set
  33987. */
  33988. setDepthWrite(enable: boolean): void;
  33989. /**
  33990. * Gets a boolean indicating if stencil buffer is enabled
  33991. * @returns the current stencil buffer state
  33992. */
  33993. getStencilBuffer(): boolean;
  33994. /**
  33995. * Enable or disable the stencil buffer
  33996. * @param enable defines if the stencil buffer must be enabled or disabled
  33997. */
  33998. setStencilBuffer(enable: boolean): void;
  33999. /**
  34000. * Gets the current stencil mask
  34001. * @returns a number defining the new stencil mask to use
  34002. */
  34003. getStencilMask(): number;
  34004. /**
  34005. * Sets the current stencil mask
  34006. * @param mask defines the new stencil mask to use
  34007. */
  34008. setStencilMask(mask: number): void;
  34009. /**
  34010. * Gets the current stencil function
  34011. * @returns a number defining the stencil function to use
  34012. */
  34013. getStencilFunction(): number;
  34014. /**
  34015. * Gets the current stencil reference value
  34016. * @returns a number defining the stencil reference value to use
  34017. */
  34018. getStencilFunctionReference(): number;
  34019. /**
  34020. * Gets the current stencil mask
  34021. * @returns a number defining the stencil mask to use
  34022. */
  34023. getStencilFunctionMask(): number;
  34024. /**
  34025. * Sets the current stencil function
  34026. * @param stencilFunc defines the new stencil function to use
  34027. */
  34028. setStencilFunction(stencilFunc: number): void;
  34029. /**
  34030. * Sets the current stencil reference
  34031. * @param reference defines the new stencil reference to use
  34032. */
  34033. setStencilFunctionReference(reference: number): void;
  34034. /**
  34035. * Sets the current stencil mask
  34036. * @param mask defines the new stencil mask to use
  34037. */
  34038. setStencilFunctionMask(mask: number): void;
  34039. /**
  34040. * Gets the current stencil operation when stencil fails
  34041. * @returns a number defining stencil operation to use when stencil fails
  34042. */
  34043. getStencilOperationFail(): number;
  34044. /**
  34045. * Gets the current stencil operation when depth fails
  34046. * @returns a number defining stencil operation to use when depth fails
  34047. */
  34048. getStencilOperationDepthFail(): number;
  34049. /**
  34050. * Gets the current stencil operation when stencil passes
  34051. * @returns a number defining stencil operation to use when stencil passes
  34052. */
  34053. getStencilOperationPass(): number;
  34054. /**
  34055. * Sets the stencil operation to use when stencil fails
  34056. * @param operation defines the stencil operation to use when stencil fails
  34057. */
  34058. setStencilOperationFail(operation: number): void;
  34059. /**
  34060. * Sets the stencil operation to use when depth fails
  34061. * @param operation defines the stencil operation to use when depth fails
  34062. */
  34063. setStencilOperationDepthFail(operation: number): void;
  34064. /**
  34065. * Sets the stencil operation to use when stencil passes
  34066. * @param operation defines the stencil operation to use when stencil passes
  34067. */
  34068. setStencilOperationPass(operation: number): void;
  34069. /**
  34070. * Sets a boolean indicating if the dithering state is enabled or disabled
  34071. * @param value defines the dithering state
  34072. */
  34073. setDitheringState(value: boolean): void;
  34074. /**
  34075. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34076. * @param value defines the rasterizer state
  34077. */
  34078. setRasterizerState(value: boolean): void;
  34079. /**
  34080. * Gets the current depth function
  34081. * @returns a number defining the depth function
  34082. */
  34083. getDepthFunction(): Nullable<number>;
  34084. /**
  34085. * Sets the current depth function
  34086. * @param depthFunc defines the function to use
  34087. */
  34088. setDepthFunction(depthFunc: number): void;
  34089. /**
  34090. * Sets the current depth function to GREATER
  34091. */
  34092. setDepthFunctionToGreater(): void;
  34093. /**
  34094. * Sets the current depth function to GEQUAL
  34095. */
  34096. setDepthFunctionToGreaterOrEqual(): void;
  34097. /**
  34098. * Sets the current depth function to LESS
  34099. */
  34100. setDepthFunctionToLess(): void;
  34101. /**
  34102. * Sets the current depth function to LEQUAL
  34103. */
  34104. setDepthFunctionToLessOrEqual(): void;
  34105. private _cachedStencilBuffer;
  34106. private _cachedStencilFunction;
  34107. private _cachedStencilMask;
  34108. private _cachedStencilOperationPass;
  34109. private _cachedStencilOperationFail;
  34110. private _cachedStencilOperationDepthFail;
  34111. private _cachedStencilReference;
  34112. /**
  34113. * Caches the the state of the stencil buffer
  34114. */
  34115. cacheStencilState(): void;
  34116. /**
  34117. * Restores the state of the stencil buffer
  34118. */
  34119. restoreStencilState(): void;
  34120. /**
  34121. * Directly set the WebGL Viewport
  34122. * @param x defines the x coordinate of the viewport (in screen space)
  34123. * @param y defines the y coordinate of the viewport (in screen space)
  34124. * @param width defines the width of the viewport (in screen space)
  34125. * @param height defines the height of the viewport (in screen space)
  34126. * @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
  34127. */
  34128. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34129. /**
  34130. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34131. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34132. * @param y defines the y-coordinate of the corner of the clear rectangle
  34133. * @param width defines the width of the clear rectangle
  34134. * @param height defines the height of the clear rectangle
  34135. * @param clearColor defines the clear color
  34136. */
  34137. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34138. /**
  34139. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34140. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34141. * @param y defines the y-coordinate of the corner of the clear rectangle
  34142. * @param width defines the width of the clear rectangle
  34143. * @param height defines the height of the clear rectangle
  34144. */
  34145. enableScissor(x: number, y: number, width: number, height: number): void;
  34146. /**
  34147. * Disable previously set scissor test rectangle
  34148. */
  34149. disableScissor(): void;
  34150. protected _reportDrawCall(): void;
  34151. /**
  34152. * Initializes a webVR display and starts listening to display change events
  34153. * The onVRDisplayChangedObservable will be notified upon these changes
  34154. * @returns The onVRDisplayChangedObservable
  34155. */
  34156. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34157. /** @hidden */
  34158. _prepareVRComponent(): void;
  34159. /** @hidden */
  34160. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34161. /** @hidden */
  34162. _submitVRFrame(): void;
  34163. /**
  34164. * Call this function to leave webVR mode
  34165. * Will do nothing if webVR is not supported or if there is no webVR device
  34166. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34167. */
  34168. disableVR(): void;
  34169. /**
  34170. * Gets a boolean indicating that the system is in VR mode and is presenting
  34171. * @returns true if VR mode is engaged
  34172. */
  34173. isVRPresenting(): boolean;
  34174. /** @hidden */
  34175. _requestVRFrame(): void;
  34176. /** @hidden */
  34177. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34178. /**
  34179. * Gets the source code of the vertex shader associated with a specific webGL program
  34180. * @param program defines the program to use
  34181. * @returns a string containing the source code of the vertex shader associated with the program
  34182. */
  34183. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34184. /**
  34185. * Gets the source code of the fragment shader associated with a specific webGL program
  34186. * @param program defines the program to use
  34187. * @returns a string containing the source code of the fragment shader associated with the program
  34188. */
  34189. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34190. /**
  34191. * Sets a depth stencil texture from a render target to the according uniform.
  34192. * @param channel The texture channel
  34193. * @param uniform The uniform to set
  34194. * @param texture The render target texture containing the depth stencil texture to apply
  34195. */
  34196. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34197. /**
  34198. * Sets a texture to the webGL context from a postprocess
  34199. * @param channel defines the channel to use
  34200. * @param postProcess defines the source postprocess
  34201. */
  34202. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34203. /**
  34204. * Binds the output of the passed in post process to the texture channel specified
  34205. * @param channel The channel the texture should be bound to
  34206. * @param postProcess The post process which's output should be bound
  34207. */
  34208. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34209. protected _rebuildBuffers(): void;
  34210. /** @hidden */
  34211. _renderFrame(): void;
  34212. _renderLoop(): void;
  34213. /** @hidden */
  34214. _renderViews(): boolean;
  34215. /**
  34216. * Toggle full screen mode
  34217. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34218. */
  34219. switchFullscreen(requestPointerLock: boolean): void;
  34220. /**
  34221. * Enters full screen mode
  34222. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34223. */
  34224. enterFullscreen(requestPointerLock: boolean): void;
  34225. /**
  34226. * Exits full screen mode
  34227. */
  34228. exitFullscreen(): void;
  34229. /**
  34230. * Enters Pointerlock mode
  34231. */
  34232. enterPointerlock(): void;
  34233. /**
  34234. * Exits Pointerlock mode
  34235. */
  34236. exitPointerlock(): void;
  34237. /**
  34238. * Begin a new frame
  34239. */
  34240. beginFrame(): void;
  34241. /**
  34242. * Enf the current frame
  34243. */
  34244. endFrame(): void;
  34245. resize(): void;
  34246. /**
  34247. * Force a specific size of the canvas
  34248. * @param width defines the new canvas' width
  34249. * @param height defines the new canvas' height
  34250. */
  34251. setSize(width: number, height: number): void;
  34252. /**
  34253. * Updates a dynamic vertex buffer.
  34254. * @param vertexBuffer the vertex buffer to update
  34255. * @param data the data used to update the vertex buffer
  34256. * @param byteOffset the byte offset of the data
  34257. * @param byteLength the byte length of the data
  34258. */
  34259. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34260. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34261. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34262. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34263. _releaseTexture(texture: InternalTexture): void;
  34264. /**
  34265. * @hidden
  34266. * Rescales a texture
  34267. * @param source input texutre
  34268. * @param destination destination texture
  34269. * @param scene scene to use to render the resize
  34270. * @param internalFormat format to use when resizing
  34271. * @param onComplete callback to be called when resize has completed
  34272. */
  34273. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34274. /**
  34275. * Gets the current framerate
  34276. * @returns a number representing the framerate
  34277. */
  34278. getFps(): number;
  34279. /**
  34280. * Gets the time spent between current and previous frame
  34281. * @returns a number representing the delta time in ms
  34282. */
  34283. getDeltaTime(): number;
  34284. private _measureFps;
  34285. /** @hidden */
  34286. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34287. /**
  34288. * Update a dynamic index buffer
  34289. * @param indexBuffer defines the target index buffer
  34290. * @param indices defines the data to update
  34291. * @param offset defines the offset in the target index buffer where update should start
  34292. */
  34293. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34294. /**
  34295. * Updates the sample count of a render target texture
  34296. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34297. * @param texture defines the texture to update
  34298. * @param samples defines the sample count to set
  34299. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34300. */
  34301. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34302. /**
  34303. * Updates a depth texture Comparison Mode and Function.
  34304. * If the comparison Function is equal to 0, the mode will be set to none.
  34305. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34306. * @param texture The texture to set the comparison function for
  34307. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34308. */
  34309. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34310. /**
  34311. * Creates a webGL buffer to use with instanciation
  34312. * @param capacity defines the size of the buffer
  34313. * @returns the webGL buffer
  34314. */
  34315. createInstancesBuffer(capacity: number): DataBuffer;
  34316. /**
  34317. * Delete a webGL buffer used with instanciation
  34318. * @param buffer defines the webGL buffer to delete
  34319. */
  34320. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34321. private _clientWaitAsync;
  34322. /** @hidden */
  34323. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34324. /** @hidden */
  34325. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34326. dispose(): void;
  34327. private _disableTouchAction;
  34328. /**
  34329. * Display the loading screen
  34330. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34331. */
  34332. displayLoadingUI(): void;
  34333. /**
  34334. * Hide the loading screen
  34335. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34336. */
  34337. hideLoadingUI(): void;
  34338. /**
  34339. * Gets the current loading screen object
  34340. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34341. */
  34342. get loadingScreen(): ILoadingScreen;
  34343. /**
  34344. * Sets the current loading screen object
  34345. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34346. */
  34347. set loadingScreen(loadingScreen: ILoadingScreen);
  34348. /**
  34349. * Sets the current loading screen text
  34350. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34351. */
  34352. set loadingUIText(text: string);
  34353. /**
  34354. * Sets the current loading screen background color
  34355. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34356. */
  34357. set loadingUIBackgroundColor(color: string);
  34358. /** Pointerlock and fullscreen */
  34359. /**
  34360. * Ask the browser to promote the current element to pointerlock mode
  34361. * @param element defines the DOM element to promote
  34362. */
  34363. static _RequestPointerlock(element: HTMLElement): void;
  34364. /**
  34365. * Asks the browser to exit pointerlock mode
  34366. */
  34367. static _ExitPointerlock(): void;
  34368. /**
  34369. * Ask the browser to promote the current element to fullscreen rendering mode
  34370. * @param element defines the DOM element to promote
  34371. */
  34372. static _RequestFullscreen(element: HTMLElement): void;
  34373. /**
  34374. * Asks the browser to exit fullscreen mode
  34375. */
  34376. static _ExitFullscreen(): void;
  34377. }
  34378. }
  34379. declare module BABYLON {
  34380. /**
  34381. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34382. * during the life time of the application.
  34383. */
  34384. export class EngineStore {
  34385. /** Gets the list of created engines */
  34386. static Instances: Engine[];
  34387. /** @hidden */
  34388. static _LastCreatedScene: Nullable<Scene>;
  34389. /**
  34390. * Gets the latest created engine
  34391. */
  34392. static get LastCreatedEngine(): Nullable<Engine>;
  34393. /**
  34394. * Gets the latest created scene
  34395. */
  34396. static get LastCreatedScene(): Nullable<Scene>;
  34397. /**
  34398. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34399. * @ignorenaming
  34400. */
  34401. static UseFallbackTexture: boolean;
  34402. /**
  34403. * Texture content used if a texture cannot loaded
  34404. * @ignorenaming
  34405. */
  34406. static FallbackTexture: string;
  34407. }
  34408. }
  34409. declare module BABYLON {
  34410. /**
  34411. * Helper class that provides a small promise polyfill
  34412. */
  34413. export class PromisePolyfill {
  34414. /**
  34415. * Static function used to check if the polyfill is required
  34416. * If this is the case then the function will inject the polyfill to window.Promise
  34417. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34418. */
  34419. static Apply(force?: boolean): void;
  34420. }
  34421. }
  34422. declare module BABYLON {
  34423. /**
  34424. * Interface for screenshot methods with describe argument called `size` as object with options
  34425. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34426. */
  34427. export interface IScreenshotSize {
  34428. /**
  34429. * number in pixels for canvas height
  34430. */
  34431. height?: number;
  34432. /**
  34433. * multiplier allowing render at a higher or lower resolution
  34434. * If value is defined then height and width will be ignored and taken from camera
  34435. */
  34436. precision?: number;
  34437. /**
  34438. * number in pixels for canvas width
  34439. */
  34440. width?: number;
  34441. }
  34442. }
  34443. declare module BABYLON {
  34444. interface IColor4Like {
  34445. r: float;
  34446. g: float;
  34447. b: float;
  34448. a: float;
  34449. }
  34450. /**
  34451. * Class containing a set of static utilities functions
  34452. */
  34453. export class Tools {
  34454. /**
  34455. * Gets or sets the base URL to use to load assets
  34456. */
  34457. static get BaseUrl(): string;
  34458. static set BaseUrl(value: string);
  34459. /**
  34460. * Enable/Disable Custom HTTP Request Headers globally.
  34461. * default = false
  34462. * @see CustomRequestHeaders
  34463. */
  34464. static UseCustomRequestHeaders: boolean;
  34465. /**
  34466. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34467. * i.e. when loading files, where the server/service expects an Authorization header
  34468. */
  34469. static CustomRequestHeaders: {
  34470. [key: string]: string;
  34471. };
  34472. /**
  34473. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34474. */
  34475. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34476. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34477. /**
  34478. * Default behaviour for cors in the application.
  34479. * It can be a string if the expected behavior is identical in the entire app.
  34480. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34481. */
  34482. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34483. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34484. /**
  34485. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34486. * @ignorenaming
  34487. */
  34488. static get UseFallbackTexture(): boolean;
  34489. static set UseFallbackTexture(value: boolean);
  34490. /**
  34491. * Use this object to register external classes like custom textures or material
  34492. * to allow the laoders to instantiate them
  34493. */
  34494. static get RegisteredExternalClasses(): {
  34495. [key: string]: Object;
  34496. };
  34497. static set RegisteredExternalClasses(classes: {
  34498. [key: string]: Object;
  34499. });
  34500. /**
  34501. * Texture content used if a texture cannot loaded
  34502. * @ignorenaming
  34503. */
  34504. static get fallbackTexture(): string;
  34505. static set fallbackTexture(value: string);
  34506. /**
  34507. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34508. * @param u defines the coordinate on X axis
  34509. * @param v defines the coordinate on Y axis
  34510. * @param width defines the width of the source data
  34511. * @param height defines the height of the source data
  34512. * @param pixels defines the source byte array
  34513. * @param color defines the output color
  34514. */
  34515. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34516. /**
  34517. * Interpolates between a and b via alpha
  34518. * @param a The lower value (returned when alpha = 0)
  34519. * @param b The upper value (returned when alpha = 1)
  34520. * @param alpha The interpolation-factor
  34521. * @return The mixed value
  34522. */
  34523. static Mix(a: number, b: number, alpha: number): number;
  34524. /**
  34525. * Tries to instantiate a new object from a given class name
  34526. * @param className defines the class name to instantiate
  34527. * @returns the new object or null if the system was not able to do the instantiation
  34528. */
  34529. static Instantiate(className: string): any;
  34530. /**
  34531. * Provides a slice function that will work even on IE
  34532. * @param data defines the array to slice
  34533. * @param start defines the start of the data (optional)
  34534. * @param end defines the end of the data (optional)
  34535. * @returns the new sliced array
  34536. */
  34537. static Slice<T>(data: T, start?: number, end?: number): T;
  34538. /**
  34539. * Polyfill for setImmediate
  34540. * @param action defines the action to execute after the current execution block
  34541. */
  34542. static SetImmediate(action: () => void): void;
  34543. /**
  34544. * Function indicating if a number is an exponent of 2
  34545. * @param value defines the value to test
  34546. * @returns true if the value is an exponent of 2
  34547. */
  34548. static IsExponentOfTwo(value: number): boolean;
  34549. private static _tmpFloatArray;
  34550. /**
  34551. * Returns the nearest 32-bit single precision float representation of a Number
  34552. * @param value A Number. If the parameter is of a different type, it will get converted
  34553. * to a number or to NaN if it cannot be converted
  34554. * @returns number
  34555. */
  34556. static FloatRound(value: number): number;
  34557. /**
  34558. * Extracts the filename from a path
  34559. * @param path defines the path to use
  34560. * @returns the filename
  34561. */
  34562. static GetFilename(path: string): string;
  34563. /**
  34564. * Extracts the "folder" part of a path (everything before the filename).
  34565. * @param uri The URI to extract the info from
  34566. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34567. * @returns The "folder" part of the path
  34568. */
  34569. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34570. /**
  34571. * Extracts text content from a DOM element hierarchy
  34572. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34573. */
  34574. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34575. /**
  34576. * Convert an angle in radians to degrees
  34577. * @param angle defines the angle to convert
  34578. * @returns the angle in degrees
  34579. */
  34580. static ToDegrees(angle: number): number;
  34581. /**
  34582. * Convert an angle in degrees to radians
  34583. * @param angle defines the angle to convert
  34584. * @returns the angle in radians
  34585. */
  34586. static ToRadians(angle: number): number;
  34587. /**
  34588. * Returns an array if obj is not an array
  34589. * @param obj defines the object to evaluate as an array
  34590. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34591. * @returns either obj directly if obj is an array or a new array containing obj
  34592. */
  34593. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34594. /**
  34595. * Gets the pointer prefix to use
  34596. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34597. */
  34598. static GetPointerPrefix(): string;
  34599. /**
  34600. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34601. * @param url define the url we are trying
  34602. * @param element define the dom element where to configure the cors policy
  34603. */
  34604. static SetCorsBehavior(url: string | string[], element: {
  34605. crossOrigin: string | null;
  34606. }): void;
  34607. /**
  34608. * Removes unwanted characters from an url
  34609. * @param url defines the url to clean
  34610. * @returns the cleaned url
  34611. */
  34612. static CleanUrl(url: string): string;
  34613. /**
  34614. * Gets or sets a function used to pre-process url before using them to load assets
  34615. */
  34616. static get PreprocessUrl(): (url: string) => string;
  34617. static set PreprocessUrl(processor: (url: string) => string);
  34618. /**
  34619. * Loads an image as an HTMLImageElement.
  34620. * @param input url string, ArrayBuffer, or Blob to load
  34621. * @param onLoad callback called when the image successfully loads
  34622. * @param onError callback called when the image fails to load
  34623. * @param offlineProvider offline provider for caching
  34624. * @param mimeType optional mime type
  34625. * @returns the HTMLImageElement of the loaded image
  34626. */
  34627. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34628. /**
  34629. * Loads a file from a url
  34630. * @param url url string, ArrayBuffer, or Blob to load
  34631. * @param onSuccess callback called when the file successfully loads
  34632. * @param onProgress callback called while file is loading (if the server supports this mode)
  34633. * @param offlineProvider defines the offline provider for caching
  34634. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34635. * @param onError callback called when the file fails to load
  34636. * @returns a file request object
  34637. */
  34638. 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;
  34639. /**
  34640. * Loads a file from a url
  34641. * @param url the file url to load
  34642. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34643. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34644. */
  34645. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34646. /**
  34647. * Load a script (identified by an url). When the url returns, the
  34648. * content of this file is added into a new script element, attached to the DOM (body element)
  34649. * @param scriptUrl defines the url of the script to laod
  34650. * @param onSuccess defines the callback called when the script is loaded
  34651. * @param onError defines the callback to call if an error occurs
  34652. * @param scriptId defines the id of the script element
  34653. */
  34654. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34655. /**
  34656. * Load an asynchronous script (identified by an url). When the url returns, the
  34657. * content of this file is added into a new script element, attached to the DOM (body element)
  34658. * @param scriptUrl defines the url of the script to laod
  34659. * @param scriptId defines the id of the script element
  34660. * @returns a promise request object
  34661. */
  34662. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34663. /**
  34664. * Loads a file from a blob
  34665. * @param fileToLoad defines the blob to use
  34666. * @param callback defines the callback to call when data is loaded
  34667. * @param progressCallback defines the callback to call during loading process
  34668. * @returns a file request object
  34669. */
  34670. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34671. /**
  34672. * Reads a file from a File object
  34673. * @param file defines the file to load
  34674. * @param onSuccess defines the callback to call when data is loaded
  34675. * @param onProgress defines the callback to call during loading process
  34676. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34677. * @param onError defines the callback to call when an error occurs
  34678. * @returns a file request object
  34679. */
  34680. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34681. /**
  34682. * Creates a data url from a given string content
  34683. * @param content defines the content to convert
  34684. * @returns the new data url link
  34685. */
  34686. static FileAsURL(content: string): string;
  34687. /**
  34688. * Format the given number to a specific decimal format
  34689. * @param value defines the number to format
  34690. * @param decimals defines the number of decimals to use
  34691. * @returns the formatted string
  34692. */
  34693. static Format(value: number, decimals?: number): string;
  34694. /**
  34695. * Tries to copy an object by duplicating every property
  34696. * @param source defines the source object
  34697. * @param destination defines the target object
  34698. * @param doNotCopyList defines a list of properties to avoid
  34699. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34700. */
  34701. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34702. /**
  34703. * Gets a boolean indicating if the given object has no own property
  34704. * @param obj defines the object to test
  34705. * @returns true if object has no own property
  34706. */
  34707. static IsEmpty(obj: any): boolean;
  34708. /**
  34709. * Function used to register events at window level
  34710. * @param windowElement defines the Window object to use
  34711. * @param events defines the events to register
  34712. */
  34713. static RegisterTopRootEvents(windowElement: Window, events: {
  34714. name: string;
  34715. handler: Nullable<(e: FocusEvent) => any>;
  34716. }[]): void;
  34717. /**
  34718. * Function used to unregister events from window level
  34719. * @param windowElement defines the Window object to use
  34720. * @param events defines the events to unregister
  34721. */
  34722. static UnregisterTopRootEvents(windowElement: Window, events: {
  34723. name: string;
  34724. handler: Nullable<(e: FocusEvent) => any>;
  34725. }[]): void;
  34726. /**
  34727. * @ignore
  34728. */
  34729. static _ScreenshotCanvas: HTMLCanvasElement;
  34730. /**
  34731. * Dumps the current bound framebuffer
  34732. * @param width defines the rendering width
  34733. * @param height defines the rendering height
  34734. * @param engine defines the hosting engine
  34735. * @param successCallback defines the callback triggered once the data are available
  34736. * @param mimeType defines the mime type of the result
  34737. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34738. */
  34739. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34740. /**
  34741. * Converts the canvas data to blob.
  34742. * This acts as a polyfill for browsers not supporting the to blob function.
  34743. * @param canvas Defines the canvas to extract the data from
  34744. * @param successCallback Defines the callback triggered once the data are available
  34745. * @param mimeType Defines the mime type of the result
  34746. */
  34747. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34748. /**
  34749. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34750. * @param successCallback defines the callback triggered once the data are available
  34751. * @param mimeType defines the mime type of the result
  34752. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34753. */
  34754. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34755. /**
  34756. * Downloads a blob in the browser
  34757. * @param blob defines the blob to download
  34758. * @param fileName defines the name of the downloaded file
  34759. */
  34760. static Download(blob: Blob, fileName: string): void;
  34761. /**
  34762. * Captures a screenshot of the current rendering
  34763. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34764. * @param engine defines the rendering engine
  34765. * @param camera defines the source camera
  34766. * @param size This parameter can be set to a single number or to an object with the
  34767. * following (optional) properties: precision, width, height. If a single number is passed,
  34768. * it will be used for both width and height. If an object is passed, the screenshot size
  34769. * will be derived from the parameters. The precision property is a multiplier allowing
  34770. * rendering at a higher or lower resolution
  34771. * @param successCallback defines the callback receives a single parameter which contains the
  34772. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34773. * src parameter of an <img> to display it
  34774. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34775. * Check your browser for supported MIME types
  34776. */
  34777. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34778. /**
  34779. * Captures a screenshot of the current rendering
  34780. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34781. * @param engine defines the rendering engine
  34782. * @param camera defines the source camera
  34783. * @param size This parameter can be set to a single number or to an object with the
  34784. * following (optional) properties: precision, width, height. If a single number is passed,
  34785. * it will be used for both width and height. If an object is passed, the screenshot size
  34786. * will be derived from the parameters. The precision property is a multiplier allowing
  34787. * rendering at a higher or lower resolution
  34788. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34789. * Check your browser for supported MIME types
  34790. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34791. * to the src parameter of an <img> to display it
  34792. */
  34793. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34794. /**
  34795. * Generates an image screenshot from the specified camera.
  34796. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34797. * @param engine The engine to use for rendering
  34798. * @param camera The camera to use for rendering
  34799. * @param size This parameter can be set to a single number or to an object with the
  34800. * following (optional) properties: precision, width, height. If a single number is passed,
  34801. * it will be used for both width and height. If an object is passed, the screenshot size
  34802. * will be derived from the parameters. The precision property is a multiplier allowing
  34803. * rendering at a higher or lower resolution
  34804. * @param successCallback The callback receives a single parameter which contains the
  34805. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34806. * src parameter of an <img> to display it
  34807. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34808. * Check your browser for supported MIME types
  34809. * @param samples Texture samples (default: 1)
  34810. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34811. * @param fileName A name for for the downloaded file.
  34812. */
  34813. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34814. /**
  34815. * Generates an image screenshot from the specified camera.
  34816. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34817. * @param engine The engine to use for rendering
  34818. * @param camera The camera to use for rendering
  34819. * @param size This parameter can be set to a single number or to an object with the
  34820. * following (optional) properties: precision, width, height. If a single number is passed,
  34821. * it will be used for both width and height. If an object is passed, the screenshot size
  34822. * will be derived from the parameters. The precision property is a multiplier allowing
  34823. * rendering at a higher or lower resolution
  34824. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34825. * Check your browser for supported MIME types
  34826. * @param samples Texture samples (default: 1)
  34827. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34828. * @param fileName A name for for the downloaded file.
  34829. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34830. * to the src parameter of an <img> to display it
  34831. */
  34832. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34833. /**
  34834. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34835. * Be aware Math.random() could cause collisions, but:
  34836. * "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"
  34837. * @returns a pseudo random id
  34838. */
  34839. static RandomId(): string;
  34840. /**
  34841. * Test if the given uri is a base64 string
  34842. * @param uri The uri to test
  34843. * @return True if the uri is a base64 string or false otherwise
  34844. */
  34845. static IsBase64(uri: string): boolean;
  34846. /**
  34847. * Decode the given base64 uri.
  34848. * @param uri The uri to decode
  34849. * @return The decoded base64 data.
  34850. */
  34851. static DecodeBase64(uri: string): ArrayBuffer;
  34852. /**
  34853. * Gets the absolute url.
  34854. * @param url the input url
  34855. * @return the absolute url
  34856. */
  34857. static GetAbsoluteUrl(url: string): string;
  34858. /**
  34859. * No log
  34860. */
  34861. static readonly NoneLogLevel: number;
  34862. /**
  34863. * Only message logs
  34864. */
  34865. static readonly MessageLogLevel: number;
  34866. /**
  34867. * Only warning logs
  34868. */
  34869. static readonly WarningLogLevel: number;
  34870. /**
  34871. * Only error logs
  34872. */
  34873. static readonly ErrorLogLevel: number;
  34874. /**
  34875. * All logs
  34876. */
  34877. static readonly AllLogLevel: number;
  34878. /**
  34879. * Gets a value indicating the number of loading errors
  34880. * @ignorenaming
  34881. */
  34882. static get errorsCount(): number;
  34883. /**
  34884. * Callback called when a new log is added
  34885. */
  34886. static OnNewCacheEntry: (entry: string) => void;
  34887. /**
  34888. * Log a message to the console
  34889. * @param message defines the message to log
  34890. */
  34891. static Log(message: string): void;
  34892. /**
  34893. * Write a warning message to the console
  34894. * @param message defines the message to log
  34895. */
  34896. static Warn(message: string): void;
  34897. /**
  34898. * Write an error message to the console
  34899. * @param message defines the message to log
  34900. */
  34901. static Error(message: string): void;
  34902. /**
  34903. * Gets current log cache (list of logs)
  34904. */
  34905. static get LogCache(): string;
  34906. /**
  34907. * Clears the log cache
  34908. */
  34909. static ClearLogCache(): void;
  34910. /**
  34911. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34912. */
  34913. static set LogLevels(level: number);
  34914. /**
  34915. * Checks if the window object exists
  34916. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34917. */
  34918. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34919. /**
  34920. * No performance log
  34921. */
  34922. static readonly PerformanceNoneLogLevel: number;
  34923. /**
  34924. * Use user marks to log performance
  34925. */
  34926. static readonly PerformanceUserMarkLogLevel: number;
  34927. /**
  34928. * Log performance to the console
  34929. */
  34930. static readonly PerformanceConsoleLogLevel: number;
  34931. private static _performance;
  34932. /**
  34933. * Sets the current performance log level
  34934. */
  34935. static set PerformanceLogLevel(level: number);
  34936. private static _StartPerformanceCounterDisabled;
  34937. private static _EndPerformanceCounterDisabled;
  34938. private static _StartUserMark;
  34939. private static _EndUserMark;
  34940. private static _StartPerformanceConsole;
  34941. private static _EndPerformanceConsole;
  34942. /**
  34943. * Starts a performance counter
  34944. */
  34945. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34946. /**
  34947. * Ends a specific performance coutner
  34948. */
  34949. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34950. /**
  34951. * Gets either window.performance.now() if supported or Date.now() else
  34952. */
  34953. static get Now(): number;
  34954. /**
  34955. * This method will return the name of the class used to create the instance of the given object.
  34956. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34957. * @param object the object to get the class name from
  34958. * @param isType defines if the object is actually a type
  34959. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34960. */
  34961. static GetClassName(object: any, isType?: boolean): string;
  34962. /**
  34963. * Gets the first element of an array satisfying a given predicate
  34964. * @param array defines the array to browse
  34965. * @param predicate defines the predicate to use
  34966. * @returns null if not found or the element
  34967. */
  34968. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34969. /**
  34970. * This method will return the name of the full name of the class, including its owning module (if any).
  34971. * 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).
  34972. * @param object the object to get the class name from
  34973. * @param isType defines if the object is actually a type
  34974. * @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.
  34975. * @ignorenaming
  34976. */
  34977. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34978. /**
  34979. * Returns a promise that resolves after the given amount of time.
  34980. * @param delay Number of milliseconds to delay
  34981. * @returns Promise that resolves after the given amount of time
  34982. */
  34983. static DelayAsync(delay: number): Promise<void>;
  34984. /**
  34985. * Utility function to detect if the current user agent is Safari
  34986. * @returns whether or not the current user agent is safari
  34987. */
  34988. static IsSafari(): boolean;
  34989. }
  34990. /**
  34991. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34992. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34993. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34994. * @param name The name of the class, case should be preserved
  34995. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34996. */
  34997. export function className(name: string, module?: string): (target: Object) => void;
  34998. /**
  34999. * An implementation of a loop for asynchronous functions.
  35000. */
  35001. export class AsyncLoop {
  35002. /**
  35003. * Defines the number of iterations for the loop
  35004. */
  35005. iterations: number;
  35006. /**
  35007. * Defines the current index of the loop.
  35008. */
  35009. index: number;
  35010. private _done;
  35011. private _fn;
  35012. private _successCallback;
  35013. /**
  35014. * Constructor.
  35015. * @param iterations the number of iterations.
  35016. * @param func the function to run each iteration
  35017. * @param successCallback the callback that will be called upon succesful execution
  35018. * @param offset starting offset.
  35019. */
  35020. constructor(
  35021. /**
  35022. * Defines the number of iterations for the loop
  35023. */
  35024. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35025. /**
  35026. * Execute the next iteration. Must be called after the last iteration was finished.
  35027. */
  35028. executeNext(): void;
  35029. /**
  35030. * Break the loop and run the success callback.
  35031. */
  35032. breakLoop(): void;
  35033. /**
  35034. * Create and run an async loop.
  35035. * @param iterations the number of iterations.
  35036. * @param fn the function to run each iteration
  35037. * @param successCallback the callback that will be called upon succesful execution
  35038. * @param offset starting offset.
  35039. * @returns the created async loop object
  35040. */
  35041. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35042. /**
  35043. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35044. * @param iterations total number of iterations
  35045. * @param syncedIterations number of synchronous iterations in each async iteration.
  35046. * @param fn the function to call each iteration.
  35047. * @param callback a success call back that will be called when iterating stops.
  35048. * @param breakFunction a break condition (optional)
  35049. * @param timeout timeout settings for the setTimeout function. default - 0.
  35050. * @returns the created async loop object
  35051. */
  35052. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35053. }
  35054. }
  35055. declare module BABYLON {
  35056. /**
  35057. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35058. * The underlying implementation relies on an associative array to ensure the best performances.
  35059. * The value can be anything including 'null' but except 'undefined'
  35060. */
  35061. export class StringDictionary<T> {
  35062. /**
  35063. * This will clear this dictionary and copy the content from the 'source' one.
  35064. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35065. * @param source the dictionary to take the content from and copy to this dictionary
  35066. */
  35067. copyFrom(source: StringDictionary<T>): void;
  35068. /**
  35069. * Get a value based from its key
  35070. * @param key the given key to get the matching value from
  35071. * @return the value if found, otherwise undefined is returned
  35072. */
  35073. get(key: string): T | undefined;
  35074. /**
  35075. * Get a value from its key or add it if it doesn't exist.
  35076. * This method will ensure you that a given key/data will be present in the dictionary.
  35077. * @param key the given key to get the matching value from
  35078. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35079. * The factory will only be invoked if there's no data for the given key.
  35080. * @return the value corresponding to the key.
  35081. */
  35082. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35083. /**
  35084. * Get a value from its key if present in the dictionary otherwise add it
  35085. * @param key the key to get the value from
  35086. * @param val if there's no such key/value pair in the dictionary add it with this value
  35087. * @return the value corresponding to the key
  35088. */
  35089. getOrAdd(key: string, val: T): T;
  35090. /**
  35091. * Check if there's a given key in the dictionary
  35092. * @param key the key to check for
  35093. * @return true if the key is present, false otherwise
  35094. */
  35095. contains(key: string): boolean;
  35096. /**
  35097. * Add a new key and its corresponding value
  35098. * @param key the key to add
  35099. * @param value the value corresponding to the key
  35100. * @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
  35101. */
  35102. add(key: string, value: T): boolean;
  35103. /**
  35104. * Update a specific value associated to a key
  35105. * @param key defines the key to use
  35106. * @param value defines the value to store
  35107. * @returns true if the value was updated (or false if the key was not found)
  35108. */
  35109. set(key: string, value: T): boolean;
  35110. /**
  35111. * Get the element of the given key and remove it from the dictionary
  35112. * @param key defines the key to search
  35113. * @returns the value associated with the key or null if not found
  35114. */
  35115. getAndRemove(key: string): Nullable<T>;
  35116. /**
  35117. * Remove a key/value from the dictionary.
  35118. * @param key the key to remove
  35119. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35120. */
  35121. remove(key: string): boolean;
  35122. /**
  35123. * Clear the whole content of the dictionary
  35124. */
  35125. clear(): void;
  35126. /**
  35127. * Gets the current count
  35128. */
  35129. get count(): number;
  35130. /**
  35131. * Execute a callback on each key/val of the dictionary.
  35132. * Note that you can remove any element in this dictionary in the callback implementation
  35133. * @param callback the callback to execute on a given key/value pair
  35134. */
  35135. forEach(callback: (key: string, val: T) => void): void;
  35136. /**
  35137. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35138. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35139. * Note that you can remove any element in this dictionary in the callback implementation
  35140. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35141. * @returns the first item
  35142. */
  35143. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35144. private _count;
  35145. private _data;
  35146. }
  35147. }
  35148. declare module BABYLON {
  35149. /** @hidden */
  35150. export interface ICollisionCoordinator {
  35151. createCollider(): Collider;
  35152. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35153. init(scene: Scene): void;
  35154. }
  35155. /** @hidden */
  35156. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35157. private _scene;
  35158. private _scaledPosition;
  35159. private _scaledVelocity;
  35160. private _finalPosition;
  35161. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35162. createCollider(): Collider;
  35163. init(scene: Scene): void;
  35164. private _collideWithWorld;
  35165. }
  35166. }
  35167. declare module BABYLON {
  35168. /**
  35169. * Class used to manage all inputs for the scene.
  35170. */
  35171. export class InputManager {
  35172. /** The distance in pixel that you have to move to prevent some events */
  35173. static DragMovementThreshold: number;
  35174. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35175. static LongPressDelay: number;
  35176. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35177. static DoubleClickDelay: number;
  35178. /** If you need to check double click without raising a single click at first click, enable this flag */
  35179. static ExclusiveDoubleClickMode: boolean;
  35180. private _wheelEventName;
  35181. private _onPointerMove;
  35182. private _onPointerDown;
  35183. private _onPointerUp;
  35184. private _initClickEvent;
  35185. private _initActionManager;
  35186. private _delayedSimpleClick;
  35187. private _delayedSimpleClickTimeout;
  35188. private _previousDelayedSimpleClickTimeout;
  35189. private _meshPickProceed;
  35190. private _previousButtonPressed;
  35191. private _currentPickResult;
  35192. private _previousPickResult;
  35193. private _totalPointersPressed;
  35194. private _doubleClickOccured;
  35195. private _pointerOverMesh;
  35196. private _pickedDownMesh;
  35197. private _pickedUpMesh;
  35198. private _pointerX;
  35199. private _pointerY;
  35200. private _unTranslatedPointerX;
  35201. private _unTranslatedPointerY;
  35202. private _startingPointerPosition;
  35203. private _previousStartingPointerPosition;
  35204. private _startingPointerTime;
  35205. private _previousStartingPointerTime;
  35206. private _pointerCaptures;
  35207. private _onKeyDown;
  35208. private _onKeyUp;
  35209. private _onCanvasFocusObserver;
  35210. private _onCanvasBlurObserver;
  35211. private _scene;
  35212. /**
  35213. * Creates a new InputManager
  35214. * @param scene defines the hosting scene
  35215. */
  35216. constructor(scene: Scene);
  35217. /**
  35218. * Gets the mesh that is currently under the pointer
  35219. */
  35220. get meshUnderPointer(): Nullable<AbstractMesh>;
  35221. /**
  35222. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35223. */
  35224. get unTranslatedPointer(): Vector2;
  35225. /**
  35226. * Gets or sets the current on-screen X position of the pointer
  35227. */
  35228. get pointerX(): number;
  35229. set pointerX(value: number);
  35230. /**
  35231. * Gets or sets the current on-screen Y position of the pointer
  35232. */
  35233. get pointerY(): number;
  35234. set pointerY(value: number);
  35235. private _updatePointerPosition;
  35236. private _processPointerMove;
  35237. private _setRayOnPointerInfo;
  35238. private _checkPrePointerObservable;
  35239. /**
  35240. * Use this method to simulate a pointer move on a mesh
  35241. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35242. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35243. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35244. */
  35245. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35246. /**
  35247. * Use this method to simulate a pointer down on a mesh
  35248. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35249. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35250. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35251. */
  35252. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35253. private _processPointerDown;
  35254. /** @hidden */
  35255. _isPointerSwiping(): boolean;
  35256. /**
  35257. * Use this method to simulate a pointer up on a mesh
  35258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35261. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35262. */
  35263. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35264. private _processPointerUp;
  35265. /**
  35266. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35267. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35268. * @returns true if the pointer was captured
  35269. */
  35270. isPointerCaptured(pointerId?: number): boolean;
  35271. /**
  35272. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35273. * @param attachUp defines if you want to attach events to pointerup
  35274. * @param attachDown defines if you want to attach events to pointerdown
  35275. * @param attachMove defines if you want to attach events to pointermove
  35276. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35277. */
  35278. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35279. /**
  35280. * Detaches all event handlers
  35281. */
  35282. detachControl(): void;
  35283. /**
  35284. * Force the value of meshUnderPointer
  35285. * @param mesh defines the mesh to use
  35286. */
  35287. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35288. /**
  35289. * Gets the mesh under the pointer
  35290. * @returns a Mesh or null if no mesh is under the pointer
  35291. */
  35292. getPointerOverMesh(): Nullable<AbstractMesh>;
  35293. }
  35294. }
  35295. declare module BABYLON {
  35296. /**
  35297. * Helper class used to generate session unique ID
  35298. */
  35299. export class UniqueIdGenerator {
  35300. private static _UniqueIdCounter;
  35301. /**
  35302. * Gets an unique (relatively to the current scene) Id
  35303. */
  35304. static get UniqueId(): number;
  35305. }
  35306. }
  35307. declare module BABYLON {
  35308. /**
  35309. * This class defines the direct association between an animation and a target
  35310. */
  35311. export class TargetedAnimation {
  35312. /**
  35313. * Animation to perform
  35314. */
  35315. animation: Animation;
  35316. /**
  35317. * Target to animate
  35318. */
  35319. target: any;
  35320. /**
  35321. * Serialize the object
  35322. * @returns the JSON object representing the current entity
  35323. */
  35324. serialize(): any;
  35325. }
  35326. /**
  35327. * Use this class to create coordinated animations on multiple targets
  35328. */
  35329. export class AnimationGroup implements IDisposable {
  35330. /** The name of the animation group */
  35331. name: string;
  35332. private _scene;
  35333. private _targetedAnimations;
  35334. private _animatables;
  35335. private _from;
  35336. private _to;
  35337. private _isStarted;
  35338. private _isPaused;
  35339. private _speedRatio;
  35340. private _loopAnimation;
  35341. private _isAdditive;
  35342. /**
  35343. * Gets or sets the unique id of the node
  35344. */
  35345. uniqueId: number;
  35346. /**
  35347. * This observable will notify when one animation have ended
  35348. */
  35349. onAnimationEndObservable: Observable<TargetedAnimation>;
  35350. /**
  35351. * Observer raised when one animation loops
  35352. */
  35353. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35354. /**
  35355. * Observer raised when all animations have looped
  35356. */
  35357. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35358. /**
  35359. * This observable will notify when all animations have ended.
  35360. */
  35361. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35362. /**
  35363. * This observable will notify when all animations have paused.
  35364. */
  35365. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35366. /**
  35367. * This observable will notify when all animations are playing.
  35368. */
  35369. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35370. /**
  35371. * Gets the first frame
  35372. */
  35373. get from(): number;
  35374. /**
  35375. * Gets the last frame
  35376. */
  35377. get to(): number;
  35378. /**
  35379. * Define if the animations are started
  35380. */
  35381. get isStarted(): boolean;
  35382. /**
  35383. * Gets a value indicating that the current group is playing
  35384. */
  35385. get isPlaying(): boolean;
  35386. /**
  35387. * Gets or sets the speed ratio to use for all animations
  35388. */
  35389. get speedRatio(): number;
  35390. /**
  35391. * Gets or sets the speed ratio to use for all animations
  35392. */
  35393. set speedRatio(value: number);
  35394. /**
  35395. * Gets or sets if all animations should loop or not
  35396. */
  35397. get loopAnimation(): boolean;
  35398. set loopAnimation(value: boolean);
  35399. /**
  35400. * Gets or sets if all animations should be evaluated additively
  35401. */
  35402. get isAdditive(): boolean;
  35403. set isAdditive(value: boolean);
  35404. /**
  35405. * Gets the targeted animations for this animation group
  35406. */
  35407. get targetedAnimations(): Array<TargetedAnimation>;
  35408. /**
  35409. * returning the list of animatables controlled by this animation group.
  35410. */
  35411. get animatables(): Array<Animatable>;
  35412. /**
  35413. * Instantiates a new Animation Group.
  35414. * This helps managing several animations at once.
  35415. * @see http://doc.babylonjs.com/how_to/group
  35416. * @param name Defines the name of the group
  35417. * @param scene Defines the scene the group belongs to
  35418. */
  35419. constructor(
  35420. /** The name of the animation group */
  35421. name: string, scene?: Nullable<Scene>);
  35422. /**
  35423. * Add an animation (with its target) in the group
  35424. * @param animation defines the animation we want to add
  35425. * @param target defines the target of the animation
  35426. * @returns the TargetedAnimation object
  35427. */
  35428. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35429. /**
  35430. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35431. * It can add constant keys at begin or end
  35432. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35433. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35434. * @returns the animation group
  35435. */
  35436. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35437. private _animationLoopCount;
  35438. private _animationLoopFlags;
  35439. private _processLoop;
  35440. /**
  35441. * Start all animations on given targets
  35442. * @param loop defines if animations must loop
  35443. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35444. * @param from defines the from key (optional)
  35445. * @param to defines the to key (optional)
  35446. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35447. * @returns the current animation group
  35448. */
  35449. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35450. /**
  35451. * Pause all animations
  35452. * @returns the animation group
  35453. */
  35454. pause(): AnimationGroup;
  35455. /**
  35456. * Play all animations to initial state
  35457. * This function will start() the animations if they were not started or will restart() them if they were paused
  35458. * @param loop defines if animations must loop
  35459. * @returns the animation group
  35460. */
  35461. play(loop?: boolean): AnimationGroup;
  35462. /**
  35463. * Reset all animations to initial state
  35464. * @returns the animation group
  35465. */
  35466. reset(): AnimationGroup;
  35467. /**
  35468. * Restart animations from key 0
  35469. * @returns the animation group
  35470. */
  35471. restart(): AnimationGroup;
  35472. /**
  35473. * Stop all animations
  35474. * @returns the animation group
  35475. */
  35476. stop(): AnimationGroup;
  35477. /**
  35478. * Set animation weight for all animatables
  35479. * @param weight defines the weight to use
  35480. * @return the animationGroup
  35481. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35482. */
  35483. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35484. /**
  35485. * Synchronize and normalize all animatables with a source animatable
  35486. * @param root defines the root animatable to synchronize with
  35487. * @return the animationGroup
  35488. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35489. */
  35490. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35491. /**
  35492. * Goes to a specific frame in this animation group
  35493. * @param frame the frame number to go to
  35494. * @return the animationGroup
  35495. */
  35496. goToFrame(frame: number): AnimationGroup;
  35497. /**
  35498. * Dispose all associated resources
  35499. */
  35500. dispose(): void;
  35501. private _checkAnimationGroupEnded;
  35502. /**
  35503. * Clone the current animation group and returns a copy
  35504. * @param newName defines the name of the new group
  35505. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35506. * @returns the new aniamtion group
  35507. */
  35508. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35509. /**
  35510. * Serializes the animationGroup to an object
  35511. * @returns Serialized object
  35512. */
  35513. serialize(): any;
  35514. /**
  35515. * Returns a new AnimationGroup object parsed from the source provided.
  35516. * @param parsedAnimationGroup defines the source
  35517. * @param scene defines the scene that will receive the animationGroup
  35518. * @returns a new AnimationGroup
  35519. */
  35520. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35521. /**
  35522. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35523. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35524. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35525. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35526. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35527. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35528. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35529. */
  35530. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35531. /**
  35532. * Returns the string "AnimationGroup"
  35533. * @returns "AnimationGroup"
  35534. */
  35535. getClassName(): string;
  35536. /**
  35537. * Creates a detailled string about the object
  35538. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35539. * @returns a string representing the object
  35540. */
  35541. toString(fullDetails?: boolean): string;
  35542. }
  35543. }
  35544. declare module BABYLON {
  35545. /**
  35546. * Define an interface for all classes that will hold resources
  35547. */
  35548. export interface IDisposable {
  35549. /**
  35550. * Releases all held resources
  35551. */
  35552. dispose(): void;
  35553. }
  35554. /** Interface defining initialization parameters for Scene class */
  35555. export interface SceneOptions {
  35556. /**
  35557. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35558. * It will improve performance when the number of geometries becomes important.
  35559. */
  35560. useGeometryUniqueIdsMap?: boolean;
  35561. /**
  35562. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35563. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35564. */
  35565. useMaterialMeshMap?: boolean;
  35566. /**
  35567. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35568. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35569. */
  35570. useClonedMeshMap?: boolean;
  35571. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35572. virtual?: boolean;
  35573. }
  35574. /**
  35575. * Represents a scene to be rendered by the engine.
  35576. * @see http://doc.babylonjs.com/features/scene
  35577. */
  35578. export class Scene extends AbstractScene implements IAnimatable {
  35579. /** The fog is deactivated */
  35580. static readonly FOGMODE_NONE: number;
  35581. /** The fog density is following an exponential function */
  35582. static readonly FOGMODE_EXP: number;
  35583. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35584. static readonly FOGMODE_EXP2: number;
  35585. /** The fog density is following a linear function. */
  35586. static readonly FOGMODE_LINEAR: number;
  35587. /**
  35588. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35589. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35590. */
  35591. static MinDeltaTime: number;
  35592. /**
  35593. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35594. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35595. */
  35596. static MaxDeltaTime: number;
  35597. /**
  35598. * Factory used to create the default material.
  35599. * @param name The name of the material to create
  35600. * @param scene The scene to create the material for
  35601. * @returns The default material
  35602. */
  35603. static DefaultMaterialFactory(scene: Scene): Material;
  35604. /**
  35605. * Factory used to create the a collision coordinator.
  35606. * @returns The collision coordinator
  35607. */
  35608. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35609. /** @hidden */
  35610. _inputManager: InputManager;
  35611. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35612. cameraToUseForPointers: Nullable<Camera>;
  35613. /** @hidden */
  35614. readonly _isScene: boolean;
  35615. /** @hidden */
  35616. _blockEntityCollection: boolean;
  35617. /**
  35618. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35619. */
  35620. autoClear: boolean;
  35621. /**
  35622. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35623. */
  35624. autoClearDepthAndStencil: boolean;
  35625. /**
  35626. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35627. */
  35628. clearColor: Color4;
  35629. /**
  35630. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35631. */
  35632. ambientColor: Color3;
  35633. /**
  35634. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35635. * It should only be one of the following (if not the default embedded one):
  35636. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35637. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35638. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35639. * The material properties need to be setup according to the type of texture in use.
  35640. */
  35641. environmentBRDFTexture: BaseTexture;
  35642. /** @hidden */
  35643. protected _environmentTexture: Nullable<BaseTexture>;
  35644. /**
  35645. * Texture used in all pbr material as the reflection texture.
  35646. * As in the majority of the scene they are the same (exception for multi room and so on),
  35647. * this is easier to reference from here than from all the materials.
  35648. */
  35649. get environmentTexture(): Nullable<BaseTexture>;
  35650. /**
  35651. * Texture used in all pbr material as the reflection texture.
  35652. * As in the majority of the scene they are the same (exception for multi room and so on),
  35653. * this is easier to set here than in all the materials.
  35654. */
  35655. set environmentTexture(value: Nullable<BaseTexture>);
  35656. /** @hidden */
  35657. protected _environmentIntensity: number;
  35658. /**
  35659. * Intensity of the environment in all pbr material.
  35660. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35661. * As in the majority of the scene they are the same (exception for multi room and so on),
  35662. * this is easier to reference from here than from all the materials.
  35663. */
  35664. get environmentIntensity(): number;
  35665. /**
  35666. * Intensity of the environment in all pbr material.
  35667. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35668. * As in the majority of the scene they are the same (exception for multi room and so on),
  35669. * this is easier to set here than in all the materials.
  35670. */
  35671. set environmentIntensity(value: number);
  35672. /** @hidden */
  35673. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35674. /**
  35675. * Default image processing configuration used either in the rendering
  35676. * Forward main pass or through the imageProcessingPostProcess if present.
  35677. * As in the majority of the scene they are the same (exception for multi camera),
  35678. * this is easier to reference from here than from all the materials and post process.
  35679. *
  35680. * No setter as we it is a shared configuration, you can set the values instead.
  35681. */
  35682. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35683. private _forceWireframe;
  35684. /**
  35685. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35686. */
  35687. set forceWireframe(value: boolean);
  35688. get forceWireframe(): boolean;
  35689. private _skipFrustumClipping;
  35690. /**
  35691. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35692. */
  35693. set skipFrustumClipping(value: boolean);
  35694. get skipFrustumClipping(): boolean;
  35695. private _forcePointsCloud;
  35696. /**
  35697. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35698. */
  35699. set forcePointsCloud(value: boolean);
  35700. get forcePointsCloud(): boolean;
  35701. /**
  35702. * Gets or sets the active clipplane 1
  35703. */
  35704. clipPlane: Nullable<Plane>;
  35705. /**
  35706. * Gets or sets the active clipplane 2
  35707. */
  35708. clipPlane2: Nullable<Plane>;
  35709. /**
  35710. * Gets or sets the active clipplane 3
  35711. */
  35712. clipPlane3: Nullable<Plane>;
  35713. /**
  35714. * Gets or sets the active clipplane 4
  35715. */
  35716. clipPlane4: Nullable<Plane>;
  35717. /**
  35718. * Gets or sets the active clipplane 5
  35719. */
  35720. clipPlane5: Nullable<Plane>;
  35721. /**
  35722. * Gets or sets the active clipplane 6
  35723. */
  35724. clipPlane6: Nullable<Plane>;
  35725. /**
  35726. * Gets or sets a boolean indicating if animations are enabled
  35727. */
  35728. animationsEnabled: boolean;
  35729. private _animationPropertiesOverride;
  35730. /**
  35731. * Gets or sets the animation properties override
  35732. */
  35733. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35734. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35735. /**
  35736. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35737. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35738. */
  35739. useConstantAnimationDeltaTime: boolean;
  35740. /**
  35741. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35742. * Please note that it requires to run a ray cast through the scene on every frame
  35743. */
  35744. constantlyUpdateMeshUnderPointer: boolean;
  35745. /**
  35746. * Defines the HTML cursor to use when hovering over interactive elements
  35747. */
  35748. hoverCursor: string;
  35749. /**
  35750. * Defines the HTML default cursor to use (empty by default)
  35751. */
  35752. defaultCursor: string;
  35753. /**
  35754. * Defines whether cursors are handled by the scene.
  35755. */
  35756. doNotHandleCursors: boolean;
  35757. /**
  35758. * This is used to call preventDefault() on pointer down
  35759. * in order to block unwanted artifacts like system double clicks
  35760. */
  35761. preventDefaultOnPointerDown: boolean;
  35762. /**
  35763. * This is used to call preventDefault() on pointer up
  35764. * in order to block unwanted artifacts like system double clicks
  35765. */
  35766. preventDefaultOnPointerUp: boolean;
  35767. /**
  35768. * Gets or sets user defined metadata
  35769. */
  35770. metadata: any;
  35771. /**
  35772. * For internal use only. Please do not use.
  35773. */
  35774. reservedDataStore: any;
  35775. /**
  35776. * Gets the name of the plugin used to load this scene (null by default)
  35777. */
  35778. loadingPluginName: string;
  35779. /**
  35780. * Use this array to add regular expressions used to disable offline support for specific urls
  35781. */
  35782. disableOfflineSupportExceptionRules: RegExp[];
  35783. /**
  35784. * An event triggered when the scene is disposed.
  35785. */
  35786. onDisposeObservable: Observable<Scene>;
  35787. private _onDisposeObserver;
  35788. /** Sets a function to be executed when this scene is disposed. */
  35789. set onDispose(callback: () => void);
  35790. /**
  35791. * An event triggered before rendering the scene (right after animations and physics)
  35792. */
  35793. onBeforeRenderObservable: Observable<Scene>;
  35794. private _onBeforeRenderObserver;
  35795. /** Sets a function to be executed before rendering this scene */
  35796. set beforeRender(callback: Nullable<() => void>);
  35797. /**
  35798. * An event triggered after rendering the scene
  35799. */
  35800. onAfterRenderObservable: Observable<Scene>;
  35801. /**
  35802. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35803. */
  35804. onAfterRenderCameraObservable: Observable<Camera>;
  35805. private _onAfterRenderObserver;
  35806. /** Sets a function to be executed after rendering this scene */
  35807. set afterRender(callback: Nullable<() => void>);
  35808. /**
  35809. * An event triggered before animating the scene
  35810. */
  35811. onBeforeAnimationsObservable: Observable<Scene>;
  35812. /**
  35813. * An event triggered after animations processing
  35814. */
  35815. onAfterAnimationsObservable: Observable<Scene>;
  35816. /**
  35817. * An event triggered before draw calls are ready to be sent
  35818. */
  35819. onBeforeDrawPhaseObservable: Observable<Scene>;
  35820. /**
  35821. * An event triggered after draw calls have been sent
  35822. */
  35823. onAfterDrawPhaseObservable: Observable<Scene>;
  35824. /**
  35825. * An event triggered when the scene is ready
  35826. */
  35827. onReadyObservable: Observable<Scene>;
  35828. /**
  35829. * An event triggered before rendering a camera
  35830. */
  35831. onBeforeCameraRenderObservable: Observable<Camera>;
  35832. private _onBeforeCameraRenderObserver;
  35833. /** Sets a function to be executed before rendering a camera*/
  35834. set beforeCameraRender(callback: () => void);
  35835. /**
  35836. * An event triggered after rendering a camera
  35837. */
  35838. onAfterCameraRenderObservable: Observable<Camera>;
  35839. private _onAfterCameraRenderObserver;
  35840. /** Sets a function to be executed after rendering a camera*/
  35841. set afterCameraRender(callback: () => void);
  35842. /**
  35843. * An event triggered when active meshes evaluation is about to start
  35844. */
  35845. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35846. /**
  35847. * An event triggered when active meshes evaluation is done
  35848. */
  35849. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35850. /**
  35851. * An event triggered when particles rendering is about to start
  35852. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35853. */
  35854. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35855. /**
  35856. * An event triggered when particles rendering is done
  35857. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35858. */
  35859. onAfterParticlesRenderingObservable: Observable<Scene>;
  35860. /**
  35861. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35862. */
  35863. onDataLoadedObservable: Observable<Scene>;
  35864. /**
  35865. * An event triggered when a camera is created
  35866. */
  35867. onNewCameraAddedObservable: Observable<Camera>;
  35868. /**
  35869. * An event triggered when a camera is removed
  35870. */
  35871. onCameraRemovedObservable: Observable<Camera>;
  35872. /**
  35873. * An event triggered when a light is created
  35874. */
  35875. onNewLightAddedObservable: Observable<Light>;
  35876. /**
  35877. * An event triggered when a light is removed
  35878. */
  35879. onLightRemovedObservable: Observable<Light>;
  35880. /**
  35881. * An event triggered when a geometry is created
  35882. */
  35883. onNewGeometryAddedObservable: Observable<Geometry>;
  35884. /**
  35885. * An event triggered when a geometry is removed
  35886. */
  35887. onGeometryRemovedObservable: Observable<Geometry>;
  35888. /**
  35889. * An event triggered when a transform node is created
  35890. */
  35891. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35892. /**
  35893. * An event triggered when a transform node is removed
  35894. */
  35895. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35896. /**
  35897. * An event triggered when a mesh is created
  35898. */
  35899. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35900. /**
  35901. * An event triggered when a mesh is removed
  35902. */
  35903. onMeshRemovedObservable: Observable<AbstractMesh>;
  35904. /**
  35905. * An event triggered when a skeleton is created
  35906. */
  35907. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35908. /**
  35909. * An event triggered when a skeleton is removed
  35910. */
  35911. onSkeletonRemovedObservable: Observable<Skeleton>;
  35912. /**
  35913. * An event triggered when a material is created
  35914. */
  35915. onNewMaterialAddedObservable: Observable<Material>;
  35916. /**
  35917. * An event triggered when a material is removed
  35918. */
  35919. onMaterialRemovedObservable: Observable<Material>;
  35920. /**
  35921. * An event triggered when a texture is created
  35922. */
  35923. onNewTextureAddedObservable: Observable<BaseTexture>;
  35924. /**
  35925. * An event triggered when a texture is removed
  35926. */
  35927. onTextureRemovedObservable: Observable<BaseTexture>;
  35928. /**
  35929. * An event triggered when render targets are about to be rendered
  35930. * Can happen multiple times per frame.
  35931. */
  35932. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35933. /**
  35934. * An event triggered when render targets were rendered.
  35935. * Can happen multiple times per frame.
  35936. */
  35937. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35938. /**
  35939. * An event triggered before calculating deterministic simulation step
  35940. */
  35941. onBeforeStepObservable: Observable<Scene>;
  35942. /**
  35943. * An event triggered after calculating deterministic simulation step
  35944. */
  35945. onAfterStepObservable: Observable<Scene>;
  35946. /**
  35947. * An event triggered when the activeCamera property is updated
  35948. */
  35949. onActiveCameraChanged: Observable<Scene>;
  35950. /**
  35951. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35952. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35953. * 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)
  35954. */
  35955. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35956. /**
  35957. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35958. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35959. * 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)
  35960. */
  35961. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35962. /**
  35963. * This Observable will when a mesh has been imported into the scene.
  35964. */
  35965. onMeshImportedObservable: Observable<AbstractMesh>;
  35966. /**
  35967. * This Observable will when an animation file has been imported into the scene.
  35968. */
  35969. onAnimationFileImportedObservable: Observable<Scene>;
  35970. /**
  35971. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35972. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35973. */
  35974. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35975. /** @hidden */
  35976. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35977. /**
  35978. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35979. */
  35980. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35981. /**
  35982. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35983. */
  35984. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35985. /**
  35986. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35987. */
  35988. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35989. /** Callback called when a pointer move is detected */
  35990. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35991. /** Callback called when a pointer down is detected */
  35992. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35993. /** Callback called when a pointer up is detected */
  35994. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35995. /** Callback called when a pointer pick is detected */
  35996. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35997. /**
  35998. * 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).
  35999. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36000. */
  36001. onPrePointerObservable: Observable<PointerInfoPre>;
  36002. /**
  36003. * Observable event triggered each time an input event is received from the rendering canvas
  36004. */
  36005. onPointerObservable: Observable<PointerInfo>;
  36006. /**
  36007. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36008. */
  36009. get unTranslatedPointer(): Vector2;
  36010. /**
  36011. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36012. */
  36013. static get DragMovementThreshold(): number;
  36014. static set DragMovementThreshold(value: number);
  36015. /**
  36016. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36017. */
  36018. static get LongPressDelay(): number;
  36019. static set LongPressDelay(value: number);
  36020. /**
  36021. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36022. */
  36023. static get DoubleClickDelay(): number;
  36024. static set DoubleClickDelay(value: number);
  36025. /** If you need to check double click without raising a single click at first click, enable this flag */
  36026. static get ExclusiveDoubleClickMode(): boolean;
  36027. static set ExclusiveDoubleClickMode(value: boolean);
  36028. /** @hidden */
  36029. _mirroredCameraPosition: Nullable<Vector3>;
  36030. /**
  36031. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36032. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36033. */
  36034. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36035. /**
  36036. * Observable event triggered each time an keyboard event is received from the hosting window
  36037. */
  36038. onKeyboardObservable: Observable<KeyboardInfo>;
  36039. private _useRightHandedSystem;
  36040. /**
  36041. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36042. */
  36043. set useRightHandedSystem(value: boolean);
  36044. get useRightHandedSystem(): boolean;
  36045. private _timeAccumulator;
  36046. private _currentStepId;
  36047. private _currentInternalStep;
  36048. /**
  36049. * Sets the step Id used by deterministic lock step
  36050. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36051. * @param newStepId defines the step Id
  36052. */
  36053. setStepId(newStepId: number): void;
  36054. /**
  36055. * Gets the step Id used by deterministic lock step
  36056. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36057. * @returns the step Id
  36058. */
  36059. getStepId(): number;
  36060. /**
  36061. * Gets the internal step used by deterministic lock step
  36062. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36063. * @returns the internal step
  36064. */
  36065. getInternalStep(): number;
  36066. private _fogEnabled;
  36067. /**
  36068. * Gets or sets a boolean indicating if fog is enabled on this scene
  36069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36070. * (Default is true)
  36071. */
  36072. set fogEnabled(value: boolean);
  36073. get fogEnabled(): boolean;
  36074. private _fogMode;
  36075. /**
  36076. * Gets or sets the fog mode to use
  36077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36078. * | mode | value |
  36079. * | --- | --- |
  36080. * | FOGMODE_NONE | 0 |
  36081. * | FOGMODE_EXP | 1 |
  36082. * | FOGMODE_EXP2 | 2 |
  36083. * | FOGMODE_LINEAR | 3 |
  36084. */
  36085. set fogMode(value: number);
  36086. get fogMode(): number;
  36087. /**
  36088. * Gets or sets the fog color to use
  36089. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36090. * (Default is Color3(0.2, 0.2, 0.3))
  36091. */
  36092. fogColor: Color3;
  36093. /**
  36094. * Gets or sets the fog density to use
  36095. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36096. * (Default is 0.1)
  36097. */
  36098. fogDensity: number;
  36099. /**
  36100. * Gets or sets the fog start distance to use
  36101. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36102. * (Default is 0)
  36103. */
  36104. fogStart: number;
  36105. /**
  36106. * Gets or sets the fog end distance to use
  36107. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36108. * (Default is 1000)
  36109. */
  36110. fogEnd: number;
  36111. private _shadowsEnabled;
  36112. /**
  36113. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36114. */
  36115. set shadowsEnabled(value: boolean);
  36116. get shadowsEnabled(): boolean;
  36117. private _lightsEnabled;
  36118. /**
  36119. * Gets or sets a boolean indicating if lights are enabled on this scene
  36120. */
  36121. set lightsEnabled(value: boolean);
  36122. get lightsEnabled(): boolean;
  36123. /** All of the active cameras added to this scene. */
  36124. activeCameras: Camera[];
  36125. /** @hidden */
  36126. _activeCamera: Nullable<Camera>;
  36127. /** Gets or sets the current active camera */
  36128. get activeCamera(): Nullable<Camera>;
  36129. set activeCamera(value: Nullable<Camera>);
  36130. private _defaultMaterial;
  36131. /** The default material used on meshes when no material is affected */
  36132. get defaultMaterial(): Material;
  36133. /** The default material used on meshes when no material is affected */
  36134. set defaultMaterial(value: Material);
  36135. private _texturesEnabled;
  36136. /**
  36137. * Gets or sets a boolean indicating if textures are enabled on this scene
  36138. */
  36139. set texturesEnabled(value: boolean);
  36140. get texturesEnabled(): boolean;
  36141. /**
  36142. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  36143. */
  36144. physicsEnabled: boolean;
  36145. /**
  36146. * Gets or sets a boolean indicating if particles are enabled on this scene
  36147. */
  36148. particlesEnabled: boolean;
  36149. /**
  36150. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36151. */
  36152. spritesEnabled: boolean;
  36153. private _skeletonsEnabled;
  36154. /**
  36155. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36156. */
  36157. set skeletonsEnabled(value: boolean);
  36158. get skeletonsEnabled(): boolean;
  36159. /**
  36160. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36161. */
  36162. lensFlaresEnabled: boolean;
  36163. /**
  36164. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36165. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36166. */
  36167. collisionsEnabled: boolean;
  36168. private _collisionCoordinator;
  36169. /** @hidden */
  36170. get collisionCoordinator(): ICollisionCoordinator;
  36171. /**
  36172. * Defines the gravity applied to this scene (used only for collisions)
  36173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36174. */
  36175. gravity: Vector3;
  36176. /**
  36177. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36178. */
  36179. postProcessesEnabled: boolean;
  36180. /**
  36181. * The list of postprocesses added to the scene
  36182. */
  36183. postProcesses: PostProcess[];
  36184. /**
  36185. * Gets the current postprocess manager
  36186. */
  36187. postProcessManager: PostProcessManager;
  36188. /**
  36189. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36190. */
  36191. renderTargetsEnabled: boolean;
  36192. /**
  36193. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36194. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36195. */
  36196. dumpNextRenderTargets: boolean;
  36197. /**
  36198. * The list of user defined render targets added to the scene
  36199. */
  36200. customRenderTargets: RenderTargetTexture[];
  36201. /**
  36202. * Defines if texture loading must be delayed
  36203. * If true, textures will only be loaded when they need to be rendered
  36204. */
  36205. useDelayedTextureLoading: boolean;
  36206. /**
  36207. * Gets the list of meshes imported to the scene through SceneLoader
  36208. */
  36209. importedMeshesFiles: String[];
  36210. /**
  36211. * Gets or sets a boolean indicating if probes are enabled on this scene
  36212. */
  36213. probesEnabled: boolean;
  36214. /**
  36215. * Gets or sets the current offline provider to use to store scene data
  36216. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36217. */
  36218. offlineProvider: IOfflineProvider;
  36219. /**
  36220. * Gets or sets the action manager associated with the scene
  36221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36222. */
  36223. actionManager: AbstractActionManager;
  36224. private _meshesForIntersections;
  36225. /**
  36226. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36227. */
  36228. proceduralTexturesEnabled: boolean;
  36229. private _engine;
  36230. private _totalVertices;
  36231. /** @hidden */
  36232. _activeIndices: PerfCounter;
  36233. /** @hidden */
  36234. _activeParticles: PerfCounter;
  36235. /** @hidden */
  36236. _activeBones: PerfCounter;
  36237. private _animationRatio;
  36238. /** @hidden */
  36239. _animationTimeLast: number;
  36240. /** @hidden */
  36241. _animationTime: number;
  36242. /**
  36243. * Gets or sets a general scale for animation speed
  36244. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36245. */
  36246. animationTimeScale: number;
  36247. /** @hidden */
  36248. _cachedMaterial: Nullable<Material>;
  36249. /** @hidden */
  36250. _cachedEffect: Nullable<Effect>;
  36251. /** @hidden */
  36252. _cachedVisibility: Nullable<number>;
  36253. private _renderId;
  36254. private _frameId;
  36255. private _executeWhenReadyTimeoutId;
  36256. private _intermediateRendering;
  36257. private _viewUpdateFlag;
  36258. private _projectionUpdateFlag;
  36259. /** @hidden */
  36260. _toBeDisposed: Nullable<IDisposable>[];
  36261. private _activeRequests;
  36262. /** @hidden */
  36263. _pendingData: any[];
  36264. private _isDisposed;
  36265. /**
  36266. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36267. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36268. */
  36269. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36270. private _activeMeshes;
  36271. private _processedMaterials;
  36272. private _renderTargets;
  36273. /** @hidden */
  36274. _activeParticleSystems: SmartArray<IParticleSystem>;
  36275. private _activeSkeletons;
  36276. private _softwareSkinnedMeshes;
  36277. private _renderingManager;
  36278. /** @hidden */
  36279. _activeAnimatables: Animatable[];
  36280. private _transformMatrix;
  36281. private _sceneUbo;
  36282. /** @hidden */
  36283. _viewMatrix: Matrix;
  36284. private _projectionMatrix;
  36285. /** @hidden */
  36286. _forcedViewPosition: Nullable<Vector3>;
  36287. /** @hidden */
  36288. _frustumPlanes: Plane[];
  36289. /**
  36290. * Gets the list of frustum planes (built from the active camera)
  36291. */
  36292. get frustumPlanes(): Plane[];
  36293. /**
  36294. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36295. * This is useful if there are more lights that the maximum simulteanous authorized
  36296. */
  36297. requireLightSorting: boolean;
  36298. /** @hidden */
  36299. readonly useMaterialMeshMap: boolean;
  36300. /** @hidden */
  36301. readonly useClonedMeshMap: boolean;
  36302. private _externalData;
  36303. private _uid;
  36304. /**
  36305. * @hidden
  36306. * Backing store of defined scene components.
  36307. */
  36308. _components: ISceneComponent[];
  36309. /**
  36310. * @hidden
  36311. * Backing store of defined scene components.
  36312. */
  36313. _serializableComponents: ISceneSerializableComponent[];
  36314. /**
  36315. * List of components to register on the next registration step.
  36316. */
  36317. private _transientComponents;
  36318. /**
  36319. * Registers the transient components if needed.
  36320. */
  36321. private _registerTransientComponents;
  36322. /**
  36323. * @hidden
  36324. * Add a component to the scene.
  36325. * Note that the ccomponent could be registered on th next frame if this is called after
  36326. * the register component stage.
  36327. * @param component Defines the component to add to the scene
  36328. */
  36329. _addComponent(component: ISceneComponent): void;
  36330. /**
  36331. * @hidden
  36332. * Gets a component from the scene.
  36333. * @param name defines the name of the component to retrieve
  36334. * @returns the component or null if not present
  36335. */
  36336. _getComponent(name: string): Nullable<ISceneComponent>;
  36337. /**
  36338. * @hidden
  36339. * Defines the actions happening before camera updates.
  36340. */
  36341. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36342. /**
  36343. * @hidden
  36344. * Defines the actions happening before clear the canvas.
  36345. */
  36346. _beforeClearStage: Stage<SimpleStageAction>;
  36347. /**
  36348. * @hidden
  36349. * Defines the actions when collecting render targets for the frame.
  36350. */
  36351. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36352. /**
  36353. * @hidden
  36354. * Defines the actions happening for one camera in the frame.
  36355. */
  36356. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36357. /**
  36358. * @hidden
  36359. * Defines the actions happening during the per mesh ready checks.
  36360. */
  36361. _isReadyForMeshStage: Stage<MeshStageAction>;
  36362. /**
  36363. * @hidden
  36364. * Defines the actions happening before evaluate active mesh checks.
  36365. */
  36366. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36367. /**
  36368. * @hidden
  36369. * Defines the actions happening during the evaluate sub mesh checks.
  36370. */
  36371. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36372. /**
  36373. * @hidden
  36374. * Defines the actions happening during the active mesh stage.
  36375. */
  36376. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36377. /**
  36378. * @hidden
  36379. * Defines the actions happening during the per camera render target step.
  36380. */
  36381. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36382. /**
  36383. * @hidden
  36384. * Defines the actions happening just before the active camera is drawing.
  36385. */
  36386. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36387. /**
  36388. * @hidden
  36389. * Defines the actions happening just before a render target is drawing.
  36390. */
  36391. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36392. /**
  36393. * @hidden
  36394. * Defines the actions happening just before a rendering group is drawing.
  36395. */
  36396. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36397. /**
  36398. * @hidden
  36399. * Defines the actions happening just before a mesh is drawing.
  36400. */
  36401. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36402. /**
  36403. * @hidden
  36404. * Defines the actions happening just after a mesh has been drawn.
  36405. */
  36406. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36407. /**
  36408. * @hidden
  36409. * Defines the actions happening just after a rendering group has been drawn.
  36410. */
  36411. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36412. /**
  36413. * @hidden
  36414. * Defines the actions happening just after the active camera has been drawn.
  36415. */
  36416. _afterCameraDrawStage: Stage<CameraStageAction>;
  36417. /**
  36418. * @hidden
  36419. * Defines the actions happening just after a render target has been drawn.
  36420. */
  36421. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36422. /**
  36423. * @hidden
  36424. * Defines the actions happening just after rendering all cameras and computing intersections.
  36425. */
  36426. _afterRenderStage: Stage<SimpleStageAction>;
  36427. /**
  36428. * @hidden
  36429. * Defines the actions happening when a pointer move event happens.
  36430. */
  36431. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36432. /**
  36433. * @hidden
  36434. * Defines the actions happening when a pointer down event happens.
  36435. */
  36436. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36437. /**
  36438. * @hidden
  36439. * Defines the actions happening when a pointer up event happens.
  36440. */
  36441. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36442. /**
  36443. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36444. */
  36445. private geometriesByUniqueId;
  36446. /**
  36447. * Creates a new Scene
  36448. * @param engine defines the engine to use to render this scene
  36449. * @param options defines the scene options
  36450. */
  36451. constructor(engine: Engine, options?: SceneOptions);
  36452. /**
  36453. * Gets a string idenfifying the name of the class
  36454. * @returns "Scene" string
  36455. */
  36456. getClassName(): string;
  36457. private _defaultMeshCandidates;
  36458. /**
  36459. * @hidden
  36460. */
  36461. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36462. private _defaultSubMeshCandidates;
  36463. /**
  36464. * @hidden
  36465. */
  36466. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36467. /**
  36468. * Sets the default candidate providers for the scene.
  36469. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36470. * and getCollidingSubMeshCandidates to their default function
  36471. */
  36472. setDefaultCandidateProviders(): void;
  36473. /**
  36474. * Gets the mesh that is currently under the pointer
  36475. */
  36476. get meshUnderPointer(): Nullable<AbstractMesh>;
  36477. /**
  36478. * Gets or sets the current on-screen X position of the pointer
  36479. */
  36480. get pointerX(): number;
  36481. set pointerX(value: number);
  36482. /**
  36483. * Gets or sets the current on-screen Y position of the pointer
  36484. */
  36485. get pointerY(): number;
  36486. set pointerY(value: number);
  36487. /**
  36488. * Gets the cached material (ie. the latest rendered one)
  36489. * @returns the cached material
  36490. */
  36491. getCachedMaterial(): Nullable<Material>;
  36492. /**
  36493. * Gets the cached effect (ie. the latest rendered one)
  36494. * @returns the cached effect
  36495. */
  36496. getCachedEffect(): Nullable<Effect>;
  36497. /**
  36498. * Gets the cached visibility state (ie. the latest rendered one)
  36499. * @returns the cached visibility state
  36500. */
  36501. getCachedVisibility(): Nullable<number>;
  36502. /**
  36503. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36504. * @param material defines the current material
  36505. * @param effect defines the current effect
  36506. * @param visibility defines the current visibility state
  36507. * @returns true if one parameter is not cached
  36508. */
  36509. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36510. /**
  36511. * Gets the engine associated with the scene
  36512. * @returns an Engine
  36513. */
  36514. getEngine(): Engine;
  36515. /**
  36516. * Gets the total number of vertices rendered per frame
  36517. * @returns the total number of vertices rendered per frame
  36518. */
  36519. getTotalVertices(): number;
  36520. /**
  36521. * Gets the performance counter for total vertices
  36522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36523. */
  36524. get totalVerticesPerfCounter(): PerfCounter;
  36525. /**
  36526. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36527. * @returns the total number of active indices rendered per frame
  36528. */
  36529. getActiveIndices(): number;
  36530. /**
  36531. * Gets the performance counter for active indices
  36532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36533. */
  36534. get totalActiveIndicesPerfCounter(): PerfCounter;
  36535. /**
  36536. * Gets the total number of active particles rendered per frame
  36537. * @returns the total number of active particles rendered per frame
  36538. */
  36539. getActiveParticles(): number;
  36540. /**
  36541. * Gets the performance counter for active particles
  36542. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36543. */
  36544. get activeParticlesPerfCounter(): PerfCounter;
  36545. /**
  36546. * Gets the total number of active bones rendered per frame
  36547. * @returns the total number of active bones rendered per frame
  36548. */
  36549. getActiveBones(): number;
  36550. /**
  36551. * Gets the performance counter for active bones
  36552. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36553. */
  36554. get activeBonesPerfCounter(): PerfCounter;
  36555. /**
  36556. * Gets the array of active meshes
  36557. * @returns an array of AbstractMesh
  36558. */
  36559. getActiveMeshes(): SmartArray<AbstractMesh>;
  36560. /**
  36561. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36562. * @returns a number
  36563. */
  36564. getAnimationRatio(): number;
  36565. /**
  36566. * Gets an unique Id for the current render phase
  36567. * @returns a number
  36568. */
  36569. getRenderId(): number;
  36570. /**
  36571. * Gets an unique Id for the current frame
  36572. * @returns a number
  36573. */
  36574. getFrameId(): number;
  36575. /** Call this function if you want to manually increment the render Id*/
  36576. incrementRenderId(): void;
  36577. private _createUbo;
  36578. /**
  36579. * Use this method to simulate a pointer move on a mesh
  36580. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36581. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36582. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36583. * @returns the current scene
  36584. */
  36585. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36586. /**
  36587. * Use this method to simulate a pointer down on a mesh
  36588. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36589. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36590. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36591. * @returns the current scene
  36592. */
  36593. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36594. /**
  36595. * Use this method to simulate a pointer up on a mesh
  36596. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36597. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36598. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36599. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36600. * @returns the current scene
  36601. */
  36602. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36603. /**
  36604. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36605. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36606. * @returns true if the pointer was captured
  36607. */
  36608. isPointerCaptured(pointerId?: number): boolean;
  36609. /**
  36610. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36611. * @param attachUp defines if you want to attach events to pointerup
  36612. * @param attachDown defines if you want to attach events to pointerdown
  36613. * @param attachMove defines if you want to attach events to pointermove
  36614. */
  36615. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36616. /** Detaches all event handlers*/
  36617. detachControl(): void;
  36618. /**
  36619. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36620. * Delay loaded resources are not taking in account
  36621. * @return true if all required resources are ready
  36622. */
  36623. isReady(): boolean;
  36624. /** Resets all cached information relative to material (including effect and visibility) */
  36625. resetCachedMaterial(): void;
  36626. /**
  36627. * Registers a function to be called before every frame render
  36628. * @param func defines the function to register
  36629. */
  36630. registerBeforeRender(func: () => void): void;
  36631. /**
  36632. * Unregisters a function called before every frame render
  36633. * @param func defines the function to unregister
  36634. */
  36635. unregisterBeforeRender(func: () => void): void;
  36636. /**
  36637. * Registers a function to be called after every frame render
  36638. * @param func defines the function to register
  36639. */
  36640. registerAfterRender(func: () => void): void;
  36641. /**
  36642. * Unregisters a function called after every frame render
  36643. * @param func defines the function to unregister
  36644. */
  36645. unregisterAfterRender(func: () => void): void;
  36646. private _executeOnceBeforeRender;
  36647. /**
  36648. * The provided function will run before render once and will be disposed afterwards.
  36649. * A timeout delay can be provided so that the function will be executed in N ms.
  36650. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36651. * @param func The function to be executed.
  36652. * @param timeout optional delay in ms
  36653. */
  36654. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36655. /** @hidden */
  36656. _addPendingData(data: any): void;
  36657. /** @hidden */
  36658. _removePendingData(data: any): void;
  36659. /**
  36660. * Returns the number of items waiting to be loaded
  36661. * @returns the number of items waiting to be loaded
  36662. */
  36663. getWaitingItemsCount(): number;
  36664. /**
  36665. * Returns a boolean indicating if the scene is still loading data
  36666. */
  36667. get isLoading(): boolean;
  36668. /**
  36669. * Registers a function to be executed when the scene is ready
  36670. * @param {Function} func - the function to be executed
  36671. */
  36672. executeWhenReady(func: () => void): void;
  36673. /**
  36674. * Returns a promise that resolves when the scene is ready
  36675. * @returns A promise that resolves when the scene is ready
  36676. */
  36677. whenReadyAsync(): Promise<void>;
  36678. /** @hidden */
  36679. _checkIsReady(): void;
  36680. /**
  36681. * Gets all animatable attached to the scene
  36682. */
  36683. get animatables(): Animatable[];
  36684. /**
  36685. * Resets the last animation time frame.
  36686. * Useful to override when animations start running when loading a scene for the first time.
  36687. */
  36688. resetLastAnimationTimeFrame(): void;
  36689. /**
  36690. * Gets the current view matrix
  36691. * @returns a Matrix
  36692. */
  36693. getViewMatrix(): Matrix;
  36694. /**
  36695. * Gets the current projection matrix
  36696. * @returns a Matrix
  36697. */
  36698. getProjectionMatrix(): Matrix;
  36699. /**
  36700. * Gets the current transform matrix
  36701. * @returns a Matrix made of View * Projection
  36702. */
  36703. getTransformMatrix(): Matrix;
  36704. /**
  36705. * Sets the current transform matrix
  36706. * @param viewL defines the View matrix to use
  36707. * @param projectionL defines the Projection matrix to use
  36708. * @param viewR defines the right View matrix to use (if provided)
  36709. * @param projectionR defines the right Projection matrix to use (if provided)
  36710. */
  36711. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36712. /**
  36713. * Gets the uniform buffer used to store scene data
  36714. * @returns a UniformBuffer
  36715. */
  36716. getSceneUniformBuffer(): UniformBuffer;
  36717. /**
  36718. * Gets an unique (relatively to the current scene) Id
  36719. * @returns an unique number for the scene
  36720. */
  36721. getUniqueId(): number;
  36722. /**
  36723. * Add a mesh to the list of scene's meshes
  36724. * @param newMesh defines the mesh to add
  36725. * @param recursive if all child meshes should also be added to the scene
  36726. */
  36727. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36728. /**
  36729. * Remove a mesh for the list of scene's meshes
  36730. * @param toRemove defines the mesh to remove
  36731. * @param recursive if all child meshes should also be removed from the scene
  36732. * @returns the index where the mesh was in the mesh list
  36733. */
  36734. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36735. /**
  36736. * Add a transform node to the list of scene's transform nodes
  36737. * @param newTransformNode defines the transform node to add
  36738. */
  36739. addTransformNode(newTransformNode: TransformNode): void;
  36740. /**
  36741. * Remove a transform node for the list of scene's transform nodes
  36742. * @param toRemove defines the transform node to remove
  36743. * @returns the index where the transform node was in the transform node list
  36744. */
  36745. removeTransformNode(toRemove: TransformNode): number;
  36746. /**
  36747. * Remove a skeleton for the list of scene's skeletons
  36748. * @param toRemove defines the skeleton to remove
  36749. * @returns the index where the skeleton was in the skeleton list
  36750. */
  36751. removeSkeleton(toRemove: Skeleton): number;
  36752. /**
  36753. * Remove a morph target for the list of scene's morph targets
  36754. * @param toRemove defines the morph target to remove
  36755. * @returns the index where the morph target was in the morph target list
  36756. */
  36757. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36758. /**
  36759. * Remove a light for the list of scene's lights
  36760. * @param toRemove defines the light to remove
  36761. * @returns the index where the light was in the light list
  36762. */
  36763. removeLight(toRemove: Light): number;
  36764. /**
  36765. * Remove a camera for the list of scene's cameras
  36766. * @param toRemove defines the camera to remove
  36767. * @returns the index where the camera was in the camera list
  36768. */
  36769. removeCamera(toRemove: Camera): number;
  36770. /**
  36771. * Remove a particle system for the list of scene's particle systems
  36772. * @param toRemove defines the particle system to remove
  36773. * @returns the index where the particle system was in the particle system list
  36774. */
  36775. removeParticleSystem(toRemove: IParticleSystem): number;
  36776. /**
  36777. * Remove a animation for the list of scene's animations
  36778. * @param toRemove defines the animation to remove
  36779. * @returns the index where the animation was in the animation list
  36780. */
  36781. removeAnimation(toRemove: Animation): number;
  36782. /**
  36783. * Will stop the animation of the given target
  36784. * @param target - the target
  36785. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36786. * @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)
  36787. */
  36788. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36789. /**
  36790. * Removes the given animation group from this scene.
  36791. * @param toRemove The animation group to remove
  36792. * @returns The index of the removed animation group
  36793. */
  36794. removeAnimationGroup(toRemove: AnimationGroup): number;
  36795. /**
  36796. * Removes the given multi-material from this scene.
  36797. * @param toRemove The multi-material to remove
  36798. * @returns The index of the removed multi-material
  36799. */
  36800. removeMultiMaterial(toRemove: MultiMaterial): number;
  36801. /**
  36802. * Removes the given material from this scene.
  36803. * @param toRemove The material to remove
  36804. * @returns The index of the removed material
  36805. */
  36806. removeMaterial(toRemove: Material): number;
  36807. /**
  36808. * Removes the given action manager from this scene.
  36809. * @param toRemove The action manager to remove
  36810. * @returns The index of the removed action manager
  36811. */
  36812. removeActionManager(toRemove: AbstractActionManager): number;
  36813. /**
  36814. * Removes the given texture from this scene.
  36815. * @param toRemove The texture to remove
  36816. * @returns The index of the removed texture
  36817. */
  36818. removeTexture(toRemove: BaseTexture): number;
  36819. /**
  36820. * Adds the given light to this scene
  36821. * @param newLight The light to add
  36822. */
  36823. addLight(newLight: Light): void;
  36824. /**
  36825. * Sorts the list list based on light priorities
  36826. */
  36827. sortLightsByPriority(): void;
  36828. /**
  36829. * Adds the given camera to this scene
  36830. * @param newCamera The camera to add
  36831. */
  36832. addCamera(newCamera: Camera): void;
  36833. /**
  36834. * Adds the given skeleton to this scene
  36835. * @param newSkeleton The skeleton to add
  36836. */
  36837. addSkeleton(newSkeleton: Skeleton): void;
  36838. /**
  36839. * Adds the given particle system to this scene
  36840. * @param newParticleSystem The particle system to add
  36841. */
  36842. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36843. /**
  36844. * Adds the given animation to this scene
  36845. * @param newAnimation The animation to add
  36846. */
  36847. addAnimation(newAnimation: Animation): void;
  36848. /**
  36849. * Adds the given animation group to this scene.
  36850. * @param newAnimationGroup The animation group to add
  36851. */
  36852. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36853. /**
  36854. * Adds the given multi-material to this scene
  36855. * @param newMultiMaterial The multi-material to add
  36856. */
  36857. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36858. /**
  36859. * Adds the given material to this scene
  36860. * @param newMaterial The material to add
  36861. */
  36862. addMaterial(newMaterial: Material): void;
  36863. /**
  36864. * Adds the given morph target to this scene
  36865. * @param newMorphTargetManager The morph target to add
  36866. */
  36867. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36868. /**
  36869. * Adds the given geometry to this scene
  36870. * @param newGeometry The geometry to add
  36871. */
  36872. addGeometry(newGeometry: Geometry): void;
  36873. /**
  36874. * Adds the given action manager to this scene
  36875. * @param newActionManager The action manager to add
  36876. */
  36877. addActionManager(newActionManager: AbstractActionManager): void;
  36878. /**
  36879. * Adds the given texture to this scene.
  36880. * @param newTexture The texture to add
  36881. */
  36882. addTexture(newTexture: BaseTexture): void;
  36883. /**
  36884. * Switch active camera
  36885. * @param newCamera defines the new active camera
  36886. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36887. */
  36888. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36889. /**
  36890. * sets the active camera of the scene using its ID
  36891. * @param id defines the camera's ID
  36892. * @return the new active camera or null if none found.
  36893. */
  36894. setActiveCameraByID(id: string): Nullable<Camera>;
  36895. /**
  36896. * sets the active camera of the scene using its name
  36897. * @param name defines the camera's name
  36898. * @returns the new active camera or null if none found.
  36899. */
  36900. setActiveCameraByName(name: string): Nullable<Camera>;
  36901. /**
  36902. * get an animation group using its name
  36903. * @param name defines the material's name
  36904. * @return the animation group or null if none found.
  36905. */
  36906. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36907. /**
  36908. * Get a material using its unique id
  36909. * @param uniqueId defines the material's unique id
  36910. * @return the material or null if none found.
  36911. */
  36912. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36913. /**
  36914. * get a material using its id
  36915. * @param id defines the material's ID
  36916. * @return the material or null if none found.
  36917. */
  36918. getMaterialByID(id: string): Nullable<Material>;
  36919. /**
  36920. * Gets a the last added material using a given id
  36921. * @param id defines the material's ID
  36922. * @return the last material with the given id or null if none found.
  36923. */
  36924. getLastMaterialByID(id: string): Nullable<Material>;
  36925. /**
  36926. * Gets a material using its name
  36927. * @param name defines the material's name
  36928. * @return the material or null if none found.
  36929. */
  36930. getMaterialByName(name: string): Nullable<Material>;
  36931. /**
  36932. * Get a texture using its unique id
  36933. * @param uniqueId defines the texture's unique id
  36934. * @return the texture or null if none found.
  36935. */
  36936. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36937. /**
  36938. * Gets a camera using its id
  36939. * @param id defines the id to look for
  36940. * @returns the camera or null if not found
  36941. */
  36942. getCameraByID(id: string): Nullable<Camera>;
  36943. /**
  36944. * Gets a camera using its unique id
  36945. * @param uniqueId defines the unique id to look for
  36946. * @returns the camera or null if not found
  36947. */
  36948. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36949. /**
  36950. * Gets a camera using its name
  36951. * @param name defines the camera's name
  36952. * @return the camera or null if none found.
  36953. */
  36954. getCameraByName(name: string): Nullable<Camera>;
  36955. /**
  36956. * Gets a bone using its id
  36957. * @param id defines the bone's id
  36958. * @return the bone or null if not found
  36959. */
  36960. getBoneByID(id: string): Nullable<Bone>;
  36961. /**
  36962. * Gets a bone using its id
  36963. * @param name defines the bone's name
  36964. * @return the bone or null if not found
  36965. */
  36966. getBoneByName(name: string): Nullable<Bone>;
  36967. /**
  36968. * Gets a light node using its name
  36969. * @param name defines the the light's name
  36970. * @return the light or null if none found.
  36971. */
  36972. getLightByName(name: string): Nullable<Light>;
  36973. /**
  36974. * Gets a light node using its id
  36975. * @param id defines the light's id
  36976. * @return the light or null if none found.
  36977. */
  36978. getLightByID(id: string): Nullable<Light>;
  36979. /**
  36980. * Gets a light node using its scene-generated unique ID
  36981. * @param uniqueId defines the light's unique id
  36982. * @return the light or null if none found.
  36983. */
  36984. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36985. /**
  36986. * Gets a particle system by id
  36987. * @param id defines the particle system id
  36988. * @return the corresponding system or null if none found
  36989. */
  36990. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36991. /**
  36992. * Gets a geometry using its ID
  36993. * @param id defines the geometry's id
  36994. * @return the geometry or null if none found.
  36995. */
  36996. getGeometryByID(id: string): Nullable<Geometry>;
  36997. private _getGeometryByUniqueID;
  36998. /**
  36999. * Add a new geometry to this scene
  37000. * @param geometry defines the geometry to be added to the scene.
  37001. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37002. * @return a boolean defining if the geometry was added or not
  37003. */
  37004. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37005. /**
  37006. * Removes an existing geometry
  37007. * @param geometry defines the geometry to be removed from the scene
  37008. * @return a boolean defining if the geometry was removed or not
  37009. */
  37010. removeGeometry(geometry: Geometry): boolean;
  37011. /**
  37012. * Gets the list of geometries attached to the scene
  37013. * @returns an array of Geometry
  37014. */
  37015. getGeometries(): Geometry[];
  37016. /**
  37017. * Gets the first added mesh found of a given ID
  37018. * @param id defines the id to search for
  37019. * @return the mesh found or null if not found at all
  37020. */
  37021. getMeshByID(id: string): Nullable<AbstractMesh>;
  37022. /**
  37023. * Gets a list of meshes using their id
  37024. * @param id defines the id to search for
  37025. * @returns a list of meshes
  37026. */
  37027. getMeshesByID(id: string): Array<AbstractMesh>;
  37028. /**
  37029. * Gets the first added transform node found of a given ID
  37030. * @param id defines the id to search for
  37031. * @return the found transform node or null if not found at all.
  37032. */
  37033. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37034. /**
  37035. * Gets a transform node with its auto-generated unique id
  37036. * @param uniqueId efines the unique id to search for
  37037. * @return the found transform node or null if not found at all.
  37038. */
  37039. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37040. /**
  37041. * Gets a list of transform nodes using their id
  37042. * @param id defines the id to search for
  37043. * @returns a list of transform nodes
  37044. */
  37045. getTransformNodesByID(id: string): Array<TransformNode>;
  37046. /**
  37047. * Gets a mesh with its auto-generated unique id
  37048. * @param uniqueId defines the unique id to search for
  37049. * @return the found mesh or null if not found at all.
  37050. */
  37051. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37052. /**
  37053. * Gets a the last added mesh using a given id
  37054. * @param id defines the id to search for
  37055. * @return the found mesh or null if not found at all.
  37056. */
  37057. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37058. /**
  37059. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37060. * @param id defines the id to search for
  37061. * @return the found node or null if not found at all
  37062. */
  37063. getLastEntryByID(id: string): Nullable<Node>;
  37064. /**
  37065. * Gets a node (Mesh, Camera, Light) using a given id
  37066. * @param id defines the id to search for
  37067. * @return the found node or null if not found at all
  37068. */
  37069. getNodeByID(id: string): Nullable<Node>;
  37070. /**
  37071. * Gets a node (Mesh, Camera, Light) using a given name
  37072. * @param name defines the name to search for
  37073. * @return the found node or null if not found at all.
  37074. */
  37075. getNodeByName(name: string): Nullable<Node>;
  37076. /**
  37077. * Gets a mesh using a given name
  37078. * @param name defines the name to search for
  37079. * @return the found mesh or null if not found at all.
  37080. */
  37081. getMeshByName(name: string): Nullable<AbstractMesh>;
  37082. /**
  37083. * Gets a transform node using a given name
  37084. * @param name defines the name to search for
  37085. * @return the found transform node or null if not found at all.
  37086. */
  37087. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37088. /**
  37089. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37090. * @param id defines the id to search for
  37091. * @return the found skeleton or null if not found at all.
  37092. */
  37093. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37094. /**
  37095. * Gets a skeleton using a given auto generated unique id
  37096. * @param uniqueId defines the unique id to search for
  37097. * @return the found skeleton or null if not found at all.
  37098. */
  37099. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37100. /**
  37101. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37102. * @param id defines the id to search for
  37103. * @return the found skeleton or null if not found at all.
  37104. */
  37105. getSkeletonById(id: string): Nullable<Skeleton>;
  37106. /**
  37107. * Gets a skeleton using a given name
  37108. * @param name defines the name to search for
  37109. * @return the found skeleton or null if not found at all.
  37110. */
  37111. getSkeletonByName(name: string): Nullable<Skeleton>;
  37112. /**
  37113. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37114. * @param id defines the id to search for
  37115. * @return the found morph target manager or null if not found at all.
  37116. */
  37117. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37118. /**
  37119. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37120. * @param id defines the id to search for
  37121. * @return the found morph target or null if not found at all.
  37122. */
  37123. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37124. /**
  37125. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37126. * @param name defines the name to search for
  37127. * @return the found morph target or null if not found at all.
  37128. */
  37129. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37130. /**
  37131. * Gets a boolean indicating if the given mesh is active
  37132. * @param mesh defines the mesh to look for
  37133. * @returns true if the mesh is in the active list
  37134. */
  37135. isActiveMesh(mesh: AbstractMesh): boolean;
  37136. /**
  37137. * Return a unique id as a string which can serve as an identifier for the scene
  37138. */
  37139. get uid(): string;
  37140. /**
  37141. * Add an externaly attached data from its key.
  37142. * This method call will fail and return false, if such key already exists.
  37143. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37144. * @param key the unique key that identifies the data
  37145. * @param data the data object to associate to the key for this Engine instance
  37146. * @return true if no such key were already present and the data was added successfully, false otherwise
  37147. */
  37148. addExternalData<T>(key: string, data: T): boolean;
  37149. /**
  37150. * Get an externaly attached data from its key
  37151. * @param key the unique key that identifies the data
  37152. * @return the associated data, if present (can be null), or undefined if not present
  37153. */
  37154. getExternalData<T>(key: string): Nullable<T>;
  37155. /**
  37156. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37157. * @param key the unique key that identifies the data
  37158. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37159. * @return the associated data, can be null if the factory returned null.
  37160. */
  37161. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37162. /**
  37163. * Remove an externaly attached data from the Engine instance
  37164. * @param key the unique key that identifies the data
  37165. * @return true if the data was successfully removed, false if it doesn't exist
  37166. */
  37167. removeExternalData(key: string): boolean;
  37168. private _evaluateSubMesh;
  37169. /**
  37170. * Clear the processed materials smart array preventing retention point in material dispose.
  37171. */
  37172. freeProcessedMaterials(): void;
  37173. private _preventFreeActiveMeshesAndRenderingGroups;
  37174. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37175. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37176. * when disposing several meshes in a row or a hierarchy of meshes.
  37177. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37178. */
  37179. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37180. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37181. /**
  37182. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37183. */
  37184. freeActiveMeshes(): void;
  37185. /**
  37186. * Clear the info related to rendering groups preventing retention points during dispose.
  37187. */
  37188. freeRenderingGroups(): void;
  37189. /** @hidden */
  37190. _isInIntermediateRendering(): boolean;
  37191. /**
  37192. * Lambda returning the list of potentially active meshes.
  37193. */
  37194. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37195. /**
  37196. * Lambda returning the list of potentially active sub meshes.
  37197. */
  37198. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37199. /**
  37200. * Lambda returning the list of potentially intersecting sub meshes.
  37201. */
  37202. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37203. /**
  37204. * Lambda returning the list of potentially colliding sub meshes.
  37205. */
  37206. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37207. private _activeMeshesFrozen;
  37208. private _skipEvaluateActiveMeshesCompletely;
  37209. /**
  37210. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37211. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37212. * @returns the current scene
  37213. */
  37214. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37215. /**
  37216. * Use this function to restart evaluating active meshes on every frame
  37217. * @returns the current scene
  37218. */
  37219. unfreezeActiveMeshes(): Scene;
  37220. private _evaluateActiveMeshes;
  37221. private _activeMesh;
  37222. /**
  37223. * Update the transform matrix to update from the current active camera
  37224. * @param force defines a boolean used to force the update even if cache is up to date
  37225. */
  37226. updateTransformMatrix(force?: boolean): void;
  37227. private _bindFrameBuffer;
  37228. /** @hidden */
  37229. _allowPostProcessClearColor: boolean;
  37230. /** @hidden */
  37231. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37232. private _processSubCameras;
  37233. private _checkIntersections;
  37234. /** @hidden */
  37235. _advancePhysicsEngineStep(step: number): void;
  37236. /**
  37237. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37238. */
  37239. getDeterministicFrameTime: () => number;
  37240. /** @hidden */
  37241. _animate(): void;
  37242. /** Execute all animations (for a frame) */
  37243. animate(): void;
  37244. /**
  37245. * Render the scene
  37246. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37247. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37248. */
  37249. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37250. /**
  37251. * Freeze all materials
  37252. * A frozen material will not be updatable but should be faster to render
  37253. */
  37254. freezeMaterials(): void;
  37255. /**
  37256. * Unfreeze all materials
  37257. * A frozen material will not be updatable but should be faster to render
  37258. */
  37259. unfreezeMaterials(): void;
  37260. /**
  37261. * Releases all held ressources
  37262. */
  37263. dispose(): void;
  37264. /**
  37265. * Gets if the scene is already disposed
  37266. */
  37267. get isDisposed(): boolean;
  37268. /**
  37269. * Call this function to reduce memory footprint of the scene.
  37270. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37271. */
  37272. clearCachedVertexData(): void;
  37273. /**
  37274. * This function will remove the local cached buffer data from texture.
  37275. * It will save memory but will prevent the texture from being rebuilt
  37276. */
  37277. cleanCachedTextureBuffer(): void;
  37278. /**
  37279. * Get the world extend vectors with an optional filter
  37280. *
  37281. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37282. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37283. */
  37284. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37285. min: Vector3;
  37286. max: Vector3;
  37287. };
  37288. /**
  37289. * Creates a ray that can be used to pick in the scene
  37290. * @param x defines the x coordinate of the origin (on-screen)
  37291. * @param y defines the y coordinate of the origin (on-screen)
  37292. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37293. * @param camera defines the camera to use for the picking
  37294. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37295. * @returns a Ray
  37296. */
  37297. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37298. /**
  37299. * Creates a ray that can be used to pick in the scene
  37300. * @param x defines the x coordinate of the origin (on-screen)
  37301. * @param y defines the y coordinate of the origin (on-screen)
  37302. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37303. * @param result defines the ray where to store the picking ray
  37304. * @param camera defines the camera to use for the picking
  37305. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37306. * @returns the current scene
  37307. */
  37308. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37309. /**
  37310. * Creates a ray that can be used to pick in the scene
  37311. * @param x defines the x coordinate of the origin (on-screen)
  37312. * @param y defines the y coordinate of the origin (on-screen)
  37313. * @param camera defines the camera to use for the picking
  37314. * @returns a Ray
  37315. */
  37316. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37317. /**
  37318. * Creates a ray that can be used to pick in the scene
  37319. * @param x defines the x coordinate of the origin (on-screen)
  37320. * @param y defines the y coordinate of the origin (on-screen)
  37321. * @param result defines the ray where to store the picking ray
  37322. * @param camera defines the camera to use for the picking
  37323. * @returns the current scene
  37324. */
  37325. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37326. /** Launch a ray to try to pick a mesh in the scene
  37327. * @param x position on screen
  37328. * @param y position on screen
  37329. * @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
  37330. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37331. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37332. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37333. * @returns a PickingInfo
  37334. */
  37335. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37336. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37337. * @param x position on screen
  37338. * @param y position on screen
  37339. * @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
  37340. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37341. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37342. * @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)
  37343. */
  37344. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37345. /** Use the given ray to pick a mesh in the scene
  37346. * @param ray The ray to use to pick meshes
  37347. * @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
  37348. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37349. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37350. * @returns a PickingInfo
  37351. */
  37352. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37353. /**
  37354. * Launch a ray to try to pick a mesh in the scene
  37355. * @param x X position on screen
  37356. * @param y Y position on screen
  37357. * @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
  37358. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37359. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37360. * @returns an array of PickingInfo
  37361. */
  37362. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37363. /**
  37364. * Launch a ray to try to pick a mesh in the scene
  37365. * @param ray Ray to use
  37366. * @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
  37367. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37368. * @returns an array of PickingInfo
  37369. */
  37370. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37371. /**
  37372. * Force the value of meshUnderPointer
  37373. * @param mesh defines the mesh to use
  37374. */
  37375. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37376. /**
  37377. * Gets the mesh under the pointer
  37378. * @returns a Mesh or null if no mesh is under the pointer
  37379. */
  37380. getPointerOverMesh(): Nullable<AbstractMesh>;
  37381. /** @hidden */
  37382. _rebuildGeometries(): void;
  37383. /** @hidden */
  37384. _rebuildTextures(): void;
  37385. private _getByTags;
  37386. /**
  37387. * Get a list of meshes by tags
  37388. * @param tagsQuery defines the tags query to use
  37389. * @param forEach defines a predicate used to filter results
  37390. * @returns an array of Mesh
  37391. */
  37392. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37393. /**
  37394. * Get a list of cameras by tags
  37395. * @param tagsQuery defines the tags query to use
  37396. * @param forEach defines a predicate used to filter results
  37397. * @returns an array of Camera
  37398. */
  37399. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37400. /**
  37401. * Get a list of lights by tags
  37402. * @param tagsQuery defines the tags query to use
  37403. * @param forEach defines a predicate used to filter results
  37404. * @returns an array of Light
  37405. */
  37406. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37407. /**
  37408. * Get a list of materials by tags
  37409. * @param tagsQuery defines the tags query to use
  37410. * @param forEach defines a predicate used to filter results
  37411. * @returns an array of Material
  37412. */
  37413. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37414. /**
  37415. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37416. * This allowed control for front to back rendering or reversly depending of the special needs.
  37417. *
  37418. * @param renderingGroupId The rendering group id corresponding to its index
  37419. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37420. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37421. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37422. */
  37423. 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;
  37424. /**
  37425. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37426. *
  37427. * @param renderingGroupId The rendering group id corresponding to its index
  37428. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37429. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37430. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37431. */
  37432. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37433. /**
  37434. * Gets the current auto clear configuration for one rendering group of the rendering
  37435. * manager.
  37436. * @param index the rendering group index to get the information for
  37437. * @returns The auto clear setup for the requested rendering group
  37438. */
  37439. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37440. private _blockMaterialDirtyMechanism;
  37441. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37442. get blockMaterialDirtyMechanism(): boolean;
  37443. set blockMaterialDirtyMechanism(value: boolean);
  37444. /**
  37445. * Will flag all materials as dirty to trigger new shader compilation
  37446. * @param flag defines the flag used to specify which material part must be marked as dirty
  37447. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37448. */
  37449. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37450. /** @hidden */
  37451. _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;
  37452. /** @hidden */
  37453. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37454. /** @hidden */
  37455. _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;
  37456. /** @hidden */
  37457. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37458. /** @hidden */
  37459. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37460. /** @hidden */
  37461. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37462. }
  37463. }
  37464. declare module BABYLON {
  37465. /**
  37466. * Set of assets to keep when moving a scene into an asset container.
  37467. */
  37468. export class KeepAssets extends AbstractScene {
  37469. }
  37470. /**
  37471. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37472. */
  37473. export class InstantiatedEntries {
  37474. /**
  37475. * List of new root nodes (eg. nodes with no parent)
  37476. */
  37477. rootNodes: TransformNode[];
  37478. /**
  37479. * List of new skeletons
  37480. */
  37481. skeletons: Skeleton[];
  37482. /**
  37483. * List of new animation groups
  37484. */
  37485. animationGroups: AnimationGroup[];
  37486. }
  37487. /**
  37488. * Container with a set of assets that can be added or removed from a scene.
  37489. */
  37490. export class AssetContainer extends AbstractScene {
  37491. private _wasAddedToScene;
  37492. /**
  37493. * The scene the AssetContainer belongs to.
  37494. */
  37495. scene: Scene;
  37496. /**
  37497. * Instantiates an AssetContainer.
  37498. * @param scene The scene the AssetContainer belongs to.
  37499. */
  37500. constructor(scene: Scene);
  37501. /**
  37502. * Instantiate or clone all meshes and add the new ones to the scene.
  37503. * Skeletons and animation groups will all be cloned
  37504. * @param nameFunction defines an optional function used to get new names for clones
  37505. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37506. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37507. */
  37508. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37509. /**
  37510. * Adds all the assets from the container to the scene.
  37511. */
  37512. addAllToScene(): void;
  37513. /**
  37514. * Removes all the assets in the container from the scene
  37515. */
  37516. removeAllFromScene(): void;
  37517. /**
  37518. * Disposes all the assets in the container
  37519. */
  37520. dispose(): void;
  37521. private _moveAssets;
  37522. /**
  37523. * Removes all the assets contained in the scene and adds them to the container.
  37524. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37525. */
  37526. moveAllFromScene(keepAssets?: KeepAssets): void;
  37527. /**
  37528. * 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.
  37529. * @returns the root mesh
  37530. */
  37531. createRootMesh(): Mesh;
  37532. /**
  37533. * Merge animations (direct and animation groups) from this asset container into a scene
  37534. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37535. * @param animatables set of animatables to retarget to a node from the scene
  37536. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37537. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37538. */
  37539. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37540. }
  37541. }
  37542. declare module BABYLON {
  37543. /**
  37544. * Defines how the parser contract is defined.
  37545. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37546. */
  37547. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37548. /**
  37549. * Defines how the individual parser contract is defined.
  37550. * These parser can parse an individual asset
  37551. */
  37552. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37553. /**
  37554. * Base class of the scene acting as a container for the different elements composing a scene.
  37555. * This class is dynamically extended by the different components of the scene increasing
  37556. * flexibility and reducing coupling
  37557. */
  37558. export abstract class AbstractScene {
  37559. /**
  37560. * Stores the list of available parsers in the application.
  37561. */
  37562. private static _BabylonFileParsers;
  37563. /**
  37564. * Stores the list of available individual parsers in the application.
  37565. */
  37566. private static _IndividualBabylonFileParsers;
  37567. /**
  37568. * Adds a parser in the list of available ones
  37569. * @param name Defines the name of the parser
  37570. * @param parser Defines the parser to add
  37571. */
  37572. static AddParser(name: string, parser: BabylonFileParser): void;
  37573. /**
  37574. * Gets a general parser from the list of avaialble ones
  37575. * @param name Defines the name of the parser
  37576. * @returns the requested parser or null
  37577. */
  37578. static GetParser(name: string): Nullable<BabylonFileParser>;
  37579. /**
  37580. * Adds n individual parser in the list of available ones
  37581. * @param name Defines the name of the parser
  37582. * @param parser Defines the parser to add
  37583. */
  37584. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37585. /**
  37586. * Gets an individual parser from the list of avaialble ones
  37587. * @param name Defines the name of the parser
  37588. * @returns the requested parser or null
  37589. */
  37590. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37591. /**
  37592. * Parser json data and populate both a scene and its associated container object
  37593. * @param jsonData Defines the data to parse
  37594. * @param scene Defines the scene to parse the data for
  37595. * @param container Defines the container attached to the parsing sequence
  37596. * @param rootUrl Defines the root url of the data
  37597. */
  37598. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37599. /**
  37600. * Gets the list of root nodes (ie. nodes with no parent)
  37601. */
  37602. rootNodes: Node[];
  37603. /** All of the cameras added to this scene
  37604. * @see http://doc.babylonjs.com/babylon101/cameras
  37605. */
  37606. cameras: Camera[];
  37607. /**
  37608. * All of the lights added to this scene
  37609. * @see http://doc.babylonjs.com/babylon101/lights
  37610. */
  37611. lights: Light[];
  37612. /**
  37613. * All of the (abstract) meshes added to this scene
  37614. */
  37615. meshes: AbstractMesh[];
  37616. /**
  37617. * The list of skeletons added to the scene
  37618. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37619. */
  37620. skeletons: Skeleton[];
  37621. /**
  37622. * All of the particle systems added to this scene
  37623. * @see http://doc.babylonjs.com/babylon101/particles
  37624. */
  37625. particleSystems: IParticleSystem[];
  37626. /**
  37627. * Gets a list of Animations associated with the scene
  37628. */
  37629. animations: Animation[];
  37630. /**
  37631. * All of the animation groups added to this scene
  37632. * @see http://doc.babylonjs.com/how_to/group
  37633. */
  37634. animationGroups: AnimationGroup[];
  37635. /**
  37636. * All of the multi-materials added to this scene
  37637. * @see http://doc.babylonjs.com/how_to/multi_materials
  37638. */
  37639. multiMaterials: MultiMaterial[];
  37640. /**
  37641. * All of the materials added to this scene
  37642. * In the context of a Scene, it is not supposed to be modified manually.
  37643. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37644. * Note also that the order of the Material within the array is not significant and might change.
  37645. * @see http://doc.babylonjs.com/babylon101/materials
  37646. */
  37647. materials: Material[];
  37648. /**
  37649. * The list of morph target managers added to the scene
  37650. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37651. */
  37652. morphTargetManagers: MorphTargetManager[];
  37653. /**
  37654. * The list of geometries used in the scene.
  37655. */
  37656. geometries: Geometry[];
  37657. /**
  37658. * All of the tranform nodes added to this scene
  37659. * In the context of a Scene, it is not supposed to be modified manually.
  37660. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37661. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37662. * @see http://doc.babylonjs.com/how_to/transformnode
  37663. */
  37664. transformNodes: TransformNode[];
  37665. /**
  37666. * ActionManagers available on the scene.
  37667. */
  37668. actionManagers: AbstractActionManager[];
  37669. /**
  37670. * Textures to keep.
  37671. */
  37672. textures: BaseTexture[];
  37673. /**
  37674. * Environment texture for the scene
  37675. */
  37676. environmentTexture: Nullable<BaseTexture>;
  37677. /**
  37678. * @returns all meshes, lights, cameras, transformNodes and bones
  37679. */
  37680. getNodes(): Array<Node>;
  37681. }
  37682. }
  37683. declare module BABYLON {
  37684. /**
  37685. * Interface used to define options for Sound class
  37686. */
  37687. export interface ISoundOptions {
  37688. /**
  37689. * Does the sound autoplay once loaded.
  37690. */
  37691. autoplay?: boolean;
  37692. /**
  37693. * Does the sound loop after it finishes playing once.
  37694. */
  37695. loop?: boolean;
  37696. /**
  37697. * Sound's volume
  37698. */
  37699. volume?: number;
  37700. /**
  37701. * Is it a spatial sound?
  37702. */
  37703. spatialSound?: boolean;
  37704. /**
  37705. * Maximum distance to hear that sound
  37706. */
  37707. maxDistance?: number;
  37708. /**
  37709. * Uses user defined attenuation function
  37710. */
  37711. useCustomAttenuation?: boolean;
  37712. /**
  37713. * Define the roll off factor of spatial sounds.
  37714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37715. */
  37716. rolloffFactor?: number;
  37717. /**
  37718. * Define the reference distance the sound should be heard perfectly.
  37719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37720. */
  37721. refDistance?: number;
  37722. /**
  37723. * Define the distance attenuation model the sound will follow.
  37724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37725. */
  37726. distanceModel?: string;
  37727. /**
  37728. * Defines the playback speed (1 by default)
  37729. */
  37730. playbackRate?: number;
  37731. /**
  37732. * Defines if the sound is from a streaming source
  37733. */
  37734. streaming?: boolean;
  37735. /**
  37736. * Defines an optional length (in seconds) inside the sound file
  37737. */
  37738. length?: number;
  37739. /**
  37740. * Defines an optional offset (in seconds) inside the sound file
  37741. */
  37742. offset?: number;
  37743. /**
  37744. * If true, URLs will not be required to state the audio file codec to use.
  37745. */
  37746. skipCodecCheck?: boolean;
  37747. }
  37748. /**
  37749. * Defines a sound that can be played in the application.
  37750. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37752. */
  37753. export class Sound {
  37754. /**
  37755. * The name of the sound in the scene.
  37756. */
  37757. name: string;
  37758. /**
  37759. * Does the sound autoplay once loaded.
  37760. */
  37761. autoplay: boolean;
  37762. /**
  37763. * Does the sound loop after it finishes playing once.
  37764. */
  37765. loop: boolean;
  37766. /**
  37767. * Does the sound use a custom attenuation curve to simulate the falloff
  37768. * happening when the source gets further away from the camera.
  37769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37770. */
  37771. useCustomAttenuation: boolean;
  37772. /**
  37773. * The sound track id this sound belongs to.
  37774. */
  37775. soundTrackId: number;
  37776. /**
  37777. * Is this sound currently played.
  37778. */
  37779. isPlaying: boolean;
  37780. /**
  37781. * Is this sound currently paused.
  37782. */
  37783. isPaused: boolean;
  37784. /**
  37785. * Does this sound enables spatial sound.
  37786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37787. */
  37788. spatialSound: boolean;
  37789. /**
  37790. * Define the reference distance the sound should be heard perfectly.
  37791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37792. */
  37793. refDistance: number;
  37794. /**
  37795. * Define the roll off factor of spatial sounds.
  37796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37797. */
  37798. rolloffFactor: number;
  37799. /**
  37800. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37802. */
  37803. maxDistance: number;
  37804. /**
  37805. * Define the distance attenuation model the sound will follow.
  37806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37807. */
  37808. distanceModel: string;
  37809. /**
  37810. * @hidden
  37811. * Back Compat
  37812. **/
  37813. onended: () => any;
  37814. /**
  37815. * Observable event when the current playing sound finishes.
  37816. */
  37817. onEndedObservable: Observable<Sound>;
  37818. private _panningModel;
  37819. private _playbackRate;
  37820. private _streaming;
  37821. private _startTime;
  37822. private _startOffset;
  37823. private _position;
  37824. /** @hidden */
  37825. _positionInEmitterSpace: boolean;
  37826. private _localDirection;
  37827. private _volume;
  37828. private _isReadyToPlay;
  37829. private _isDirectional;
  37830. private _readyToPlayCallback;
  37831. private _audioBuffer;
  37832. private _soundSource;
  37833. private _streamingSource;
  37834. private _soundPanner;
  37835. private _soundGain;
  37836. private _inputAudioNode;
  37837. private _outputAudioNode;
  37838. private _coneInnerAngle;
  37839. private _coneOuterAngle;
  37840. private _coneOuterGain;
  37841. private _scene;
  37842. private _connectedTransformNode;
  37843. private _customAttenuationFunction;
  37844. private _registerFunc;
  37845. private _isOutputConnected;
  37846. private _htmlAudioElement;
  37847. private _urlType;
  37848. private _length?;
  37849. private _offset?;
  37850. /** @hidden */
  37851. static _SceneComponentInitialization: (scene: Scene) => void;
  37852. /**
  37853. * Create a sound and attach it to a scene
  37854. * @param name Name of your sound
  37855. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37856. * @param scene defines the scene the sound belongs to
  37857. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37858. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37859. */
  37860. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37861. /**
  37862. * Release the sound and its associated resources
  37863. */
  37864. dispose(): void;
  37865. /**
  37866. * Gets if the sounds is ready to be played or not.
  37867. * @returns true if ready, otherwise false
  37868. */
  37869. isReady(): boolean;
  37870. private _soundLoaded;
  37871. /**
  37872. * Sets the data of the sound from an audiobuffer
  37873. * @param audioBuffer The audioBuffer containing the data
  37874. */
  37875. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37876. /**
  37877. * Updates the current sounds options such as maxdistance, loop...
  37878. * @param options A JSON object containing values named as the object properties
  37879. */
  37880. updateOptions(options: ISoundOptions): void;
  37881. private _createSpatialParameters;
  37882. private _updateSpatialParameters;
  37883. /**
  37884. * Switch the panning model to HRTF:
  37885. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37887. */
  37888. switchPanningModelToHRTF(): void;
  37889. /**
  37890. * Switch the panning model to Equal Power:
  37891. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37893. */
  37894. switchPanningModelToEqualPower(): void;
  37895. private _switchPanningModel;
  37896. /**
  37897. * Connect this sound to a sound track audio node like gain...
  37898. * @param soundTrackAudioNode the sound track audio node to connect to
  37899. */
  37900. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37901. /**
  37902. * Transform this sound into a directional source
  37903. * @param coneInnerAngle Size of the inner cone in degree
  37904. * @param coneOuterAngle Size of the outer cone in degree
  37905. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37906. */
  37907. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37908. /**
  37909. * Gets or sets the inner angle for the directional cone.
  37910. */
  37911. get directionalConeInnerAngle(): number;
  37912. /**
  37913. * Gets or sets the inner angle for the directional cone.
  37914. */
  37915. set directionalConeInnerAngle(value: number);
  37916. /**
  37917. * Gets or sets the outer angle for the directional cone.
  37918. */
  37919. get directionalConeOuterAngle(): number;
  37920. /**
  37921. * Gets or sets the outer angle for the directional cone.
  37922. */
  37923. set directionalConeOuterAngle(value: number);
  37924. /**
  37925. * Sets the position of the emitter if spatial sound is enabled
  37926. * @param newPosition Defines the new posisiton
  37927. */
  37928. setPosition(newPosition: Vector3): void;
  37929. /**
  37930. * Sets the local direction of the emitter if spatial sound is enabled
  37931. * @param newLocalDirection Defines the new local direction
  37932. */
  37933. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37934. private _updateDirection;
  37935. /** @hidden */
  37936. updateDistanceFromListener(): void;
  37937. /**
  37938. * Sets a new custom attenuation function for the sound.
  37939. * @param callback Defines the function used for the attenuation
  37940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37941. */
  37942. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37943. /**
  37944. * Play the sound
  37945. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37946. * @param offset (optional) Start the sound at a specific time in seconds
  37947. * @param length (optional) Sound duration (in seconds)
  37948. */
  37949. play(time?: number, offset?: number, length?: number): void;
  37950. private _onended;
  37951. /**
  37952. * Stop the sound
  37953. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37954. */
  37955. stop(time?: number): void;
  37956. /**
  37957. * Put the sound in pause
  37958. */
  37959. pause(): void;
  37960. /**
  37961. * Sets a dedicated volume for this sounds
  37962. * @param newVolume Define the new volume of the sound
  37963. * @param time Define time for gradual change to new volume
  37964. */
  37965. setVolume(newVolume: number, time?: number): void;
  37966. /**
  37967. * Set the sound play back rate
  37968. * @param newPlaybackRate Define the playback rate the sound should be played at
  37969. */
  37970. setPlaybackRate(newPlaybackRate: number): void;
  37971. /**
  37972. * Gets the volume of the sound.
  37973. * @returns the volume of the sound
  37974. */
  37975. getVolume(): number;
  37976. /**
  37977. * Attach the sound to a dedicated mesh
  37978. * @param transformNode The transform node to connect the sound with
  37979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37980. */
  37981. attachToMesh(transformNode: TransformNode): void;
  37982. /**
  37983. * Detach the sound from the previously attached mesh
  37984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37985. */
  37986. detachFromMesh(): void;
  37987. private _onRegisterAfterWorldMatrixUpdate;
  37988. /**
  37989. * Clone the current sound in the scene.
  37990. * @returns the new sound clone
  37991. */
  37992. clone(): Nullable<Sound>;
  37993. /**
  37994. * Gets the current underlying audio buffer containing the data
  37995. * @returns the audio buffer
  37996. */
  37997. getAudioBuffer(): Nullable<AudioBuffer>;
  37998. /**
  37999. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38000. * @returns the source node
  38001. */
  38002. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38003. /**
  38004. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38005. * @returns the gain node
  38006. */
  38007. getSoundGain(): Nullable<GainNode>;
  38008. /**
  38009. * Serializes the Sound in a JSON representation
  38010. * @returns the JSON representation of the sound
  38011. */
  38012. serialize(): any;
  38013. /**
  38014. * Parse a JSON representation of a sound to innstantiate in a given scene
  38015. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38016. * @param scene Define the scene the new parsed sound should be created in
  38017. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38018. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38019. * @returns the newly parsed sound
  38020. */
  38021. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38022. }
  38023. }
  38024. declare module BABYLON {
  38025. /**
  38026. * This defines an action helpful to play a defined sound on a triggered action.
  38027. */
  38028. export class PlaySoundAction extends Action {
  38029. private _sound;
  38030. /**
  38031. * Instantiate the action
  38032. * @param triggerOptions defines the trigger options
  38033. * @param sound defines the sound to play
  38034. * @param condition defines the trigger related conditions
  38035. */
  38036. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38037. /** @hidden */
  38038. _prepare(): void;
  38039. /**
  38040. * Execute the action and play the sound.
  38041. */
  38042. execute(): void;
  38043. /**
  38044. * Serializes the actions and its related information.
  38045. * @param parent defines the object to serialize in
  38046. * @returns the serialized object
  38047. */
  38048. serialize(parent: any): any;
  38049. }
  38050. /**
  38051. * This defines an action helpful to stop a defined sound on a triggered action.
  38052. */
  38053. export class StopSoundAction extends Action {
  38054. private _sound;
  38055. /**
  38056. * Instantiate the action
  38057. * @param triggerOptions defines the trigger options
  38058. * @param sound defines the sound to stop
  38059. * @param condition defines the trigger related conditions
  38060. */
  38061. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38062. /** @hidden */
  38063. _prepare(): void;
  38064. /**
  38065. * Execute the action and stop the sound.
  38066. */
  38067. execute(): void;
  38068. /**
  38069. * Serializes the actions and its related information.
  38070. * @param parent defines the object to serialize in
  38071. * @returns the serialized object
  38072. */
  38073. serialize(parent: any): any;
  38074. }
  38075. }
  38076. declare module BABYLON {
  38077. /**
  38078. * This defines an action responsible to change the value of a property
  38079. * by interpolating between its current value and the newly set one once triggered.
  38080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38081. */
  38082. export class InterpolateValueAction extends Action {
  38083. /**
  38084. * Defines the path of the property where the value should be interpolated
  38085. */
  38086. propertyPath: string;
  38087. /**
  38088. * Defines the target value at the end of the interpolation.
  38089. */
  38090. value: any;
  38091. /**
  38092. * Defines the time it will take for the property to interpolate to the value.
  38093. */
  38094. duration: number;
  38095. /**
  38096. * Defines if the other scene animations should be stopped when the action has been triggered
  38097. */
  38098. stopOtherAnimations?: boolean;
  38099. /**
  38100. * Defines a callback raised once the interpolation animation has been done.
  38101. */
  38102. onInterpolationDone?: () => void;
  38103. /**
  38104. * Observable triggered once the interpolation animation has been done.
  38105. */
  38106. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38107. private _target;
  38108. private _effectiveTarget;
  38109. private _property;
  38110. /**
  38111. * Instantiate the action
  38112. * @param triggerOptions defines the trigger options
  38113. * @param target defines the object containing the value to interpolate
  38114. * @param propertyPath defines the path to the property in the target object
  38115. * @param value defines the target value at the end of the interpolation
  38116. * @param duration deines the time it will take for the property to interpolate to the value.
  38117. * @param condition defines the trigger related conditions
  38118. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38119. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38120. */
  38121. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38122. /** @hidden */
  38123. _prepare(): void;
  38124. /**
  38125. * Execute the action starts the value interpolation.
  38126. */
  38127. execute(): void;
  38128. /**
  38129. * Serializes the actions and its related information.
  38130. * @param parent defines the object to serialize in
  38131. * @returns the serialized object
  38132. */
  38133. serialize(parent: any): any;
  38134. }
  38135. }
  38136. declare module BABYLON {
  38137. /**
  38138. * Options allowed during the creation of a sound track.
  38139. */
  38140. export interface ISoundTrackOptions {
  38141. /**
  38142. * The volume the sound track should take during creation
  38143. */
  38144. volume?: number;
  38145. /**
  38146. * Define if the sound track is the main sound track of the scene
  38147. */
  38148. mainTrack?: boolean;
  38149. }
  38150. /**
  38151. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38152. * It will be also used in a future release to apply effects on a specific track.
  38153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38154. */
  38155. export class SoundTrack {
  38156. /**
  38157. * The unique identifier of the sound track in the scene.
  38158. */
  38159. id: number;
  38160. /**
  38161. * The list of sounds included in the sound track.
  38162. */
  38163. soundCollection: Array<Sound>;
  38164. private _outputAudioNode;
  38165. private _scene;
  38166. private _connectedAnalyser;
  38167. private _options;
  38168. private _isInitialized;
  38169. /**
  38170. * Creates a new sound track.
  38171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38172. * @param scene Define the scene the sound track belongs to
  38173. * @param options
  38174. */
  38175. constructor(scene: Scene, options?: ISoundTrackOptions);
  38176. private _initializeSoundTrackAudioGraph;
  38177. /**
  38178. * Release the sound track and its associated resources
  38179. */
  38180. dispose(): void;
  38181. /**
  38182. * Adds a sound to this sound track
  38183. * @param sound define the cound to add
  38184. * @ignoreNaming
  38185. */
  38186. AddSound(sound: Sound): void;
  38187. /**
  38188. * Removes a sound to this sound track
  38189. * @param sound define the cound to remove
  38190. * @ignoreNaming
  38191. */
  38192. RemoveSound(sound: Sound): void;
  38193. /**
  38194. * Set a global volume for the full sound track.
  38195. * @param newVolume Define the new volume of the sound track
  38196. */
  38197. setVolume(newVolume: number): void;
  38198. /**
  38199. * Switch the panning model to HRTF:
  38200. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38202. */
  38203. switchPanningModelToHRTF(): void;
  38204. /**
  38205. * Switch the panning model to Equal Power:
  38206. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38208. */
  38209. switchPanningModelToEqualPower(): void;
  38210. /**
  38211. * Connect the sound track to an audio analyser allowing some amazing
  38212. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38214. * @param analyser The analyser to connect to the engine
  38215. */
  38216. connectToAnalyser(analyser: Analyser): void;
  38217. }
  38218. }
  38219. declare module BABYLON {
  38220. interface AbstractScene {
  38221. /**
  38222. * The list of sounds used in the scene.
  38223. */
  38224. sounds: Nullable<Array<Sound>>;
  38225. }
  38226. interface Scene {
  38227. /**
  38228. * @hidden
  38229. * Backing field
  38230. */
  38231. _mainSoundTrack: SoundTrack;
  38232. /**
  38233. * The main sound track played by the scene.
  38234. * It cotains your primary collection of sounds.
  38235. */
  38236. mainSoundTrack: SoundTrack;
  38237. /**
  38238. * The list of sound tracks added to the scene
  38239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38240. */
  38241. soundTracks: Nullable<Array<SoundTrack>>;
  38242. /**
  38243. * Gets a sound using a given name
  38244. * @param name defines the name to search for
  38245. * @return the found sound or null if not found at all.
  38246. */
  38247. getSoundByName(name: string): Nullable<Sound>;
  38248. /**
  38249. * Gets or sets if audio support is enabled
  38250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38251. */
  38252. audioEnabled: boolean;
  38253. /**
  38254. * Gets or sets if audio will be output to headphones
  38255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38256. */
  38257. headphone: boolean;
  38258. /**
  38259. * Gets or sets custom audio listener position provider
  38260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38261. */
  38262. audioListenerPositionProvider: Nullable<() => Vector3>;
  38263. /**
  38264. * Gets or sets a refresh rate when using 3D audio positioning
  38265. */
  38266. audioPositioningRefreshRate: number;
  38267. }
  38268. /**
  38269. * Defines the sound scene component responsible to manage any sounds
  38270. * in a given scene.
  38271. */
  38272. export class AudioSceneComponent implements ISceneSerializableComponent {
  38273. /**
  38274. * The component name helpfull to identify the component in the list of scene components.
  38275. */
  38276. readonly name: string;
  38277. /**
  38278. * The scene the component belongs to.
  38279. */
  38280. scene: Scene;
  38281. private _audioEnabled;
  38282. /**
  38283. * Gets whether audio is enabled or not.
  38284. * Please use related enable/disable method to switch state.
  38285. */
  38286. get audioEnabled(): boolean;
  38287. private _headphone;
  38288. /**
  38289. * Gets whether audio is outputing to headphone or not.
  38290. * Please use the according Switch methods to change output.
  38291. */
  38292. get headphone(): boolean;
  38293. /**
  38294. * Gets or sets a refresh rate when using 3D audio positioning
  38295. */
  38296. audioPositioningRefreshRate: number;
  38297. private _audioListenerPositionProvider;
  38298. /**
  38299. * Gets the current audio listener position provider
  38300. */
  38301. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38302. /**
  38303. * Sets a custom listener position for all sounds in the scene
  38304. * By default, this is the position of the first active camera
  38305. */
  38306. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38307. /**
  38308. * Creates a new instance of the component for the given scene
  38309. * @param scene Defines the scene to register the component in
  38310. */
  38311. constructor(scene: Scene);
  38312. /**
  38313. * Registers the component in a given scene
  38314. */
  38315. register(): void;
  38316. /**
  38317. * Rebuilds the elements related to this component in case of
  38318. * context lost for instance.
  38319. */
  38320. rebuild(): void;
  38321. /**
  38322. * Serializes the component data to the specified json object
  38323. * @param serializationObject The object to serialize to
  38324. */
  38325. serialize(serializationObject: any): void;
  38326. /**
  38327. * Adds all the elements from the container to the scene
  38328. * @param container the container holding the elements
  38329. */
  38330. addFromContainer(container: AbstractScene): void;
  38331. /**
  38332. * Removes all the elements in the container from the scene
  38333. * @param container contains the elements to remove
  38334. * @param dispose if the removed element should be disposed (default: false)
  38335. */
  38336. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38337. /**
  38338. * Disposes the component and the associated ressources.
  38339. */
  38340. dispose(): void;
  38341. /**
  38342. * Disables audio in the associated scene.
  38343. */
  38344. disableAudio(): void;
  38345. /**
  38346. * Enables audio in the associated scene.
  38347. */
  38348. enableAudio(): void;
  38349. /**
  38350. * Switch audio to headphone output.
  38351. */
  38352. switchAudioModeForHeadphones(): void;
  38353. /**
  38354. * Switch audio to normal speakers.
  38355. */
  38356. switchAudioModeForNormalSpeakers(): void;
  38357. private _cachedCameraDirection;
  38358. private _cachedCameraPosition;
  38359. private _lastCheck;
  38360. private _afterRender;
  38361. }
  38362. }
  38363. declare module BABYLON {
  38364. /**
  38365. * Wraps one or more Sound objects and selects one with random weight for playback.
  38366. */
  38367. export class WeightedSound {
  38368. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38369. loop: boolean;
  38370. private _coneInnerAngle;
  38371. private _coneOuterAngle;
  38372. private _volume;
  38373. /** A Sound is currently playing. */
  38374. isPlaying: boolean;
  38375. /** A Sound is currently paused. */
  38376. isPaused: boolean;
  38377. private _sounds;
  38378. private _weights;
  38379. private _currentIndex?;
  38380. /**
  38381. * Creates a new WeightedSound from the list of sounds given.
  38382. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38383. * @param sounds Array of Sounds that will be selected from.
  38384. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38385. */
  38386. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38387. /**
  38388. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38389. */
  38390. get directionalConeInnerAngle(): number;
  38391. /**
  38392. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38393. */
  38394. set directionalConeInnerAngle(value: number);
  38395. /**
  38396. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38397. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38398. */
  38399. get directionalConeOuterAngle(): number;
  38400. /**
  38401. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38402. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38403. */
  38404. set directionalConeOuterAngle(value: number);
  38405. /**
  38406. * Playback volume.
  38407. */
  38408. get volume(): number;
  38409. /**
  38410. * Playback volume.
  38411. */
  38412. set volume(value: number);
  38413. private _onended;
  38414. /**
  38415. * Suspend playback
  38416. */
  38417. pause(): void;
  38418. /**
  38419. * Stop playback
  38420. */
  38421. stop(): void;
  38422. /**
  38423. * Start playback.
  38424. * @param startOffset Position the clip head at a specific time in seconds.
  38425. */
  38426. play(startOffset?: number): void;
  38427. }
  38428. }
  38429. declare module BABYLON {
  38430. /**
  38431. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38433. */
  38434. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38435. /**
  38436. * Gets the name of the behavior.
  38437. */
  38438. get name(): string;
  38439. /**
  38440. * The easing function used by animations
  38441. */
  38442. static EasingFunction: BackEase;
  38443. /**
  38444. * The easing mode used by animations
  38445. */
  38446. static EasingMode: number;
  38447. /**
  38448. * The duration of the animation, in milliseconds
  38449. */
  38450. transitionDuration: number;
  38451. /**
  38452. * Length of the distance animated by the transition when lower radius is reached
  38453. */
  38454. lowerRadiusTransitionRange: number;
  38455. /**
  38456. * Length of the distance animated by the transition when upper radius is reached
  38457. */
  38458. upperRadiusTransitionRange: number;
  38459. private _autoTransitionRange;
  38460. /**
  38461. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38462. */
  38463. get autoTransitionRange(): boolean;
  38464. /**
  38465. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38466. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38467. */
  38468. set autoTransitionRange(value: boolean);
  38469. private _attachedCamera;
  38470. private _onAfterCheckInputsObserver;
  38471. private _onMeshTargetChangedObserver;
  38472. /**
  38473. * Initializes the behavior.
  38474. */
  38475. init(): void;
  38476. /**
  38477. * Attaches the behavior to its arc rotate camera.
  38478. * @param camera Defines the camera to attach the behavior to
  38479. */
  38480. attach(camera: ArcRotateCamera): void;
  38481. /**
  38482. * Detaches the behavior from its current arc rotate camera.
  38483. */
  38484. detach(): void;
  38485. private _radiusIsAnimating;
  38486. private _radiusBounceTransition;
  38487. private _animatables;
  38488. private _cachedWheelPrecision;
  38489. /**
  38490. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38491. * @param radiusLimit The limit to check against.
  38492. * @return Bool to indicate if at limit.
  38493. */
  38494. private _isRadiusAtLimit;
  38495. /**
  38496. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38497. * @param radiusDelta The delta by which to animate to. Can be negative.
  38498. */
  38499. private _applyBoundRadiusAnimation;
  38500. /**
  38501. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38502. */
  38503. protected _clearAnimationLocks(): void;
  38504. /**
  38505. * Stops and removes all animations that have been applied to the camera
  38506. */
  38507. stopAllAnimations(): void;
  38508. }
  38509. }
  38510. declare module BABYLON {
  38511. /**
  38512. * 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.
  38513. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38514. */
  38515. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38516. /**
  38517. * Gets the name of the behavior.
  38518. */
  38519. get name(): string;
  38520. private _mode;
  38521. private _radiusScale;
  38522. private _positionScale;
  38523. private _defaultElevation;
  38524. private _elevationReturnTime;
  38525. private _elevationReturnWaitTime;
  38526. private _zoomStopsAnimation;
  38527. private _framingTime;
  38528. /**
  38529. * The easing function used by animations
  38530. */
  38531. static EasingFunction: ExponentialEase;
  38532. /**
  38533. * The easing mode used by animations
  38534. */
  38535. static EasingMode: number;
  38536. /**
  38537. * Sets the current mode used by the behavior
  38538. */
  38539. set mode(mode: number);
  38540. /**
  38541. * Gets current mode used by the behavior.
  38542. */
  38543. get mode(): number;
  38544. /**
  38545. * Sets the scale applied to the radius (1 by default)
  38546. */
  38547. set radiusScale(radius: number);
  38548. /**
  38549. * Gets the scale applied to the radius
  38550. */
  38551. get radiusScale(): number;
  38552. /**
  38553. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38554. */
  38555. set positionScale(scale: number);
  38556. /**
  38557. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38558. */
  38559. get positionScale(): number;
  38560. /**
  38561. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38562. * behaviour is triggered, in radians.
  38563. */
  38564. set defaultElevation(elevation: number);
  38565. /**
  38566. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38567. * behaviour is triggered, in radians.
  38568. */
  38569. get defaultElevation(): number;
  38570. /**
  38571. * Sets the time (in milliseconds) taken to return to the default beta position.
  38572. * Negative value indicates camera should not return to default.
  38573. */
  38574. set elevationReturnTime(speed: number);
  38575. /**
  38576. * Gets the time (in milliseconds) taken to return to the default beta position.
  38577. * Negative value indicates camera should not return to default.
  38578. */
  38579. get elevationReturnTime(): number;
  38580. /**
  38581. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38582. */
  38583. set elevationReturnWaitTime(time: number);
  38584. /**
  38585. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38586. */
  38587. get elevationReturnWaitTime(): number;
  38588. /**
  38589. * Sets the flag that indicates if user zooming should stop animation.
  38590. */
  38591. set zoomStopsAnimation(flag: boolean);
  38592. /**
  38593. * Gets the flag that indicates if user zooming should stop animation.
  38594. */
  38595. get zoomStopsAnimation(): boolean;
  38596. /**
  38597. * Sets the transition time when framing the mesh, in milliseconds
  38598. */
  38599. set framingTime(time: number);
  38600. /**
  38601. * Gets the transition time when framing the mesh, in milliseconds
  38602. */
  38603. get framingTime(): number;
  38604. /**
  38605. * Define if the behavior should automatically change the configured
  38606. * camera limits and sensibilities.
  38607. */
  38608. autoCorrectCameraLimitsAndSensibility: boolean;
  38609. private _onPrePointerObservableObserver;
  38610. private _onAfterCheckInputsObserver;
  38611. private _onMeshTargetChangedObserver;
  38612. private _attachedCamera;
  38613. private _isPointerDown;
  38614. private _lastInteractionTime;
  38615. /**
  38616. * Initializes the behavior.
  38617. */
  38618. init(): void;
  38619. /**
  38620. * Attaches the behavior to its arc rotate camera.
  38621. * @param camera Defines the camera to attach the behavior to
  38622. */
  38623. attach(camera: ArcRotateCamera): void;
  38624. /**
  38625. * Detaches the behavior from its current arc rotate camera.
  38626. */
  38627. detach(): void;
  38628. private _animatables;
  38629. private _betaIsAnimating;
  38630. private _betaTransition;
  38631. private _radiusTransition;
  38632. private _vectorTransition;
  38633. /**
  38634. * Targets the given mesh and updates zoom level accordingly.
  38635. * @param mesh The mesh to target.
  38636. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38637. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38638. */
  38639. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38640. /**
  38641. * Targets the given mesh with its children and updates zoom level accordingly.
  38642. * @param mesh The mesh to target.
  38643. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38644. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38645. */
  38646. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38647. /**
  38648. * Targets the given meshes with their children and updates zoom level accordingly.
  38649. * @param meshes The mesh to target.
  38650. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38651. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38652. */
  38653. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38654. /**
  38655. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38656. * @param minimumWorld Determines the smaller position of the bounding box extend
  38657. * @param maximumWorld Determines the bigger position of the bounding box extend
  38658. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38659. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38660. */
  38661. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38662. /**
  38663. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38664. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38665. * frustum width.
  38666. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38667. * to fully enclose the mesh in the viewing frustum.
  38668. */
  38669. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38670. /**
  38671. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38672. * is automatically returned to its default position (expected to be above ground plane).
  38673. */
  38674. private _maintainCameraAboveGround;
  38675. /**
  38676. * Returns the frustum slope based on the canvas ratio and camera FOV
  38677. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38678. */
  38679. private _getFrustumSlope;
  38680. /**
  38681. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38682. */
  38683. private _clearAnimationLocks;
  38684. /**
  38685. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38686. */
  38687. private _applyUserInteraction;
  38688. /**
  38689. * Stops and removes all animations that have been applied to the camera
  38690. */
  38691. stopAllAnimations(): void;
  38692. /**
  38693. * Gets a value indicating if the user is moving the camera
  38694. */
  38695. get isUserIsMoving(): boolean;
  38696. /**
  38697. * The camera can move all the way towards the mesh.
  38698. */
  38699. static IgnoreBoundsSizeMode: number;
  38700. /**
  38701. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38702. */
  38703. static FitFrustumSidesMode: number;
  38704. }
  38705. }
  38706. declare module BABYLON {
  38707. /**
  38708. * Base class for Camera Pointer Inputs.
  38709. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38710. * for example usage.
  38711. */
  38712. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38713. /**
  38714. * Defines the camera the input is attached to.
  38715. */
  38716. abstract camera: Camera;
  38717. /**
  38718. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38719. */
  38720. protected _altKey: boolean;
  38721. protected _ctrlKey: boolean;
  38722. protected _metaKey: boolean;
  38723. protected _shiftKey: boolean;
  38724. /**
  38725. * Which mouse buttons were pressed at time of last mouse event.
  38726. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38727. */
  38728. protected _buttonsPressed: number;
  38729. /**
  38730. * Defines the buttons associated with the input to handle camera move.
  38731. */
  38732. buttons: number[];
  38733. /**
  38734. * Attach the input controls to a specific dom element to get the input from.
  38735. * @param element Defines the element the controls should be listened from
  38736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38737. */
  38738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38739. /**
  38740. * Detach the current controls from the specified dom element.
  38741. * @param element Defines the element to stop listening the inputs from
  38742. */
  38743. detachControl(element: Nullable<HTMLElement>): void;
  38744. /**
  38745. * Gets the class name of the current input.
  38746. * @returns the class name
  38747. */
  38748. getClassName(): string;
  38749. /**
  38750. * Get the friendly name associated with the input class.
  38751. * @returns the input friendly name
  38752. */
  38753. getSimpleName(): string;
  38754. /**
  38755. * Called on pointer POINTERDOUBLETAP event.
  38756. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38757. */
  38758. protected onDoubleTap(type: string): void;
  38759. /**
  38760. * Called on pointer POINTERMOVE event if only a single touch is active.
  38761. * Override this method to provide functionality.
  38762. */
  38763. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38764. /**
  38765. * Called on pointer POINTERMOVE event if multiple touches are active.
  38766. * Override this method to provide functionality.
  38767. */
  38768. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38769. /**
  38770. * Called on JS contextmenu event.
  38771. * Override this method to provide functionality.
  38772. */
  38773. protected onContextMenu(evt: PointerEvent): void;
  38774. /**
  38775. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38776. * press.
  38777. * Override this method to provide functionality.
  38778. */
  38779. protected onButtonDown(evt: PointerEvent): void;
  38780. /**
  38781. * Called each time a new POINTERUP event occurs. Ie, for each button
  38782. * release.
  38783. * Override this method to provide functionality.
  38784. */
  38785. protected onButtonUp(evt: PointerEvent): void;
  38786. /**
  38787. * Called when window becomes inactive.
  38788. * Override this method to provide functionality.
  38789. */
  38790. protected onLostFocus(): void;
  38791. private _pointerInput;
  38792. private _observer;
  38793. private _onLostFocus;
  38794. private pointA;
  38795. private pointB;
  38796. }
  38797. }
  38798. declare module BABYLON {
  38799. /**
  38800. * Manage the pointers inputs to control an arc rotate camera.
  38801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38802. */
  38803. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38804. /**
  38805. * Defines the camera the input is attached to.
  38806. */
  38807. camera: ArcRotateCamera;
  38808. /**
  38809. * Gets the class name of the current input.
  38810. * @returns the class name
  38811. */
  38812. getClassName(): string;
  38813. /**
  38814. * Defines the buttons associated with the input to handle camera move.
  38815. */
  38816. buttons: number[];
  38817. /**
  38818. * Defines the pointer angular sensibility along the X axis or how fast is
  38819. * the camera rotating.
  38820. */
  38821. angularSensibilityX: number;
  38822. /**
  38823. * Defines the pointer angular sensibility along the Y axis or how fast is
  38824. * the camera rotating.
  38825. */
  38826. angularSensibilityY: number;
  38827. /**
  38828. * Defines the pointer pinch precision or how fast is the camera zooming.
  38829. */
  38830. pinchPrecision: number;
  38831. /**
  38832. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38833. * from 0.
  38834. * It defines the percentage of current camera.radius to use as delta when
  38835. * pinch zoom is used.
  38836. */
  38837. pinchDeltaPercentage: number;
  38838. /**
  38839. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38840. * that any object in the plane at the camera's target point will scale
  38841. * perfectly with finger motion.
  38842. * Overrides pinchDeltaPercentage and pinchPrecision.
  38843. */
  38844. useNaturalPinchZoom: boolean;
  38845. /**
  38846. * Defines the pointer panning sensibility or how fast is the camera moving.
  38847. */
  38848. panningSensibility: number;
  38849. /**
  38850. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38851. */
  38852. multiTouchPanning: boolean;
  38853. /**
  38854. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38855. * zoom (pinch) through multitouch.
  38856. */
  38857. multiTouchPanAndZoom: boolean;
  38858. /**
  38859. * Revers pinch action direction.
  38860. */
  38861. pinchInwards: boolean;
  38862. private _isPanClick;
  38863. private _twoFingerActivityCount;
  38864. private _isPinching;
  38865. /**
  38866. * Called on pointer POINTERMOVE event if only a single touch is active.
  38867. */
  38868. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38869. /**
  38870. * Called on pointer POINTERDOUBLETAP event.
  38871. */
  38872. protected onDoubleTap(type: string): void;
  38873. /**
  38874. * Called on pointer POINTERMOVE event if multiple touches are active.
  38875. */
  38876. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38877. /**
  38878. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38879. * press.
  38880. */
  38881. protected onButtonDown(evt: PointerEvent): void;
  38882. /**
  38883. * Called each time a new POINTERUP event occurs. Ie, for each button
  38884. * release.
  38885. */
  38886. protected onButtonUp(evt: PointerEvent): void;
  38887. /**
  38888. * Called when window becomes inactive.
  38889. */
  38890. protected onLostFocus(): void;
  38891. }
  38892. }
  38893. declare module BABYLON {
  38894. /**
  38895. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38897. */
  38898. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38899. /**
  38900. * Defines the camera the input is attached to.
  38901. */
  38902. camera: ArcRotateCamera;
  38903. /**
  38904. * Defines the list of key codes associated with the up action (increase alpha)
  38905. */
  38906. keysUp: number[];
  38907. /**
  38908. * Defines the list of key codes associated with the down action (decrease alpha)
  38909. */
  38910. keysDown: number[];
  38911. /**
  38912. * Defines the list of key codes associated with the left action (increase beta)
  38913. */
  38914. keysLeft: number[];
  38915. /**
  38916. * Defines the list of key codes associated with the right action (decrease beta)
  38917. */
  38918. keysRight: number[];
  38919. /**
  38920. * Defines the list of key codes associated with the reset action.
  38921. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38922. */
  38923. keysReset: number[];
  38924. /**
  38925. * Defines the panning sensibility of the inputs.
  38926. * (How fast is the camera panning)
  38927. */
  38928. panningSensibility: number;
  38929. /**
  38930. * Defines the zooming sensibility of the inputs.
  38931. * (How fast is the camera zooming)
  38932. */
  38933. zoomingSensibility: number;
  38934. /**
  38935. * Defines whether maintaining the alt key down switch the movement mode from
  38936. * orientation to zoom.
  38937. */
  38938. useAltToZoom: boolean;
  38939. /**
  38940. * Rotation speed of the camera
  38941. */
  38942. angularSpeed: number;
  38943. private _keys;
  38944. private _ctrlPressed;
  38945. private _altPressed;
  38946. private _onCanvasBlurObserver;
  38947. private _onKeyboardObserver;
  38948. private _engine;
  38949. private _scene;
  38950. /**
  38951. * Attach the input controls to a specific dom element to get the input from.
  38952. * @param element Defines the element the controls should be listened from
  38953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38954. */
  38955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38956. /**
  38957. * Detach the current controls from the specified dom element.
  38958. * @param element Defines the element to stop listening the inputs from
  38959. */
  38960. detachControl(element: Nullable<HTMLElement>): void;
  38961. /**
  38962. * Update the current camera state depending on the inputs that have been used this frame.
  38963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38964. */
  38965. checkInputs(): void;
  38966. /**
  38967. * Gets the class name of the current intput.
  38968. * @returns the class name
  38969. */
  38970. getClassName(): string;
  38971. /**
  38972. * Get the friendly name associated with the input class.
  38973. * @returns the input friendly name
  38974. */
  38975. getSimpleName(): string;
  38976. }
  38977. }
  38978. declare module BABYLON {
  38979. /**
  38980. * Manage the mouse wheel inputs to control an arc rotate camera.
  38981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38982. */
  38983. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38984. /**
  38985. * Defines the camera the input is attached to.
  38986. */
  38987. camera: ArcRotateCamera;
  38988. /**
  38989. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38990. */
  38991. wheelPrecision: number;
  38992. /**
  38993. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38994. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38995. */
  38996. wheelDeltaPercentage: number;
  38997. private _wheel;
  38998. private _observer;
  38999. private computeDeltaFromMouseWheelLegacyEvent;
  39000. /**
  39001. * Attach the input controls to a specific dom element to get the input from.
  39002. * @param element Defines the element the controls should be listened from
  39003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39004. */
  39005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39006. /**
  39007. * Detach the current controls from the specified dom element.
  39008. * @param element Defines the element to stop listening the inputs from
  39009. */
  39010. detachControl(element: Nullable<HTMLElement>): void;
  39011. /**
  39012. * Gets the class name of the current intput.
  39013. * @returns the class name
  39014. */
  39015. getClassName(): string;
  39016. /**
  39017. * Get the friendly name associated with the input class.
  39018. * @returns the input friendly name
  39019. */
  39020. getSimpleName(): string;
  39021. }
  39022. }
  39023. declare module BABYLON {
  39024. /**
  39025. * Default Inputs manager for the ArcRotateCamera.
  39026. * It groups all the default supported inputs for ease of use.
  39027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39028. */
  39029. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39030. /**
  39031. * Instantiates a new ArcRotateCameraInputsManager.
  39032. * @param camera Defines the camera the inputs belong to
  39033. */
  39034. constructor(camera: ArcRotateCamera);
  39035. /**
  39036. * Add mouse wheel input support to the input manager.
  39037. * @returns the current input manager
  39038. */
  39039. addMouseWheel(): ArcRotateCameraInputsManager;
  39040. /**
  39041. * Add pointers input support to the input manager.
  39042. * @returns the current input manager
  39043. */
  39044. addPointers(): ArcRotateCameraInputsManager;
  39045. /**
  39046. * Add keyboard input support to the input manager.
  39047. * @returns the current input manager
  39048. */
  39049. addKeyboard(): ArcRotateCameraInputsManager;
  39050. }
  39051. }
  39052. declare module BABYLON {
  39053. /**
  39054. * This represents an orbital type of camera.
  39055. *
  39056. * 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.
  39057. * 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.
  39058. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39059. */
  39060. export class ArcRotateCamera extends TargetCamera {
  39061. /**
  39062. * Defines the rotation angle of the camera along the longitudinal axis.
  39063. */
  39064. alpha: number;
  39065. /**
  39066. * Defines the rotation angle of the camera along the latitudinal axis.
  39067. */
  39068. beta: number;
  39069. /**
  39070. * Defines the radius of the camera from it s target point.
  39071. */
  39072. radius: number;
  39073. protected _target: Vector3;
  39074. protected _targetHost: Nullable<AbstractMesh>;
  39075. /**
  39076. * Defines the target point of the camera.
  39077. * The camera looks towards it form the radius distance.
  39078. */
  39079. get target(): Vector3;
  39080. set target(value: Vector3);
  39081. /**
  39082. * Define the current local position of the camera in the scene
  39083. */
  39084. get position(): Vector3;
  39085. set position(newPosition: Vector3);
  39086. protected _upVector: Vector3;
  39087. protected _upToYMatrix: Matrix;
  39088. protected _YToUpMatrix: Matrix;
  39089. /**
  39090. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39091. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39092. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39093. */
  39094. set upVector(vec: Vector3);
  39095. get upVector(): Vector3;
  39096. /**
  39097. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39098. */
  39099. setMatUp(): void;
  39100. /**
  39101. * Current inertia value on the longitudinal axis.
  39102. * The bigger this number the longer it will take for the camera to stop.
  39103. */
  39104. inertialAlphaOffset: number;
  39105. /**
  39106. * Current inertia value on the latitudinal axis.
  39107. * The bigger this number the longer it will take for the camera to stop.
  39108. */
  39109. inertialBetaOffset: number;
  39110. /**
  39111. * Current inertia value on the radius axis.
  39112. * The bigger this number the longer it will take for the camera to stop.
  39113. */
  39114. inertialRadiusOffset: number;
  39115. /**
  39116. * Minimum allowed angle on the longitudinal axis.
  39117. * This can help limiting how the Camera is able to move in the scene.
  39118. */
  39119. lowerAlphaLimit: Nullable<number>;
  39120. /**
  39121. * Maximum allowed angle on the longitudinal axis.
  39122. * This can help limiting how the Camera is able to move in the scene.
  39123. */
  39124. upperAlphaLimit: Nullable<number>;
  39125. /**
  39126. * Minimum allowed angle on the latitudinal axis.
  39127. * This can help limiting how the Camera is able to move in the scene.
  39128. */
  39129. lowerBetaLimit: number;
  39130. /**
  39131. * Maximum allowed angle on the latitudinal axis.
  39132. * This can help limiting how the Camera is able to move in the scene.
  39133. */
  39134. upperBetaLimit: number;
  39135. /**
  39136. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39137. * This can help limiting how the Camera is able to move in the scene.
  39138. */
  39139. lowerRadiusLimit: Nullable<number>;
  39140. /**
  39141. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39142. * This can help limiting how the Camera is able to move in the scene.
  39143. */
  39144. upperRadiusLimit: Nullable<number>;
  39145. /**
  39146. * Defines the current inertia value used during panning of the camera along the X axis.
  39147. */
  39148. inertialPanningX: number;
  39149. /**
  39150. * Defines the current inertia value used during panning of the camera along the Y axis.
  39151. */
  39152. inertialPanningY: number;
  39153. /**
  39154. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39155. * Basically if your fingers moves away from more than this distance you will be considered
  39156. * in pinch mode.
  39157. */
  39158. pinchToPanMaxDistance: number;
  39159. /**
  39160. * Defines the maximum distance the camera can pan.
  39161. * This could help keeping the cammera always in your scene.
  39162. */
  39163. panningDistanceLimit: Nullable<number>;
  39164. /**
  39165. * Defines the target of the camera before paning.
  39166. */
  39167. panningOriginTarget: Vector3;
  39168. /**
  39169. * Defines the value of the inertia used during panning.
  39170. * 0 would mean stop inertia and one would mean no decelleration at all.
  39171. */
  39172. panningInertia: number;
  39173. /**
  39174. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39175. */
  39176. get angularSensibilityX(): number;
  39177. set angularSensibilityX(value: number);
  39178. /**
  39179. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39180. */
  39181. get angularSensibilityY(): number;
  39182. set angularSensibilityY(value: number);
  39183. /**
  39184. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39185. */
  39186. get pinchPrecision(): number;
  39187. set pinchPrecision(value: number);
  39188. /**
  39189. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39190. * It will be used instead of pinchDeltaPrecision if different from 0.
  39191. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39192. */
  39193. get pinchDeltaPercentage(): number;
  39194. set pinchDeltaPercentage(value: number);
  39195. /**
  39196. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39197. * and pinch delta percentage.
  39198. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39199. * that any object in the plane at the camera's target point will scale
  39200. * perfectly with finger motion.
  39201. */
  39202. get useNaturalPinchZoom(): boolean;
  39203. set useNaturalPinchZoom(value: boolean);
  39204. /**
  39205. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39206. */
  39207. get panningSensibility(): number;
  39208. set panningSensibility(value: number);
  39209. /**
  39210. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39211. */
  39212. get keysUp(): number[];
  39213. set keysUp(value: number[]);
  39214. /**
  39215. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39216. */
  39217. get keysDown(): number[];
  39218. set keysDown(value: number[]);
  39219. /**
  39220. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39221. */
  39222. get keysLeft(): number[];
  39223. set keysLeft(value: number[]);
  39224. /**
  39225. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39226. */
  39227. get keysRight(): number[];
  39228. set keysRight(value: number[]);
  39229. /**
  39230. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39231. */
  39232. get wheelPrecision(): number;
  39233. set wheelPrecision(value: number);
  39234. /**
  39235. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39236. * It will be used instead of pinchDeltaPrecision if different from 0.
  39237. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39238. */
  39239. get wheelDeltaPercentage(): number;
  39240. set wheelDeltaPercentage(value: number);
  39241. /**
  39242. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39243. */
  39244. zoomOnFactor: number;
  39245. /**
  39246. * Defines a screen offset for the camera position.
  39247. */
  39248. targetScreenOffset: Vector2;
  39249. /**
  39250. * Allows the camera to be completely reversed.
  39251. * If false the camera can not arrive upside down.
  39252. */
  39253. allowUpsideDown: boolean;
  39254. /**
  39255. * Define if double tap/click is used to restore the previously saved state of the camera.
  39256. */
  39257. useInputToRestoreState: boolean;
  39258. /** @hidden */
  39259. _viewMatrix: Matrix;
  39260. /** @hidden */
  39261. _useCtrlForPanning: boolean;
  39262. /** @hidden */
  39263. _panningMouseButton: number;
  39264. /**
  39265. * Defines the input associated to the camera.
  39266. */
  39267. inputs: ArcRotateCameraInputsManager;
  39268. /** @hidden */
  39269. _reset: () => void;
  39270. /**
  39271. * Defines the allowed panning axis.
  39272. */
  39273. panningAxis: Vector3;
  39274. protected _localDirection: Vector3;
  39275. protected _transformedDirection: Vector3;
  39276. private _bouncingBehavior;
  39277. /**
  39278. * Gets the bouncing behavior of the camera if it has been enabled.
  39279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39280. */
  39281. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39282. /**
  39283. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39284. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39285. */
  39286. get useBouncingBehavior(): boolean;
  39287. set useBouncingBehavior(value: boolean);
  39288. private _framingBehavior;
  39289. /**
  39290. * Gets the framing behavior of the camera if it has been enabled.
  39291. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39292. */
  39293. get framingBehavior(): Nullable<FramingBehavior>;
  39294. /**
  39295. * Defines if the framing behavior of the camera is enabled on the camera.
  39296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39297. */
  39298. get useFramingBehavior(): boolean;
  39299. set useFramingBehavior(value: boolean);
  39300. private _autoRotationBehavior;
  39301. /**
  39302. * Gets the auto rotation behavior of the camera if it has been enabled.
  39303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39304. */
  39305. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39306. /**
  39307. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39309. */
  39310. get useAutoRotationBehavior(): boolean;
  39311. set useAutoRotationBehavior(value: boolean);
  39312. /**
  39313. * Observable triggered when the mesh target has been changed on the camera.
  39314. */
  39315. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39316. /**
  39317. * Event raised when the camera is colliding with a mesh.
  39318. */
  39319. onCollide: (collidedMesh: AbstractMesh) => void;
  39320. /**
  39321. * Defines whether the camera should check collision with the objects oh the scene.
  39322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39323. */
  39324. checkCollisions: boolean;
  39325. /**
  39326. * Defines the collision radius of the camera.
  39327. * This simulates a sphere around the camera.
  39328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39329. */
  39330. collisionRadius: Vector3;
  39331. protected _collider: Collider;
  39332. protected _previousPosition: Vector3;
  39333. protected _collisionVelocity: Vector3;
  39334. protected _newPosition: Vector3;
  39335. protected _previousAlpha: number;
  39336. protected _previousBeta: number;
  39337. protected _previousRadius: number;
  39338. protected _collisionTriggered: boolean;
  39339. protected _targetBoundingCenter: Nullable<Vector3>;
  39340. private _computationVector;
  39341. /**
  39342. * Instantiates a new ArcRotateCamera in a given scene
  39343. * @param name Defines the name of the camera
  39344. * @param alpha Defines the camera rotation along the logitudinal axis
  39345. * @param beta Defines the camera rotation along the latitudinal axis
  39346. * @param radius Defines the camera distance from its target
  39347. * @param target Defines the camera target
  39348. * @param scene Defines the scene the camera belongs to
  39349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39350. */
  39351. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39352. /** @hidden */
  39353. _initCache(): void;
  39354. /** @hidden */
  39355. _updateCache(ignoreParentClass?: boolean): void;
  39356. protected _getTargetPosition(): Vector3;
  39357. private _storedAlpha;
  39358. private _storedBeta;
  39359. private _storedRadius;
  39360. private _storedTarget;
  39361. private _storedTargetScreenOffset;
  39362. /**
  39363. * Stores the current state of the camera (alpha, beta, radius and target)
  39364. * @returns the camera itself
  39365. */
  39366. storeState(): Camera;
  39367. /**
  39368. * @hidden
  39369. * Restored camera state. You must call storeState() first
  39370. */
  39371. _restoreStateValues(): boolean;
  39372. /** @hidden */
  39373. _isSynchronizedViewMatrix(): boolean;
  39374. /**
  39375. * Attached controls to the current camera.
  39376. * @param element Defines the element the controls should be listened from
  39377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39378. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39379. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39380. */
  39381. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39382. /**
  39383. * Detach the current controls from the camera.
  39384. * The camera will stop reacting to inputs.
  39385. * @param element Defines the element to stop listening the inputs from
  39386. */
  39387. detachControl(element: HTMLElement): void;
  39388. /** @hidden */
  39389. _checkInputs(): void;
  39390. protected _checkLimits(): void;
  39391. /**
  39392. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39393. */
  39394. rebuildAnglesAndRadius(): void;
  39395. /**
  39396. * Use a position to define the current camera related information like alpha, beta and radius
  39397. * @param position Defines the position to set the camera at
  39398. */
  39399. setPosition(position: Vector3): void;
  39400. /**
  39401. * Defines the target the camera should look at.
  39402. * This will automatically adapt alpha beta and radius to fit within the new target.
  39403. * @param target Defines the new target as a Vector or a mesh
  39404. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39405. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39406. */
  39407. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39408. /** @hidden */
  39409. _getViewMatrix(): Matrix;
  39410. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39411. /**
  39412. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39413. * @param meshes Defines the mesh to zoom on
  39414. * @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)
  39415. */
  39416. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39417. /**
  39418. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39419. * The target will be changed but the radius
  39420. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39421. * @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)
  39422. */
  39423. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39424. min: Vector3;
  39425. max: Vector3;
  39426. distance: number;
  39427. }, doNotUpdateMaxZ?: boolean): void;
  39428. /**
  39429. * @override
  39430. * Override Camera.createRigCamera
  39431. */
  39432. createRigCamera(name: string, cameraIndex: number): Camera;
  39433. /**
  39434. * @hidden
  39435. * @override
  39436. * Override Camera._updateRigCameras
  39437. */
  39438. _updateRigCameras(): void;
  39439. /**
  39440. * Destroy the camera and release the current resources hold by it.
  39441. */
  39442. dispose(): void;
  39443. /**
  39444. * Gets the current object class name.
  39445. * @return the class name
  39446. */
  39447. getClassName(): string;
  39448. }
  39449. }
  39450. declare module BABYLON {
  39451. /**
  39452. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39453. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39454. */
  39455. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39456. /**
  39457. * Gets the name of the behavior.
  39458. */
  39459. get name(): string;
  39460. private _zoomStopsAnimation;
  39461. private _idleRotationSpeed;
  39462. private _idleRotationWaitTime;
  39463. private _idleRotationSpinupTime;
  39464. /**
  39465. * Sets the flag that indicates if user zooming should stop animation.
  39466. */
  39467. set zoomStopsAnimation(flag: boolean);
  39468. /**
  39469. * Gets the flag that indicates if user zooming should stop animation.
  39470. */
  39471. get zoomStopsAnimation(): boolean;
  39472. /**
  39473. * Sets the default speed at which the camera rotates around the model.
  39474. */
  39475. set idleRotationSpeed(speed: number);
  39476. /**
  39477. * Gets the default speed at which the camera rotates around the model.
  39478. */
  39479. get idleRotationSpeed(): number;
  39480. /**
  39481. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39482. */
  39483. set idleRotationWaitTime(time: number);
  39484. /**
  39485. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39486. */
  39487. get idleRotationWaitTime(): number;
  39488. /**
  39489. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39490. */
  39491. set idleRotationSpinupTime(time: number);
  39492. /**
  39493. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39494. */
  39495. get idleRotationSpinupTime(): number;
  39496. /**
  39497. * Gets a value indicating if the camera is currently rotating because of this behavior
  39498. */
  39499. get rotationInProgress(): boolean;
  39500. private _onPrePointerObservableObserver;
  39501. private _onAfterCheckInputsObserver;
  39502. private _attachedCamera;
  39503. private _isPointerDown;
  39504. private _lastFrameTime;
  39505. private _lastInteractionTime;
  39506. private _cameraRotationSpeed;
  39507. /**
  39508. * Initializes the behavior.
  39509. */
  39510. init(): void;
  39511. /**
  39512. * Attaches the behavior to its arc rotate camera.
  39513. * @param camera Defines the camera to attach the behavior to
  39514. */
  39515. attach(camera: ArcRotateCamera): void;
  39516. /**
  39517. * Detaches the behavior from its current arc rotate camera.
  39518. */
  39519. detach(): void;
  39520. /**
  39521. * Returns true if user is scrolling.
  39522. * @return true if user is scrolling.
  39523. */
  39524. private _userIsZooming;
  39525. private _lastFrameRadius;
  39526. private _shouldAnimationStopForInteraction;
  39527. /**
  39528. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39529. */
  39530. private _applyUserInteraction;
  39531. private _userIsMoving;
  39532. }
  39533. }
  39534. declare module BABYLON {
  39535. /**
  39536. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39537. */
  39538. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39539. private ui;
  39540. /**
  39541. * The name of the behavior
  39542. */
  39543. name: string;
  39544. /**
  39545. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39546. */
  39547. distanceAwayFromFace: number;
  39548. /**
  39549. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39550. */
  39551. distanceAwayFromBottomOfFace: number;
  39552. private _faceVectors;
  39553. private _target;
  39554. private _scene;
  39555. private _onRenderObserver;
  39556. private _tmpMatrix;
  39557. private _tmpVector;
  39558. /**
  39559. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39560. * @param ui The transform node that should be attched to the mesh
  39561. */
  39562. constructor(ui: TransformNode);
  39563. /**
  39564. * Initializes the behavior
  39565. */
  39566. init(): void;
  39567. private _closestFace;
  39568. private _zeroVector;
  39569. private _lookAtTmpMatrix;
  39570. private _lookAtToRef;
  39571. /**
  39572. * Attaches the AttachToBoxBehavior to the passed in mesh
  39573. * @param target The mesh that the specified node will be attached to
  39574. */
  39575. attach(target: Mesh): void;
  39576. /**
  39577. * Detaches the behavior from the mesh
  39578. */
  39579. detach(): void;
  39580. }
  39581. }
  39582. declare module BABYLON {
  39583. /**
  39584. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39585. */
  39586. export class FadeInOutBehavior implements Behavior<Mesh> {
  39587. /**
  39588. * Time in milliseconds to delay before fading in (Default: 0)
  39589. */
  39590. delay: number;
  39591. /**
  39592. * Time in milliseconds for the mesh to fade in (Default: 300)
  39593. */
  39594. fadeInTime: number;
  39595. private _millisecondsPerFrame;
  39596. private _hovered;
  39597. private _hoverValue;
  39598. private _ownerNode;
  39599. /**
  39600. * Instatiates the FadeInOutBehavior
  39601. */
  39602. constructor();
  39603. /**
  39604. * The name of the behavior
  39605. */
  39606. get name(): string;
  39607. /**
  39608. * Initializes the behavior
  39609. */
  39610. init(): void;
  39611. /**
  39612. * Attaches the fade behavior on the passed in mesh
  39613. * @param ownerNode The mesh that will be faded in/out once attached
  39614. */
  39615. attach(ownerNode: Mesh): void;
  39616. /**
  39617. * Detaches the behavior from the mesh
  39618. */
  39619. detach(): void;
  39620. /**
  39621. * Triggers the mesh to begin fading in or out
  39622. * @param value if the object should fade in or out (true to fade in)
  39623. */
  39624. fadeIn(value: boolean): void;
  39625. private _update;
  39626. private _setAllVisibility;
  39627. }
  39628. }
  39629. declare module BABYLON {
  39630. /**
  39631. * Class containing a set of static utilities functions for managing Pivots
  39632. * @hidden
  39633. */
  39634. export class PivotTools {
  39635. private static _PivotCached;
  39636. private static _OldPivotPoint;
  39637. private static _PivotTranslation;
  39638. private static _PivotTmpVector;
  39639. /** @hidden */
  39640. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39641. /** @hidden */
  39642. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39643. }
  39644. }
  39645. declare module BABYLON {
  39646. /**
  39647. * Class containing static functions to help procedurally build meshes
  39648. */
  39649. export class PlaneBuilder {
  39650. /**
  39651. * Creates a plane mesh
  39652. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39653. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39654. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39656. * * 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
  39657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39658. * @param name defines the name of the mesh
  39659. * @param options defines the options used to create the mesh
  39660. * @param scene defines the hosting scene
  39661. * @returns the plane mesh
  39662. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39663. */
  39664. static CreatePlane(name: string, options: {
  39665. size?: number;
  39666. width?: number;
  39667. height?: number;
  39668. sideOrientation?: number;
  39669. frontUVs?: Vector4;
  39670. backUVs?: Vector4;
  39671. updatable?: boolean;
  39672. sourcePlane?: Plane;
  39673. }, scene?: Nullable<Scene>): Mesh;
  39674. }
  39675. }
  39676. declare module BABYLON {
  39677. /**
  39678. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39679. */
  39680. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39681. private static _AnyMouseID;
  39682. /**
  39683. * Abstract mesh the behavior is set on
  39684. */
  39685. attachedNode: AbstractMesh;
  39686. private _dragPlane;
  39687. private _scene;
  39688. private _pointerObserver;
  39689. private _beforeRenderObserver;
  39690. private static _planeScene;
  39691. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39692. /**
  39693. * 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)
  39694. */
  39695. maxDragAngle: number;
  39696. /**
  39697. * @hidden
  39698. */
  39699. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39700. /**
  39701. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39702. */
  39703. currentDraggingPointerID: number;
  39704. /**
  39705. * The last position where the pointer hit the drag plane in world space
  39706. */
  39707. lastDragPosition: Vector3;
  39708. /**
  39709. * If the behavior is currently in a dragging state
  39710. */
  39711. dragging: boolean;
  39712. /**
  39713. * 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)
  39714. */
  39715. dragDeltaRatio: number;
  39716. /**
  39717. * If the drag plane orientation should be updated during the dragging (Default: true)
  39718. */
  39719. updateDragPlane: boolean;
  39720. private _debugMode;
  39721. private _moving;
  39722. /**
  39723. * Fires each time the attached mesh is dragged with the pointer
  39724. * * delta between last drag position and current drag position in world space
  39725. * * dragDistance along the drag axis
  39726. * * dragPlaneNormal normal of the current drag plane used during the drag
  39727. * * dragPlanePoint in world space where the drag intersects the drag plane
  39728. */
  39729. onDragObservable: Observable<{
  39730. delta: Vector3;
  39731. dragPlanePoint: Vector3;
  39732. dragPlaneNormal: Vector3;
  39733. dragDistance: number;
  39734. pointerId: number;
  39735. }>;
  39736. /**
  39737. * Fires each time a drag begins (eg. mouse down on mesh)
  39738. */
  39739. onDragStartObservable: Observable<{
  39740. dragPlanePoint: Vector3;
  39741. pointerId: number;
  39742. }>;
  39743. /**
  39744. * Fires each time a drag ends (eg. mouse release after drag)
  39745. */
  39746. onDragEndObservable: Observable<{
  39747. dragPlanePoint: Vector3;
  39748. pointerId: number;
  39749. }>;
  39750. /**
  39751. * If the attached mesh should be moved when dragged
  39752. */
  39753. moveAttached: boolean;
  39754. /**
  39755. * If the drag behavior will react to drag events (Default: true)
  39756. */
  39757. enabled: boolean;
  39758. /**
  39759. * If pointer events should start and release the drag (Default: true)
  39760. */
  39761. startAndReleaseDragOnPointerEvents: boolean;
  39762. /**
  39763. * If camera controls should be detached during the drag
  39764. */
  39765. detachCameraControls: boolean;
  39766. /**
  39767. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39768. */
  39769. useObjectOrientationForDragging: boolean;
  39770. private _options;
  39771. /**
  39772. * Gets the options used by the behavior
  39773. */
  39774. get options(): {
  39775. dragAxis?: Vector3;
  39776. dragPlaneNormal?: Vector3;
  39777. };
  39778. /**
  39779. * Sets the options used by the behavior
  39780. */
  39781. set options(options: {
  39782. dragAxis?: Vector3;
  39783. dragPlaneNormal?: Vector3;
  39784. });
  39785. /**
  39786. * Creates a pointer drag behavior that can be attached to a mesh
  39787. * @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)
  39788. */
  39789. constructor(options?: {
  39790. dragAxis?: Vector3;
  39791. dragPlaneNormal?: Vector3;
  39792. });
  39793. /**
  39794. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39795. */
  39796. validateDrag: (targetPosition: Vector3) => boolean;
  39797. /**
  39798. * The name of the behavior
  39799. */
  39800. get name(): string;
  39801. /**
  39802. * Initializes the behavior
  39803. */
  39804. init(): void;
  39805. private _tmpVector;
  39806. private _alternatePickedPoint;
  39807. private _worldDragAxis;
  39808. private _targetPosition;
  39809. private _attachedElement;
  39810. /**
  39811. * Attaches the drag behavior the passed in mesh
  39812. * @param ownerNode The mesh that will be dragged around once attached
  39813. * @param predicate Predicate to use for pick filtering
  39814. */
  39815. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39816. /**
  39817. * Force relase the drag action by code.
  39818. */
  39819. releaseDrag(): void;
  39820. private _startDragRay;
  39821. private _lastPointerRay;
  39822. /**
  39823. * Simulates the start of a pointer drag event on the behavior
  39824. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39825. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39826. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39827. */
  39828. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39829. private _startDrag;
  39830. private _dragDelta;
  39831. private _moveDrag;
  39832. private _pickWithRayOnDragPlane;
  39833. private _pointA;
  39834. private _pointB;
  39835. private _pointC;
  39836. private _lineA;
  39837. private _lineB;
  39838. private _localAxis;
  39839. private _lookAt;
  39840. private _updateDragPlanePosition;
  39841. /**
  39842. * Detaches the behavior from the mesh
  39843. */
  39844. detach(): void;
  39845. }
  39846. }
  39847. declare module BABYLON {
  39848. /**
  39849. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39850. */
  39851. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39852. private _dragBehaviorA;
  39853. private _dragBehaviorB;
  39854. private _startDistance;
  39855. private _initialScale;
  39856. private _targetScale;
  39857. private _ownerNode;
  39858. private _sceneRenderObserver;
  39859. /**
  39860. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39861. */
  39862. constructor();
  39863. /**
  39864. * The name of the behavior
  39865. */
  39866. get name(): string;
  39867. /**
  39868. * Initializes the behavior
  39869. */
  39870. init(): void;
  39871. private _getCurrentDistance;
  39872. /**
  39873. * Attaches the scale behavior the passed in mesh
  39874. * @param ownerNode The mesh that will be scaled around once attached
  39875. */
  39876. attach(ownerNode: Mesh): void;
  39877. /**
  39878. * Detaches the behavior from the mesh
  39879. */
  39880. detach(): void;
  39881. }
  39882. }
  39883. declare module BABYLON {
  39884. /**
  39885. * 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
  39886. */
  39887. export class SixDofDragBehavior implements Behavior<Mesh> {
  39888. private static _virtualScene;
  39889. private _ownerNode;
  39890. private _sceneRenderObserver;
  39891. private _scene;
  39892. private _targetPosition;
  39893. private _virtualOriginMesh;
  39894. private _virtualDragMesh;
  39895. private _pointerObserver;
  39896. private _moving;
  39897. private _startingOrientation;
  39898. private _attachedElement;
  39899. /**
  39900. * 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)
  39901. */
  39902. private zDragFactor;
  39903. /**
  39904. * If the object should rotate to face the drag origin
  39905. */
  39906. rotateDraggedObject: boolean;
  39907. /**
  39908. * If the behavior is currently in a dragging state
  39909. */
  39910. dragging: boolean;
  39911. /**
  39912. * 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)
  39913. */
  39914. dragDeltaRatio: number;
  39915. /**
  39916. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39917. */
  39918. currentDraggingPointerID: number;
  39919. /**
  39920. * If camera controls should be detached during the drag
  39921. */
  39922. detachCameraControls: boolean;
  39923. /**
  39924. * Fires each time a drag starts
  39925. */
  39926. onDragStartObservable: Observable<{}>;
  39927. /**
  39928. * Fires each time a drag ends (eg. mouse release after drag)
  39929. */
  39930. onDragEndObservable: Observable<{}>;
  39931. /**
  39932. * 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
  39933. */
  39934. constructor();
  39935. /**
  39936. * The name of the behavior
  39937. */
  39938. get name(): string;
  39939. /**
  39940. * Initializes the behavior
  39941. */
  39942. init(): void;
  39943. /**
  39944. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39945. */
  39946. private get _pointerCamera();
  39947. /**
  39948. * Attaches the scale behavior the passed in mesh
  39949. * @param ownerNode The mesh that will be scaled around once attached
  39950. */
  39951. attach(ownerNode: Mesh): void;
  39952. /**
  39953. * Detaches the behavior from the mesh
  39954. */
  39955. detach(): void;
  39956. }
  39957. }
  39958. declare module BABYLON {
  39959. /**
  39960. * Class used to apply inverse kinematics to bones
  39961. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39962. */
  39963. export class BoneIKController {
  39964. private static _tmpVecs;
  39965. private static _tmpQuat;
  39966. private static _tmpMats;
  39967. /**
  39968. * Gets or sets the target mesh
  39969. */
  39970. targetMesh: AbstractMesh;
  39971. /** Gets or sets the mesh used as pole */
  39972. poleTargetMesh: AbstractMesh;
  39973. /**
  39974. * Gets or sets the bone used as pole
  39975. */
  39976. poleTargetBone: Nullable<Bone>;
  39977. /**
  39978. * Gets or sets the target position
  39979. */
  39980. targetPosition: Vector3;
  39981. /**
  39982. * Gets or sets the pole target position
  39983. */
  39984. poleTargetPosition: Vector3;
  39985. /**
  39986. * Gets or sets the pole target local offset
  39987. */
  39988. poleTargetLocalOffset: Vector3;
  39989. /**
  39990. * Gets or sets the pole angle
  39991. */
  39992. poleAngle: number;
  39993. /**
  39994. * Gets or sets the mesh associated with the controller
  39995. */
  39996. mesh: AbstractMesh;
  39997. /**
  39998. * 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)
  39999. */
  40000. slerpAmount: number;
  40001. private _bone1Quat;
  40002. private _bone1Mat;
  40003. private _bone2Ang;
  40004. private _bone1;
  40005. private _bone2;
  40006. private _bone1Length;
  40007. private _bone2Length;
  40008. private _maxAngle;
  40009. private _maxReach;
  40010. private _rightHandedSystem;
  40011. private _bendAxis;
  40012. private _slerping;
  40013. private _adjustRoll;
  40014. /**
  40015. * Gets or sets maximum allowed angle
  40016. */
  40017. get maxAngle(): number;
  40018. set maxAngle(value: number);
  40019. /**
  40020. * Creates a new BoneIKController
  40021. * @param mesh defines the mesh to control
  40022. * @param bone defines the bone to control
  40023. * @param options defines options to set up the controller
  40024. */
  40025. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40026. targetMesh?: AbstractMesh;
  40027. poleTargetMesh?: AbstractMesh;
  40028. poleTargetBone?: Bone;
  40029. poleTargetLocalOffset?: Vector3;
  40030. poleAngle?: number;
  40031. bendAxis?: Vector3;
  40032. maxAngle?: number;
  40033. slerpAmount?: number;
  40034. });
  40035. private _setMaxAngle;
  40036. /**
  40037. * Force the controller to update the bones
  40038. */
  40039. update(): void;
  40040. }
  40041. }
  40042. declare module BABYLON {
  40043. /**
  40044. * Class used to make a bone look toward a point in space
  40045. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40046. */
  40047. export class BoneLookController {
  40048. private static _tmpVecs;
  40049. private static _tmpQuat;
  40050. private static _tmpMats;
  40051. /**
  40052. * The target Vector3 that the bone will look at
  40053. */
  40054. target: Vector3;
  40055. /**
  40056. * The mesh that the bone is attached to
  40057. */
  40058. mesh: AbstractMesh;
  40059. /**
  40060. * The bone that will be looking to the target
  40061. */
  40062. bone: Bone;
  40063. /**
  40064. * The up axis of the coordinate system that is used when the bone is rotated
  40065. */
  40066. upAxis: Vector3;
  40067. /**
  40068. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40069. */
  40070. upAxisSpace: Space;
  40071. /**
  40072. * Used to make an adjustment to the yaw of the bone
  40073. */
  40074. adjustYaw: number;
  40075. /**
  40076. * Used to make an adjustment to the pitch of the bone
  40077. */
  40078. adjustPitch: number;
  40079. /**
  40080. * Used to make an adjustment to the roll of the bone
  40081. */
  40082. adjustRoll: number;
  40083. /**
  40084. * 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)
  40085. */
  40086. slerpAmount: number;
  40087. private _minYaw;
  40088. private _maxYaw;
  40089. private _minPitch;
  40090. private _maxPitch;
  40091. private _minYawSin;
  40092. private _minYawCos;
  40093. private _maxYawSin;
  40094. private _maxYawCos;
  40095. private _midYawConstraint;
  40096. private _minPitchTan;
  40097. private _maxPitchTan;
  40098. private _boneQuat;
  40099. private _slerping;
  40100. private _transformYawPitch;
  40101. private _transformYawPitchInv;
  40102. private _firstFrameSkipped;
  40103. private _yawRange;
  40104. private _fowardAxis;
  40105. /**
  40106. * Gets or sets the minimum yaw angle that the bone can look to
  40107. */
  40108. get minYaw(): number;
  40109. set minYaw(value: number);
  40110. /**
  40111. * Gets or sets the maximum yaw angle that the bone can look to
  40112. */
  40113. get maxYaw(): number;
  40114. set maxYaw(value: number);
  40115. /**
  40116. * Gets or sets the minimum pitch angle that the bone can look to
  40117. */
  40118. get minPitch(): number;
  40119. set minPitch(value: number);
  40120. /**
  40121. * Gets or sets the maximum pitch angle that the bone can look to
  40122. */
  40123. get maxPitch(): number;
  40124. set maxPitch(value: number);
  40125. /**
  40126. * Create a BoneLookController
  40127. * @param mesh the mesh that the bone belongs to
  40128. * @param bone the bone that will be looking to the target
  40129. * @param target the target Vector3 to look at
  40130. * @param options optional settings:
  40131. * * maxYaw: the maximum angle the bone will yaw to
  40132. * * minYaw: the minimum angle the bone will yaw to
  40133. * * maxPitch: the maximum angle the bone will pitch to
  40134. * * minPitch: the minimum angle the bone will yaw to
  40135. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40136. * * upAxis: the up axis of the coordinate system
  40137. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40138. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40139. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40140. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40141. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40142. * * adjustRoll: used to make an adjustment to the roll of the bone
  40143. **/
  40144. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40145. maxYaw?: number;
  40146. minYaw?: number;
  40147. maxPitch?: number;
  40148. minPitch?: number;
  40149. slerpAmount?: number;
  40150. upAxis?: Vector3;
  40151. upAxisSpace?: Space;
  40152. yawAxis?: Vector3;
  40153. pitchAxis?: Vector3;
  40154. adjustYaw?: number;
  40155. adjustPitch?: number;
  40156. adjustRoll?: number;
  40157. });
  40158. /**
  40159. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40160. */
  40161. update(): void;
  40162. private _getAngleDiff;
  40163. private _getAngleBetween;
  40164. private _isAngleBetween;
  40165. }
  40166. }
  40167. declare module BABYLON {
  40168. /**
  40169. * Manage the gamepad inputs to control an arc rotate camera.
  40170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40171. */
  40172. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40173. /**
  40174. * Defines the camera the input is attached to.
  40175. */
  40176. camera: ArcRotateCamera;
  40177. /**
  40178. * Defines the gamepad the input is gathering event from.
  40179. */
  40180. gamepad: Nullable<Gamepad>;
  40181. /**
  40182. * Defines the gamepad rotation sensiblity.
  40183. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40184. */
  40185. gamepadRotationSensibility: number;
  40186. /**
  40187. * Defines the gamepad move sensiblity.
  40188. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40189. */
  40190. gamepadMoveSensibility: number;
  40191. private _yAxisScale;
  40192. /**
  40193. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40194. */
  40195. get invertYAxis(): boolean;
  40196. set invertYAxis(value: boolean);
  40197. private _onGamepadConnectedObserver;
  40198. private _onGamepadDisconnectedObserver;
  40199. /**
  40200. * Attach the input controls to a specific dom element to get the input from.
  40201. * @param element Defines the element the controls should be listened from
  40202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40203. */
  40204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40205. /**
  40206. * Detach the current controls from the specified dom element.
  40207. * @param element Defines the element to stop listening the inputs from
  40208. */
  40209. detachControl(element: Nullable<HTMLElement>): void;
  40210. /**
  40211. * Update the current camera state depending on the inputs that have been used this frame.
  40212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40213. */
  40214. checkInputs(): void;
  40215. /**
  40216. * Gets the class name of the current intput.
  40217. * @returns the class name
  40218. */
  40219. getClassName(): string;
  40220. /**
  40221. * Get the friendly name associated with the input class.
  40222. * @returns the input friendly name
  40223. */
  40224. getSimpleName(): string;
  40225. }
  40226. }
  40227. declare module BABYLON {
  40228. interface ArcRotateCameraInputsManager {
  40229. /**
  40230. * Add orientation input support to the input manager.
  40231. * @returns the current input manager
  40232. */
  40233. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40234. }
  40235. /**
  40236. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40238. */
  40239. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40240. /**
  40241. * Defines the camera the input is attached to.
  40242. */
  40243. camera: ArcRotateCamera;
  40244. /**
  40245. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40246. */
  40247. alphaCorrection: number;
  40248. /**
  40249. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40250. */
  40251. gammaCorrection: number;
  40252. private _alpha;
  40253. private _gamma;
  40254. private _dirty;
  40255. private _deviceOrientationHandler;
  40256. /**
  40257. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40258. */
  40259. constructor();
  40260. /**
  40261. * Attach the input controls to a specific dom element to get the input from.
  40262. * @param element Defines the element the controls should be listened from
  40263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40264. */
  40265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40266. /** @hidden */
  40267. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40268. /**
  40269. * Update the current camera state depending on the inputs that have been used this frame.
  40270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40271. */
  40272. checkInputs(): void;
  40273. /**
  40274. * Detach the current controls from the specified dom element.
  40275. * @param element Defines the element to stop listening the inputs from
  40276. */
  40277. detachControl(element: Nullable<HTMLElement>): void;
  40278. /**
  40279. * Gets the class name of the current intput.
  40280. * @returns the class name
  40281. */
  40282. getClassName(): string;
  40283. /**
  40284. * Get the friendly name associated with the input class.
  40285. * @returns the input friendly name
  40286. */
  40287. getSimpleName(): string;
  40288. }
  40289. }
  40290. declare module BABYLON {
  40291. /**
  40292. * Listen to mouse events to control the camera.
  40293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40294. */
  40295. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40296. /**
  40297. * Defines the camera the input is attached to.
  40298. */
  40299. camera: FlyCamera;
  40300. /**
  40301. * Defines if touch is enabled. (Default is true.)
  40302. */
  40303. touchEnabled: boolean;
  40304. /**
  40305. * Defines the buttons associated with the input to handle camera rotation.
  40306. */
  40307. buttons: number[];
  40308. /**
  40309. * Assign buttons for Yaw control.
  40310. */
  40311. buttonsYaw: number[];
  40312. /**
  40313. * Assign buttons for Pitch control.
  40314. */
  40315. buttonsPitch: number[];
  40316. /**
  40317. * Assign buttons for Roll control.
  40318. */
  40319. buttonsRoll: number[];
  40320. /**
  40321. * Detect if any button is being pressed while mouse is moved.
  40322. * -1 = Mouse locked.
  40323. * 0 = Left button.
  40324. * 1 = Middle Button.
  40325. * 2 = Right Button.
  40326. */
  40327. activeButton: number;
  40328. /**
  40329. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40330. * Higher values reduce its sensitivity.
  40331. */
  40332. angularSensibility: number;
  40333. private _mousemoveCallback;
  40334. private _observer;
  40335. private _rollObserver;
  40336. private previousPosition;
  40337. private noPreventDefault;
  40338. private element;
  40339. /**
  40340. * Listen to mouse events to control the camera.
  40341. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40343. */
  40344. constructor(touchEnabled?: boolean);
  40345. /**
  40346. * Attach the mouse control to the HTML DOM element.
  40347. * @param element Defines the element that listens to the input events.
  40348. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40349. */
  40350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40351. /**
  40352. * Detach the current controls from the specified dom element.
  40353. * @param element Defines the element to stop listening the inputs from
  40354. */
  40355. detachControl(element: Nullable<HTMLElement>): void;
  40356. /**
  40357. * Gets the class name of the current input.
  40358. * @returns the class name.
  40359. */
  40360. getClassName(): string;
  40361. /**
  40362. * Get the friendly name associated with the input class.
  40363. * @returns the input's friendly name.
  40364. */
  40365. getSimpleName(): string;
  40366. private _pointerInput;
  40367. private _onMouseMove;
  40368. /**
  40369. * Rotate camera by mouse offset.
  40370. */
  40371. private rotateCamera;
  40372. }
  40373. }
  40374. declare module BABYLON {
  40375. /**
  40376. * Default Inputs manager for the FlyCamera.
  40377. * It groups all the default supported inputs for ease of use.
  40378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40379. */
  40380. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40381. /**
  40382. * Instantiates a new FlyCameraInputsManager.
  40383. * @param camera Defines the camera the inputs belong to.
  40384. */
  40385. constructor(camera: FlyCamera);
  40386. /**
  40387. * Add keyboard input support to the input manager.
  40388. * @returns the new FlyCameraKeyboardMoveInput().
  40389. */
  40390. addKeyboard(): FlyCameraInputsManager;
  40391. /**
  40392. * Add mouse input support to the input manager.
  40393. * @param touchEnabled Enable touch screen support.
  40394. * @returns the new FlyCameraMouseInput().
  40395. */
  40396. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40397. }
  40398. }
  40399. declare module BABYLON {
  40400. /**
  40401. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40402. * such as in a 3D Space Shooter or a Flight Simulator.
  40403. */
  40404. export class FlyCamera extends TargetCamera {
  40405. /**
  40406. * Define the collision ellipsoid of the camera.
  40407. * This is helpful for simulating a camera body, like a player's body.
  40408. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40409. */
  40410. ellipsoid: Vector3;
  40411. /**
  40412. * Define an offset for the position of the ellipsoid around the camera.
  40413. * This can be helpful if the camera is attached away from the player's body center,
  40414. * such as at its head.
  40415. */
  40416. ellipsoidOffset: Vector3;
  40417. /**
  40418. * Enable or disable collisions of the camera with the rest of the scene objects.
  40419. */
  40420. checkCollisions: boolean;
  40421. /**
  40422. * Enable or disable gravity on the camera.
  40423. */
  40424. applyGravity: boolean;
  40425. /**
  40426. * Define the current direction the camera is moving to.
  40427. */
  40428. cameraDirection: Vector3;
  40429. /**
  40430. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40431. * This overrides and empties cameraRotation.
  40432. */
  40433. rotationQuaternion: Quaternion;
  40434. /**
  40435. * Track Roll to maintain the wanted Rolling when looking around.
  40436. */
  40437. _trackRoll: number;
  40438. /**
  40439. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40440. */
  40441. rollCorrect: number;
  40442. /**
  40443. * Mimic a banked turn, Rolling the camera when Yawing.
  40444. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40445. */
  40446. bankedTurn: boolean;
  40447. /**
  40448. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40449. */
  40450. bankedTurnLimit: number;
  40451. /**
  40452. * Value of 0 disables the banked Roll.
  40453. * Value of 1 is equal to the Yaw angle in radians.
  40454. */
  40455. bankedTurnMultiplier: number;
  40456. /**
  40457. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40458. */
  40459. inputs: FlyCameraInputsManager;
  40460. /**
  40461. * Gets the input sensibility for mouse input.
  40462. * Higher values reduce sensitivity.
  40463. */
  40464. get angularSensibility(): number;
  40465. /**
  40466. * Sets the input sensibility for a mouse input.
  40467. * Higher values reduce sensitivity.
  40468. */
  40469. set angularSensibility(value: number);
  40470. /**
  40471. * Get the keys for camera movement forward.
  40472. */
  40473. get keysForward(): number[];
  40474. /**
  40475. * Set the keys for camera movement forward.
  40476. */
  40477. set keysForward(value: number[]);
  40478. /**
  40479. * Get the keys for camera movement backward.
  40480. */
  40481. get keysBackward(): number[];
  40482. set keysBackward(value: number[]);
  40483. /**
  40484. * Get the keys for camera movement up.
  40485. */
  40486. get keysUp(): number[];
  40487. /**
  40488. * Set the keys for camera movement up.
  40489. */
  40490. set keysUp(value: number[]);
  40491. /**
  40492. * Get the keys for camera movement down.
  40493. */
  40494. get keysDown(): number[];
  40495. /**
  40496. * Set the keys for camera movement down.
  40497. */
  40498. set keysDown(value: number[]);
  40499. /**
  40500. * Get the keys for camera movement left.
  40501. */
  40502. get keysLeft(): number[];
  40503. /**
  40504. * Set the keys for camera movement left.
  40505. */
  40506. set keysLeft(value: number[]);
  40507. /**
  40508. * Set the keys for camera movement right.
  40509. */
  40510. get keysRight(): number[];
  40511. /**
  40512. * Set the keys for camera movement right.
  40513. */
  40514. set keysRight(value: number[]);
  40515. /**
  40516. * Event raised when the camera collides with a mesh in the scene.
  40517. */
  40518. onCollide: (collidedMesh: AbstractMesh) => void;
  40519. private _collider;
  40520. private _needMoveForGravity;
  40521. private _oldPosition;
  40522. private _diffPosition;
  40523. private _newPosition;
  40524. /** @hidden */
  40525. _localDirection: Vector3;
  40526. /** @hidden */
  40527. _transformedDirection: Vector3;
  40528. /**
  40529. * Instantiates a FlyCamera.
  40530. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40531. * such as in a 3D Space Shooter or a Flight Simulator.
  40532. * @param name Define the name of the camera in the scene.
  40533. * @param position Define the starting position of the camera in the scene.
  40534. * @param scene Define the scene the camera belongs to.
  40535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40536. */
  40537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40538. /**
  40539. * Attach a control to the HTML DOM element.
  40540. * @param element Defines the element that listens to the input events.
  40541. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40542. */
  40543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40544. /**
  40545. * Detach a control from the HTML DOM element.
  40546. * The camera will stop reacting to that input.
  40547. * @param element Defines the element that listens to the input events.
  40548. */
  40549. detachControl(element: HTMLElement): void;
  40550. private _collisionMask;
  40551. /**
  40552. * Get the mask that the camera ignores in collision events.
  40553. */
  40554. get collisionMask(): number;
  40555. /**
  40556. * Set the mask that the camera ignores in collision events.
  40557. */
  40558. set collisionMask(mask: number);
  40559. /** @hidden */
  40560. _collideWithWorld(displacement: Vector3): void;
  40561. /** @hidden */
  40562. private _onCollisionPositionChange;
  40563. /** @hidden */
  40564. _checkInputs(): void;
  40565. /** @hidden */
  40566. _decideIfNeedsToMove(): boolean;
  40567. /** @hidden */
  40568. _updatePosition(): void;
  40569. /**
  40570. * Restore the Roll to its target value at the rate specified.
  40571. * @param rate - Higher means slower restoring.
  40572. * @hidden
  40573. */
  40574. restoreRoll(rate: number): void;
  40575. /**
  40576. * Destroy the camera and release the current resources held by it.
  40577. */
  40578. dispose(): void;
  40579. /**
  40580. * Get the current object class name.
  40581. * @returns the class name.
  40582. */
  40583. getClassName(): string;
  40584. }
  40585. }
  40586. declare module BABYLON {
  40587. /**
  40588. * Listen to keyboard events to control the camera.
  40589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40590. */
  40591. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40592. /**
  40593. * Defines the camera the input is attached to.
  40594. */
  40595. camera: FlyCamera;
  40596. /**
  40597. * The list of keyboard keys used to control the forward move of the camera.
  40598. */
  40599. keysForward: number[];
  40600. /**
  40601. * The list of keyboard keys used to control the backward move of the camera.
  40602. */
  40603. keysBackward: number[];
  40604. /**
  40605. * The list of keyboard keys used to control the forward move of the camera.
  40606. */
  40607. keysUp: number[];
  40608. /**
  40609. * The list of keyboard keys used to control the backward move of the camera.
  40610. */
  40611. keysDown: number[];
  40612. /**
  40613. * The list of keyboard keys used to control the right strafe move of the camera.
  40614. */
  40615. keysRight: number[];
  40616. /**
  40617. * The list of keyboard keys used to control the left strafe move of the camera.
  40618. */
  40619. keysLeft: number[];
  40620. private _keys;
  40621. private _onCanvasBlurObserver;
  40622. private _onKeyboardObserver;
  40623. private _engine;
  40624. private _scene;
  40625. /**
  40626. * Attach the input controls to a specific dom element to get the input from.
  40627. * @param element Defines the element the controls should be listened from
  40628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40629. */
  40630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40631. /**
  40632. * Detach the current controls from the specified dom element.
  40633. * @param element Defines the element to stop listening the inputs from
  40634. */
  40635. detachControl(element: Nullable<HTMLElement>): void;
  40636. /**
  40637. * Gets the class name of the current intput.
  40638. * @returns the class name
  40639. */
  40640. getClassName(): string;
  40641. /** @hidden */
  40642. _onLostFocus(e: FocusEvent): void;
  40643. /**
  40644. * Get the friendly name associated with the input class.
  40645. * @returns the input friendly name
  40646. */
  40647. getSimpleName(): string;
  40648. /**
  40649. * Update the current camera state depending on the inputs that have been used this frame.
  40650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40651. */
  40652. checkInputs(): void;
  40653. }
  40654. }
  40655. declare module BABYLON {
  40656. /**
  40657. * Manage the mouse wheel inputs to control a follow camera.
  40658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40659. */
  40660. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40661. /**
  40662. * Defines the camera the input is attached to.
  40663. */
  40664. camera: FollowCamera;
  40665. /**
  40666. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40667. */
  40668. axisControlRadius: boolean;
  40669. /**
  40670. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40671. */
  40672. axisControlHeight: boolean;
  40673. /**
  40674. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40675. */
  40676. axisControlRotation: boolean;
  40677. /**
  40678. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40679. * relation to mouseWheel events.
  40680. */
  40681. wheelPrecision: number;
  40682. /**
  40683. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40684. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40685. */
  40686. wheelDeltaPercentage: number;
  40687. private _wheel;
  40688. private _observer;
  40689. /**
  40690. * Attach the input controls to a specific dom element to get the input from.
  40691. * @param element Defines the element the controls should be listened from
  40692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40693. */
  40694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40695. /**
  40696. * Detach the current controls from the specified dom element.
  40697. * @param element Defines the element to stop listening the inputs from
  40698. */
  40699. detachControl(element: Nullable<HTMLElement>): void;
  40700. /**
  40701. * Gets the class name of the current intput.
  40702. * @returns the class name
  40703. */
  40704. getClassName(): string;
  40705. /**
  40706. * Get the friendly name associated with the input class.
  40707. * @returns the input friendly name
  40708. */
  40709. getSimpleName(): string;
  40710. }
  40711. }
  40712. declare module BABYLON {
  40713. /**
  40714. * Manage the pointers inputs to control an follow camera.
  40715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40716. */
  40717. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40718. /**
  40719. * Defines the camera the input is attached to.
  40720. */
  40721. camera: FollowCamera;
  40722. /**
  40723. * Gets the class name of the current input.
  40724. * @returns the class name
  40725. */
  40726. getClassName(): string;
  40727. /**
  40728. * Defines the pointer angular sensibility along the X axis or how fast is
  40729. * the camera rotating.
  40730. * A negative number will reverse the axis direction.
  40731. */
  40732. angularSensibilityX: number;
  40733. /**
  40734. * Defines the pointer angular sensibility along the Y axis or how fast is
  40735. * the camera rotating.
  40736. * A negative number will reverse the axis direction.
  40737. */
  40738. angularSensibilityY: number;
  40739. /**
  40740. * Defines the pointer pinch precision or how fast is the camera zooming.
  40741. * A negative number will reverse the axis direction.
  40742. */
  40743. pinchPrecision: number;
  40744. /**
  40745. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40746. * from 0.
  40747. * It defines the percentage of current camera.radius to use as delta when
  40748. * pinch zoom is used.
  40749. */
  40750. pinchDeltaPercentage: number;
  40751. /**
  40752. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40753. */
  40754. axisXControlRadius: boolean;
  40755. /**
  40756. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40757. */
  40758. axisXControlHeight: boolean;
  40759. /**
  40760. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40761. */
  40762. axisXControlRotation: boolean;
  40763. /**
  40764. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40765. */
  40766. axisYControlRadius: boolean;
  40767. /**
  40768. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40769. */
  40770. axisYControlHeight: boolean;
  40771. /**
  40772. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40773. */
  40774. axisYControlRotation: boolean;
  40775. /**
  40776. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40777. */
  40778. axisPinchControlRadius: boolean;
  40779. /**
  40780. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40781. */
  40782. axisPinchControlHeight: boolean;
  40783. /**
  40784. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40785. */
  40786. axisPinchControlRotation: boolean;
  40787. /**
  40788. * Log error messages if basic misconfiguration has occurred.
  40789. */
  40790. warningEnable: boolean;
  40791. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40792. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40793. private _warningCounter;
  40794. private _warning;
  40795. }
  40796. }
  40797. declare module BABYLON {
  40798. /**
  40799. * Default Inputs manager for the FollowCamera.
  40800. * It groups all the default supported inputs for ease of use.
  40801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40802. */
  40803. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40804. /**
  40805. * Instantiates a new FollowCameraInputsManager.
  40806. * @param camera Defines the camera the inputs belong to
  40807. */
  40808. constructor(camera: FollowCamera);
  40809. /**
  40810. * Add keyboard input support to the input manager.
  40811. * @returns the current input manager
  40812. */
  40813. addKeyboard(): FollowCameraInputsManager;
  40814. /**
  40815. * Add mouse wheel input support to the input manager.
  40816. * @returns the current input manager
  40817. */
  40818. addMouseWheel(): FollowCameraInputsManager;
  40819. /**
  40820. * Add pointers input support to the input manager.
  40821. * @returns the current input manager
  40822. */
  40823. addPointers(): FollowCameraInputsManager;
  40824. /**
  40825. * Add orientation input support to the input manager.
  40826. * @returns the current input manager
  40827. */
  40828. addVRDeviceOrientation(): FollowCameraInputsManager;
  40829. }
  40830. }
  40831. declare module BABYLON {
  40832. /**
  40833. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40834. * an arc rotate version arcFollowCamera are available.
  40835. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40836. */
  40837. export class FollowCamera extends TargetCamera {
  40838. /**
  40839. * Distance the follow camera should follow an object at
  40840. */
  40841. radius: number;
  40842. /**
  40843. * Minimum allowed distance of the camera to the axis of rotation
  40844. * (The camera can not get closer).
  40845. * This can help limiting how the Camera is able to move in the scene.
  40846. */
  40847. lowerRadiusLimit: Nullable<number>;
  40848. /**
  40849. * Maximum allowed distance of the camera to the axis of rotation
  40850. * (The camera can not get further).
  40851. * This can help limiting how the Camera is able to move in the scene.
  40852. */
  40853. upperRadiusLimit: Nullable<number>;
  40854. /**
  40855. * Define a rotation offset between the camera and the object it follows
  40856. */
  40857. rotationOffset: number;
  40858. /**
  40859. * Minimum allowed angle to camera position relative to target object.
  40860. * This can help limiting how the Camera is able to move in the scene.
  40861. */
  40862. lowerRotationOffsetLimit: Nullable<number>;
  40863. /**
  40864. * Maximum allowed angle to camera position relative to target object.
  40865. * This can help limiting how the Camera is able to move in the scene.
  40866. */
  40867. upperRotationOffsetLimit: Nullable<number>;
  40868. /**
  40869. * Define a height offset between the camera and the object it follows.
  40870. * It can help following an object from the top (like a car chaing a plane)
  40871. */
  40872. heightOffset: number;
  40873. /**
  40874. * Minimum allowed height of camera position relative to target object.
  40875. * This can help limiting how the Camera is able to move in the scene.
  40876. */
  40877. lowerHeightOffsetLimit: Nullable<number>;
  40878. /**
  40879. * Maximum allowed height of camera position relative to target object.
  40880. * This can help limiting how the Camera is able to move in the scene.
  40881. */
  40882. upperHeightOffsetLimit: Nullable<number>;
  40883. /**
  40884. * Define how fast the camera can accelerate to follow it s target.
  40885. */
  40886. cameraAcceleration: number;
  40887. /**
  40888. * Define the speed limit of the camera following an object.
  40889. */
  40890. maxCameraSpeed: number;
  40891. /**
  40892. * Define the target of the camera.
  40893. */
  40894. lockedTarget: Nullable<AbstractMesh>;
  40895. /**
  40896. * Defines the input associated with the camera.
  40897. */
  40898. inputs: FollowCameraInputsManager;
  40899. /**
  40900. * Instantiates the follow camera.
  40901. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40902. * @param name Define the name of the camera in the scene
  40903. * @param position Define the position of the camera
  40904. * @param scene Define the scene the camera belong to
  40905. * @param lockedTarget Define the target of the camera
  40906. */
  40907. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40908. private _follow;
  40909. /**
  40910. * Attached controls to the current camera.
  40911. * @param element Defines the element the controls should be listened from
  40912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40913. */
  40914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40915. /**
  40916. * Detach the current controls from the camera.
  40917. * The camera will stop reacting to inputs.
  40918. * @param element Defines the element to stop listening the inputs from
  40919. */
  40920. detachControl(element: HTMLElement): void;
  40921. /** @hidden */
  40922. _checkInputs(): void;
  40923. private _checkLimits;
  40924. /**
  40925. * Gets the camera class name.
  40926. * @returns the class name
  40927. */
  40928. getClassName(): string;
  40929. }
  40930. /**
  40931. * Arc Rotate version of the follow camera.
  40932. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40933. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40934. */
  40935. export class ArcFollowCamera extends TargetCamera {
  40936. /** The longitudinal angle of the camera */
  40937. alpha: number;
  40938. /** The latitudinal angle of the camera */
  40939. beta: number;
  40940. /** The radius of the camera from its target */
  40941. radius: number;
  40942. /** Define the camera target (the messh it should follow) */
  40943. target: Nullable<AbstractMesh>;
  40944. private _cartesianCoordinates;
  40945. /**
  40946. * Instantiates a new ArcFollowCamera
  40947. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40948. * @param name Define the name of the camera
  40949. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40950. * @param beta Define the rotation angle of the camera around the elevation axis
  40951. * @param radius Define the radius of the camera from its target point
  40952. * @param target Define the target of the camera
  40953. * @param scene Define the scene the camera belongs to
  40954. */
  40955. constructor(name: string,
  40956. /** The longitudinal angle of the camera */
  40957. alpha: number,
  40958. /** The latitudinal angle of the camera */
  40959. beta: number,
  40960. /** The radius of the camera from its target */
  40961. radius: number,
  40962. /** Define the camera target (the messh it should follow) */
  40963. target: Nullable<AbstractMesh>, scene: Scene);
  40964. private _follow;
  40965. /** @hidden */
  40966. _checkInputs(): void;
  40967. /**
  40968. * Returns the class name of the object.
  40969. * It is mostly used internally for serialization purposes.
  40970. */
  40971. getClassName(): string;
  40972. }
  40973. }
  40974. declare module BABYLON {
  40975. /**
  40976. * Manage the keyboard inputs to control the movement of a follow camera.
  40977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40978. */
  40979. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40980. /**
  40981. * Defines the camera the input is attached to.
  40982. */
  40983. camera: FollowCamera;
  40984. /**
  40985. * Defines the list of key codes associated with the up action (increase heightOffset)
  40986. */
  40987. keysHeightOffsetIncr: number[];
  40988. /**
  40989. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40990. */
  40991. keysHeightOffsetDecr: number[];
  40992. /**
  40993. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40994. */
  40995. keysHeightOffsetModifierAlt: boolean;
  40996. /**
  40997. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40998. */
  40999. keysHeightOffsetModifierCtrl: boolean;
  41000. /**
  41001. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41002. */
  41003. keysHeightOffsetModifierShift: boolean;
  41004. /**
  41005. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41006. */
  41007. keysRotationOffsetIncr: number[];
  41008. /**
  41009. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41010. */
  41011. keysRotationOffsetDecr: number[];
  41012. /**
  41013. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41014. */
  41015. keysRotationOffsetModifierAlt: boolean;
  41016. /**
  41017. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41018. */
  41019. keysRotationOffsetModifierCtrl: boolean;
  41020. /**
  41021. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41022. */
  41023. keysRotationOffsetModifierShift: boolean;
  41024. /**
  41025. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41026. */
  41027. keysRadiusIncr: number[];
  41028. /**
  41029. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41030. */
  41031. keysRadiusDecr: number[];
  41032. /**
  41033. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41034. */
  41035. keysRadiusModifierAlt: boolean;
  41036. /**
  41037. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41038. */
  41039. keysRadiusModifierCtrl: boolean;
  41040. /**
  41041. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41042. */
  41043. keysRadiusModifierShift: boolean;
  41044. /**
  41045. * Defines the rate of change of heightOffset.
  41046. */
  41047. heightSensibility: number;
  41048. /**
  41049. * Defines the rate of change of rotationOffset.
  41050. */
  41051. rotationSensibility: number;
  41052. /**
  41053. * Defines the rate of change of radius.
  41054. */
  41055. radiusSensibility: number;
  41056. private _keys;
  41057. private _ctrlPressed;
  41058. private _altPressed;
  41059. private _shiftPressed;
  41060. private _onCanvasBlurObserver;
  41061. private _onKeyboardObserver;
  41062. private _engine;
  41063. private _scene;
  41064. /**
  41065. * Attach the input controls to a specific dom element to get the input from.
  41066. * @param element Defines the element the controls should be listened from
  41067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41068. */
  41069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41070. /**
  41071. * Detach the current controls from the specified dom element.
  41072. * @param element Defines the element to stop listening the inputs from
  41073. */
  41074. detachControl(element: Nullable<HTMLElement>): void;
  41075. /**
  41076. * Update the current camera state depending on the inputs that have been used this frame.
  41077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41078. */
  41079. checkInputs(): void;
  41080. /**
  41081. * Gets the class name of the current input.
  41082. * @returns the class name
  41083. */
  41084. getClassName(): string;
  41085. /**
  41086. * Get the friendly name associated with the input class.
  41087. * @returns the input friendly name
  41088. */
  41089. getSimpleName(): string;
  41090. /**
  41091. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41092. * allow modification of the heightOffset value.
  41093. */
  41094. private _modifierHeightOffset;
  41095. /**
  41096. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41097. * allow modification of the rotationOffset value.
  41098. */
  41099. private _modifierRotationOffset;
  41100. /**
  41101. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41102. * allow modification of the radius value.
  41103. */
  41104. private _modifierRadius;
  41105. }
  41106. }
  41107. declare module BABYLON {
  41108. interface FreeCameraInputsManager {
  41109. /**
  41110. * @hidden
  41111. */
  41112. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41113. /**
  41114. * Add orientation input support to the input manager.
  41115. * @returns the current input manager
  41116. */
  41117. addDeviceOrientation(): FreeCameraInputsManager;
  41118. }
  41119. /**
  41120. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41121. * Screen rotation is taken into account.
  41122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41123. */
  41124. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41125. private _camera;
  41126. private _screenOrientationAngle;
  41127. private _constantTranform;
  41128. private _screenQuaternion;
  41129. private _alpha;
  41130. private _beta;
  41131. private _gamma;
  41132. /**
  41133. * Can be used to detect if a device orientation sensor is available on a device
  41134. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41135. * @returns a promise that will resolve on orientation change
  41136. */
  41137. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41138. /**
  41139. * @hidden
  41140. */
  41141. _onDeviceOrientationChangedObservable: Observable<void>;
  41142. /**
  41143. * Instantiates a new input
  41144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41145. */
  41146. constructor();
  41147. /**
  41148. * Define the camera controlled by the input.
  41149. */
  41150. get camera(): FreeCamera;
  41151. set camera(camera: FreeCamera);
  41152. /**
  41153. * Attach the input controls to a specific dom element to get the input from.
  41154. * @param element Defines the element the controls should be listened from
  41155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41156. */
  41157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41158. private _orientationChanged;
  41159. private _deviceOrientation;
  41160. /**
  41161. * Detach the current controls from the specified dom element.
  41162. * @param element Defines the element to stop listening the inputs from
  41163. */
  41164. detachControl(element: Nullable<HTMLElement>): void;
  41165. /**
  41166. * Update the current camera state depending on the inputs that have been used this frame.
  41167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41168. */
  41169. checkInputs(): void;
  41170. /**
  41171. * Gets the class name of the current intput.
  41172. * @returns the class name
  41173. */
  41174. getClassName(): string;
  41175. /**
  41176. * Get the friendly name associated with the input class.
  41177. * @returns the input friendly name
  41178. */
  41179. getSimpleName(): string;
  41180. }
  41181. }
  41182. declare module BABYLON {
  41183. /**
  41184. * Manage the gamepad inputs to control a free camera.
  41185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41186. */
  41187. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41188. /**
  41189. * Define the camera the input is attached to.
  41190. */
  41191. camera: FreeCamera;
  41192. /**
  41193. * Define the Gamepad controlling the input
  41194. */
  41195. gamepad: Nullable<Gamepad>;
  41196. /**
  41197. * Defines the gamepad rotation sensiblity.
  41198. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41199. */
  41200. gamepadAngularSensibility: number;
  41201. /**
  41202. * Defines the gamepad move sensiblity.
  41203. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41204. */
  41205. gamepadMoveSensibility: number;
  41206. private _yAxisScale;
  41207. /**
  41208. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41209. */
  41210. get invertYAxis(): boolean;
  41211. set invertYAxis(value: boolean);
  41212. private _onGamepadConnectedObserver;
  41213. private _onGamepadDisconnectedObserver;
  41214. private _cameraTransform;
  41215. private _deltaTransform;
  41216. private _vector3;
  41217. private _vector2;
  41218. /**
  41219. * Attach the input controls to a specific dom element to get the input from.
  41220. * @param element Defines the element the controls should be listened from
  41221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41222. */
  41223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41224. /**
  41225. * Detach the current controls from the specified dom element.
  41226. * @param element Defines the element to stop listening the inputs from
  41227. */
  41228. detachControl(element: Nullable<HTMLElement>): void;
  41229. /**
  41230. * Update the current camera state depending on the inputs that have been used this frame.
  41231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41232. */
  41233. checkInputs(): void;
  41234. /**
  41235. * Gets the class name of the current intput.
  41236. * @returns the class name
  41237. */
  41238. getClassName(): string;
  41239. /**
  41240. * Get the friendly name associated with the input class.
  41241. * @returns the input friendly name
  41242. */
  41243. getSimpleName(): string;
  41244. }
  41245. }
  41246. declare module BABYLON {
  41247. /**
  41248. * Defines the potential axis of a Joystick
  41249. */
  41250. export enum JoystickAxis {
  41251. /** X axis */
  41252. X = 0,
  41253. /** Y axis */
  41254. Y = 1,
  41255. /** Z axis */
  41256. Z = 2
  41257. }
  41258. /**
  41259. * Class used to define virtual joystick (used in touch mode)
  41260. */
  41261. export class VirtualJoystick {
  41262. /**
  41263. * Gets or sets a boolean indicating that left and right values must be inverted
  41264. */
  41265. reverseLeftRight: boolean;
  41266. /**
  41267. * Gets or sets a boolean indicating that up and down values must be inverted
  41268. */
  41269. reverseUpDown: boolean;
  41270. /**
  41271. * Gets the offset value for the position (ie. the change of the position value)
  41272. */
  41273. deltaPosition: Vector3;
  41274. /**
  41275. * Gets a boolean indicating if the virtual joystick was pressed
  41276. */
  41277. pressed: boolean;
  41278. /**
  41279. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41280. */
  41281. static Canvas: Nullable<HTMLCanvasElement>;
  41282. private static _globalJoystickIndex;
  41283. private static vjCanvasContext;
  41284. private static vjCanvasWidth;
  41285. private static vjCanvasHeight;
  41286. private static halfWidth;
  41287. private _action;
  41288. private _axisTargetedByLeftAndRight;
  41289. private _axisTargetedByUpAndDown;
  41290. private _joystickSensibility;
  41291. private _inversedSensibility;
  41292. private _joystickPointerID;
  41293. private _joystickColor;
  41294. private _joystickPointerPos;
  41295. private _joystickPreviousPointerPos;
  41296. private _joystickPointerStartPos;
  41297. private _deltaJoystickVector;
  41298. private _leftJoystick;
  41299. private _touches;
  41300. private _onPointerDownHandlerRef;
  41301. private _onPointerMoveHandlerRef;
  41302. private _onPointerUpHandlerRef;
  41303. private _onResize;
  41304. /**
  41305. * Creates a new virtual joystick
  41306. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41307. */
  41308. constructor(leftJoystick?: boolean);
  41309. /**
  41310. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41311. * @param newJoystickSensibility defines the new sensibility
  41312. */
  41313. setJoystickSensibility(newJoystickSensibility: number): void;
  41314. private _onPointerDown;
  41315. private _onPointerMove;
  41316. private _onPointerUp;
  41317. /**
  41318. * Change the color of the virtual joystick
  41319. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41320. */
  41321. setJoystickColor(newColor: string): void;
  41322. /**
  41323. * Defines a callback to call when the joystick is touched
  41324. * @param action defines the callback
  41325. */
  41326. setActionOnTouch(action: () => any): void;
  41327. /**
  41328. * Defines which axis you'd like to control for left & right
  41329. * @param axis defines the axis to use
  41330. */
  41331. setAxisForLeftRight(axis: JoystickAxis): void;
  41332. /**
  41333. * Defines which axis you'd like to control for up & down
  41334. * @param axis defines the axis to use
  41335. */
  41336. setAxisForUpDown(axis: JoystickAxis): void;
  41337. private _drawVirtualJoystick;
  41338. /**
  41339. * Release internal HTML canvas
  41340. */
  41341. releaseCanvas(): void;
  41342. }
  41343. }
  41344. declare module BABYLON {
  41345. interface FreeCameraInputsManager {
  41346. /**
  41347. * Add virtual joystick input support to the input manager.
  41348. * @returns the current input manager
  41349. */
  41350. addVirtualJoystick(): FreeCameraInputsManager;
  41351. }
  41352. /**
  41353. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41355. */
  41356. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41357. /**
  41358. * Defines the camera the input is attached to.
  41359. */
  41360. camera: FreeCamera;
  41361. private _leftjoystick;
  41362. private _rightjoystick;
  41363. /**
  41364. * Gets the left stick of the virtual joystick.
  41365. * @returns The virtual Joystick
  41366. */
  41367. getLeftJoystick(): VirtualJoystick;
  41368. /**
  41369. * Gets the right stick of the virtual joystick.
  41370. * @returns The virtual Joystick
  41371. */
  41372. getRightJoystick(): VirtualJoystick;
  41373. /**
  41374. * Update the current camera state depending on the inputs that have been used this frame.
  41375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41376. */
  41377. checkInputs(): void;
  41378. /**
  41379. * Attach the input controls to a specific dom element to get the input from.
  41380. * @param element Defines the element the controls should be listened from
  41381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41382. */
  41383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41384. /**
  41385. * Detach the current controls from the specified dom element.
  41386. * @param element Defines the element to stop listening the inputs from
  41387. */
  41388. detachControl(element: Nullable<HTMLElement>): void;
  41389. /**
  41390. * Gets the class name of the current intput.
  41391. * @returns the class name
  41392. */
  41393. getClassName(): string;
  41394. /**
  41395. * Get the friendly name associated with the input class.
  41396. * @returns the input friendly name
  41397. */
  41398. getSimpleName(): string;
  41399. }
  41400. }
  41401. declare module BABYLON {
  41402. /**
  41403. * This represents a FPS type of camera controlled by touch.
  41404. * This is like a universal camera minus the Gamepad controls.
  41405. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41406. */
  41407. export class TouchCamera extends FreeCamera {
  41408. /**
  41409. * Defines the touch sensibility for rotation.
  41410. * The higher the faster.
  41411. */
  41412. get touchAngularSensibility(): number;
  41413. set touchAngularSensibility(value: number);
  41414. /**
  41415. * Defines the touch sensibility for move.
  41416. * The higher the faster.
  41417. */
  41418. get touchMoveSensibility(): number;
  41419. set touchMoveSensibility(value: number);
  41420. /**
  41421. * Instantiates a new touch camera.
  41422. * This represents a FPS type of camera controlled by touch.
  41423. * This is like a universal camera minus the Gamepad controls.
  41424. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41425. * @param name Define the name of the camera in the scene
  41426. * @param position Define the start position of the camera in the scene
  41427. * @param scene Define the scene the camera belongs to
  41428. */
  41429. constructor(name: string, position: Vector3, scene: Scene);
  41430. /**
  41431. * Gets the current object class name.
  41432. * @return the class name
  41433. */
  41434. getClassName(): string;
  41435. /** @hidden */
  41436. _setupInputs(): void;
  41437. }
  41438. }
  41439. declare module BABYLON {
  41440. /**
  41441. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41442. * being tilted forward or back and left or right.
  41443. */
  41444. export class DeviceOrientationCamera extends FreeCamera {
  41445. private _initialQuaternion;
  41446. private _quaternionCache;
  41447. private _tmpDragQuaternion;
  41448. private _disablePointerInputWhenUsingDeviceOrientation;
  41449. /**
  41450. * Creates a new device orientation camera
  41451. * @param name The name of the camera
  41452. * @param position The start position camera
  41453. * @param scene The scene the camera belongs to
  41454. */
  41455. constructor(name: string, position: Vector3, scene: Scene);
  41456. /**
  41457. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41458. */
  41459. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41460. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41461. private _dragFactor;
  41462. /**
  41463. * Enabled turning on the y axis when the orientation sensor is active
  41464. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41465. */
  41466. enableHorizontalDragging(dragFactor?: number): void;
  41467. /**
  41468. * Gets the current instance class name ("DeviceOrientationCamera").
  41469. * This helps avoiding instanceof at run time.
  41470. * @returns the class name
  41471. */
  41472. getClassName(): string;
  41473. /**
  41474. * @hidden
  41475. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41476. */
  41477. _checkInputs(): void;
  41478. /**
  41479. * Reset the camera to its default orientation on the specified axis only.
  41480. * @param axis The axis to reset
  41481. */
  41482. resetToCurrentRotation(axis?: Axis): void;
  41483. }
  41484. }
  41485. declare module BABYLON {
  41486. /**
  41487. * Defines supported buttons for XBox360 compatible gamepads
  41488. */
  41489. export enum Xbox360Button {
  41490. /** A */
  41491. A = 0,
  41492. /** B */
  41493. B = 1,
  41494. /** X */
  41495. X = 2,
  41496. /** Y */
  41497. Y = 3,
  41498. /** Left button */
  41499. LB = 4,
  41500. /** Right button */
  41501. RB = 5,
  41502. /** Back */
  41503. Back = 8,
  41504. /** Start */
  41505. Start = 9,
  41506. /** Left stick */
  41507. LeftStick = 10,
  41508. /** Right stick */
  41509. RightStick = 11
  41510. }
  41511. /** Defines values for XBox360 DPad */
  41512. export enum Xbox360Dpad {
  41513. /** Up */
  41514. Up = 12,
  41515. /** Down */
  41516. Down = 13,
  41517. /** Left */
  41518. Left = 14,
  41519. /** Right */
  41520. Right = 15
  41521. }
  41522. /**
  41523. * Defines a XBox360 gamepad
  41524. */
  41525. export class Xbox360Pad extends Gamepad {
  41526. private _leftTrigger;
  41527. private _rightTrigger;
  41528. private _onlefttriggerchanged;
  41529. private _onrighttriggerchanged;
  41530. private _onbuttondown;
  41531. private _onbuttonup;
  41532. private _ondpaddown;
  41533. private _ondpadup;
  41534. /** Observable raised when a button is pressed */
  41535. onButtonDownObservable: Observable<Xbox360Button>;
  41536. /** Observable raised when a button is released */
  41537. onButtonUpObservable: Observable<Xbox360Button>;
  41538. /** Observable raised when a pad is pressed */
  41539. onPadDownObservable: Observable<Xbox360Dpad>;
  41540. /** Observable raised when a pad is released */
  41541. onPadUpObservable: Observable<Xbox360Dpad>;
  41542. private _buttonA;
  41543. private _buttonB;
  41544. private _buttonX;
  41545. private _buttonY;
  41546. private _buttonBack;
  41547. private _buttonStart;
  41548. private _buttonLB;
  41549. private _buttonRB;
  41550. private _buttonLeftStick;
  41551. private _buttonRightStick;
  41552. private _dPadUp;
  41553. private _dPadDown;
  41554. private _dPadLeft;
  41555. private _dPadRight;
  41556. private _isXboxOnePad;
  41557. /**
  41558. * Creates a new XBox360 gamepad object
  41559. * @param id defines the id of this gamepad
  41560. * @param index defines its index
  41561. * @param gamepad defines the internal HTML gamepad object
  41562. * @param xboxOne defines if it is a XBox One gamepad
  41563. */
  41564. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41565. /**
  41566. * Defines the callback to call when left trigger is pressed
  41567. * @param callback defines the callback to use
  41568. */
  41569. onlefttriggerchanged(callback: (value: number) => void): void;
  41570. /**
  41571. * Defines the callback to call when right trigger is pressed
  41572. * @param callback defines the callback to use
  41573. */
  41574. onrighttriggerchanged(callback: (value: number) => void): void;
  41575. /**
  41576. * Gets the left trigger value
  41577. */
  41578. get leftTrigger(): number;
  41579. /**
  41580. * Sets the left trigger value
  41581. */
  41582. set leftTrigger(newValue: number);
  41583. /**
  41584. * Gets the right trigger value
  41585. */
  41586. get rightTrigger(): number;
  41587. /**
  41588. * Sets the right trigger value
  41589. */
  41590. set rightTrigger(newValue: number);
  41591. /**
  41592. * Defines the callback to call when a button is pressed
  41593. * @param callback defines the callback to use
  41594. */
  41595. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41596. /**
  41597. * Defines the callback to call when a button is released
  41598. * @param callback defines the callback to use
  41599. */
  41600. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41601. /**
  41602. * Defines the callback to call when a pad is pressed
  41603. * @param callback defines the callback to use
  41604. */
  41605. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41606. /**
  41607. * Defines the callback to call when a pad is released
  41608. * @param callback defines the callback to use
  41609. */
  41610. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41611. private _setButtonValue;
  41612. private _setDPadValue;
  41613. /**
  41614. * Gets the value of the `A` button
  41615. */
  41616. get buttonA(): number;
  41617. /**
  41618. * Sets the value of the `A` button
  41619. */
  41620. set buttonA(value: number);
  41621. /**
  41622. * Gets the value of the `B` button
  41623. */
  41624. get buttonB(): number;
  41625. /**
  41626. * Sets the value of the `B` button
  41627. */
  41628. set buttonB(value: number);
  41629. /**
  41630. * Gets the value of the `X` button
  41631. */
  41632. get buttonX(): number;
  41633. /**
  41634. * Sets the value of the `X` button
  41635. */
  41636. set buttonX(value: number);
  41637. /**
  41638. * Gets the value of the `Y` button
  41639. */
  41640. get buttonY(): number;
  41641. /**
  41642. * Sets the value of the `Y` button
  41643. */
  41644. set buttonY(value: number);
  41645. /**
  41646. * Gets the value of the `Start` button
  41647. */
  41648. get buttonStart(): number;
  41649. /**
  41650. * Sets the value of the `Start` button
  41651. */
  41652. set buttonStart(value: number);
  41653. /**
  41654. * Gets the value of the `Back` button
  41655. */
  41656. get buttonBack(): number;
  41657. /**
  41658. * Sets the value of the `Back` button
  41659. */
  41660. set buttonBack(value: number);
  41661. /**
  41662. * Gets the value of the `Left` button
  41663. */
  41664. get buttonLB(): number;
  41665. /**
  41666. * Sets the value of the `Left` button
  41667. */
  41668. set buttonLB(value: number);
  41669. /**
  41670. * Gets the value of the `Right` button
  41671. */
  41672. get buttonRB(): number;
  41673. /**
  41674. * Sets the value of the `Right` button
  41675. */
  41676. set buttonRB(value: number);
  41677. /**
  41678. * Gets the value of the Left joystick
  41679. */
  41680. get buttonLeftStick(): number;
  41681. /**
  41682. * Sets the value of the Left joystick
  41683. */
  41684. set buttonLeftStick(value: number);
  41685. /**
  41686. * Gets the value of the Right joystick
  41687. */
  41688. get buttonRightStick(): number;
  41689. /**
  41690. * Sets the value of the Right joystick
  41691. */
  41692. set buttonRightStick(value: number);
  41693. /**
  41694. * Gets the value of D-pad up
  41695. */
  41696. get dPadUp(): number;
  41697. /**
  41698. * Sets the value of D-pad up
  41699. */
  41700. set dPadUp(value: number);
  41701. /**
  41702. * Gets the value of D-pad down
  41703. */
  41704. get dPadDown(): number;
  41705. /**
  41706. * Sets the value of D-pad down
  41707. */
  41708. set dPadDown(value: number);
  41709. /**
  41710. * Gets the value of D-pad left
  41711. */
  41712. get dPadLeft(): number;
  41713. /**
  41714. * Sets the value of D-pad left
  41715. */
  41716. set dPadLeft(value: number);
  41717. /**
  41718. * Gets the value of D-pad right
  41719. */
  41720. get dPadRight(): number;
  41721. /**
  41722. * Sets the value of D-pad right
  41723. */
  41724. set dPadRight(value: number);
  41725. /**
  41726. * Force the gamepad to synchronize with device values
  41727. */
  41728. update(): void;
  41729. /**
  41730. * Disposes the gamepad
  41731. */
  41732. dispose(): void;
  41733. }
  41734. }
  41735. declare module BABYLON {
  41736. /**
  41737. * Defines supported buttons for DualShock compatible gamepads
  41738. */
  41739. export enum DualShockButton {
  41740. /** Cross */
  41741. Cross = 0,
  41742. /** Circle */
  41743. Circle = 1,
  41744. /** Square */
  41745. Square = 2,
  41746. /** Triangle */
  41747. Triangle = 3,
  41748. /** L1 */
  41749. L1 = 4,
  41750. /** R1 */
  41751. R1 = 5,
  41752. /** Share */
  41753. Share = 8,
  41754. /** Options */
  41755. Options = 9,
  41756. /** Left stick */
  41757. LeftStick = 10,
  41758. /** Right stick */
  41759. RightStick = 11
  41760. }
  41761. /** Defines values for DualShock DPad */
  41762. export enum DualShockDpad {
  41763. /** Up */
  41764. Up = 12,
  41765. /** Down */
  41766. Down = 13,
  41767. /** Left */
  41768. Left = 14,
  41769. /** Right */
  41770. Right = 15
  41771. }
  41772. /**
  41773. * Defines a DualShock gamepad
  41774. */
  41775. export class DualShockPad extends Gamepad {
  41776. private _leftTrigger;
  41777. private _rightTrigger;
  41778. private _onlefttriggerchanged;
  41779. private _onrighttriggerchanged;
  41780. private _onbuttondown;
  41781. private _onbuttonup;
  41782. private _ondpaddown;
  41783. private _ondpadup;
  41784. /** Observable raised when a button is pressed */
  41785. onButtonDownObservable: Observable<DualShockButton>;
  41786. /** Observable raised when a button is released */
  41787. onButtonUpObservable: Observable<DualShockButton>;
  41788. /** Observable raised when a pad is pressed */
  41789. onPadDownObservable: Observable<DualShockDpad>;
  41790. /** Observable raised when a pad is released */
  41791. onPadUpObservable: Observable<DualShockDpad>;
  41792. private _buttonCross;
  41793. private _buttonCircle;
  41794. private _buttonSquare;
  41795. private _buttonTriangle;
  41796. private _buttonShare;
  41797. private _buttonOptions;
  41798. private _buttonL1;
  41799. private _buttonR1;
  41800. private _buttonLeftStick;
  41801. private _buttonRightStick;
  41802. private _dPadUp;
  41803. private _dPadDown;
  41804. private _dPadLeft;
  41805. private _dPadRight;
  41806. /**
  41807. * Creates a new DualShock gamepad object
  41808. * @param id defines the id of this gamepad
  41809. * @param index defines its index
  41810. * @param gamepad defines the internal HTML gamepad object
  41811. */
  41812. constructor(id: string, index: number, gamepad: any);
  41813. /**
  41814. * Defines the callback to call when left trigger is pressed
  41815. * @param callback defines the callback to use
  41816. */
  41817. onlefttriggerchanged(callback: (value: number) => void): void;
  41818. /**
  41819. * Defines the callback to call when right trigger is pressed
  41820. * @param callback defines the callback to use
  41821. */
  41822. onrighttriggerchanged(callback: (value: number) => void): void;
  41823. /**
  41824. * Gets the left trigger value
  41825. */
  41826. get leftTrigger(): number;
  41827. /**
  41828. * Sets the left trigger value
  41829. */
  41830. set leftTrigger(newValue: number);
  41831. /**
  41832. * Gets the right trigger value
  41833. */
  41834. get rightTrigger(): number;
  41835. /**
  41836. * Sets the right trigger value
  41837. */
  41838. set rightTrigger(newValue: number);
  41839. /**
  41840. * Defines the callback to call when a button is pressed
  41841. * @param callback defines the callback to use
  41842. */
  41843. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41844. /**
  41845. * Defines the callback to call when a button is released
  41846. * @param callback defines the callback to use
  41847. */
  41848. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41849. /**
  41850. * Defines the callback to call when a pad is pressed
  41851. * @param callback defines the callback to use
  41852. */
  41853. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41854. /**
  41855. * Defines the callback to call when a pad is released
  41856. * @param callback defines the callback to use
  41857. */
  41858. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41859. private _setButtonValue;
  41860. private _setDPadValue;
  41861. /**
  41862. * Gets the value of the `Cross` button
  41863. */
  41864. get buttonCross(): number;
  41865. /**
  41866. * Sets the value of the `Cross` button
  41867. */
  41868. set buttonCross(value: number);
  41869. /**
  41870. * Gets the value of the `Circle` button
  41871. */
  41872. get buttonCircle(): number;
  41873. /**
  41874. * Sets the value of the `Circle` button
  41875. */
  41876. set buttonCircle(value: number);
  41877. /**
  41878. * Gets the value of the `Square` button
  41879. */
  41880. get buttonSquare(): number;
  41881. /**
  41882. * Sets the value of the `Square` button
  41883. */
  41884. set buttonSquare(value: number);
  41885. /**
  41886. * Gets the value of the `Triangle` button
  41887. */
  41888. get buttonTriangle(): number;
  41889. /**
  41890. * Sets the value of the `Triangle` button
  41891. */
  41892. set buttonTriangle(value: number);
  41893. /**
  41894. * Gets the value of the `Options` button
  41895. */
  41896. get buttonOptions(): number;
  41897. /**
  41898. * Sets the value of the `Options` button
  41899. */
  41900. set buttonOptions(value: number);
  41901. /**
  41902. * Gets the value of the `Share` button
  41903. */
  41904. get buttonShare(): number;
  41905. /**
  41906. * Sets the value of the `Share` button
  41907. */
  41908. set buttonShare(value: number);
  41909. /**
  41910. * Gets the value of the `L1` button
  41911. */
  41912. get buttonL1(): number;
  41913. /**
  41914. * Sets the value of the `L1` button
  41915. */
  41916. set buttonL1(value: number);
  41917. /**
  41918. * Gets the value of the `R1` button
  41919. */
  41920. get buttonR1(): number;
  41921. /**
  41922. * Sets the value of the `R1` button
  41923. */
  41924. set buttonR1(value: number);
  41925. /**
  41926. * Gets the value of the Left joystick
  41927. */
  41928. get buttonLeftStick(): number;
  41929. /**
  41930. * Sets the value of the Left joystick
  41931. */
  41932. set buttonLeftStick(value: number);
  41933. /**
  41934. * Gets the value of the Right joystick
  41935. */
  41936. get buttonRightStick(): number;
  41937. /**
  41938. * Sets the value of the Right joystick
  41939. */
  41940. set buttonRightStick(value: number);
  41941. /**
  41942. * Gets the value of D-pad up
  41943. */
  41944. get dPadUp(): number;
  41945. /**
  41946. * Sets the value of D-pad up
  41947. */
  41948. set dPadUp(value: number);
  41949. /**
  41950. * Gets the value of D-pad down
  41951. */
  41952. get dPadDown(): number;
  41953. /**
  41954. * Sets the value of D-pad down
  41955. */
  41956. set dPadDown(value: number);
  41957. /**
  41958. * Gets the value of D-pad left
  41959. */
  41960. get dPadLeft(): number;
  41961. /**
  41962. * Sets the value of D-pad left
  41963. */
  41964. set dPadLeft(value: number);
  41965. /**
  41966. * Gets the value of D-pad right
  41967. */
  41968. get dPadRight(): number;
  41969. /**
  41970. * Sets the value of D-pad right
  41971. */
  41972. set dPadRight(value: number);
  41973. /**
  41974. * Force the gamepad to synchronize with device values
  41975. */
  41976. update(): void;
  41977. /**
  41978. * Disposes the gamepad
  41979. */
  41980. dispose(): void;
  41981. }
  41982. }
  41983. declare module BABYLON {
  41984. /**
  41985. * Manager for handling gamepads
  41986. */
  41987. export class GamepadManager {
  41988. private _scene?;
  41989. private _babylonGamepads;
  41990. private _oneGamepadConnected;
  41991. /** @hidden */
  41992. _isMonitoring: boolean;
  41993. private _gamepadEventSupported;
  41994. private _gamepadSupport?;
  41995. /**
  41996. * observable to be triggered when the gamepad controller has been connected
  41997. */
  41998. onGamepadConnectedObservable: Observable<Gamepad>;
  41999. /**
  42000. * observable to be triggered when the gamepad controller has been disconnected
  42001. */
  42002. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42003. private _onGamepadConnectedEvent;
  42004. private _onGamepadDisconnectedEvent;
  42005. /**
  42006. * Initializes the gamepad manager
  42007. * @param _scene BabylonJS scene
  42008. */
  42009. constructor(_scene?: Scene | undefined);
  42010. /**
  42011. * The gamepads in the game pad manager
  42012. */
  42013. get gamepads(): Gamepad[];
  42014. /**
  42015. * Get the gamepad controllers based on type
  42016. * @param type The type of gamepad controller
  42017. * @returns Nullable gamepad
  42018. */
  42019. getGamepadByType(type?: number): Nullable<Gamepad>;
  42020. /**
  42021. * Disposes the gamepad manager
  42022. */
  42023. dispose(): void;
  42024. private _addNewGamepad;
  42025. private _startMonitoringGamepads;
  42026. private _stopMonitoringGamepads;
  42027. /** @hidden */
  42028. _checkGamepadsStatus(): void;
  42029. private _updateGamepadObjects;
  42030. }
  42031. }
  42032. declare module BABYLON {
  42033. interface Scene {
  42034. /** @hidden */
  42035. _gamepadManager: Nullable<GamepadManager>;
  42036. /**
  42037. * Gets the gamepad manager associated with the scene
  42038. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42039. */
  42040. gamepadManager: GamepadManager;
  42041. }
  42042. /**
  42043. * Interface representing a free camera inputs manager
  42044. */
  42045. interface FreeCameraInputsManager {
  42046. /**
  42047. * Adds gamepad input support to the FreeCameraInputsManager.
  42048. * @returns the FreeCameraInputsManager
  42049. */
  42050. addGamepad(): FreeCameraInputsManager;
  42051. }
  42052. /**
  42053. * Interface representing an arc rotate camera inputs manager
  42054. */
  42055. interface ArcRotateCameraInputsManager {
  42056. /**
  42057. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42058. * @returns the camera inputs manager
  42059. */
  42060. addGamepad(): ArcRotateCameraInputsManager;
  42061. }
  42062. /**
  42063. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42064. */
  42065. export class GamepadSystemSceneComponent implements ISceneComponent {
  42066. /**
  42067. * The component name helpfull to identify the component in the list of scene components.
  42068. */
  42069. readonly name: string;
  42070. /**
  42071. * The scene the component belongs to.
  42072. */
  42073. scene: Scene;
  42074. /**
  42075. * Creates a new instance of the component for the given scene
  42076. * @param scene Defines the scene to register the component in
  42077. */
  42078. constructor(scene: Scene);
  42079. /**
  42080. * Registers the component in a given scene
  42081. */
  42082. register(): void;
  42083. /**
  42084. * Rebuilds the elements related to this component in case of
  42085. * context lost for instance.
  42086. */
  42087. rebuild(): void;
  42088. /**
  42089. * Disposes the component and the associated ressources
  42090. */
  42091. dispose(): void;
  42092. private _beforeCameraUpdate;
  42093. }
  42094. }
  42095. declare module BABYLON {
  42096. /**
  42097. * 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,
  42098. * which still works and will still be found in many Playgrounds.
  42099. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42100. */
  42101. export class UniversalCamera extends TouchCamera {
  42102. /**
  42103. * Defines the gamepad rotation sensiblity.
  42104. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42105. */
  42106. get gamepadAngularSensibility(): number;
  42107. set gamepadAngularSensibility(value: number);
  42108. /**
  42109. * Defines the gamepad move sensiblity.
  42110. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42111. */
  42112. get gamepadMoveSensibility(): number;
  42113. set gamepadMoveSensibility(value: number);
  42114. /**
  42115. * 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,
  42116. * which still works and will still be found in many Playgrounds.
  42117. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42118. * @param name Define the name of the camera in the scene
  42119. * @param position Define the start position of the camera in the scene
  42120. * @param scene Define the scene the camera belongs to
  42121. */
  42122. constructor(name: string, position: Vector3, scene: Scene);
  42123. /**
  42124. * Gets the current object class name.
  42125. * @return the class name
  42126. */
  42127. getClassName(): string;
  42128. }
  42129. }
  42130. declare module BABYLON {
  42131. /**
  42132. * This represents a FPS type of camera. This is only here for back compat purpose.
  42133. * Please use the UniversalCamera instead as both are identical.
  42134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42135. */
  42136. export class GamepadCamera extends UniversalCamera {
  42137. /**
  42138. * Instantiates a new Gamepad Camera
  42139. * This represents a FPS type of camera. This is only here for back compat purpose.
  42140. * Please use the UniversalCamera instead as both are identical.
  42141. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42142. * @param name Define the name of the camera in the scene
  42143. * @param position Define the start position of the camera in the scene
  42144. * @param scene Define the scene the camera belongs to
  42145. */
  42146. constructor(name: string, position: Vector3, scene: Scene);
  42147. /**
  42148. * Gets the current object class name.
  42149. * @return the class name
  42150. */
  42151. getClassName(): string;
  42152. }
  42153. }
  42154. declare module BABYLON {
  42155. /** @hidden */
  42156. export var passPixelShader: {
  42157. name: string;
  42158. shader: string;
  42159. };
  42160. }
  42161. declare module BABYLON {
  42162. /** @hidden */
  42163. export var passCubePixelShader: {
  42164. name: string;
  42165. shader: string;
  42166. };
  42167. }
  42168. declare module BABYLON {
  42169. /**
  42170. * PassPostProcess which produces an output the same as it's input
  42171. */
  42172. export class PassPostProcess extends PostProcess {
  42173. /**
  42174. * Creates the PassPostProcess
  42175. * @param name The name of the effect.
  42176. * @param options The required width/height ratio to downsize to before computing the render pass.
  42177. * @param camera The camera to apply the render pass to.
  42178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42179. * @param engine The engine which the post process will be applied. (default: current engine)
  42180. * @param reusable If the post process can be reused on the same frame. (default: false)
  42181. * @param textureType The type of texture to be used when performing the post processing.
  42182. * @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)
  42183. */
  42184. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42185. }
  42186. /**
  42187. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42188. */
  42189. export class PassCubePostProcess extends PostProcess {
  42190. private _face;
  42191. /**
  42192. * Gets or sets the cube face to display.
  42193. * * 0 is +X
  42194. * * 1 is -X
  42195. * * 2 is +Y
  42196. * * 3 is -Y
  42197. * * 4 is +Z
  42198. * * 5 is -Z
  42199. */
  42200. get face(): number;
  42201. set face(value: number);
  42202. /**
  42203. * Creates the PassCubePostProcess
  42204. * @param name The name of the effect.
  42205. * @param options The required width/height ratio to downsize to before computing the render pass.
  42206. * @param camera The camera to apply the render pass to.
  42207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42208. * @param engine The engine which the post process will be applied. (default: current engine)
  42209. * @param reusable If the post process can be reused on the same frame. (default: false)
  42210. * @param textureType The type of texture to be used when performing the post processing.
  42211. * @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)
  42212. */
  42213. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42214. }
  42215. }
  42216. declare module BABYLON {
  42217. /** @hidden */
  42218. export var anaglyphPixelShader: {
  42219. name: string;
  42220. shader: string;
  42221. };
  42222. }
  42223. declare module BABYLON {
  42224. /**
  42225. * Postprocess used to generate anaglyphic rendering
  42226. */
  42227. export class AnaglyphPostProcess extends PostProcess {
  42228. private _passedProcess;
  42229. /**
  42230. * Creates a new AnaglyphPostProcess
  42231. * @param name defines postprocess name
  42232. * @param options defines creation options or target ratio scale
  42233. * @param rigCameras defines cameras using this postprocess
  42234. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42235. * @param engine defines hosting engine
  42236. * @param reusable defines if the postprocess will be reused multiple times per frame
  42237. */
  42238. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42239. }
  42240. }
  42241. declare module BABYLON {
  42242. /**
  42243. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42244. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42245. */
  42246. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42247. /**
  42248. * Creates a new AnaglyphArcRotateCamera
  42249. * @param name defines camera name
  42250. * @param alpha defines alpha angle (in radians)
  42251. * @param beta defines beta angle (in radians)
  42252. * @param radius defines radius
  42253. * @param target defines camera target
  42254. * @param interaxialDistance defines distance between each color axis
  42255. * @param scene defines the hosting scene
  42256. */
  42257. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42258. /**
  42259. * Gets camera class name
  42260. * @returns AnaglyphArcRotateCamera
  42261. */
  42262. getClassName(): string;
  42263. }
  42264. }
  42265. declare module BABYLON {
  42266. /**
  42267. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42268. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42269. */
  42270. export class AnaglyphFreeCamera extends FreeCamera {
  42271. /**
  42272. * Creates a new AnaglyphFreeCamera
  42273. * @param name defines camera name
  42274. * @param position defines initial position
  42275. * @param interaxialDistance defines distance between each color axis
  42276. * @param scene defines the hosting scene
  42277. */
  42278. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42279. /**
  42280. * Gets camera class name
  42281. * @returns AnaglyphFreeCamera
  42282. */
  42283. getClassName(): string;
  42284. }
  42285. }
  42286. declare module BABYLON {
  42287. /**
  42288. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42289. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42290. */
  42291. export class AnaglyphGamepadCamera extends GamepadCamera {
  42292. /**
  42293. * Creates a new AnaglyphGamepadCamera
  42294. * @param name defines camera name
  42295. * @param position defines initial position
  42296. * @param interaxialDistance defines distance between each color axis
  42297. * @param scene defines the hosting scene
  42298. */
  42299. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42300. /**
  42301. * Gets camera class name
  42302. * @returns AnaglyphGamepadCamera
  42303. */
  42304. getClassName(): string;
  42305. }
  42306. }
  42307. declare module BABYLON {
  42308. /**
  42309. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42310. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42311. */
  42312. export class AnaglyphUniversalCamera extends UniversalCamera {
  42313. /**
  42314. * Creates a new AnaglyphUniversalCamera
  42315. * @param name defines camera name
  42316. * @param position defines initial position
  42317. * @param interaxialDistance defines distance between each color axis
  42318. * @param scene defines the hosting scene
  42319. */
  42320. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42321. /**
  42322. * Gets camera class name
  42323. * @returns AnaglyphUniversalCamera
  42324. */
  42325. getClassName(): string;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42331. * @see http://doc.babylonjs.com/features/cameras
  42332. */
  42333. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42334. /**
  42335. * Creates a new StereoscopicArcRotateCamera
  42336. * @param name defines camera name
  42337. * @param alpha defines alpha angle (in radians)
  42338. * @param beta defines beta angle (in radians)
  42339. * @param radius defines radius
  42340. * @param target defines camera target
  42341. * @param interaxialDistance defines distance between each color axis
  42342. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42343. * @param scene defines the hosting scene
  42344. */
  42345. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42346. /**
  42347. * Gets camera class name
  42348. * @returns StereoscopicArcRotateCamera
  42349. */
  42350. getClassName(): string;
  42351. }
  42352. }
  42353. declare module BABYLON {
  42354. /**
  42355. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42356. * @see http://doc.babylonjs.com/features/cameras
  42357. */
  42358. export class StereoscopicFreeCamera extends FreeCamera {
  42359. /**
  42360. * Creates a new StereoscopicFreeCamera
  42361. * @param name defines camera name
  42362. * @param position defines initial position
  42363. * @param interaxialDistance defines distance between each color axis
  42364. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42365. * @param scene defines the hosting scene
  42366. */
  42367. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42368. /**
  42369. * Gets camera class name
  42370. * @returns StereoscopicFreeCamera
  42371. */
  42372. getClassName(): string;
  42373. }
  42374. }
  42375. declare module BABYLON {
  42376. /**
  42377. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42378. * @see http://doc.babylonjs.com/features/cameras
  42379. */
  42380. export class StereoscopicGamepadCamera extends GamepadCamera {
  42381. /**
  42382. * Creates a new StereoscopicGamepadCamera
  42383. * @param name defines camera name
  42384. * @param position defines initial position
  42385. * @param interaxialDistance defines distance between each color axis
  42386. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42387. * @param scene defines the hosting scene
  42388. */
  42389. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42390. /**
  42391. * Gets camera class name
  42392. * @returns StereoscopicGamepadCamera
  42393. */
  42394. getClassName(): string;
  42395. }
  42396. }
  42397. declare module BABYLON {
  42398. /**
  42399. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42400. * @see http://doc.babylonjs.com/features/cameras
  42401. */
  42402. export class StereoscopicUniversalCamera extends UniversalCamera {
  42403. /**
  42404. * Creates a new StereoscopicUniversalCamera
  42405. * @param name defines camera name
  42406. * @param position defines initial position
  42407. * @param interaxialDistance defines distance between each color axis
  42408. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42409. * @param scene defines the hosting scene
  42410. */
  42411. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42412. /**
  42413. * Gets camera class name
  42414. * @returns StereoscopicUniversalCamera
  42415. */
  42416. getClassName(): string;
  42417. }
  42418. }
  42419. declare module BABYLON {
  42420. /**
  42421. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42422. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42423. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42424. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42425. */
  42426. export class VirtualJoysticksCamera extends FreeCamera {
  42427. /**
  42428. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42429. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42430. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42431. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42432. * @param name Define the name of the camera in the scene
  42433. * @param position Define the start position of the camera in the scene
  42434. * @param scene Define the scene the camera belongs to
  42435. */
  42436. constructor(name: string, position: Vector3, scene: Scene);
  42437. /**
  42438. * Gets the current object class name.
  42439. * @return the class name
  42440. */
  42441. getClassName(): string;
  42442. }
  42443. }
  42444. declare module BABYLON {
  42445. /**
  42446. * This represents all the required metrics to create a VR camera.
  42447. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42448. */
  42449. export class VRCameraMetrics {
  42450. /**
  42451. * Define the horizontal resolution off the screen.
  42452. */
  42453. hResolution: number;
  42454. /**
  42455. * Define the vertical resolution off the screen.
  42456. */
  42457. vResolution: number;
  42458. /**
  42459. * Define the horizontal screen size.
  42460. */
  42461. hScreenSize: number;
  42462. /**
  42463. * Define the vertical screen size.
  42464. */
  42465. vScreenSize: number;
  42466. /**
  42467. * Define the vertical screen center position.
  42468. */
  42469. vScreenCenter: number;
  42470. /**
  42471. * Define the distance of the eyes to the screen.
  42472. */
  42473. eyeToScreenDistance: number;
  42474. /**
  42475. * Define the distance between both lenses
  42476. */
  42477. lensSeparationDistance: number;
  42478. /**
  42479. * Define the distance between both viewer's eyes.
  42480. */
  42481. interpupillaryDistance: number;
  42482. /**
  42483. * Define the distortion factor of the VR postprocess.
  42484. * Please, touch with care.
  42485. */
  42486. distortionK: number[];
  42487. /**
  42488. * Define the chromatic aberration correction factors for the VR post process.
  42489. */
  42490. chromaAbCorrection: number[];
  42491. /**
  42492. * Define the scale factor of the post process.
  42493. * The smaller the better but the slower.
  42494. */
  42495. postProcessScaleFactor: number;
  42496. /**
  42497. * Define an offset for the lens center.
  42498. */
  42499. lensCenterOffset: number;
  42500. /**
  42501. * Define if the current vr camera should compensate the distortion of the lense or not.
  42502. */
  42503. compensateDistortion: boolean;
  42504. /**
  42505. * Defines if multiview should be enabled when rendering (Default: false)
  42506. */
  42507. multiviewEnabled: boolean;
  42508. /**
  42509. * Gets the rendering aspect ratio based on the provided resolutions.
  42510. */
  42511. get aspectRatio(): number;
  42512. /**
  42513. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42514. */
  42515. get aspectRatioFov(): number;
  42516. /**
  42517. * @hidden
  42518. */
  42519. get leftHMatrix(): Matrix;
  42520. /**
  42521. * @hidden
  42522. */
  42523. get rightHMatrix(): Matrix;
  42524. /**
  42525. * @hidden
  42526. */
  42527. get leftPreViewMatrix(): Matrix;
  42528. /**
  42529. * @hidden
  42530. */
  42531. get rightPreViewMatrix(): Matrix;
  42532. /**
  42533. * Get the default VRMetrics based on the most generic setup.
  42534. * @returns the default vr metrics
  42535. */
  42536. static GetDefault(): VRCameraMetrics;
  42537. }
  42538. }
  42539. declare module BABYLON {
  42540. /** @hidden */
  42541. export var vrDistortionCorrectionPixelShader: {
  42542. name: string;
  42543. shader: string;
  42544. };
  42545. }
  42546. declare module BABYLON {
  42547. /**
  42548. * VRDistortionCorrectionPostProcess used for mobile VR
  42549. */
  42550. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42551. private _isRightEye;
  42552. private _distortionFactors;
  42553. private _postProcessScaleFactor;
  42554. private _lensCenterOffset;
  42555. private _scaleIn;
  42556. private _scaleFactor;
  42557. private _lensCenter;
  42558. /**
  42559. * Initializes the VRDistortionCorrectionPostProcess
  42560. * @param name The name of the effect.
  42561. * @param camera The camera to apply the render pass to.
  42562. * @param isRightEye If this is for the right eye distortion
  42563. * @param vrMetrics All the required metrics for the VR camera
  42564. */
  42565. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42571. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42572. */
  42573. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42574. /**
  42575. * Creates a new VRDeviceOrientationArcRotateCamera
  42576. * @param name defines camera name
  42577. * @param alpha defines the camera rotation along the logitudinal axis
  42578. * @param beta defines the camera rotation along the latitudinal axis
  42579. * @param radius defines the camera distance from its target
  42580. * @param target defines the camera target
  42581. * @param scene defines the scene the camera belongs to
  42582. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42583. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42584. */
  42585. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42586. /**
  42587. * Gets camera class name
  42588. * @returns VRDeviceOrientationArcRotateCamera
  42589. */
  42590. getClassName(): string;
  42591. }
  42592. }
  42593. declare module BABYLON {
  42594. /**
  42595. * Camera used to simulate VR rendering (based on FreeCamera)
  42596. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42597. */
  42598. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42599. /**
  42600. * Creates a new VRDeviceOrientationFreeCamera
  42601. * @param name defines camera name
  42602. * @param position defines the start position of the camera
  42603. * @param scene defines the scene the camera belongs to
  42604. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42605. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42606. */
  42607. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42608. /**
  42609. * Gets camera class name
  42610. * @returns VRDeviceOrientationFreeCamera
  42611. */
  42612. getClassName(): string;
  42613. }
  42614. }
  42615. declare module BABYLON {
  42616. /**
  42617. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42618. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42619. */
  42620. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42621. /**
  42622. * Creates a new VRDeviceOrientationGamepadCamera
  42623. * @param name defines camera name
  42624. * @param position defines the start position of the camera
  42625. * @param scene defines the scene the camera belongs to
  42626. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42627. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42628. */
  42629. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42630. /**
  42631. * Gets camera class name
  42632. * @returns VRDeviceOrientationGamepadCamera
  42633. */
  42634. getClassName(): string;
  42635. }
  42636. }
  42637. declare module BABYLON {
  42638. /** @hidden */
  42639. export var imageProcessingPixelShader: {
  42640. name: string;
  42641. shader: string;
  42642. };
  42643. }
  42644. declare module BABYLON {
  42645. /**
  42646. * ImageProcessingPostProcess
  42647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42648. */
  42649. export class ImageProcessingPostProcess extends PostProcess {
  42650. /**
  42651. * Default configuration related to image processing available in the PBR Material.
  42652. */
  42653. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42654. /**
  42655. * Gets the image processing configuration used either in this material.
  42656. */
  42657. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42658. /**
  42659. * Sets the Default image processing configuration used either in the this material.
  42660. *
  42661. * If sets to null, the scene one is in use.
  42662. */
  42663. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42664. /**
  42665. * Keep track of the image processing observer to allow dispose and replace.
  42666. */
  42667. private _imageProcessingObserver;
  42668. /**
  42669. * Attaches a new image processing configuration to the PBR Material.
  42670. * @param configuration
  42671. */
  42672. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42673. /**
  42674. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42675. */
  42676. get colorCurves(): Nullable<ColorCurves>;
  42677. /**
  42678. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42679. */
  42680. set colorCurves(value: Nullable<ColorCurves>);
  42681. /**
  42682. * Gets wether the color curves effect is enabled.
  42683. */
  42684. get colorCurvesEnabled(): boolean;
  42685. /**
  42686. * Sets wether the color curves effect is enabled.
  42687. */
  42688. set colorCurvesEnabled(value: boolean);
  42689. /**
  42690. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42691. */
  42692. get colorGradingTexture(): Nullable<BaseTexture>;
  42693. /**
  42694. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42695. */
  42696. set colorGradingTexture(value: Nullable<BaseTexture>);
  42697. /**
  42698. * Gets wether the color grading effect is enabled.
  42699. */
  42700. get colorGradingEnabled(): boolean;
  42701. /**
  42702. * Gets wether the color grading effect is enabled.
  42703. */
  42704. set colorGradingEnabled(value: boolean);
  42705. /**
  42706. * Gets exposure used in the effect.
  42707. */
  42708. get exposure(): number;
  42709. /**
  42710. * Sets exposure used in the effect.
  42711. */
  42712. set exposure(value: number);
  42713. /**
  42714. * Gets wether tonemapping is enabled or not.
  42715. */
  42716. get toneMappingEnabled(): boolean;
  42717. /**
  42718. * Sets wether tonemapping is enabled or not
  42719. */
  42720. set toneMappingEnabled(value: boolean);
  42721. /**
  42722. * Gets the type of tone mapping effect.
  42723. */
  42724. get toneMappingType(): number;
  42725. /**
  42726. * Sets the type of tone mapping effect.
  42727. */
  42728. set toneMappingType(value: number);
  42729. /**
  42730. * Gets contrast used in the effect.
  42731. */
  42732. get contrast(): number;
  42733. /**
  42734. * Sets contrast used in the effect.
  42735. */
  42736. set contrast(value: number);
  42737. /**
  42738. * Gets Vignette stretch size.
  42739. */
  42740. get vignetteStretch(): number;
  42741. /**
  42742. * Sets Vignette stretch size.
  42743. */
  42744. set vignetteStretch(value: number);
  42745. /**
  42746. * Gets Vignette centre X Offset.
  42747. */
  42748. get vignetteCentreX(): number;
  42749. /**
  42750. * Sets Vignette centre X Offset.
  42751. */
  42752. set vignetteCentreX(value: number);
  42753. /**
  42754. * Gets Vignette centre Y Offset.
  42755. */
  42756. get vignetteCentreY(): number;
  42757. /**
  42758. * Sets Vignette centre Y Offset.
  42759. */
  42760. set vignetteCentreY(value: number);
  42761. /**
  42762. * Gets Vignette weight or intensity of the vignette effect.
  42763. */
  42764. get vignetteWeight(): number;
  42765. /**
  42766. * Sets Vignette weight or intensity of the vignette effect.
  42767. */
  42768. set vignetteWeight(value: number);
  42769. /**
  42770. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42771. * if vignetteEnabled is set to true.
  42772. */
  42773. get vignetteColor(): Color4;
  42774. /**
  42775. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42776. * if vignetteEnabled is set to true.
  42777. */
  42778. set vignetteColor(value: Color4);
  42779. /**
  42780. * Gets Camera field of view used by the Vignette effect.
  42781. */
  42782. get vignetteCameraFov(): number;
  42783. /**
  42784. * Sets Camera field of view used by the Vignette effect.
  42785. */
  42786. set vignetteCameraFov(value: number);
  42787. /**
  42788. * Gets the vignette blend mode allowing different kind of effect.
  42789. */
  42790. get vignetteBlendMode(): number;
  42791. /**
  42792. * Sets the vignette blend mode allowing different kind of effect.
  42793. */
  42794. set vignetteBlendMode(value: number);
  42795. /**
  42796. * Gets wether the vignette effect is enabled.
  42797. */
  42798. get vignetteEnabled(): boolean;
  42799. /**
  42800. * Sets wether the vignette effect is enabled.
  42801. */
  42802. set vignetteEnabled(value: boolean);
  42803. private _fromLinearSpace;
  42804. /**
  42805. * Gets wether the input of the processing is in Gamma or Linear Space.
  42806. */
  42807. get fromLinearSpace(): boolean;
  42808. /**
  42809. * Sets wether the input of the processing is in Gamma or Linear Space.
  42810. */
  42811. set fromLinearSpace(value: boolean);
  42812. /**
  42813. * Defines cache preventing GC.
  42814. */
  42815. private _defines;
  42816. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42817. /**
  42818. * "ImageProcessingPostProcess"
  42819. * @returns "ImageProcessingPostProcess"
  42820. */
  42821. getClassName(): string;
  42822. protected _updateParameters(): void;
  42823. dispose(camera?: Camera): void;
  42824. }
  42825. }
  42826. declare module BABYLON {
  42827. /**
  42828. * Class containing static functions to help procedurally build meshes
  42829. */
  42830. export class GroundBuilder {
  42831. /**
  42832. * Creates a ground mesh
  42833. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42834. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42836. * @param name defines the name of the mesh
  42837. * @param options defines the options used to create the mesh
  42838. * @param scene defines the hosting scene
  42839. * @returns the ground mesh
  42840. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42841. */
  42842. static CreateGround(name: string, options: {
  42843. width?: number;
  42844. height?: number;
  42845. subdivisions?: number;
  42846. subdivisionsX?: number;
  42847. subdivisionsY?: number;
  42848. updatable?: boolean;
  42849. }, scene: any): Mesh;
  42850. /**
  42851. * Creates a tiled ground mesh
  42852. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42853. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42854. * * 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
  42855. * * 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
  42856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42857. * @param name defines the name of the mesh
  42858. * @param options defines the options used to create the mesh
  42859. * @param scene defines the hosting scene
  42860. * @returns the tiled ground mesh
  42861. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42862. */
  42863. static CreateTiledGround(name: string, options: {
  42864. xmin: number;
  42865. zmin: number;
  42866. xmax: number;
  42867. zmax: number;
  42868. subdivisions?: {
  42869. w: number;
  42870. h: number;
  42871. };
  42872. precision?: {
  42873. w: number;
  42874. h: number;
  42875. };
  42876. updatable?: boolean;
  42877. }, scene?: Nullable<Scene>): Mesh;
  42878. /**
  42879. * Creates a ground mesh from a height map
  42880. * * The parameter `url` sets the URL of the height map image resource.
  42881. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42882. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42883. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42884. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42885. * * 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.
  42886. * * 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).
  42887. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42889. * @param name defines the name of the mesh
  42890. * @param url defines the url to the height map
  42891. * @param options defines the options used to create the mesh
  42892. * @param scene defines the hosting scene
  42893. * @returns the ground mesh
  42894. * @see https://doc.babylonjs.com/babylon101/height_map
  42895. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42896. */
  42897. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42898. width?: number;
  42899. height?: number;
  42900. subdivisions?: number;
  42901. minHeight?: number;
  42902. maxHeight?: number;
  42903. colorFilter?: Color3;
  42904. alphaFilter?: number;
  42905. updatable?: boolean;
  42906. onReady?: (mesh: GroundMesh) => void;
  42907. }, scene?: Nullable<Scene>): GroundMesh;
  42908. }
  42909. }
  42910. declare module BABYLON {
  42911. /**
  42912. * Class containing static functions to help procedurally build meshes
  42913. */
  42914. export class TorusBuilder {
  42915. /**
  42916. * Creates a torus mesh
  42917. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42918. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42919. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42921. * * 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
  42922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42923. * @param name defines the name of the mesh
  42924. * @param options defines the options used to create the mesh
  42925. * @param scene defines the hosting scene
  42926. * @returns the torus mesh
  42927. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42928. */
  42929. static CreateTorus(name: string, options: {
  42930. diameter?: number;
  42931. thickness?: number;
  42932. tessellation?: number;
  42933. updatable?: boolean;
  42934. sideOrientation?: number;
  42935. frontUVs?: Vector4;
  42936. backUVs?: Vector4;
  42937. }, scene: any): Mesh;
  42938. }
  42939. }
  42940. declare module BABYLON {
  42941. /**
  42942. * Class containing static functions to help procedurally build meshes
  42943. */
  42944. export class CylinderBuilder {
  42945. /**
  42946. * Creates a cylinder or a cone mesh
  42947. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42948. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42949. * * 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.
  42950. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42951. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42952. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42953. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42954. * * 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).
  42955. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42956. * * 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).
  42957. * * 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
  42958. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42959. * * 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
  42960. * * 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.
  42961. * * If `enclose` is false, a ring surface is one element.
  42962. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42963. * * 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
  42964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42965. * * 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
  42966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42967. * @param name defines the name of the mesh
  42968. * @param options defines the options used to create the mesh
  42969. * @param scene defines the hosting scene
  42970. * @returns the cylinder mesh
  42971. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42972. */
  42973. static CreateCylinder(name: string, options: {
  42974. height?: number;
  42975. diameterTop?: number;
  42976. diameterBottom?: number;
  42977. diameter?: number;
  42978. tessellation?: number;
  42979. subdivisions?: number;
  42980. arc?: number;
  42981. faceColors?: Color4[];
  42982. faceUV?: Vector4[];
  42983. updatable?: boolean;
  42984. hasRings?: boolean;
  42985. enclose?: boolean;
  42986. cap?: number;
  42987. sideOrientation?: number;
  42988. frontUVs?: Vector4;
  42989. backUVs?: Vector4;
  42990. }, scene: any): Mesh;
  42991. }
  42992. }
  42993. declare module BABYLON {
  42994. /**
  42995. * States of the webXR experience
  42996. */
  42997. export enum WebXRState {
  42998. /**
  42999. * Transitioning to being in XR mode
  43000. */
  43001. ENTERING_XR = 0,
  43002. /**
  43003. * Transitioning to non XR mode
  43004. */
  43005. EXITING_XR = 1,
  43006. /**
  43007. * In XR mode and presenting
  43008. */
  43009. IN_XR = 2,
  43010. /**
  43011. * Not entered XR mode
  43012. */
  43013. NOT_IN_XR = 3
  43014. }
  43015. /**
  43016. * Abstraction of the XR render target
  43017. */
  43018. export interface WebXRRenderTarget extends IDisposable {
  43019. /**
  43020. * xrpresent context of the canvas which can be used to display/mirror xr content
  43021. */
  43022. canvasContext: WebGLRenderingContext;
  43023. /**
  43024. * xr layer for the canvas
  43025. */
  43026. xrLayer: Nullable<XRWebGLLayer>;
  43027. /**
  43028. * Initializes the xr layer for the session
  43029. * @param xrSession xr session
  43030. * @returns a promise that will resolve once the XR Layer has been created
  43031. */
  43032. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43033. }
  43034. }
  43035. declare module BABYLON {
  43036. /**
  43037. * COnfiguration object for WebXR output canvas
  43038. */
  43039. export class WebXRManagedOutputCanvasOptions {
  43040. /**
  43041. * An optional canvas in case you wish to create it yourself and provide it here.
  43042. * If not provided, a new canvas will be created
  43043. */
  43044. canvasElement?: HTMLCanvasElement;
  43045. /**
  43046. * Options for this XR Layer output
  43047. */
  43048. canvasOptions?: XRWebGLLayerOptions;
  43049. /**
  43050. * CSS styling for a newly created canvas (if not provided)
  43051. */
  43052. newCanvasCssStyle?: string;
  43053. /**
  43054. * Get the default values of the configuration object
  43055. * @returns default values of this configuration object
  43056. */
  43057. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43058. }
  43059. /**
  43060. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43061. */
  43062. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43063. private _options;
  43064. private _canvas;
  43065. private _engine;
  43066. /**
  43067. * Rendering context of the canvas which can be used to display/mirror xr content
  43068. */
  43069. canvasContext: WebGLRenderingContext;
  43070. /**
  43071. * xr layer for the canvas
  43072. */
  43073. xrLayer: Nullable<XRWebGLLayer>;
  43074. /**
  43075. * Initializes the canvas to be added/removed upon entering/exiting xr
  43076. * @param _xrSessionManager The XR Session manager
  43077. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43078. */
  43079. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43080. /**
  43081. * Disposes of the object
  43082. */
  43083. dispose(): void;
  43084. /**
  43085. * Initializes the xr layer for the session
  43086. * @param xrSession xr session
  43087. * @returns a promise that will resolve once the XR Layer has been created
  43088. */
  43089. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43090. private _addCanvas;
  43091. private _removeCanvas;
  43092. private _setManagedOutputCanvas;
  43093. }
  43094. }
  43095. declare module BABYLON {
  43096. /**
  43097. * Manages an XRSession to work with Babylon's engine
  43098. * @see https://doc.babylonjs.com/how_to/webxr
  43099. */
  43100. export class WebXRSessionManager implements IDisposable {
  43101. /** The scene which the session should be created for */
  43102. scene: Scene;
  43103. private _referenceSpace;
  43104. private _rttProvider;
  43105. private _sessionEnded;
  43106. private _xrNavigator;
  43107. private baseLayer;
  43108. /**
  43109. * The base reference space from which the session started. good if you want to reset your
  43110. * reference space
  43111. */
  43112. baseReferenceSpace: XRReferenceSpace;
  43113. /**
  43114. * Current XR frame
  43115. */
  43116. currentFrame: Nullable<XRFrame>;
  43117. /** WebXR timestamp updated every frame */
  43118. currentTimestamp: number;
  43119. /**
  43120. * Used just in case of a failure to initialize an immersive session.
  43121. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43122. */
  43123. defaultHeightCompensation: number;
  43124. /**
  43125. * Fires every time a new xrFrame arrives which can be used to update the camera
  43126. */
  43127. onXRFrameObservable: Observable<XRFrame>;
  43128. /**
  43129. * Fires when the reference space changed
  43130. */
  43131. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43132. /**
  43133. * Fires when the xr session is ended either by the device or manually done
  43134. */
  43135. onXRSessionEnded: Observable<any>;
  43136. /**
  43137. * Fires when the xr session is ended either by the device or manually done
  43138. */
  43139. onXRSessionInit: Observable<XRSession>;
  43140. /**
  43141. * Underlying xr session
  43142. */
  43143. session: XRSession;
  43144. /**
  43145. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43146. * or get the offset the player is currently at.
  43147. */
  43148. viewerReferenceSpace: XRReferenceSpace;
  43149. /**
  43150. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43151. * @param scene The scene which the session should be created for
  43152. */
  43153. constructor(
  43154. /** The scene which the session should be created for */
  43155. scene: Scene);
  43156. /**
  43157. * The current reference space used in this session. This reference space can constantly change!
  43158. * It is mainly used to offset the camera's position.
  43159. */
  43160. get referenceSpace(): XRReferenceSpace;
  43161. /**
  43162. * Set a new reference space and triggers the observable
  43163. */
  43164. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43165. /**
  43166. * Disposes of the session manager
  43167. */
  43168. dispose(): void;
  43169. /**
  43170. * Stops the xrSession and restores the render loop
  43171. * @returns Promise which resolves after it exits XR
  43172. */
  43173. exitXRAsync(): Promise<void>;
  43174. /**
  43175. * Gets the correct render target texture to be rendered this frame for this eye
  43176. * @param eye the eye for which to get the render target
  43177. * @returns the render target for the specified eye
  43178. */
  43179. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43180. /**
  43181. * Creates a WebXRRenderTarget object for the XR session
  43182. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43183. * @param options optional options to provide when creating a new render target
  43184. * @returns a WebXR render target to which the session can render
  43185. */
  43186. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43187. /**
  43188. * Initializes the manager
  43189. * After initialization enterXR can be called to start an XR session
  43190. * @returns Promise which resolves after it is initialized
  43191. */
  43192. initializeAsync(): Promise<void>;
  43193. /**
  43194. * Initializes an xr session
  43195. * @param xrSessionMode mode to initialize
  43196. * @param xrSessionInit defines optional and required values to pass to the session builder
  43197. * @returns a promise which will resolve once the session has been initialized
  43198. */
  43199. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43200. /**
  43201. * Checks if a session would be supported for the creation options specified
  43202. * @param sessionMode session mode to check if supported eg. immersive-vr
  43203. * @returns A Promise that resolves to true if supported and false if not
  43204. */
  43205. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43206. /**
  43207. * Resets the reference space to the one started the session
  43208. */
  43209. resetReferenceSpace(): void;
  43210. /**
  43211. * Starts rendering to the xr layer
  43212. */
  43213. runXRRenderLoop(): void;
  43214. /**
  43215. * Sets the reference space on the xr session
  43216. * @param referenceSpaceType space to set
  43217. * @returns a promise that will resolve once the reference space has been set
  43218. */
  43219. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43220. /**
  43221. * Updates the render state of the session
  43222. * @param state state to set
  43223. * @returns a promise that resolves once the render state has been updated
  43224. */
  43225. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43226. /**
  43227. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43228. * @param sessionMode defines the session to test
  43229. * @returns a promise with boolean as final value
  43230. */
  43231. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43232. private _createRenderTargetTexture;
  43233. }
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * WebXR Camera which holds the views for the xrSession
  43238. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43239. */
  43240. export class WebXRCamera extends FreeCamera {
  43241. private _xrSessionManager;
  43242. private _firstFrame;
  43243. private _referenceQuaternion;
  43244. private _referencedPosition;
  43245. private _xrInvPositionCache;
  43246. private _xrInvQuaternionCache;
  43247. /**
  43248. * Should position compensation execute on first frame.
  43249. * This is used when copying the position from a native (non XR) camera
  43250. */
  43251. compensateOnFirstFrame: boolean;
  43252. /**
  43253. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43254. * @param name the name of the camera
  43255. * @param scene the scene to add the camera to
  43256. * @param _xrSessionManager a constructed xr session manager
  43257. */
  43258. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43259. /**
  43260. * Return the user's height, unrelated to the current ground.
  43261. * This will be the y position of this camera, when ground level is 0.
  43262. */
  43263. get realWorldHeight(): number;
  43264. /** @hidden */
  43265. _updateForDualEyeDebugging(): void;
  43266. /**
  43267. * Sets this camera's transformation based on a non-vr camera
  43268. * @param otherCamera the non-vr camera to copy the transformation from
  43269. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43270. */
  43271. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43272. /**
  43273. * Gets the current instance class name ("WebXRCamera").
  43274. * @returns the class name
  43275. */
  43276. getClassName(): string;
  43277. private _updateFromXRSession;
  43278. private _updateNumberOfRigCameras;
  43279. private _updateReferenceSpace;
  43280. private _updateReferenceSpaceOffset;
  43281. }
  43282. }
  43283. declare module BABYLON {
  43284. /**
  43285. * Defining the interface required for a (webxr) feature
  43286. */
  43287. export interface IWebXRFeature extends IDisposable {
  43288. /**
  43289. * Is this feature attached
  43290. */
  43291. attached: boolean;
  43292. /**
  43293. * Should auto-attach be disabled?
  43294. */
  43295. disableAutoAttach: boolean;
  43296. /**
  43297. * Attach the feature to the session
  43298. * Will usually be called by the features manager
  43299. *
  43300. * @param force should attachment be forced (even when already attached)
  43301. * @returns true if successful.
  43302. */
  43303. attach(force?: boolean): boolean;
  43304. /**
  43305. * Detach the feature from the session
  43306. * Will usually be called by the features manager
  43307. *
  43308. * @returns true if successful.
  43309. */
  43310. detach(): boolean;
  43311. }
  43312. /**
  43313. * A list of the currently available features without referencing them
  43314. */
  43315. export class WebXRFeatureName {
  43316. /**
  43317. * The name of the anchor system feature
  43318. */
  43319. static ANCHOR_SYSTEM: string;
  43320. /**
  43321. * The name of the background remover feature
  43322. */
  43323. static BACKGROUND_REMOVER: string;
  43324. /**
  43325. * The name of the hit test feature
  43326. */
  43327. static HIT_TEST: string;
  43328. /**
  43329. * physics impostors for xr controllers feature
  43330. */
  43331. static PHYSICS_CONTROLLERS: string;
  43332. /**
  43333. * The name of the plane detection feature
  43334. */
  43335. static PLANE_DETECTION: string;
  43336. /**
  43337. * The name of the pointer selection feature
  43338. */
  43339. static POINTER_SELECTION: string;
  43340. /**
  43341. * The name of the teleportation feature
  43342. */
  43343. static TELEPORTATION: string;
  43344. }
  43345. /**
  43346. * Defining the constructor of a feature. Used to register the modules.
  43347. */
  43348. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43349. /**
  43350. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43351. * It is mainly used in AR sessions.
  43352. *
  43353. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43354. */
  43355. export class WebXRFeaturesManager implements IDisposable {
  43356. private _xrSessionManager;
  43357. private static readonly _AvailableFeatures;
  43358. private _features;
  43359. /**
  43360. * constructs a new features manages.
  43361. *
  43362. * @param _xrSessionManager an instance of WebXRSessionManager
  43363. */
  43364. constructor(_xrSessionManager: WebXRSessionManager);
  43365. /**
  43366. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43367. * Mainly used internally.
  43368. *
  43369. * @param featureName the name of the feature to register
  43370. * @param constructorFunction the function used to construct the module
  43371. * @param version the (babylon) version of the module
  43372. * @param stable is that a stable version of this module
  43373. */
  43374. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43375. /**
  43376. * Returns a constructor of a specific feature.
  43377. *
  43378. * @param featureName the name of the feature to construct
  43379. * @param version the version of the feature to load
  43380. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43381. * @param options optional options provided to the module.
  43382. * @returns a function that, when called, will return a new instance of this feature
  43383. */
  43384. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43385. /**
  43386. * Can be used to return the list of features currently registered
  43387. *
  43388. * @returns an Array of available features
  43389. */
  43390. static GetAvailableFeatures(): string[];
  43391. /**
  43392. * Gets the versions available for a specific feature
  43393. * @param featureName the name of the feature
  43394. * @returns an array with the available versions
  43395. */
  43396. static GetAvailableVersions(featureName: string): string[];
  43397. /**
  43398. * Return the latest unstable version of this feature
  43399. * @param featureName the name of the feature to search
  43400. * @returns the version number. if not found will return -1
  43401. */
  43402. static GetLatestVersionOfFeature(featureName: string): number;
  43403. /**
  43404. * Return the latest stable version of this feature
  43405. * @param featureName the name of the feature to search
  43406. * @returns the version number. if not found will return -1
  43407. */
  43408. static GetStableVersionOfFeature(featureName: string): number;
  43409. /**
  43410. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43411. * Can be used during a session to start a feature
  43412. * @param featureName the name of feature to attach
  43413. */
  43414. attachFeature(featureName: string): void;
  43415. /**
  43416. * Can be used inside a session or when the session ends to detach a specific feature
  43417. * @param featureName the name of the feature to detach
  43418. */
  43419. detachFeature(featureName: string): void;
  43420. /**
  43421. * Used to disable an already-enabled feature
  43422. * The feature will be disposed and will be recreated once enabled.
  43423. * @param featureName the feature to disable
  43424. * @returns true if disable was successful
  43425. */
  43426. disableFeature(featureName: string | {
  43427. Name: string;
  43428. }): boolean;
  43429. /**
  43430. * dispose this features manager
  43431. */
  43432. dispose(): void;
  43433. /**
  43434. * 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.
  43435. * 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.
  43436. *
  43437. * @param featureName the name of the feature to load or the class of the feature
  43438. * @param version optional version to load. if not provided the latest version will be enabled
  43439. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43440. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43441. * @returns a new constructed feature or throws an error if feature not found.
  43442. */
  43443. enableFeature(featureName: string | {
  43444. Name: string;
  43445. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43446. /**
  43447. * get the implementation of an enabled feature.
  43448. * @param featureName the name of the feature to load
  43449. * @returns the feature class, if found
  43450. */
  43451. getEnabledFeature(featureName: string): IWebXRFeature;
  43452. /**
  43453. * Get the list of enabled features
  43454. * @returns an array of enabled features
  43455. */
  43456. getEnabledFeatures(): string[];
  43457. }
  43458. }
  43459. declare module BABYLON {
  43460. /**
  43461. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43462. * @see https://doc.babylonjs.com/how_to/webxr
  43463. */
  43464. export class WebXRExperienceHelper implements IDisposable {
  43465. private scene;
  43466. private _nonVRCamera;
  43467. private _originalSceneAutoClear;
  43468. private _supported;
  43469. /**
  43470. * Camera used to render xr content
  43471. */
  43472. camera: WebXRCamera;
  43473. /** A features manager for this xr session */
  43474. featuresManager: WebXRFeaturesManager;
  43475. /**
  43476. * Observers registered here will be triggered after the camera's initial transformation is set
  43477. * This can be used to set a different ground level or an extra rotation.
  43478. *
  43479. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43480. * to the position set after this observable is done executing.
  43481. */
  43482. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43483. /**
  43484. * Fires when the state of the experience helper has changed
  43485. */
  43486. onStateChangedObservable: Observable<WebXRState>;
  43487. /** Session manager used to keep track of xr session */
  43488. sessionManager: WebXRSessionManager;
  43489. /**
  43490. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43491. */
  43492. state: WebXRState;
  43493. /**
  43494. * Creates a WebXRExperienceHelper
  43495. * @param scene The scene the helper should be created in
  43496. */
  43497. private constructor();
  43498. /**
  43499. * Creates the experience helper
  43500. * @param scene the scene to attach the experience helper to
  43501. * @returns a promise for the experience helper
  43502. */
  43503. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43504. /**
  43505. * Disposes of the experience helper
  43506. */
  43507. dispose(): void;
  43508. /**
  43509. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43510. * @param sessionMode options for the XR session
  43511. * @param referenceSpaceType frame of reference of the XR session
  43512. * @param renderTarget the output canvas that will be used to enter XR mode
  43513. * @returns promise that resolves after xr mode has entered
  43514. */
  43515. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43516. /**
  43517. * Exits XR mode and returns the scene to its original state
  43518. * @returns promise that resolves after xr mode has exited
  43519. */
  43520. exitXRAsync(): Promise<void>;
  43521. private _nonXRToXRCamera;
  43522. private _setState;
  43523. }
  43524. }
  43525. declare module BABYLON {
  43526. /**
  43527. * X-Y values for axes in WebXR
  43528. */
  43529. export interface IWebXRMotionControllerAxesValue {
  43530. /**
  43531. * The value of the x axis
  43532. */
  43533. x: number;
  43534. /**
  43535. * The value of the y-axis
  43536. */
  43537. y: number;
  43538. }
  43539. /**
  43540. * changed / previous values for the values of this component
  43541. */
  43542. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43543. /**
  43544. * current (this frame) value
  43545. */
  43546. current: T;
  43547. /**
  43548. * previous (last change) value
  43549. */
  43550. previous: T;
  43551. }
  43552. /**
  43553. * Represents changes in the component between current frame and last values recorded
  43554. */
  43555. export interface IWebXRMotionControllerComponentChanges {
  43556. /**
  43557. * will be populated with previous and current values if axes changed
  43558. */
  43559. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43560. /**
  43561. * will be populated with previous and current values if pressed changed
  43562. */
  43563. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43564. /**
  43565. * will be populated with previous and current values if touched changed
  43566. */
  43567. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43568. /**
  43569. * will be populated with previous and current values if value changed
  43570. */
  43571. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43572. }
  43573. /**
  43574. * This class represents a single component (for example button or thumbstick) of a motion controller
  43575. */
  43576. export class WebXRControllerComponent implements IDisposable {
  43577. /**
  43578. * the id of this component
  43579. */
  43580. id: string;
  43581. /**
  43582. * the type of the component
  43583. */
  43584. type: MotionControllerComponentType;
  43585. private _buttonIndex;
  43586. private _axesIndices;
  43587. private _axes;
  43588. private _changes;
  43589. private _currentValue;
  43590. private _hasChanges;
  43591. private _pressed;
  43592. private _touched;
  43593. /**
  43594. * button component type
  43595. */
  43596. static BUTTON_TYPE: MotionControllerComponentType;
  43597. /**
  43598. * squeeze component type
  43599. */
  43600. static SQUEEZE_TYPE: MotionControllerComponentType;
  43601. /**
  43602. * Thumbstick component type
  43603. */
  43604. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43605. /**
  43606. * Touchpad component type
  43607. */
  43608. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43609. /**
  43610. * trigger component type
  43611. */
  43612. static TRIGGER_TYPE: MotionControllerComponentType;
  43613. /**
  43614. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43615. * the axes data changes
  43616. */
  43617. onAxisValueChangedObservable: Observable<{
  43618. x: number;
  43619. y: number;
  43620. }>;
  43621. /**
  43622. * Observers registered here will be triggered when the state of a button changes
  43623. * State change is either pressed / touched / value
  43624. */
  43625. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43626. /**
  43627. * Creates a new component for a motion controller.
  43628. * It is created by the motion controller itself
  43629. *
  43630. * @param id the id of this component
  43631. * @param type the type of the component
  43632. * @param _buttonIndex index in the buttons array of the gamepad
  43633. * @param _axesIndices indices of the values in the axes array of the gamepad
  43634. */
  43635. constructor(
  43636. /**
  43637. * the id of this component
  43638. */
  43639. id: string,
  43640. /**
  43641. * the type of the component
  43642. */
  43643. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43644. /**
  43645. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43646. */
  43647. get axes(): IWebXRMotionControllerAxesValue;
  43648. /**
  43649. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43650. */
  43651. get changes(): IWebXRMotionControllerComponentChanges;
  43652. /**
  43653. * Return whether or not the component changed the last frame
  43654. */
  43655. get hasChanges(): boolean;
  43656. /**
  43657. * is the button currently pressed
  43658. */
  43659. get pressed(): boolean;
  43660. /**
  43661. * is the button currently touched
  43662. */
  43663. get touched(): boolean;
  43664. /**
  43665. * Get the current value of this component
  43666. */
  43667. get value(): number;
  43668. /**
  43669. * Dispose this component
  43670. */
  43671. dispose(): void;
  43672. /**
  43673. * Are there axes correlating to this component
  43674. * @return true is axes data is available
  43675. */
  43676. isAxes(): boolean;
  43677. /**
  43678. * Is this component a button (hence - pressable)
  43679. * @returns true if can be pressed
  43680. */
  43681. isButton(): boolean;
  43682. /**
  43683. * update this component using the gamepad object it is in. Called on every frame
  43684. * @param nativeController the native gamepad controller object
  43685. */
  43686. update(nativeController: IMinimalMotionControllerObject): void;
  43687. }
  43688. }
  43689. declare module BABYLON {
  43690. /**
  43691. * Class used to represent data loading progression
  43692. */
  43693. export class SceneLoaderProgressEvent {
  43694. /** defines if data length to load can be evaluated */
  43695. readonly lengthComputable: boolean;
  43696. /** defines the loaded data length */
  43697. readonly loaded: number;
  43698. /** defines the data length to load */
  43699. readonly total: number;
  43700. /**
  43701. * Create a new progress event
  43702. * @param lengthComputable defines if data length to load can be evaluated
  43703. * @param loaded defines the loaded data length
  43704. * @param total defines the data length to load
  43705. */
  43706. constructor(
  43707. /** defines if data length to load can be evaluated */
  43708. lengthComputable: boolean,
  43709. /** defines the loaded data length */
  43710. loaded: number,
  43711. /** defines the data length to load */
  43712. total: number);
  43713. /**
  43714. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43715. * @param event defines the source event
  43716. * @returns a new SceneLoaderProgressEvent
  43717. */
  43718. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43719. }
  43720. /**
  43721. * Interface used by SceneLoader plugins to define supported file extensions
  43722. */
  43723. export interface ISceneLoaderPluginExtensions {
  43724. /**
  43725. * Defines the list of supported extensions
  43726. */
  43727. [extension: string]: {
  43728. isBinary: boolean;
  43729. };
  43730. }
  43731. /**
  43732. * Interface used by SceneLoader plugin factory
  43733. */
  43734. export interface ISceneLoaderPluginFactory {
  43735. /**
  43736. * Defines the name of the factory
  43737. */
  43738. name: string;
  43739. /**
  43740. * Function called to create a new plugin
  43741. * @return the new plugin
  43742. */
  43743. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43744. /**
  43745. * The callback that returns true if the data can be directly loaded.
  43746. * @param data string containing the file data
  43747. * @returns if the data can be loaded directly
  43748. */
  43749. canDirectLoad?(data: string): boolean;
  43750. }
  43751. /**
  43752. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43753. */
  43754. export interface ISceneLoaderPluginBase {
  43755. /**
  43756. * The friendly name of this plugin.
  43757. */
  43758. name: string;
  43759. /**
  43760. * The file extensions supported by this plugin.
  43761. */
  43762. extensions: string | ISceneLoaderPluginExtensions;
  43763. /**
  43764. * The callback called when loading from a url.
  43765. * @param scene scene loading this url
  43766. * @param url url to load
  43767. * @param onSuccess callback called when the file successfully loads
  43768. * @param onProgress callback called while file is loading (if the server supports this mode)
  43769. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43770. * @param onError callback called when the file fails to load
  43771. * @returns a file request object
  43772. */
  43773. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43774. /**
  43775. * The callback called when loading from a file object.
  43776. * @param scene scene loading this file
  43777. * @param file defines the file to load
  43778. * @param onSuccess defines the callback to call when data is loaded
  43779. * @param onProgress defines the callback to call during loading process
  43780. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43781. * @param onError defines the callback to call when an error occurs
  43782. * @returns a file request object
  43783. */
  43784. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43785. /**
  43786. * The callback that returns true if the data can be directly loaded.
  43787. * @param data string containing the file data
  43788. * @returns if the data can be loaded directly
  43789. */
  43790. canDirectLoad?(data: string): boolean;
  43791. /**
  43792. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43793. * @param scene scene loading this data
  43794. * @param data string containing the data
  43795. * @returns data to pass to the plugin
  43796. */
  43797. directLoad?(scene: Scene, data: string): any;
  43798. /**
  43799. * The callback that allows custom handling of the root url based on the response url.
  43800. * @param rootUrl the original root url
  43801. * @param responseURL the response url if available
  43802. * @returns the new root url
  43803. */
  43804. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43805. }
  43806. /**
  43807. * Interface used to define a SceneLoader plugin
  43808. */
  43809. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43810. /**
  43811. * Import meshes into a scene.
  43812. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43813. * @param scene The scene to import into
  43814. * @param data The data to import
  43815. * @param rootUrl The root url for scene and resources
  43816. * @param meshes The meshes array to import into
  43817. * @param particleSystems The particle systems array to import into
  43818. * @param skeletons The skeletons array to import into
  43819. * @param onError The callback when import fails
  43820. * @returns True if successful or false otherwise
  43821. */
  43822. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43823. /**
  43824. * Load into a scene.
  43825. * @param scene The scene to load into
  43826. * @param data The data to import
  43827. * @param rootUrl The root url for scene and resources
  43828. * @param onError The callback when import fails
  43829. * @returns True if successful or false otherwise
  43830. */
  43831. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43832. /**
  43833. * Load into an asset container.
  43834. * @param scene The scene to load into
  43835. * @param data The data to import
  43836. * @param rootUrl The root url for scene and resources
  43837. * @param onError The callback when import fails
  43838. * @returns The loaded asset container
  43839. */
  43840. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43841. }
  43842. /**
  43843. * Interface used to define an async SceneLoader plugin
  43844. */
  43845. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43846. /**
  43847. * Import meshes into a scene.
  43848. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43849. * @param scene The scene to import into
  43850. * @param data The data to import
  43851. * @param rootUrl The root url for scene and resources
  43852. * @param onProgress The callback when the load progresses
  43853. * @param fileName Defines the name of the file to load
  43854. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43855. */
  43856. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43857. meshes: AbstractMesh[];
  43858. particleSystems: IParticleSystem[];
  43859. skeletons: Skeleton[];
  43860. animationGroups: AnimationGroup[];
  43861. }>;
  43862. /**
  43863. * Load into a scene.
  43864. * @param scene The scene to load into
  43865. * @param data The data to import
  43866. * @param rootUrl The root url for scene and resources
  43867. * @param onProgress The callback when the load progresses
  43868. * @param fileName Defines the name of the file to load
  43869. * @returns Nothing
  43870. */
  43871. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43872. /**
  43873. * Load into an asset container.
  43874. * @param scene The scene to load into
  43875. * @param data The data to import
  43876. * @param rootUrl The root url for scene and resources
  43877. * @param onProgress The callback when the load progresses
  43878. * @param fileName Defines the name of the file to load
  43879. * @returns The loaded asset container
  43880. */
  43881. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43882. }
  43883. /**
  43884. * Mode that determines how to handle old animation groups before loading new ones.
  43885. */
  43886. export enum SceneLoaderAnimationGroupLoadingMode {
  43887. /**
  43888. * Reset all old animations to initial state then dispose them.
  43889. */
  43890. Clean = 0,
  43891. /**
  43892. * Stop all old animations.
  43893. */
  43894. Stop = 1,
  43895. /**
  43896. * Restart old animations from first frame.
  43897. */
  43898. Sync = 2,
  43899. /**
  43900. * Old animations remains untouched.
  43901. */
  43902. NoSync = 3
  43903. }
  43904. /**
  43905. * Class used to load scene from various file formats using registered plugins
  43906. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43907. */
  43908. export class SceneLoader {
  43909. /**
  43910. * No logging while loading
  43911. */
  43912. static readonly NO_LOGGING: number;
  43913. /**
  43914. * Minimal logging while loading
  43915. */
  43916. static readonly MINIMAL_LOGGING: number;
  43917. /**
  43918. * Summary logging while loading
  43919. */
  43920. static readonly SUMMARY_LOGGING: number;
  43921. /**
  43922. * Detailled logging while loading
  43923. */
  43924. static readonly DETAILED_LOGGING: number;
  43925. /**
  43926. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43927. */
  43928. static get ForceFullSceneLoadingForIncremental(): boolean;
  43929. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43930. /**
  43931. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43932. */
  43933. static get ShowLoadingScreen(): boolean;
  43934. static set ShowLoadingScreen(value: boolean);
  43935. /**
  43936. * Defines the current logging level (while loading the scene)
  43937. * @ignorenaming
  43938. */
  43939. static get loggingLevel(): number;
  43940. static set loggingLevel(value: number);
  43941. /**
  43942. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43943. */
  43944. static get CleanBoneMatrixWeights(): boolean;
  43945. static set CleanBoneMatrixWeights(value: boolean);
  43946. /**
  43947. * Event raised when a plugin is used to load a scene
  43948. */
  43949. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43950. private static _registeredPlugins;
  43951. private static _getDefaultPlugin;
  43952. private static _getPluginForExtension;
  43953. private static _getPluginForDirectLoad;
  43954. private static _getPluginForFilename;
  43955. private static _getDirectLoad;
  43956. private static _loadData;
  43957. private static _getFileInfo;
  43958. /**
  43959. * Gets a plugin that can load the given extension
  43960. * @param extension defines the extension to load
  43961. * @returns a plugin or null if none works
  43962. */
  43963. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43964. /**
  43965. * Gets a boolean indicating that the given extension can be loaded
  43966. * @param extension defines the extension to load
  43967. * @returns true if the extension is supported
  43968. */
  43969. static IsPluginForExtensionAvailable(extension: string): boolean;
  43970. /**
  43971. * Adds a new plugin to the list of registered plugins
  43972. * @param plugin defines the plugin to add
  43973. */
  43974. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43975. /**
  43976. * Import meshes into a scene
  43977. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43978. * @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)
  43979. * @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)
  43980. * @param scene the instance of BABYLON.Scene to append to
  43981. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43982. * @param onProgress a callback with a progress event for each file being loaded
  43983. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43984. * @param pluginExtension the extension used to determine the plugin
  43985. * @returns The loaded plugin
  43986. */
  43987. 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>;
  43988. /**
  43989. * Import meshes into a scene
  43990. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43991. * @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)
  43992. * @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)
  43993. * @param scene the instance of BABYLON.Scene to append to
  43994. * @param onProgress a callback with a progress event for each file being loaded
  43995. * @param pluginExtension the extension used to determine the plugin
  43996. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43997. */
  43998. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43999. meshes: AbstractMesh[];
  44000. particleSystems: IParticleSystem[];
  44001. skeletons: Skeleton[];
  44002. animationGroups: AnimationGroup[];
  44003. }>;
  44004. /**
  44005. * Load a scene
  44006. * @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)
  44007. * @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)
  44008. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44009. * @param onSuccess a callback with the scene when import succeeds
  44010. * @param onProgress a callback with a progress event for each file being loaded
  44011. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44012. * @param pluginExtension the extension used to determine the plugin
  44013. * @returns The loaded plugin
  44014. */
  44015. 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>;
  44016. /**
  44017. * Load a scene
  44018. * @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)
  44019. * @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)
  44020. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44021. * @param onProgress a callback with a progress event for each file being loaded
  44022. * @param pluginExtension the extension used to determine the plugin
  44023. * @returns The loaded scene
  44024. */
  44025. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44026. /**
  44027. * Append a scene
  44028. * @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)
  44029. * @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)
  44030. * @param scene is the instance of BABYLON.Scene to append to
  44031. * @param onSuccess a callback with the scene when import succeeds
  44032. * @param onProgress a callback with a progress event for each file being loaded
  44033. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44034. * @param pluginExtension the extension used to determine the plugin
  44035. * @returns The loaded plugin
  44036. */
  44037. 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>;
  44038. /**
  44039. * Append a scene
  44040. * @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)
  44041. * @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)
  44042. * @param scene is the instance of BABYLON.Scene to append to
  44043. * @param onProgress a callback with a progress event for each file being loaded
  44044. * @param pluginExtension the extension used to determine the plugin
  44045. * @returns The given scene
  44046. */
  44047. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44048. /**
  44049. * Load a scene into an asset container
  44050. * @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)
  44051. * @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)
  44052. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44053. * @param onSuccess a callback with the scene when import succeeds
  44054. * @param onProgress a callback with a progress event for each file being loaded
  44055. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44056. * @param pluginExtension the extension used to determine the plugin
  44057. * @returns The loaded plugin
  44058. */
  44059. 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>;
  44060. /**
  44061. * Load a scene into an asset container
  44062. * @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)
  44063. * @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)
  44064. * @param scene is the instance of Scene to append to
  44065. * @param onProgress a callback with a progress event for each file being loaded
  44066. * @param pluginExtension the extension used to determine the plugin
  44067. * @returns The loaded asset container
  44068. */
  44069. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44070. /**
  44071. * Import animations from a file into a scene
  44072. * @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)
  44073. * @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)
  44074. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44075. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44076. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44077. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44078. * @param onSuccess a callback with the scene when import succeeds
  44079. * @param onProgress a callback with a progress event for each file being loaded
  44080. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44081. */
  44082. 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;
  44083. /**
  44084. * Import animations from a file into a scene
  44085. * @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)
  44086. * @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)
  44087. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44088. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44089. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44090. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44091. * @param onSuccess a callback with the scene when import succeeds
  44092. * @param onProgress a callback with a progress event for each file being loaded
  44093. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44094. * @returns the updated scene with imported animations
  44095. */
  44096. 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>;
  44097. }
  44098. }
  44099. declare module BABYLON {
  44100. /**
  44101. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44102. */
  44103. export type MotionControllerHandedness = "none" | "left" | "right";
  44104. /**
  44105. * The type of components available in motion controllers.
  44106. * This is not the name of the component.
  44107. */
  44108. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44109. /**
  44110. * The state of a controller component
  44111. */
  44112. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44113. /**
  44114. * The schema of motion controller layout.
  44115. * No object will be initialized using this interface
  44116. * This is used just to define the profile.
  44117. */
  44118. export interface IMotionControllerLayout {
  44119. /**
  44120. * Path to load the assets. Usually relative to the base path
  44121. */
  44122. assetPath: string;
  44123. /**
  44124. * Available components (unsorted)
  44125. */
  44126. components: {
  44127. /**
  44128. * A map of component Ids
  44129. */
  44130. [componentId: string]: {
  44131. /**
  44132. * The type of input the component outputs
  44133. */
  44134. type: MotionControllerComponentType;
  44135. /**
  44136. * The indices of this component in the gamepad object
  44137. */
  44138. gamepadIndices: {
  44139. /**
  44140. * Index of button
  44141. */
  44142. button?: number;
  44143. /**
  44144. * If available, index of x-axis
  44145. */
  44146. xAxis?: number;
  44147. /**
  44148. * If available, index of y-axis
  44149. */
  44150. yAxis?: number;
  44151. };
  44152. /**
  44153. * The mesh's root node name
  44154. */
  44155. rootNodeName: string;
  44156. /**
  44157. * Animation definitions for this model
  44158. */
  44159. visualResponses: {
  44160. [stateKey: string]: {
  44161. /**
  44162. * What property will be animated
  44163. */
  44164. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44165. /**
  44166. * What states influence this visual response
  44167. */
  44168. states: MotionControllerComponentStateType[];
  44169. /**
  44170. * Type of animation - movement or visibility
  44171. */
  44172. valueNodeProperty: "transform" | "visibility";
  44173. /**
  44174. * Base node name to move. Its position will be calculated according to the min and max nodes
  44175. */
  44176. valueNodeName?: string;
  44177. /**
  44178. * Minimum movement node
  44179. */
  44180. minNodeName?: string;
  44181. /**
  44182. * Max movement node
  44183. */
  44184. maxNodeName?: string;
  44185. };
  44186. };
  44187. /**
  44188. * If touch enabled, what is the name of node to display user feedback
  44189. */
  44190. touchPointNodeName?: string;
  44191. };
  44192. };
  44193. /**
  44194. * Is it xr standard mapping or not
  44195. */
  44196. gamepadMapping: "" | "xr-standard";
  44197. /**
  44198. * Base root node of this entire model
  44199. */
  44200. rootNodeName: string;
  44201. /**
  44202. * Defines the main button component id
  44203. */
  44204. selectComponentId: string;
  44205. }
  44206. /**
  44207. * A definition for the layout map in the input profile
  44208. */
  44209. export interface IMotionControllerLayoutMap {
  44210. /**
  44211. * Layouts with handedness type as a key
  44212. */
  44213. [handedness: string]: IMotionControllerLayout;
  44214. }
  44215. /**
  44216. * The XR Input profile schema
  44217. * Profiles can be found here:
  44218. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44219. */
  44220. export interface IMotionControllerProfile {
  44221. /**
  44222. * fallback profiles for this profileId
  44223. */
  44224. fallbackProfileIds: string[];
  44225. /**
  44226. * The layout map, with handedness as key
  44227. */
  44228. layouts: IMotionControllerLayoutMap;
  44229. /**
  44230. * The id of this profile
  44231. * correlates to the profile(s) in the xrInput.profiles array
  44232. */
  44233. profileId: string;
  44234. }
  44235. /**
  44236. * A helper-interface for the 3 meshes needed for controller button animation
  44237. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44238. */
  44239. export interface IMotionControllerButtonMeshMap {
  44240. /**
  44241. * the mesh that defines the pressed value mesh position.
  44242. * This is used to find the max-position of this button
  44243. */
  44244. pressedMesh: AbstractMesh;
  44245. /**
  44246. * the mesh that defines the unpressed value mesh position.
  44247. * This is used to find the min (or initial) position of this button
  44248. */
  44249. unpressedMesh: AbstractMesh;
  44250. /**
  44251. * The mesh that will be changed when value changes
  44252. */
  44253. valueMesh: AbstractMesh;
  44254. }
  44255. /**
  44256. * A helper-interface for the 3 meshes needed for controller axis animation.
  44257. * This will be expanded when touchpad animations are fully supported
  44258. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44259. */
  44260. export interface IMotionControllerMeshMap {
  44261. /**
  44262. * the mesh that defines the maximum value mesh position.
  44263. */
  44264. maxMesh?: AbstractMesh;
  44265. /**
  44266. * the mesh that defines the minimum value mesh position.
  44267. */
  44268. minMesh?: AbstractMesh;
  44269. /**
  44270. * The mesh that will be changed when axis value changes
  44271. */
  44272. valueMesh: AbstractMesh;
  44273. }
  44274. /**
  44275. * The elements needed for change-detection of the gamepad objects in motion controllers
  44276. */
  44277. export interface IMinimalMotionControllerObject {
  44278. /**
  44279. * Available axes of this controller
  44280. */
  44281. axes: number[];
  44282. /**
  44283. * An array of available buttons
  44284. */
  44285. buttons: Array<{
  44286. /**
  44287. * Value of the button/trigger
  44288. */
  44289. value: number;
  44290. /**
  44291. * If the button/trigger is currently touched
  44292. */
  44293. touched: boolean;
  44294. /**
  44295. * If the button/trigger is currently pressed
  44296. */
  44297. pressed: boolean;
  44298. }>;
  44299. }
  44300. /**
  44301. * An Abstract Motion controller
  44302. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44303. * Each component has an observable to check for changes in value and state
  44304. */
  44305. export abstract class WebXRAbstractMotionController implements IDisposable {
  44306. protected scene: Scene;
  44307. protected layout: IMotionControllerLayout;
  44308. /**
  44309. * The gamepad object correlating to this controller
  44310. */
  44311. gamepadObject: IMinimalMotionControllerObject;
  44312. /**
  44313. * handedness (left/right/none) of this controller
  44314. */
  44315. handedness: MotionControllerHandedness;
  44316. private _initComponent;
  44317. private _modelReady;
  44318. /**
  44319. * A map of components (WebXRControllerComponent) in this motion controller
  44320. * Components have a ComponentType and can also have both button and axis definitions
  44321. */
  44322. readonly components: {
  44323. [id: string]: WebXRControllerComponent;
  44324. };
  44325. /**
  44326. * Disable the model's animation. Can be set at any time.
  44327. */
  44328. disableAnimation: boolean;
  44329. /**
  44330. * Observers registered here will be triggered when the model of this controller is done loading
  44331. */
  44332. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44333. /**
  44334. * The profile id of this motion controller
  44335. */
  44336. abstract profileId: string;
  44337. /**
  44338. * The root mesh of the model. It is null if the model was not yet initialized
  44339. */
  44340. rootMesh: Nullable<AbstractMesh>;
  44341. /**
  44342. * constructs a new abstract motion controller
  44343. * @param scene the scene to which the model of the controller will be added
  44344. * @param layout The profile layout to load
  44345. * @param gamepadObject The gamepad object correlating to this controller
  44346. * @param handedness handedness (left/right/none) of this controller
  44347. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44348. */
  44349. constructor(scene: Scene, layout: IMotionControllerLayout,
  44350. /**
  44351. * The gamepad object correlating to this controller
  44352. */
  44353. gamepadObject: IMinimalMotionControllerObject,
  44354. /**
  44355. * handedness (left/right/none) of this controller
  44356. */
  44357. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  44358. /**
  44359. * Dispose this controller, the model mesh and all its components
  44360. */
  44361. dispose(): void;
  44362. /**
  44363. * Returns all components of specific type
  44364. * @param type the type to search for
  44365. * @return an array of components with this type
  44366. */
  44367. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44368. /**
  44369. * get a component based an its component id as defined in layout.components
  44370. * @param id the id of the component
  44371. * @returns the component correlates to the id or undefined if not found
  44372. */
  44373. getComponent(id: string): WebXRControllerComponent;
  44374. /**
  44375. * Get the list of components available in this motion controller
  44376. * @returns an array of strings correlating to available components
  44377. */
  44378. getComponentIds(): string[];
  44379. /**
  44380. * Get the first component of specific type
  44381. * @param type type of component to find
  44382. * @return a controller component or null if not found
  44383. */
  44384. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44385. /**
  44386. * Get the main (Select) component of this controller as defined in the layout
  44387. * @returns the main component of this controller
  44388. */
  44389. getMainComponent(): WebXRControllerComponent;
  44390. /**
  44391. * Loads the model correlating to this controller
  44392. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44393. * @returns A promise fulfilled with the result of the model loading
  44394. */
  44395. loadModel(): Promise<boolean>;
  44396. /**
  44397. * Update this model using the current XRFrame
  44398. * @param xrFrame the current xr frame to use and update the model
  44399. */
  44400. updateFromXRFrame(xrFrame: XRFrame): void;
  44401. /**
  44402. * Backwards compatibility due to a deeply-integrated typo
  44403. */
  44404. get handness(): XREye;
  44405. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44406. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44407. /**
  44408. * Moves the axis on the controller mesh based on its current state
  44409. * @param axis the index of the axis
  44410. * @param axisValue the value of the axis which determines the meshes new position
  44411. * @hidden
  44412. */
  44413. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44414. /**
  44415. * Update the model itself with the current frame data
  44416. * @param xrFrame the frame to use for updating the model mesh
  44417. */
  44418. protected updateModel(xrFrame: XRFrame): void;
  44419. /**
  44420. * Get the filename and path for this controller's model
  44421. * @returns a map of filename and path
  44422. */
  44423. protected abstract _getFilenameAndPath(): {
  44424. filename: string;
  44425. path: string;
  44426. };
  44427. /**
  44428. * This function is called before the mesh is loaded. It checks for loading constraints.
  44429. * For example, this function can check if the GLB loader is available
  44430. * If this function returns false, the generic controller will be loaded instead
  44431. * @returns Is the client ready to load the mesh
  44432. */
  44433. protected abstract _getModelLoadingConstraints(): boolean;
  44434. /**
  44435. * This function will be called after the model was successfully loaded and can be used
  44436. * for mesh transformations before it is available for the user
  44437. * @param meshes the loaded meshes
  44438. */
  44439. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44440. /**
  44441. * Set the root mesh for this controller. Important for the WebXR controller class
  44442. * @param meshes the loaded meshes
  44443. */
  44444. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44445. /**
  44446. * A function executed each frame that updates the mesh (if needed)
  44447. * @param xrFrame the current xrFrame
  44448. */
  44449. protected abstract _updateModel(xrFrame: XRFrame): void;
  44450. private _getGenericFilenameAndPath;
  44451. private _getGenericParentMesh;
  44452. }
  44453. }
  44454. declare module BABYLON {
  44455. /**
  44456. * A generic trigger-only motion controller for WebXR
  44457. */
  44458. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44459. /**
  44460. * Static version of the profile id of this controller
  44461. */
  44462. static ProfileId: string;
  44463. profileId: string;
  44464. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  44465. protected _getFilenameAndPath(): {
  44466. filename: string;
  44467. path: string;
  44468. };
  44469. protected _getModelLoadingConstraints(): boolean;
  44470. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44471. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44472. protected _updateModel(): void;
  44473. }
  44474. }
  44475. declare module BABYLON {
  44476. /**
  44477. * Class containing static functions to help procedurally build meshes
  44478. */
  44479. export class SphereBuilder {
  44480. /**
  44481. * Creates a sphere mesh
  44482. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44483. * * 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`)
  44484. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44485. * * 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
  44486. * * 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)
  44487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44488. * * 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
  44489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44490. * @param name defines the name of the mesh
  44491. * @param options defines the options used to create the mesh
  44492. * @param scene defines the hosting scene
  44493. * @returns the sphere mesh
  44494. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44495. */
  44496. static CreateSphere(name: string, options: {
  44497. segments?: number;
  44498. diameter?: number;
  44499. diameterX?: number;
  44500. diameterY?: number;
  44501. diameterZ?: number;
  44502. arc?: number;
  44503. slice?: number;
  44504. sideOrientation?: number;
  44505. frontUVs?: Vector4;
  44506. backUVs?: Vector4;
  44507. updatable?: boolean;
  44508. }, scene?: Nullable<Scene>): Mesh;
  44509. }
  44510. }
  44511. declare module BABYLON {
  44512. /**
  44513. * A profiled motion controller has its profile loaded from an online repository.
  44514. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44515. */
  44516. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44517. private _repositoryUrl;
  44518. private _buttonMeshMapping;
  44519. private _touchDots;
  44520. /**
  44521. * The profile ID of this controller. Will be populated when the controller initializes.
  44522. */
  44523. profileId: string;
  44524. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44525. dispose(): void;
  44526. protected _getFilenameAndPath(): {
  44527. filename: string;
  44528. path: string;
  44529. };
  44530. protected _getModelLoadingConstraints(): boolean;
  44531. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44532. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44533. protected _updateModel(_xrFrame: XRFrame): void;
  44534. }
  44535. }
  44536. declare module BABYLON {
  44537. /**
  44538. * A construction function type to create a new controller based on an xrInput object
  44539. */
  44540. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44541. /**
  44542. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44543. *
  44544. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44545. * it should be replaced with auto-loaded controllers.
  44546. *
  44547. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44548. */
  44549. export class WebXRMotionControllerManager {
  44550. private static _AvailableControllers;
  44551. private static _Fallbacks;
  44552. private static _ProfileLoadingPromises;
  44553. private static _ProfilesList;
  44554. /**
  44555. * The base URL of the online controller repository. Can be changed at any time.
  44556. */
  44557. static BaseRepositoryUrl: string;
  44558. /**
  44559. * Which repository gets priority - local or online
  44560. */
  44561. static PrioritizeOnlineRepository: boolean;
  44562. /**
  44563. * Use the online repository, or use only locally-defined controllers
  44564. */
  44565. static UseOnlineRepository: boolean;
  44566. /**
  44567. * Clear the cache used for profile loading and reload when requested again
  44568. */
  44569. static ClearProfilesCache(): void;
  44570. /**
  44571. * Register the default fallbacks.
  44572. * This function is called automatically when this file is imported.
  44573. */
  44574. static DefaultFallbacks(): void;
  44575. /**
  44576. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44577. * @param profileId the profile to which a fallback needs to be found
  44578. * @return an array with corresponding fallback profiles
  44579. */
  44580. static FindFallbackWithProfileId(profileId: string): string[];
  44581. /**
  44582. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44583. * The order of search:
  44584. *
  44585. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44586. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44587. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44588. * 4) return the generic trigger controller if none were found
  44589. *
  44590. * @param xrInput the xrInput to which a new controller is initialized
  44591. * @param scene the scene to which the model will be added
  44592. * @param forceProfile force a certain profile for this controller
  44593. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44594. */
  44595. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44596. /**
  44597. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44598. *
  44599. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44600. *
  44601. * @param type the profile type to register
  44602. * @param constructFunction the function to be called when loading this profile
  44603. */
  44604. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44605. /**
  44606. * Register a fallback to a specific profile.
  44607. * @param profileId the profileId that will receive the fallbacks
  44608. * @param fallbacks A list of fallback profiles
  44609. */
  44610. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44611. /**
  44612. * Will update the list of profiles available in the repository
  44613. * @return a promise that resolves to a map of profiles available online
  44614. */
  44615. static UpdateProfilesList(): Promise<{
  44616. [profile: string]: string;
  44617. }>;
  44618. private static _LoadProfileFromRepository;
  44619. private static _LoadProfilesFromAvailableControllers;
  44620. }
  44621. }
  44622. declare module BABYLON {
  44623. /**
  44624. * Configuration options for the WebXR controller creation
  44625. */
  44626. export interface IWebXRControllerOptions {
  44627. /**
  44628. * Should the controller mesh be animated when a user interacts with it
  44629. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44630. */
  44631. disableMotionControllerAnimation?: boolean;
  44632. /**
  44633. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44634. */
  44635. doNotLoadControllerMesh?: boolean;
  44636. /**
  44637. * Force a specific controller type for this controller.
  44638. * This can be used when creating your own profile or when testing different controllers
  44639. */
  44640. forceControllerProfile?: string;
  44641. }
  44642. /**
  44643. * Represents an XR controller
  44644. */
  44645. export class WebXRInputSource {
  44646. private _scene;
  44647. /** The underlying input source for the controller */
  44648. inputSource: XRInputSource;
  44649. private _options;
  44650. private _tmpQuaternion;
  44651. private _tmpVector;
  44652. private _uniqueId;
  44653. /**
  44654. * 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
  44655. */
  44656. grip?: AbstractMesh;
  44657. /**
  44658. * If available, this is the gamepad object related to this controller.
  44659. * Using this object it is possible to get click events and trackpad changes of the
  44660. * webxr controller that is currently being used.
  44661. */
  44662. motionController?: WebXRAbstractMotionController;
  44663. /**
  44664. * Event that fires when the controller is removed/disposed.
  44665. * The object provided as event data is this controller, after associated assets were disposed.
  44666. * uniqueId is still available.
  44667. */
  44668. onDisposeObservable: Observable<WebXRInputSource>;
  44669. /**
  44670. * Will be triggered when the mesh associated with the motion controller is done loading.
  44671. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44672. * A shortened version of controller -> motion controller -> on mesh loaded.
  44673. */
  44674. onMeshLoadedObservable: Observable<AbstractMesh>;
  44675. /**
  44676. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44677. */
  44678. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44679. /**
  44680. * Pointer which can be used to select objects or attach a visible laser to
  44681. */
  44682. pointer: AbstractMesh;
  44683. /**
  44684. * Creates the controller
  44685. * @see https://doc.babylonjs.com/how_to/webxr
  44686. * @param _scene the scene which the controller should be associated to
  44687. * @param inputSource the underlying input source for the controller
  44688. * @param _options options for this controller creation
  44689. */
  44690. constructor(_scene: Scene,
  44691. /** The underlying input source for the controller */
  44692. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44693. /**
  44694. * Get this controllers unique id
  44695. */
  44696. get uniqueId(): string;
  44697. /**
  44698. * Disposes of the object
  44699. */
  44700. dispose(): void;
  44701. /**
  44702. * Gets a world space ray coming from the pointer or grip
  44703. * @param result the resulting ray
  44704. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44705. */
  44706. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44707. /**
  44708. * Updates the controller pose based on the given XRFrame
  44709. * @param xrFrame xr frame to update the pose with
  44710. * @param referenceSpace reference space to use
  44711. */
  44712. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44713. }
  44714. }
  44715. declare module BABYLON {
  44716. /**
  44717. * The schema for initialization options of the XR Input class
  44718. */
  44719. export interface IWebXRInputOptions {
  44720. /**
  44721. * If set to true no model will be automatically loaded
  44722. */
  44723. doNotLoadControllerMeshes?: boolean;
  44724. /**
  44725. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44726. * If not found, the xr input profile data will be used.
  44727. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44728. */
  44729. forceInputProfile?: string;
  44730. /**
  44731. * Do not send a request to the controller repository to load the profile.
  44732. *
  44733. * Instead, use the controllers available in babylon itself.
  44734. */
  44735. disableOnlineControllerRepository?: boolean;
  44736. /**
  44737. * A custom URL for the controllers repository
  44738. */
  44739. customControllersRepositoryURL?: string;
  44740. /**
  44741. * Should the controller model's components not move according to the user input
  44742. */
  44743. disableControllerAnimation?: boolean;
  44744. }
  44745. /**
  44746. * XR input used to track XR inputs such as controllers/rays
  44747. */
  44748. export class WebXRInput implements IDisposable {
  44749. /**
  44750. * the xr session manager for this session
  44751. */
  44752. xrSessionManager: WebXRSessionManager;
  44753. /**
  44754. * the WebXR camera for this session. Mainly used for teleportation
  44755. */
  44756. xrCamera: WebXRCamera;
  44757. private readonly options;
  44758. /**
  44759. * XR controllers being tracked
  44760. */
  44761. controllers: Array<WebXRInputSource>;
  44762. private _frameObserver;
  44763. private _sessionEndedObserver;
  44764. private _sessionInitObserver;
  44765. /**
  44766. * Event when a controller has been connected/added
  44767. */
  44768. onControllerAddedObservable: Observable<WebXRInputSource>;
  44769. /**
  44770. * Event when a controller has been removed/disconnected
  44771. */
  44772. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44773. /**
  44774. * Initializes the WebXRInput
  44775. * @param xrSessionManager the xr session manager for this session
  44776. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44777. * @param options = initialization options for this xr input
  44778. */
  44779. constructor(
  44780. /**
  44781. * the xr session manager for this session
  44782. */
  44783. xrSessionManager: WebXRSessionManager,
  44784. /**
  44785. * the WebXR camera for this session. Mainly used for teleportation
  44786. */
  44787. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44788. private _onInputSourcesChange;
  44789. private _addAndRemoveControllers;
  44790. /**
  44791. * Disposes of the object
  44792. */
  44793. dispose(): void;
  44794. }
  44795. }
  44796. declare module BABYLON {
  44797. /**
  44798. * This is the base class for all WebXR features.
  44799. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44800. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44801. */
  44802. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44803. protected _xrSessionManager: WebXRSessionManager;
  44804. private _attached;
  44805. private _removeOnDetach;
  44806. /**
  44807. * Should auto-attach be disabled?
  44808. */
  44809. disableAutoAttach: boolean;
  44810. /**
  44811. * Construct a new (abstract) WebXR feature
  44812. * @param _xrSessionManager the xr session manager for this feature
  44813. */
  44814. constructor(_xrSessionManager: WebXRSessionManager);
  44815. /**
  44816. * Is this feature attached
  44817. */
  44818. get attached(): boolean;
  44819. /**
  44820. * attach this feature
  44821. *
  44822. * @param force should attachment be forced (even when already attached)
  44823. * @returns true if successful, false is failed or already attached
  44824. */
  44825. attach(force?: boolean): boolean;
  44826. /**
  44827. * detach this feature.
  44828. *
  44829. * @returns true if successful, false if failed or already detached
  44830. */
  44831. detach(): boolean;
  44832. /**
  44833. * Dispose this feature and all of the resources attached
  44834. */
  44835. dispose(): void;
  44836. /**
  44837. * This is used to register callbacks that will automatically be removed when detach is called.
  44838. * @param observable the observable to which the observer will be attached
  44839. * @param callback the callback to register
  44840. */
  44841. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44842. /**
  44843. * Code in this function will be executed on each xrFrame received from the browser.
  44844. * This function will not execute after the feature is detached.
  44845. * @param _xrFrame the current frame
  44846. */
  44847. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44848. }
  44849. }
  44850. declare module BABYLON {
  44851. /**
  44852. * Renders a layer on top of an existing scene
  44853. */
  44854. export class UtilityLayerRenderer implements IDisposable {
  44855. /** the original scene that will be rendered on top of */
  44856. originalScene: Scene;
  44857. private _pointerCaptures;
  44858. private _lastPointerEvents;
  44859. private static _DefaultUtilityLayer;
  44860. private static _DefaultKeepDepthUtilityLayer;
  44861. private _sharedGizmoLight;
  44862. private _renderCamera;
  44863. /**
  44864. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44865. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44866. * @returns the camera that is used when rendering the utility layer
  44867. */
  44868. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44869. /**
  44870. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44871. * @param cam the camera that should be used when rendering the utility layer
  44872. */
  44873. setRenderCamera(cam: Nullable<Camera>): void;
  44874. /**
  44875. * @hidden
  44876. * Light which used by gizmos to get light shading
  44877. */
  44878. _getSharedGizmoLight(): HemisphericLight;
  44879. /**
  44880. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44881. */
  44882. pickUtilitySceneFirst: boolean;
  44883. /**
  44884. * 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)
  44885. */
  44886. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44887. /**
  44888. * 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)
  44889. */
  44890. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44891. /**
  44892. * The scene that is rendered on top of the original scene
  44893. */
  44894. utilityLayerScene: Scene;
  44895. /**
  44896. * If the utility layer should automatically be rendered on top of existing scene
  44897. */
  44898. shouldRender: boolean;
  44899. /**
  44900. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44901. */
  44902. onlyCheckPointerDownEvents: boolean;
  44903. /**
  44904. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44905. */
  44906. processAllEvents: boolean;
  44907. /**
  44908. * Observable raised when the pointer move from the utility layer scene to the main scene
  44909. */
  44910. onPointerOutObservable: Observable<number>;
  44911. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44912. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44913. private _afterRenderObserver;
  44914. private _sceneDisposeObserver;
  44915. private _originalPointerObserver;
  44916. /**
  44917. * Instantiates a UtilityLayerRenderer
  44918. * @param originalScene the original scene that will be rendered on top of
  44919. * @param handleEvents boolean indicating if the utility layer should handle events
  44920. */
  44921. constructor(
  44922. /** the original scene that will be rendered on top of */
  44923. originalScene: Scene, handleEvents?: boolean);
  44924. private _notifyObservers;
  44925. /**
  44926. * Renders the utility layers scene on top of the original scene
  44927. */
  44928. render(): void;
  44929. /**
  44930. * Disposes of the renderer
  44931. */
  44932. dispose(): void;
  44933. private _updateCamera;
  44934. }
  44935. }
  44936. declare module BABYLON {
  44937. /**
  44938. * Options interface for the pointer selection module
  44939. */
  44940. export interface IWebXRControllerPointerSelectionOptions {
  44941. /**
  44942. * if provided, this scene will be used to render meshes.
  44943. */
  44944. customUtilityLayerScene?: Scene;
  44945. /**
  44946. * 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)
  44947. * If not disabled, the last picked point will be used to execute a pointer up event
  44948. * If disabled, pointer up event will be triggered right after the pointer down event.
  44949. * Used in screen and gaze target ray mode only
  44950. */
  44951. disablePointerUpOnTouchOut: boolean;
  44952. /**
  44953. * For gaze mode (time to select instead of press)
  44954. */
  44955. forceGazeMode: boolean;
  44956. /**
  44957. * 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
  44958. * to start a new countdown to the pointer down event.
  44959. * Defaults to 1.
  44960. */
  44961. gazeModePointerMovedFactor?: number;
  44962. /**
  44963. * Different button type to use instead of the main component
  44964. */
  44965. overrideButtonId?: string;
  44966. /**
  44967. * use this rendering group id for the meshes (optional)
  44968. */
  44969. renderingGroupId?: number;
  44970. /**
  44971. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44972. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44973. * 3000 means 3 seconds between pointing at something and selecting it
  44974. */
  44975. timeToSelect?: number;
  44976. /**
  44977. * Should meshes created here be added to a utility layer or the main scene
  44978. */
  44979. useUtilityLayer?: boolean;
  44980. /**
  44981. * the xr input to use with this pointer selection
  44982. */
  44983. xrInput: WebXRInput;
  44984. }
  44985. /**
  44986. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44987. */
  44988. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44989. private readonly _options;
  44990. private static _idCounter;
  44991. private _attachController;
  44992. private _controllers;
  44993. private _scene;
  44994. private _tmpVectorForPickCompare;
  44995. /**
  44996. * The module's name
  44997. */
  44998. static readonly Name: string;
  44999. /**
  45000. * The (Babylon) version of this module.
  45001. * This is an integer representing the implementation version.
  45002. * This number does not correspond to the WebXR specs version
  45003. */
  45004. static readonly Version: number;
  45005. /**
  45006. * Disable lighting on the laser pointer (so it will always be visible)
  45007. */
  45008. disablePointerLighting: boolean;
  45009. /**
  45010. * Disable lighting on the selection mesh (so it will always be visible)
  45011. */
  45012. disableSelectionMeshLighting: boolean;
  45013. /**
  45014. * Should the laser pointer be displayed
  45015. */
  45016. displayLaserPointer: boolean;
  45017. /**
  45018. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45019. */
  45020. displaySelectionMesh: boolean;
  45021. /**
  45022. * This color will be set to the laser pointer when selection is triggered
  45023. */
  45024. laserPointerPickedColor: Color3;
  45025. /**
  45026. * Default color of the laser pointer
  45027. */
  45028. lasterPointerDefaultColor: Color3;
  45029. /**
  45030. * default color of the selection ring
  45031. */
  45032. selectionMeshDefaultColor: Color3;
  45033. /**
  45034. * This color will be applied to the selection ring when selection is triggered
  45035. */
  45036. selectionMeshPickedColor: Color3;
  45037. /**
  45038. * Optional filter to be used for ray selection. This predicate shares behavior with
  45039. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45040. */
  45041. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45042. /**
  45043. * constructs a new background remover module
  45044. * @param _xrSessionManager the session manager for this module
  45045. * @param _options read-only options to be used in this module
  45046. */
  45047. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45048. /**
  45049. * attach this feature
  45050. * Will usually be called by the features manager
  45051. *
  45052. * @returns true if successful.
  45053. */
  45054. attach(): boolean;
  45055. /**
  45056. * detach this feature.
  45057. * Will usually be called by the features manager
  45058. *
  45059. * @returns true if successful.
  45060. */
  45061. detach(): boolean;
  45062. /**
  45063. * Will get the mesh under a specific pointer.
  45064. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45065. * @param controllerId the controllerId to check
  45066. * @returns The mesh under pointer or null if no mesh is under the pointer
  45067. */
  45068. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45069. /**
  45070. * Get the xr controller that correlates to the pointer id in the pointer event
  45071. *
  45072. * @param id the pointer id to search for
  45073. * @returns the controller that correlates to this id or null if not found
  45074. */
  45075. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45076. protected _onXRFrame(_xrFrame: XRFrame): void;
  45077. private _attachGazeMode;
  45078. private _attachScreenRayMode;
  45079. private _attachTrackedPointerRayMode;
  45080. private _convertNormalToDirectionOfRay;
  45081. private _detachController;
  45082. private _generateNewMeshPair;
  45083. private _pickingMoved;
  45084. private _updatePointerDistance;
  45085. }
  45086. }
  45087. declare module BABYLON {
  45088. /**
  45089. * Button which can be used to enter a different mode of XR
  45090. */
  45091. export class WebXREnterExitUIButton {
  45092. /** button element */
  45093. element: HTMLElement;
  45094. /** XR initialization options for the button */
  45095. sessionMode: XRSessionMode;
  45096. /** Reference space type */
  45097. referenceSpaceType: XRReferenceSpaceType;
  45098. /**
  45099. * Creates a WebXREnterExitUIButton
  45100. * @param element button element
  45101. * @param sessionMode XR initialization session mode
  45102. * @param referenceSpaceType the type of reference space to be used
  45103. */
  45104. constructor(
  45105. /** button element */
  45106. element: HTMLElement,
  45107. /** XR initialization options for the button */
  45108. sessionMode: XRSessionMode,
  45109. /** Reference space type */
  45110. referenceSpaceType: XRReferenceSpaceType);
  45111. /**
  45112. * Extendable function which can be used to update the button's visuals when the state changes
  45113. * @param activeButton the current active button in the UI
  45114. */
  45115. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45116. }
  45117. /**
  45118. * Options to create the webXR UI
  45119. */
  45120. export class WebXREnterExitUIOptions {
  45121. /**
  45122. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45123. */
  45124. customButtons?: Array<WebXREnterExitUIButton>;
  45125. /**
  45126. * A reference space type to use when creating the default button.
  45127. * Default is local-floor
  45128. */
  45129. referenceSpaceType?: XRReferenceSpaceType;
  45130. /**
  45131. * Context to enter xr with
  45132. */
  45133. renderTarget?: Nullable<WebXRRenderTarget>;
  45134. /**
  45135. * A session mode to use when creating the default button.
  45136. * Default is immersive-vr
  45137. */
  45138. sessionMode?: XRSessionMode;
  45139. }
  45140. /**
  45141. * UI to allow the user to enter/exit XR mode
  45142. */
  45143. export class WebXREnterExitUI implements IDisposable {
  45144. private scene;
  45145. /** version of the options passed to this UI */
  45146. options: WebXREnterExitUIOptions;
  45147. private _activeButton;
  45148. private _buttons;
  45149. private _overlay;
  45150. /**
  45151. * Fired every time the active button is changed.
  45152. *
  45153. * When xr is entered via a button that launches xr that button will be the callback parameter
  45154. *
  45155. * When exiting xr the callback parameter will be null)
  45156. */
  45157. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45158. /**
  45159. *
  45160. * @param scene babylon scene object to use
  45161. * @param options (read-only) version of the options passed to this UI
  45162. */
  45163. private constructor();
  45164. /**
  45165. * Creates UI to allow the user to enter/exit XR mode
  45166. * @param scene the scene to add the ui to
  45167. * @param helper the xr experience helper to enter/exit xr with
  45168. * @param options options to configure the UI
  45169. * @returns the created ui
  45170. */
  45171. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45172. /**
  45173. * Disposes of the XR UI component
  45174. */
  45175. dispose(): void;
  45176. private _updateButtons;
  45177. }
  45178. }
  45179. declare module BABYLON {
  45180. /**
  45181. * Class containing static functions to help procedurally build meshes
  45182. */
  45183. export class LinesBuilder {
  45184. /**
  45185. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45186. * * 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
  45187. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45188. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45189. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45190. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45191. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45192. * * 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
  45193. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45196. * @param name defines the name of the new line system
  45197. * @param options defines the options used to create the line system
  45198. * @param scene defines the hosting scene
  45199. * @returns a new line system mesh
  45200. */
  45201. static CreateLineSystem(name: string, options: {
  45202. lines: Vector3[][];
  45203. updatable?: boolean;
  45204. instance?: Nullable<LinesMesh>;
  45205. colors?: Nullable<Color4[][]>;
  45206. useVertexAlpha?: boolean;
  45207. }, scene: Nullable<Scene>): LinesMesh;
  45208. /**
  45209. * Creates a line mesh
  45210. * 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
  45211. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45212. * * The parameter `points` is an array successive Vector3
  45213. * * 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
  45214. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45215. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45216. * * When updating an instance, remember that only point positions can change, not the number of points
  45217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45218. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45219. * @param name defines the name of the new line system
  45220. * @param options defines the options used to create the line system
  45221. * @param scene defines the hosting scene
  45222. * @returns a new line mesh
  45223. */
  45224. static CreateLines(name: string, options: {
  45225. points: Vector3[];
  45226. updatable?: boolean;
  45227. instance?: Nullable<LinesMesh>;
  45228. colors?: Color4[];
  45229. useVertexAlpha?: boolean;
  45230. }, scene?: Nullable<Scene>): LinesMesh;
  45231. /**
  45232. * Creates a dashed line mesh
  45233. * * 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
  45234. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45235. * * The parameter `points` is an array successive Vector3
  45236. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45237. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45238. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45239. * * 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
  45240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45241. * * When updating an instance, remember that only point positions can change, not the number of points
  45242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45243. * @param name defines the name of the mesh
  45244. * @param options defines the options used to create the mesh
  45245. * @param scene defines the hosting scene
  45246. * @returns the dashed line mesh
  45247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45248. */
  45249. static CreateDashedLines(name: string, options: {
  45250. points: Vector3[];
  45251. dashSize?: number;
  45252. gapSize?: number;
  45253. dashNb?: number;
  45254. updatable?: boolean;
  45255. instance?: LinesMesh;
  45256. useVertexAlpha?: boolean;
  45257. }, scene?: Nullable<Scene>): LinesMesh;
  45258. }
  45259. }
  45260. declare module BABYLON {
  45261. /**
  45262. * The options container for the teleportation module
  45263. */
  45264. export interface IWebXRTeleportationOptions {
  45265. /**
  45266. * if provided, this scene will be used to render meshes.
  45267. */
  45268. customUtilityLayerScene?: Scene;
  45269. /**
  45270. * Values to configure the default target mesh
  45271. */
  45272. defaultTargetMeshOptions?: {
  45273. /**
  45274. * Fill color of the teleportation area
  45275. */
  45276. teleportationFillColor?: string;
  45277. /**
  45278. * Border color for the teleportation area
  45279. */
  45280. teleportationBorderColor?: string;
  45281. /**
  45282. * Disable the mesh's animation sequence
  45283. */
  45284. disableAnimation?: boolean;
  45285. /**
  45286. * Disable lighting on the material or the ring and arrow
  45287. */
  45288. disableLighting?: boolean;
  45289. /**
  45290. * Override the default material of the torus and arrow
  45291. */
  45292. torusArrowMaterial?: Material;
  45293. };
  45294. /**
  45295. * A list of meshes to use as floor meshes.
  45296. * Meshes can be added and removed after initializing the feature using the
  45297. * addFloorMesh and removeFloorMesh functions
  45298. * If empty, rotation will still work
  45299. */
  45300. floorMeshes?: AbstractMesh[];
  45301. /**
  45302. * use this rendering group id for the meshes (optional)
  45303. */
  45304. renderingGroupId?: number;
  45305. /**
  45306. * Should teleportation move only to snap points
  45307. */
  45308. snapPointsOnly?: boolean;
  45309. /**
  45310. * An array of points to which the teleportation will snap to.
  45311. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45312. */
  45313. snapPositions?: Vector3[];
  45314. /**
  45315. * How close should the teleportation ray be in order to snap to position.
  45316. * Default to 0.8 units (meters)
  45317. */
  45318. snapToPositionRadius?: number;
  45319. /**
  45320. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45321. * If you want to support rotation, make sure your mesh has a direction indicator.
  45322. *
  45323. * When left untouched, the default mesh will be initialized.
  45324. */
  45325. teleportationTargetMesh?: AbstractMesh;
  45326. /**
  45327. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45328. */
  45329. timeToTeleport?: number;
  45330. /**
  45331. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45332. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45333. */
  45334. useMainComponentOnly?: boolean;
  45335. /**
  45336. * Should meshes created here be added to a utility layer or the main scene
  45337. */
  45338. useUtilityLayer?: boolean;
  45339. /**
  45340. * Babylon XR Input class for controller
  45341. */
  45342. xrInput: WebXRInput;
  45343. }
  45344. /**
  45345. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45346. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45347. * the input of the attached controllers.
  45348. */
  45349. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45350. private _options;
  45351. private _controllers;
  45352. private _currentTeleportationControllerId;
  45353. private _floorMeshes;
  45354. private _quadraticBezierCurve;
  45355. private _selectionFeature;
  45356. private _snapToPositions;
  45357. private _snappedToPoint;
  45358. private _teleportationRingMaterial?;
  45359. private _tmpRay;
  45360. private _tmpVector;
  45361. /**
  45362. * The module's name
  45363. */
  45364. static readonly Name: string;
  45365. /**
  45366. * The (Babylon) version of this module.
  45367. * This is an integer representing the implementation version.
  45368. * This number does not correspond to the webxr specs version
  45369. */
  45370. static readonly Version: number;
  45371. /**
  45372. * Is movement backwards enabled
  45373. */
  45374. backwardsMovementEnabled: boolean;
  45375. /**
  45376. * Distance to travel when moving backwards
  45377. */
  45378. backwardsTeleportationDistance: number;
  45379. /**
  45380. * The distance from the user to the inspection point in the direction of the controller
  45381. * A higher number will allow the user to move further
  45382. * defaults to 5 (meters, in xr units)
  45383. */
  45384. parabolicCheckRadius: number;
  45385. /**
  45386. * Should the module support parabolic ray on top of direct ray
  45387. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45388. * Very helpful when moving between floors / different heights
  45389. */
  45390. parabolicRayEnabled: boolean;
  45391. /**
  45392. * How much rotation should be applied when rotating right and left
  45393. */
  45394. rotationAngle: number;
  45395. /**
  45396. * Is rotation enabled when moving forward?
  45397. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45398. */
  45399. rotationEnabled: boolean;
  45400. /**
  45401. * constructs a new anchor system
  45402. * @param _xrSessionManager an instance of WebXRSessionManager
  45403. * @param _options configuration object for this feature
  45404. */
  45405. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45406. /**
  45407. * Get the snapPointsOnly flag
  45408. */
  45409. get snapPointsOnly(): boolean;
  45410. /**
  45411. * Sets the snapPointsOnly flag
  45412. * @param snapToPoints should teleportation be exclusively to snap points
  45413. */
  45414. set snapPointsOnly(snapToPoints: boolean);
  45415. /**
  45416. * Add a new mesh to the floor meshes array
  45417. * @param mesh the mesh to use as floor mesh
  45418. */
  45419. addFloorMesh(mesh: AbstractMesh): void;
  45420. /**
  45421. * Add a new snap-to point to fix teleportation to this position
  45422. * @param newSnapPoint The new Snap-To point
  45423. */
  45424. addSnapPoint(newSnapPoint: Vector3): void;
  45425. attach(): boolean;
  45426. detach(): boolean;
  45427. dispose(): void;
  45428. /**
  45429. * Remove a mesh from the floor meshes array
  45430. * @param mesh the mesh to remove
  45431. */
  45432. removeFloorMesh(mesh: AbstractMesh): void;
  45433. /**
  45434. * Remove a mesh from the floor meshes array using its name
  45435. * @param name the mesh name to remove
  45436. */
  45437. removeFloorMeshByName(name: string): void;
  45438. /**
  45439. * 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
  45440. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45441. * @returns was the point found and removed or not
  45442. */
  45443. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45444. /**
  45445. * This function sets a selection feature that will be disabled when
  45446. * the forward ray is shown and will be reattached when hidden.
  45447. * This is used to remove the selection rays when moving.
  45448. * @param selectionFeature the feature to disable when forward movement is enabled
  45449. */
  45450. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45451. protected _onXRFrame(_xrFrame: XRFrame): void;
  45452. private _attachController;
  45453. private _createDefaultTargetMesh;
  45454. private _detachController;
  45455. private _findClosestSnapPointWithRadius;
  45456. private _setTargetMeshPosition;
  45457. private _setTargetMeshVisibility;
  45458. private _showParabolicPath;
  45459. private _teleportForward;
  45460. }
  45461. }
  45462. declare module BABYLON {
  45463. /**
  45464. * Options for the default xr helper
  45465. */
  45466. export class WebXRDefaultExperienceOptions {
  45467. /**
  45468. * Enable or disable default UI to enter XR
  45469. */
  45470. disableDefaultUI?: boolean;
  45471. /**
  45472. * Should teleportation not initialize. defaults to false.
  45473. */
  45474. disableTeleportation?: boolean;
  45475. /**
  45476. * Floor meshes that will be used for teleport
  45477. */
  45478. floorMeshes?: Array<AbstractMesh>;
  45479. /**
  45480. * If set to true, the first frame will not be used to reset position
  45481. * The first frame is mainly used when copying transformation from the old camera
  45482. * Mainly used in AR
  45483. */
  45484. ignoreNativeCameraTransformation?: boolean;
  45485. /**
  45486. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45487. */
  45488. inputOptions?: IWebXRInputOptions;
  45489. /**
  45490. * optional configuration for the output canvas
  45491. */
  45492. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45493. /**
  45494. * optional UI options. This can be used among other to change session mode and reference space type
  45495. */
  45496. uiOptions?: WebXREnterExitUIOptions;
  45497. /**
  45498. * When loading teleportation and pointer select, use stable versions instead of latest.
  45499. */
  45500. useStablePlugins?: boolean;
  45501. }
  45502. /**
  45503. * Default experience which provides a similar setup to the previous webVRExperience
  45504. */
  45505. export class WebXRDefaultExperience {
  45506. /**
  45507. * Base experience
  45508. */
  45509. baseExperience: WebXRExperienceHelper;
  45510. /**
  45511. * Enables ui for entering/exiting xr
  45512. */
  45513. enterExitUI: WebXREnterExitUI;
  45514. /**
  45515. * Input experience extension
  45516. */
  45517. input: WebXRInput;
  45518. /**
  45519. * Enables laser pointer and selection
  45520. */
  45521. pointerSelection: WebXRControllerPointerSelection;
  45522. /**
  45523. * Default target xr should render to
  45524. */
  45525. renderTarget: WebXRRenderTarget;
  45526. /**
  45527. * Enables teleportation
  45528. */
  45529. teleportation: WebXRMotionControllerTeleportation;
  45530. private constructor();
  45531. /**
  45532. * Creates the default xr experience
  45533. * @param scene scene
  45534. * @param options options for basic configuration
  45535. * @returns resulting WebXRDefaultExperience
  45536. */
  45537. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45538. /**
  45539. * DIsposes of the experience helper
  45540. */
  45541. dispose(): void;
  45542. }
  45543. }
  45544. declare module BABYLON {
  45545. /**
  45546. * Options to modify the vr teleportation behavior.
  45547. */
  45548. export interface VRTeleportationOptions {
  45549. /**
  45550. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45551. */
  45552. floorMeshName?: string;
  45553. /**
  45554. * A list of meshes to be used as the teleportation floor. (default: empty)
  45555. */
  45556. floorMeshes?: Mesh[];
  45557. /**
  45558. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45559. */
  45560. teleportationMode?: number;
  45561. /**
  45562. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45563. */
  45564. teleportationTime?: number;
  45565. /**
  45566. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45567. */
  45568. teleportationSpeed?: number;
  45569. /**
  45570. * The easing function used in the animation or null for Linear. (default CircleEase)
  45571. */
  45572. easingFunction?: EasingFunction;
  45573. }
  45574. /**
  45575. * Options to modify the vr experience helper's behavior.
  45576. */
  45577. export interface VRExperienceHelperOptions extends WebVROptions {
  45578. /**
  45579. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45580. */
  45581. createDeviceOrientationCamera?: boolean;
  45582. /**
  45583. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45584. */
  45585. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45586. /**
  45587. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45588. */
  45589. laserToggle?: boolean;
  45590. /**
  45591. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45592. */
  45593. floorMeshes?: Mesh[];
  45594. /**
  45595. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45596. */
  45597. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45598. /**
  45599. * Defines if WebXR should be used instead of WebVR (if available)
  45600. */
  45601. useXR?: boolean;
  45602. }
  45603. /**
  45604. * Event containing information after VR has been entered
  45605. */
  45606. export class OnAfterEnteringVRObservableEvent {
  45607. /**
  45608. * If entering vr was successful
  45609. */
  45610. success: boolean;
  45611. }
  45612. /**
  45613. * Helps to quickly add VR support to an existing scene.
  45614. * See http://doc.babylonjs.com/how_to/webvr_helper
  45615. */
  45616. export class VRExperienceHelper {
  45617. /** Options to modify the vr experience helper's behavior. */
  45618. webVROptions: VRExperienceHelperOptions;
  45619. private _scene;
  45620. private _position;
  45621. private _btnVR;
  45622. private _btnVRDisplayed;
  45623. private _webVRsupported;
  45624. private _webVRready;
  45625. private _webVRrequesting;
  45626. private _webVRpresenting;
  45627. private _hasEnteredVR;
  45628. private _fullscreenVRpresenting;
  45629. private _inputElement;
  45630. private _webVRCamera;
  45631. private _vrDeviceOrientationCamera;
  45632. private _deviceOrientationCamera;
  45633. private _existingCamera;
  45634. private _onKeyDown;
  45635. private _onVrDisplayPresentChange;
  45636. private _onVRDisplayChanged;
  45637. private _onVRRequestPresentStart;
  45638. private _onVRRequestPresentComplete;
  45639. /**
  45640. * 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)
  45641. */
  45642. enableGazeEvenWhenNoPointerLock: boolean;
  45643. /**
  45644. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45645. */
  45646. exitVROnDoubleTap: boolean;
  45647. /**
  45648. * Observable raised right before entering VR.
  45649. */
  45650. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45651. /**
  45652. * Observable raised when entering VR has completed.
  45653. */
  45654. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45655. /**
  45656. * Observable raised when exiting VR.
  45657. */
  45658. onExitingVRObservable: Observable<VRExperienceHelper>;
  45659. /**
  45660. * Observable raised when controller mesh is loaded.
  45661. */
  45662. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45663. /** Return this.onEnteringVRObservable
  45664. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45665. */
  45666. get onEnteringVR(): Observable<VRExperienceHelper>;
  45667. /** Return this.onExitingVRObservable
  45668. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45669. */
  45670. get onExitingVR(): Observable<VRExperienceHelper>;
  45671. /** Return this.onControllerMeshLoadedObservable
  45672. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45673. */
  45674. get onControllerMeshLoaded(): Observable<WebVRController>;
  45675. private _rayLength;
  45676. private _useCustomVRButton;
  45677. private _teleportationRequested;
  45678. private _teleportActive;
  45679. private _floorMeshName;
  45680. private _floorMeshesCollection;
  45681. private _teleportationMode;
  45682. private _teleportationTime;
  45683. private _teleportationSpeed;
  45684. private _teleportationEasing;
  45685. private _rotationAllowed;
  45686. private _teleportBackwardsVector;
  45687. private _teleportationTarget;
  45688. private _isDefaultTeleportationTarget;
  45689. private _postProcessMove;
  45690. private _teleportationFillColor;
  45691. private _teleportationBorderColor;
  45692. private _rotationAngle;
  45693. private _haloCenter;
  45694. private _cameraGazer;
  45695. private _padSensibilityUp;
  45696. private _padSensibilityDown;
  45697. private _leftController;
  45698. private _rightController;
  45699. private _gazeColor;
  45700. private _laserColor;
  45701. private _pickedLaserColor;
  45702. private _pickedGazeColor;
  45703. /**
  45704. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45705. */
  45706. onNewMeshSelected: Observable<AbstractMesh>;
  45707. /**
  45708. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45709. * This observable will provide the mesh and the controller used to select the mesh
  45710. */
  45711. onMeshSelectedWithController: Observable<{
  45712. mesh: AbstractMesh;
  45713. controller: WebVRController;
  45714. }>;
  45715. /**
  45716. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45717. */
  45718. onNewMeshPicked: Observable<PickingInfo>;
  45719. private _circleEase;
  45720. /**
  45721. * Observable raised before camera teleportation
  45722. */
  45723. onBeforeCameraTeleport: Observable<Vector3>;
  45724. /**
  45725. * Observable raised after camera teleportation
  45726. */
  45727. onAfterCameraTeleport: Observable<Vector3>;
  45728. /**
  45729. * Observable raised when current selected mesh gets unselected
  45730. */
  45731. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45732. private _raySelectionPredicate;
  45733. /**
  45734. * To be optionaly changed by user to define custom ray selection
  45735. */
  45736. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45737. /**
  45738. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45739. */
  45740. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45741. /**
  45742. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45743. */
  45744. teleportationEnabled: boolean;
  45745. private _defaultHeight;
  45746. private _teleportationInitialized;
  45747. private _interactionsEnabled;
  45748. private _interactionsRequested;
  45749. private _displayGaze;
  45750. private _displayLaserPointer;
  45751. /**
  45752. * The mesh used to display where the user is going to teleport.
  45753. */
  45754. get teleportationTarget(): Mesh;
  45755. /**
  45756. * Sets the mesh to be used to display where the user is going to teleport.
  45757. */
  45758. set teleportationTarget(value: Mesh);
  45759. /**
  45760. * 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
  45761. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45762. * See http://doc.babylonjs.com/resources/baking_transformations
  45763. */
  45764. get gazeTrackerMesh(): Mesh;
  45765. set gazeTrackerMesh(value: Mesh);
  45766. /**
  45767. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45768. */
  45769. updateGazeTrackerScale: boolean;
  45770. /**
  45771. * If the gaze trackers color should be updated when selecting meshes
  45772. */
  45773. updateGazeTrackerColor: boolean;
  45774. /**
  45775. * If the controller laser color should be updated when selecting meshes
  45776. */
  45777. updateControllerLaserColor: boolean;
  45778. /**
  45779. * The gaze tracking mesh corresponding to the left controller
  45780. */
  45781. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45782. /**
  45783. * The gaze tracking mesh corresponding to the right controller
  45784. */
  45785. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45786. /**
  45787. * If the ray of the gaze should be displayed.
  45788. */
  45789. get displayGaze(): boolean;
  45790. /**
  45791. * Sets if the ray of the gaze should be displayed.
  45792. */
  45793. set displayGaze(value: boolean);
  45794. /**
  45795. * If the ray of the LaserPointer should be displayed.
  45796. */
  45797. get displayLaserPointer(): boolean;
  45798. /**
  45799. * Sets if the ray of the LaserPointer should be displayed.
  45800. */
  45801. set displayLaserPointer(value: boolean);
  45802. /**
  45803. * The deviceOrientationCamera used as the camera when not in VR.
  45804. */
  45805. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45806. /**
  45807. * Based on the current WebVR support, returns the current VR camera used.
  45808. */
  45809. get currentVRCamera(): Nullable<Camera>;
  45810. /**
  45811. * The webVRCamera which is used when in VR.
  45812. */
  45813. get webVRCamera(): WebVRFreeCamera;
  45814. /**
  45815. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45816. */
  45817. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45818. /**
  45819. * The html button that is used to trigger entering into VR.
  45820. */
  45821. get vrButton(): Nullable<HTMLButtonElement>;
  45822. private get _teleportationRequestInitiated();
  45823. /**
  45824. * Defines whether or not Pointer lock should be requested when switching to
  45825. * full screen.
  45826. */
  45827. requestPointerLockOnFullScreen: boolean;
  45828. /**
  45829. * If asking to force XR, this will be populated with the default xr experience
  45830. */
  45831. xr: WebXRDefaultExperience;
  45832. /**
  45833. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45834. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45835. */
  45836. xrTestDone: boolean;
  45837. /**
  45838. * Instantiates a VRExperienceHelper.
  45839. * Helps to quickly add VR support to an existing scene.
  45840. * @param scene The scene the VRExperienceHelper belongs to.
  45841. * @param webVROptions Options to modify the vr experience helper's behavior.
  45842. */
  45843. constructor(scene: Scene,
  45844. /** Options to modify the vr experience helper's behavior. */
  45845. webVROptions?: VRExperienceHelperOptions);
  45846. private completeVRInit;
  45847. private _onDefaultMeshLoaded;
  45848. private _onResize;
  45849. private _onFullscreenChange;
  45850. /**
  45851. * Gets a value indicating if we are currently in VR mode.
  45852. */
  45853. get isInVRMode(): boolean;
  45854. private onVrDisplayPresentChange;
  45855. private onVRDisplayChanged;
  45856. private moveButtonToBottomRight;
  45857. private displayVRButton;
  45858. private updateButtonVisibility;
  45859. private _cachedAngularSensibility;
  45860. /**
  45861. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45862. * Otherwise, will use the fullscreen API.
  45863. */
  45864. enterVR(): void;
  45865. /**
  45866. * Attempt to exit VR, or fullscreen.
  45867. */
  45868. exitVR(): void;
  45869. /**
  45870. * The position of the vr experience helper.
  45871. */
  45872. get position(): Vector3;
  45873. /**
  45874. * Sets the position of the vr experience helper.
  45875. */
  45876. set position(value: Vector3);
  45877. /**
  45878. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45879. */
  45880. enableInteractions(): void;
  45881. private get _noControllerIsActive();
  45882. private beforeRender;
  45883. private _isTeleportationFloor;
  45884. /**
  45885. * Adds a floor mesh to be used for teleportation.
  45886. * @param floorMesh the mesh to be used for teleportation.
  45887. */
  45888. addFloorMesh(floorMesh: Mesh): void;
  45889. /**
  45890. * Removes a floor mesh from being used for teleportation.
  45891. * @param floorMesh the mesh to be removed.
  45892. */
  45893. removeFloorMesh(floorMesh: Mesh): void;
  45894. /**
  45895. * Enables interactions and teleportation using the VR controllers and gaze.
  45896. * @param vrTeleportationOptions options to modify teleportation behavior.
  45897. */
  45898. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45899. private _onNewGamepadConnected;
  45900. private _tryEnableInteractionOnController;
  45901. private _onNewGamepadDisconnected;
  45902. private _enableInteractionOnController;
  45903. private _checkTeleportWithRay;
  45904. private _checkRotate;
  45905. private _checkTeleportBackwards;
  45906. private _enableTeleportationOnController;
  45907. private _createTeleportationCircles;
  45908. private _displayTeleportationTarget;
  45909. private _hideTeleportationTarget;
  45910. private _rotateCamera;
  45911. private _moveTeleportationSelectorTo;
  45912. private _workingVector;
  45913. private _workingQuaternion;
  45914. private _workingMatrix;
  45915. /**
  45916. * Time Constant Teleportation Mode
  45917. */
  45918. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45919. /**
  45920. * Speed Constant Teleportation Mode
  45921. */
  45922. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45923. /**
  45924. * Teleports the users feet to the desired location
  45925. * @param location The location where the user's feet should be placed
  45926. */
  45927. teleportCamera(location: Vector3): void;
  45928. private _convertNormalToDirectionOfRay;
  45929. private _castRayAndSelectObject;
  45930. private _notifySelectedMeshUnselected;
  45931. /**
  45932. * Permanently set new colors for the laser pointer
  45933. * @param color the new laser color
  45934. * @param pickedColor the new laser color when picked mesh detected
  45935. */
  45936. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45937. /**
  45938. * Set lighting enabled / disabled on the laser pointer of both controllers
  45939. * @param enabled should the lighting be enabled on the laser pointer
  45940. */
  45941. setLaserLightingState(enabled?: boolean): void;
  45942. /**
  45943. * Permanently set new colors for the gaze pointer
  45944. * @param color the new gaze color
  45945. * @param pickedColor the new gaze color when picked mesh detected
  45946. */
  45947. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45948. /**
  45949. * Sets the color of the laser ray from the vr controllers.
  45950. * @param color new color for the ray.
  45951. */
  45952. changeLaserColor(color: Color3): void;
  45953. /**
  45954. * Sets the color of the ray from the vr headsets gaze.
  45955. * @param color new color for the ray.
  45956. */
  45957. changeGazeColor(color: Color3): void;
  45958. /**
  45959. * Exits VR and disposes of the vr experience helper
  45960. */
  45961. dispose(): void;
  45962. /**
  45963. * Gets the name of the VRExperienceHelper class
  45964. * @returns "VRExperienceHelper"
  45965. */
  45966. getClassName(): string;
  45967. }
  45968. }
  45969. declare module BABYLON {
  45970. /**
  45971. * Contains an array of blocks representing the octree
  45972. */
  45973. export interface IOctreeContainer<T> {
  45974. /**
  45975. * Blocks within the octree
  45976. */
  45977. blocks: Array<OctreeBlock<T>>;
  45978. }
  45979. /**
  45980. * Class used to store a cell in an octree
  45981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45982. */
  45983. export class OctreeBlock<T> {
  45984. /**
  45985. * Gets the content of the current block
  45986. */
  45987. entries: T[];
  45988. /**
  45989. * Gets the list of block children
  45990. */
  45991. blocks: Array<OctreeBlock<T>>;
  45992. private _depth;
  45993. private _maxDepth;
  45994. private _capacity;
  45995. private _minPoint;
  45996. private _maxPoint;
  45997. private _boundingVectors;
  45998. private _creationFunc;
  45999. /**
  46000. * Creates a new block
  46001. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46002. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46003. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46004. * @param depth defines the current depth of this block in the octree
  46005. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46006. * @param creationFunc defines a callback to call when an element is added to the block
  46007. */
  46008. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46009. /**
  46010. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46011. */
  46012. get capacity(): number;
  46013. /**
  46014. * Gets the minimum vector (in world space) of the block's bounding box
  46015. */
  46016. get minPoint(): Vector3;
  46017. /**
  46018. * Gets the maximum vector (in world space) of the block's bounding box
  46019. */
  46020. get maxPoint(): Vector3;
  46021. /**
  46022. * Add a new element to this block
  46023. * @param entry defines the element to add
  46024. */
  46025. addEntry(entry: T): void;
  46026. /**
  46027. * Remove an element from this block
  46028. * @param entry defines the element to remove
  46029. */
  46030. removeEntry(entry: T): void;
  46031. /**
  46032. * Add an array of elements to this block
  46033. * @param entries defines the array of elements to add
  46034. */
  46035. addEntries(entries: T[]): void;
  46036. /**
  46037. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46038. * @param frustumPlanes defines the frustum planes to test
  46039. * @param selection defines the array to store current content if selection is positive
  46040. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46041. */
  46042. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46043. /**
  46044. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46045. * @param sphereCenter defines the bounding sphere center
  46046. * @param sphereRadius defines the bounding sphere radius
  46047. * @param selection defines the array to store current content if selection is positive
  46048. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46049. */
  46050. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46051. /**
  46052. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46053. * @param ray defines the ray to test with
  46054. * @param selection defines the array to store current content if selection is positive
  46055. */
  46056. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46057. /**
  46058. * Subdivide the content into child blocks (this block will then be empty)
  46059. */
  46060. createInnerBlocks(): void;
  46061. /**
  46062. * @hidden
  46063. */
  46064. 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;
  46065. }
  46066. }
  46067. declare module BABYLON {
  46068. /**
  46069. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46070. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46071. */
  46072. export class Octree<T> {
  46073. /** 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.) */
  46074. maxDepth: number;
  46075. /**
  46076. * Blocks within the octree containing objects
  46077. */
  46078. blocks: Array<OctreeBlock<T>>;
  46079. /**
  46080. * Content stored in the octree
  46081. */
  46082. dynamicContent: T[];
  46083. private _maxBlockCapacity;
  46084. private _selectionContent;
  46085. private _creationFunc;
  46086. /**
  46087. * Creates a octree
  46088. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46089. * @param creationFunc function to be used to instatiate the octree
  46090. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46091. * @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.)
  46092. */
  46093. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46094. /** 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.) */
  46095. maxDepth?: number);
  46096. /**
  46097. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46098. * @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);
  46099. * @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);
  46100. * @param entries meshes to be added to the octree blocks
  46101. */
  46102. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46103. /**
  46104. * Adds a mesh to the octree
  46105. * @param entry Mesh to add to the octree
  46106. */
  46107. addMesh(entry: T): void;
  46108. /**
  46109. * Remove an element from the octree
  46110. * @param entry defines the element to remove
  46111. */
  46112. removeMesh(entry: T): void;
  46113. /**
  46114. * Selects an array of meshes within the frustum
  46115. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46116. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46117. * @returns array of meshes within the frustum
  46118. */
  46119. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46120. /**
  46121. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46122. * @param sphereCenter defines the bounding sphere center
  46123. * @param sphereRadius defines the bounding sphere radius
  46124. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46125. * @returns an array of objects that intersect the sphere
  46126. */
  46127. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46128. /**
  46129. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46130. * @param ray defines the ray to test with
  46131. * @returns array of intersected objects
  46132. */
  46133. intersectsRay(ray: Ray): SmartArray<T>;
  46134. /**
  46135. * Adds a mesh into the octree block if it intersects the block
  46136. */
  46137. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46138. /**
  46139. * Adds a submesh into the octree block if it intersects the block
  46140. */
  46141. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46142. }
  46143. }
  46144. declare module BABYLON {
  46145. interface Scene {
  46146. /**
  46147. * @hidden
  46148. * Backing Filed
  46149. */
  46150. _selectionOctree: Octree<AbstractMesh>;
  46151. /**
  46152. * Gets the octree used to boost mesh selection (picking)
  46153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46154. */
  46155. selectionOctree: Octree<AbstractMesh>;
  46156. /**
  46157. * Creates or updates the octree used to boost selection (picking)
  46158. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46159. * @param maxCapacity defines the maximum capacity per leaf
  46160. * @param maxDepth defines the maximum depth of the octree
  46161. * @returns an octree of AbstractMesh
  46162. */
  46163. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46164. }
  46165. interface AbstractMesh {
  46166. /**
  46167. * @hidden
  46168. * Backing Field
  46169. */
  46170. _submeshesOctree: Octree<SubMesh>;
  46171. /**
  46172. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46173. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46174. * @param maxCapacity defines the maximum size of each block (64 by default)
  46175. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46176. * @returns the new octree
  46177. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46178. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46179. */
  46180. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46181. }
  46182. /**
  46183. * Defines the octree scene component responsible to manage any octrees
  46184. * in a given scene.
  46185. */
  46186. export class OctreeSceneComponent {
  46187. /**
  46188. * The component name help to identify the component in the list of scene components.
  46189. */
  46190. readonly name: string;
  46191. /**
  46192. * The scene the component belongs to.
  46193. */
  46194. scene: Scene;
  46195. /**
  46196. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46197. */
  46198. readonly checksIsEnabled: boolean;
  46199. /**
  46200. * Creates a new instance of the component for the given scene
  46201. * @param scene Defines the scene to register the component in
  46202. */
  46203. constructor(scene: Scene);
  46204. /**
  46205. * Registers the component in a given scene
  46206. */
  46207. register(): void;
  46208. /**
  46209. * Return the list of active meshes
  46210. * @returns the list of active meshes
  46211. */
  46212. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46213. /**
  46214. * Return the list of active sub meshes
  46215. * @param mesh The mesh to get the candidates sub meshes from
  46216. * @returns the list of active sub meshes
  46217. */
  46218. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46219. private _tempRay;
  46220. /**
  46221. * Return the list of sub meshes intersecting with a given local ray
  46222. * @param mesh defines the mesh to find the submesh for
  46223. * @param localRay defines the ray in local space
  46224. * @returns the list of intersecting sub meshes
  46225. */
  46226. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46227. /**
  46228. * Return the list of sub meshes colliding with a collider
  46229. * @param mesh defines the mesh to find the submesh for
  46230. * @param collider defines the collider to evaluate the collision against
  46231. * @returns the list of colliding sub meshes
  46232. */
  46233. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46234. /**
  46235. * Rebuilds the elements related to this component in case of
  46236. * context lost for instance.
  46237. */
  46238. rebuild(): void;
  46239. /**
  46240. * Disposes the component and the associated ressources.
  46241. */
  46242. dispose(): void;
  46243. }
  46244. }
  46245. declare module BABYLON {
  46246. /**
  46247. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46248. */
  46249. export class Gizmo implements IDisposable {
  46250. /** The utility layer the gizmo will be added to */
  46251. gizmoLayer: UtilityLayerRenderer;
  46252. /**
  46253. * The root mesh of the gizmo
  46254. */
  46255. _rootMesh: Mesh;
  46256. private _attachedMesh;
  46257. /**
  46258. * Ratio for the scale of the gizmo (Default: 1)
  46259. */
  46260. scaleRatio: number;
  46261. /**
  46262. * If a custom mesh has been set (Default: false)
  46263. */
  46264. protected _customMeshSet: boolean;
  46265. /**
  46266. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46267. * * When set, interactions will be enabled
  46268. */
  46269. get attachedMesh(): Nullable<AbstractMesh>;
  46270. set attachedMesh(value: Nullable<AbstractMesh>);
  46271. /**
  46272. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46273. * @param mesh The mesh to replace the default mesh of the gizmo
  46274. */
  46275. setCustomMesh(mesh: Mesh): void;
  46276. /**
  46277. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46278. */
  46279. updateGizmoRotationToMatchAttachedMesh: boolean;
  46280. /**
  46281. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46282. */
  46283. updateGizmoPositionToMatchAttachedMesh: boolean;
  46284. /**
  46285. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46286. */
  46287. updateScale: boolean;
  46288. protected _interactionsEnabled: boolean;
  46289. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46290. private _beforeRenderObserver;
  46291. private _tempVector;
  46292. /**
  46293. * Creates a gizmo
  46294. * @param gizmoLayer The utility layer the gizmo will be added to
  46295. */
  46296. constructor(
  46297. /** The utility layer the gizmo will be added to */
  46298. gizmoLayer?: UtilityLayerRenderer);
  46299. /**
  46300. * Updates the gizmo to match the attached mesh's position/rotation
  46301. */
  46302. protected _update(): void;
  46303. /**
  46304. * Disposes of the gizmo
  46305. */
  46306. dispose(): void;
  46307. }
  46308. }
  46309. declare module BABYLON {
  46310. /**
  46311. * Single plane drag gizmo
  46312. */
  46313. export class PlaneDragGizmo extends Gizmo {
  46314. /**
  46315. * Drag behavior responsible for the gizmos dragging interactions
  46316. */
  46317. dragBehavior: PointerDragBehavior;
  46318. private _pointerObserver;
  46319. /**
  46320. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46321. */
  46322. snapDistance: number;
  46323. /**
  46324. * Event that fires each time the gizmo snaps to a new location.
  46325. * * snapDistance is the the change in distance
  46326. */
  46327. onSnapObservable: Observable<{
  46328. snapDistance: number;
  46329. }>;
  46330. private _plane;
  46331. private _coloredMaterial;
  46332. private _hoverMaterial;
  46333. private _isEnabled;
  46334. private _parent;
  46335. /** @hidden */
  46336. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46337. /** @hidden */
  46338. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46339. /**
  46340. * Creates a PlaneDragGizmo
  46341. * @param gizmoLayer The utility layer the gizmo will be added to
  46342. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46343. * @param color The color of the gizmo
  46344. */
  46345. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46346. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46347. /**
  46348. * If the gizmo is enabled
  46349. */
  46350. set isEnabled(value: boolean);
  46351. get isEnabled(): boolean;
  46352. /**
  46353. * Disposes of the gizmo
  46354. */
  46355. dispose(): void;
  46356. }
  46357. }
  46358. declare module BABYLON {
  46359. /**
  46360. * Gizmo that enables dragging a mesh along 3 axis
  46361. */
  46362. export class PositionGizmo extends Gizmo {
  46363. /**
  46364. * Internal gizmo used for interactions on the x axis
  46365. */
  46366. xGizmo: AxisDragGizmo;
  46367. /**
  46368. * Internal gizmo used for interactions on the y axis
  46369. */
  46370. yGizmo: AxisDragGizmo;
  46371. /**
  46372. * Internal gizmo used for interactions on the z axis
  46373. */
  46374. zGizmo: AxisDragGizmo;
  46375. /**
  46376. * Internal gizmo used for interactions on the yz plane
  46377. */
  46378. xPlaneGizmo: PlaneDragGizmo;
  46379. /**
  46380. * Internal gizmo used for interactions on the xz plane
  46381. */
  46382. yPlaneGizmo: PlaneDragGizmo;
  46383. /**
  46384. * Internal gizmo used for interactions on the xy plane
  46385. */
  46386. zPlaneGizmo: PlaneDragGizmo;
  46387. /**
  46388. * private variables
  46389. */
  46390. private _meshAttached;
  46391. private _updateGizmoRotationToMatchAttachedMesh;
  46392. private _snapDistance;
  46393. private _scaleRatio;
  46394. /** Fires an event when any of it's sub gizmos are dragged */
  46395. onDragStartObservable: Observable<unknown>;
  46396. /** Fires an event when any of it's sub gizmos are released from dragging */
  46397. onDragEndObservable: Observable<unknown>;
  46398. /**
  46399. * If set to true, planar drag is enabled
  46400. */
  46401. private _planarGizmoEnabled;
  46402. get attachedMesh(): Nullable<AbstractMesh>;
  46403. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46404. /**
  46405. * Creates a PositionGizmo
  46406. * @param gizmoLayer The utility layer the gizmo will be added to
  46407. */
  46408. constructor(gizmoLayer?: UtilityLayerRenderer);
  46409. /**
  46410. * If the planar drag gizmo is enabled
  46411. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46412. */
  46413. set planarGizmoEnabled(value: boolean);
  46414. get planarGizmoEnabled(): boolean;
  46415. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46416. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46417. /**
  46418. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46419. */
  46420. set snapDistance(value: number);
  46421. get snapDistance(): number;
  46422. /**
  46423. * Ratio for the scale of the gizmo (Default: 1)
  46424. */
  46425. set scaleRatio(value: number);
  46426. get scaleRatio(): number;
  46427. /**
  46428. * Disposes of the gizmo
  46429. */
  46430. dispose(): void;
  46431. /**
  46432. * CustomMeshes are not supported by this gizmo
  46433. * @param mesh The mesh to replace the default mesh of the gizmo
  46434. */
  46435. setCustomMesh(mesh: Mesh): void;
  46436. }
  46437. }
  46438. declare module BABYLON {
  46439. /**
  46440. * Single axis drag gizmo
  46441. */
  46442. export class AxisDragGizmo extends Gizmo {
  46443. /**
  46444. * Drag behavior responsible for the gizmos dragging interactions
  46445. */
  46446. dragBehavior: PointerDragBehavior;
  46447. private _pointerObserver;
  46448. /**
  46449. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46450. */
  46451. snapDistance: number;
  46452. /**
  46453. * Event that fires each time the gizmo snaps to a new location.
  46454. * * snapDistance is the the change in distance
  46455. */
  46456. onSnapObservable: Observable<{
  46457. snapDistance: number;
  46458. }>;
  46459. private _isEnabled;
  46460. private _parent;
  46461. private _arrow;
  46462. private _coloredMaterial;
  46463. private _hoverMaterial;
  46464. /** @hidden */
  46465. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46466. /** @hidden */
  46467. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46468. /**
  46469. * Creates an AxisDragGizmo
  46470. * @param gizmoLayer The utility layer the gizmo will be added to
  46471. * @param dragAxis The axis which the gizmo will be able to drag on
  46472. * @param color The color of the gizmo
  46473. */
  46474. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46475. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46476. /**
  46477. * If the gizmo is enabled
  46478. */
  46479. set isEnabled(value: boolean);
  46480. get isEnabled(): boolean;
  46481. /**
  46482. * Disposes of the gizmo
  46483. */
  46484. dispose(): void;
  46485. }
  46486. }
  46487. declare module BABYLON.Debug {
  46488. /**
  46489. * The Axes viewer will show 3 axes in a specific point in space
  46490. */
  46491. export class AxesViewer {
  46492. private _xAxis;
  46493. private _yAxis;
  46494. private _zAxis;
  46495. private _scaleLinesFactor;
  46496. private _instanced;
  46497. /**
  46498. * Gets the hosting scene
  46499. */
  46500. scene: Scene;
  46501. /**
  46502. * Gets or sets a number used to scale line length
  46503. */
  46504. scaleLines: number;
  46505. /** Gets the node hierarchy used to render x-axis */
  46506. get xAxis(): TransformNode;
  46507. /** Gets the node hierarchy used to render y-axis */
  46508. get yAxis(): TransformNode;
  46509. /** Gets the node hierarchy used to render z-axis */
  46510. get zAxis(): TransformNode;
  46511. /**
  46512. * Creates a new AxesViewer
  46513. * @param scene defines the hosting scene
  46514. * @param scaleLines defines a number used to scale line length (1 by default)
  46515. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46516. * @param xAxis defines the node hierarchy used to render the x-axis
  46517. * @param yAxis defines the node hierarchy used to render the y-axis
  46518. * @param zAxis defines the node hierarchy used to render the z-axis
  46519. */
  46520. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46521. /**
  46522. * Force the viewer to update
  46523. * @param position defines the position of the viewer
  46524. * @param xaxis defines the x axis of the viewer
  46525. * @param yaxis defines the y axis of the viewer
  46526. * @param zaxis defines the z axis of the viewer
  46527. */
  46528. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46529. /**
  46530. * Creates an instance of this axes viewer.
  46531. * @returns a new axes viewer with instanced meshes
  46532. */
  46533. createInstance(): AxesViewer;
  46534. /** Releases resources */
  46535. dispose(): void;
  46536. private static _SetRenderingGroupId;
  46537. }
  46538. }
  46539. declare module BABYLON.Debug {
  46540. /**
  46541. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46542. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46543. */
  46544. export class BoneAxesViewer extends AxesViewer {
  46545. /**
  46546. * Gets or sets the target mesh where to display the axes viewer
  46547. */
  46548. mesh: Nullable<Mesh>;
  46549. /**
  46550. * Gets or sets the target bone where to display the axes viewer
  46551. */
  46552. bone: Nullable<Bone>;
  46553. /** Gets current position */
  46554. pos: Vector3;
  46555. /** Gets direction of X axis */
  46556. xaxis: Vector3;
  46557. /** Gets direction of Y axis */
  46558. yaxis: Vector3;
  46559. /** Gets direction of Z axis */
  46560. zaxis: Vector3;
  46561. /**
  46562. * Creates a new BoneAxesViewer
  46563. * @param scene defines the hosting scene
  46564. * @param bone defines the target bone
  46565. * @param mesh defines the target mesh
  46566. * @param scaleLines defines a scaling factor for line length (1 by default)
  46567. */
  46568. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46569. /**
  46570. * Force the viewer to update
  46571. */
  46572. update(): void;
  46573. /** Releases resources */
  46574. dispose(): void;
  46575. }
  46576. }
  46577. declare module BABYLON {
  46578. /**
  46579. * Interface used to define scene explorer extensibility option
  46580. */
  46581. export interface IExplorerExtensibilityOption {
  46582. /**
  46583. * Define the option label
  46584. */
  46585. label: string;
  46586. /**
  46587. * Defines the action to execute on click
  46588. */
  46589. action: (entity: any) => void;
  46590. }
  46591. /**
  46592. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46593. */
  46594. export interface IExplorerExtensibilityGroup {
  46595. /**
  46596. * Defines a predicate to test if a given type mut be extended
  46597. */
  46598. predicate: (entity: any) => boolean;
  46599. /**
  46600. * Gets the list of options added to a type
  46601. */
  46602. entries: IExplorerExtensibilityOption[];
  46603. }
  46604. /**
  46605. * Interface used to define the options to use to create the Inspector
  46606. */
  46607. export interface IInspectorOptions {
  46608. /**
  46609. * Display in overlay mode (default: false)
  46610. */
  46611. overlay?: boolean;
  46612. /**
  46613. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46614. */
  46615. globalRoot?: HTMLElement;
  46616. /**
  46617. * Display the Scene explorer
  46618. */
  46619. showExplorer?: boolean;
  46620. /**
  46621. * Display the property inspector
  46622. */
  46623. showInspector?: boolean;
  46624. /**
  46625. * Display in embed mode (both panes on the right)
  46626. */
  46627. embedMode?: boolean;
  46628. /**
  46629. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46630. */
  46631. handleResize?: boolean;
  46632. /**
  46633. * Allow the panes to popup (default: true)
  46634. */
  46635. enablePopup?: boolean;
  46636. /**
  46637. * Allow the panes to be closed by users (default: true)
  46638. */
  46639. enableClose?: boolean;
  46640. /**
  46641. * Optional list of extensibility entries
  46642. */
  46643. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46644. /**
  46645. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46646. */
  46647. inspectorURL?: string;
  46648. /**
  46649. * Optional initial tab (default to DebugLayerTab.Properties)
  46650. */
  46651. initialTab?: DebugLayerTab;
  46652. }
  46653. interface Scene {
  46654. /**
  46655. * @hidden
  46656. * Backing field
  46657. */
  46658. _debugLayer: DebugLayer;
  46659. /**
  46660. * Gets the debug layer (aka Inspector) associated with the scene
  46661. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46662. */
  46663. debugLayer: DebugLayer;
  46664. }
  46665. /**
  46666. * Enum of inspector action tab
  46667. */
  46668. export enum DebugLayerTab {
  46669. /**
  46670. * Properties tag (default)
  46671. */
  46672. Properties = 0,
  46673. /**
  46674. * Debug tab
  46675. */
  46676. Debug = 1,
  46677. /**
  46678. * Statistics tab
  46679. */
  46680. Statistics = 2,
  46681. /**
  46682. * Tools tab
  46683. */
  46684. Tools = 3,
  46685. /**
  46686. * Settings tab
  46687. */
  46688. Settings = 4
  46689. }
  46690. /**
  46691. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46692. * what is happening in your scene
  46693. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46694. */
  46695. export class DebugLayer {
  46696. /**
  46697. * Define the url to get the inspector script from.
  46698. * By default it uses the babylonjs CDN.
  46699. * @ignoreNaming
  46700. */
  46701. static InspectorURL: string;
  46702. private _scene;
  46703. private BJSINSPECTOR;
  46704. private _onPropertyChangedObservable?;
  46705. /**
  46706. * Observable triggered when a property is changed through the inspector.
  46707. */
  46708. get onPropertyChangedObservable(): any;
  46709. /**
  46710. * Instantiates a new debug layer.
  46711. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46712. * what is happening in your scene
  46713. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46714. * @param scene Defines the scene to inspect
  46715. */
  46716. constructor(scene: Scene);
  46717. /** Creates the inspector window. */
  46718. private _createInspector;
  46719. /**
  46720. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46721. * @param entity defines the entity to select
  46722. * @param lineContainerTitle defines the specific block to highlight
  46723. */
  46724. select(entity: any, lineContainerTitle?: string): void;
  46725. /** Get the inspector from bundle or global */
  46726. private _getGlobalInspector;
  46727. /**
  46728. * Get if the inspector is visible or not.
  46729. * @returns true if visible otherwise, false
  46730. */
  46731. isVisible(): boolean;
  46732. /**
  46733. * Hide the inspector and close its window.
  46734. */
  46735. hide(): void;
  46736. /**
  46737. * Launch the debugLayer.
  46738. * @param config Define the configuration of the inspector
  46739. * @return a promise fulfilled when the debug layer is visible
  46740. */
  46741. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46742. }
  46743. }
  46744. declare module BABYLON {
  46745. /**
  46746. * Class containing static functions to help procedurally build meshes
  46747. */
  46748. export class BoxBuilder {
  46749. /**
  46750. * Creates a box mesh
  46751. * * The parameter `size` sets the size (float) of each box side (default 1)
  46752. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46753. * * 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)
  46754. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46756. * * 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
  46757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46758. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46759. * @param name defines the name of the mesh
  46760. * @param options defines the options used to create the mesh
  46761. * @param scene defines the hosting scene
  46762. * @returns the box mesh
  46763. */
  46764. static CreateBox(name: string, options: {
  46765. size?: number;
  46766. width?: number;
  46767. height?: number;
  46768. depth?: number;
  46769. faceUV?: Vector4[];
  46770. faceColors?: Color4[];
  46771. sideOrientation?: number;
  46772. frontUVs?: Vector4;
  46773. backUVs?: Vector4;
  46774. wrap?: boolean;
  46775. topBaseAt?: number;
  46776. bottomBaseAt?: number;
  46777. updatable?: boolean;
  46778. }, scene?: Nullable<Scene>): Mesh;
  46779. }
  46780. }
  46781. declare module BABYLON.Debug {
  46782. /**
  46783. * Used to show the physics impostor around the specific mesh
  46784. */
  46785. export class PhysicsViewer {
  46786. /** @hidden */
  46787. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46788. /** @hidden */
  46789. protected _meshes: Array<Nullable<AbstractMesh>>;
  46790. /** @hidden */
  46791. protected _scene: Nullable<Scene>;
  46792. /** @hidden */
  46793. protected _numMeshes: number;
  46794. /** @hidden */
  46795. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46796. private _renderFunction;
  46797. private _utilityLayer;
  46798. private _debugBoxMesh;
  46799. private _debugSphereMesh;
  46800. private _debugCylinderMesh;
  46801. private _debugMaterial;
  46802. private _debugMeshMeshes;
  46803. /**
  46804. * Creates a new PhysicsViewer
  46805. * @param scene defines the hosting scene
  46806. */
  46807. constructor(scene: Scene);
  46808. /** @hidden */
  46809. protected _updateDebugMeshes(): void;
  46810. /**
  46811. * Renders a specified physic impostor
  46812. * @param impostor defines the impostor to render
  46813. * @param targetMesh defines the mesh represented by the impostor
  46814. * @returns the new debug mesh used to render the impostor
  46815. */
  46816. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46817. /**
  46818. * Hides a specified physic impostor
  46819. * @param impostor defines the impostor to hide
  46820. */
  46821. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46822. private _getDebugMaterial;
  46823. private _getDebugBoxMesh;
  46824. private _getDebugSphereMesh;
  46825. private _getDebugCylinderMesh;
  46826. private _getDebugMeshMesh;
  46827. private _getDebugMesh;
  46828. /** Releases all resources */
  46829. dispose(): void;
  46830. }
  46831. }
  46832. declare module BABYLON {
  46833. /**
  46834. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46835. * in order to better appreciate the issue one might have.
  46836. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46837. */
  46838. export class RayHelper {
  46839. /**
  46840. * Defines the ray we are currently tryin to visualize.
  46841. */
  46842. ray: Nullable<Ray>;
  46843. private _renderPoints;
  46844. private _renderLine;
  46845. private _renderFunction;
  46846. private _scene;
  46847. private _updateToMeshFunction;
  46848. private _attachedToMesh;
  46849. private _meshSpaceDirection;
  46850. private _meshSpaceOrigin;
  46851. /**
  46852. * Helper function to create a colored helper in a scene in one line.
  46853. * @param ray Defines the ray we are currently tryin to visualize
  46854. * @param scene Defines the scene the ray is used in
  46855. * @param color Defines the color we want to see the ray in
  46856. * @returns The newly created ray helper.
  46857. */
  46858. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46859. /**
  46860. * Instantiate a new ray helper.
  46861. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46862. * in order to better appreciate the issue one might have.
  46863. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46864. * @param ray Defines the ray we are currently tryin to visualize
  46865. */
  46866. constructor(ray: Ray);
  46867. /**
  46868. * Shows the ray we are willing to debug.
  46869. * @param scene Defines the scene the ray needs to be rendered in
  46870. * @param color Defines the color the ray needs to be rendered in
  46871. */
  46872. show(scene: Scene, color?: Color3): void;
  46873. /**
  46874. * Hides the ray we are debugging.
  46875. */
  46876. hide(): void;
  46877. private _render;
  46878. /**
  46879. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46880. * @param mesh Defines the mesh we want the helper attached to
  46881. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46882. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46883. * @param length Defines the length of the ray
  46884. */
  46885. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46886. /**
  46887. * Detach the ray helper from the mesh it has previously been attached to.
  46888. */
  46889. detachFromMesh(): void;
  46890. private _updateToMesh;
  46891. /**
  46892. * Dispose the helper and release its associated resources.
  46893. */
  46894. dispose(): void;
  46895. }
  46896. }
  46897. declare module BABYLON.Debug {
  46898. /**
  46899. * Class used to render a debug view of a given skeleton
  46900. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46901. */
  46902. export class SkeletonViewer {
  46903. /** defines the skeleton to render */
  46904. skeleton: Skeleton;
  46905. /** defines the mesh attached to the skeleton */
  46906. mesh: AbstractMesh;
  46907. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46908. autoUpdateBonesMatrices: boolean;
  46909. /** defines the rendering group id to use with the viewer */
  46910. renderingGroupId: number;
  46911. /** Gets or sets the color used to render the skeleton */
  46912. color: Color3;
  46913. private _scene;
  46914. private _debugLines;
  46915. private _debugMesh;
  46916. private _isEnabled;
  46917. private _renderFunction;
  46918. private _utilityLayer;
  46919. /**
  46920. * Returns the mesh used to render the bones
  46921. */
  46922. get debugMesh(): Nullable<LinesMesh>;
  46923. /**
  46924. * Creates a new SkeletonViewer
  46925. * @param skeleton defines the skeleton to render
  46926. * @param mesh defines the mesh attached to the skeleton
  46927. * @param scene defines the hosting scene
  46928. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46929. * @param renderingGroupId defines the rendering group id to use with the viewer
  46930. */
  46931. constructor(
  46932. /** defines the skeleton to render */
  46933. skeleton: Skeleton,
  46934. /** defines the mesh attached to the skeleton */
  46935. mesh: AbstractMesh, scene: Scene,
  46936. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46937. autoUpdateBonesMatrices?: boolean,
  46938. /** defines the rendering group id to use with the viewer */
  46939. renderingGroupId?: number);
  46940. /** Gets or sets a boolean indicating if the viewer is enabled */
  46941. set isEnabled(value: boolean);
  46942. get isEnabled(): boolean;
  46943. private _getBonePosition;
  46944. private _getLinesForBonesWithLength;
  46945. private _getLinesForBonesNoLength;
  46946. /** Update the viewer to sync with current skeleton state */
  46947. update(): void;
  46948. /** Release associated resources */
  46949. dispose(): void;
  46950. }
  46951. }
  46952. declare module BABYLON {
  46953. /**
  46954. * This class will take all inputs from Keyboard, Pointer, and
  46955. * any Gamepads and provide a polling system that all devices
  46956. * will use. This class assumes that there will only be one
  46957. * pointer device and one keyboard.
  46958. */
  46959. export class DeviceInputSystem implements IDisposable {
  46960. /** POINTER_DEVICE */
  46961. static readonly POINTER_DEVICE: string;
  46962. /** KEYBOARD_DEVICE */
  46963. static readonly KEYBOARD_DEVICE: string;
  46964. /**
  46965. * Observable to be triggered when a device is connected
  46966. */
  46967. onDeviceConnectedObservable: Observable<string>;
  46968. /**
  46969. * Observable to be triggered when a device is disconnected
  46970. */
  46971. onDeviceDisconnectedObservable: Observable<string>;
  46972. private _inputs;
  46973. private _gamepads;
  46974. private _keyboardActive;
  46975. private _pointerActive;
  46976. private _elementToAttachTo;
  46977. private _keyboardDownEvent;
  46978. private _keyboardUpEvent;
  46979. private _pointerMoveEvent;
  46980. private _pointerDownEvent;
  46981. private _pointerUpEvent;
  46982. private _gamepadConnectedEvent;
  46983. private _gamepadDisconnectedEvent;
  46984. private static _MAX_KEYCODES;
  46985. private static _MAX_POINTER_INPUTS;
  46986. /**
  46987. * Default Constructor
  46988. * @param engine - engine to pull input element from
  46989. */
  46990. constructor(engine: Engine);
  46991. /**
  46992. * Checks for current device input value, given an id and input index
  46993. * @param deviceName Id of connected device
  46994. * @param inputIndex Index of device input
  46995. * @returns Current value of input
  46996. */
  46997. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  46998. /**
  46999. * Dispose of all the eventlisteners and clears the observables
  47000. */
  47001. dispose(): void;
  47002. /**
  47003. * Add device and inputs to device map
  47004. * @param deviceName Assigned name of device (may be SN)
  47005. * @param numberOfInputs Number of input entries to create for given device
  47006. */
  47007. private _registerDevice;
  47008. /**
  47009. * Given a specific device name, remove that device from the device map
  47010. * @param deviceName Name of device to be removed
  47011. */
  47012. private _unregisterDevice;
  47013. /**
  47014. * Handle all actions that come from keyboard interaction
  47015. */
  47016. private _handleKeyActions;
  47017. /**
  47018. * Handle all actions that come from pointer interaction
  47019. */
  47020. private _handlePointerActions;
  47021. /**
  47022. * Handle all actions that come from gamepad interaction
  47023. */
  47024. private _handleGamepadActions;
  47025. /**
  47026. * Update all non-event based devices with each frame
  47027. */
  47028. private _updateDevice;
  47029. }
  47030. }
  47031. declare module BABYLON {
  47032. /**
  47033. * Options to create the null engine
  47034. */
  47035. export class NullEngineOptions {
  47036. /**
  47037. * Render width (Default: 512)
  47038. */
  47039. renderWidth: number;
  47040. /**
  47041. * Render height (Default: 256)
  47042. */
  47043. renderHeight: number;
  47044. /**
  47045. * Texture size (Default: 512)
  47046. */
  47047. textureSize: number;
  47048. /**
  47049. * If delta time between frames should be constant
  47050. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47051. */
  47052. deterministicLockstep: boolean;
  47053. /**
  47054. * Maximum about of steps between frames (Default: 4)
  47055. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47056. */
  47057. lockstepMaxSteps: number;
  47058. }
  47059. /**
  47060. * The null engine class provides support for headless version of babylon.js.
  47061. * This can be used in server side scenario or for testing purposes
  47062. */
  47063. export class NullEngine extends Engine {
  47064. private _options;
  47065. /**
  47066. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47067. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47068. * @returns true if engine is in deterministic lock step mode
  47069. */
  47070. isDeterministicLockStep(): boolean;
  47071. /**
  47072. * Gets the max steps when engine is running in deterministic lock step
  47073. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47074. * @returns the max steps
  47075. */
  47076. getLockstepMaxSteps(): number;
  47077. /**
  47078. * Gets the current hardware scaling level.
  47079. * By default the hardware scaling level is computed from the window device ratio.
  47080. * 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.
  47081. * @returns a number indicating the current hardware scaling level
  47082. */
  47083. getHardwareScalingLevel(): number;
  47084. constructor(options?: NullEngineOptions);
  47085. /**
  47086. * Creates a vertex buffer
  47087. * @param vertices the data for the vertex buffer
  47088. * @returns the new WebGL static buffer
  47089. */
  47090. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47091. /**
  47092. * Creates a new index buffer
  47093. * @param indices defines the content of the index buffer
  47094. * @param updatable defines if the index buffer must be updatable
  47095. * @returns a new webGL buffer
  47096. */
  47097. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47098. /**
  47099. * Clear the current render buffer or the current render target (if any is set up)
  47100. * @param color defines the color to use
  47101. * @param backBuffer defines if the back buffer must be cleared
  47102. * @param depth defines if the depth buffer must be cleared
  47103. * @param stencil defines if the stencil buffer must be cleared
  47104. */
  47105. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47106. /**
  47107. * Gets the current render width
  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 width
  47110. */
  47111. getRenderWidth(useScreen?: boolean): number;
  47112. /**
  47113. * Gets the current render height
  47114. * @param useScreen defines if screen size must be used (or the current render target if any)
  47115. * @returns a number defining the current render height
  47116. */
  47117. getRenderHeight(useScreen?: boolean): number;
  47118. /**
  47119. * Set the WebGL's viewport
  47120. * @param viewport defines the viewport element to be used
  47121. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47122. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47123. */
  47124. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47125. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47126. /**
  47127. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47128. * @param pipelineContext defines the pipeline context to use
  47129. * @param uniformsNames defines the list of uniform names
  47130. * @returns an array of webGL uniform locations
  47131. */
  47132. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47133. /**
  47134. * Gets the lsit of active attributes for a given webGL program
  47135. * @param pipelineContext defines the pipeline context to use
  47136. * @param attributesNames defines the list of attribute names to get
  47137. * @returns an array of indices indicating the offset of each attribute
  47138. */
  47139. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47140. /**
  47141. * Binds an effect to the webGL context
  47142. * @param effect defines the effect to bind
  47143. */
  47144. bindSamplers(effect: Effect): void;
  47145. /**
  47146. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47147. * @param effect defines the effect to activate
  47148. */
  47149. enableEffect(effect: Effect): void;
  47150. /**
  47151. * Set various states to the webGL context
  47152. * @param culling defines backface culling state
  47153. * @param zOffset defines the value to apply to zOffset (0 by default)
  47154. * @param force defines if states must be applied even if cache is up to date
  47155. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47156. */
  47157. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47158. /**
  47159. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47164. /**
  47165. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47170. /**
  47171. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47176. /**
  47177. * Set the value of an uniform to an array of int32 (stored as vec4)
  47178. * @param uniform defines the webGL uniform location where to store the value
  47179. * @param array defines the array of int32 to store
  47180. */
  47181. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47182. /**
  47183. * Set the value of an uniform to an array of float32
  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. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47188. /**
  47189. * Set the value of an uniform to an array of float32 (stored as vec2)
  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. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47194. /**
  47195. * Set the value of an uniform to an array of float32 (stored as vec3)
  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. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47200. /**
  47201. * Set the value of an uniform to an array of float32 (stored as vec4)
  47202. * @param uniform defines the webGL uniform location where to store the value
  47203. * @param array defines the array of float32 to store
  47204. */
  47205. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47206. /**
  47207. * Set the value of an uniform to an array of number
  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. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47212. /**
  47213. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47218. /**
  47219. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47224. /**
  47225. * Set the value of an uniform to an array of number (stored as vec4)
  47226. * @param uniform defines the webGL uniform location where to store the value
  47227. * @param array defines the array of number to store
  47228. */
  47229. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47230. /**
  47231. * Set the value of an uniform to an array of float32 (stored as matrices)
  47232. * @param uniform defines the webGL uniform location where to store the value
  47233. * @param matrices defines the array of float32 to store
  47234. */
  47235. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47236. /**
  47237. * Set the value of an uniform to a matrix (3x3)
  47238. * @param uniform defines the webGL uniform location where to store the value
  47239. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47240. */
  47241. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47242. /**
  47243. * Set the value of an uniform to a matrix (2x2)
  47244. * @param uniform defines the webGL uniform location where to store the value
  47245. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47246. */
  47247. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47248. /**
  47249. * Set the value of an uniform to a number (float)
  47250. * @param uniform defines the webGL uniform location where to store the value
  47251. * @param value defines the float number to store
  47252. */
  47253. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47254. /**
  47255. * Set the value of an uniform to a vec2
  47256. * @param uniform defines the webGL uniform location where to store the value
  47257. * @param x defines the 1st component of the value
  47258. * @param y defines the 2nd component of the value
  47259. */
  47260. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47261. /**
  47262. * Set the value of an uniform to a vec3
  47263. * @param uniform defines the webGL uniform location where to store the value
  47264. * @param x defines the 1st component of the value
  47265. * @param y defines the 2nd component of the value
  47266. * @param z defines the 3rd component of the value
  47267. */
  47268. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47269. /**
  47270. * Set the value of an uniform to a boolean
  47271. * @param uniform defines the webGL uniform location where to store the value
  47272. * @param bool defines the boolean to store
  47273. */
  47274. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47275. /**
  47276. * Set the value of an uniform to a vec4
  47277. * @param uniform defines the webGL uniform location where to store the value
  47278. * @param x defines the 1st component of the value
  47279. * @param y defines the 2nd component of the value
  47280. * @param z defines the 3rd component of the value
  47281. * @param w defines the 4th component of the value
  47282. */
  47283. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47284. /**
  47285. * Sets the current alpha mode
  47286. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47287. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47288. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47289. */
  47290. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47291. /**
  47292. * Bind webGl buffers directly to the webGL context
  47293. * @param vertexBuffers defines the vertex buffer to bind
  47294. * @param indexBuffer defines the index buffer to bind
  47295. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47296. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47297. * @param effect defines the effect associated with the vertex buffer
  47298. */
  47299. bindBuffers(vertexBuffers: {
  47300. [key: string]: VertexBuffer;
  47301. }, indexBuffer: DataBuffer, effect: Effect): void;
  47302. /**
  47303. * Force the entire cache to be cleared
  47304. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47305. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47306. */
  47307. wipeCaches(bruteForce?: boolean): void;
  47308. /**
  47309. * Send a draw order
  47310. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47311. * @param indexStart defines the starting index
  47312. * @param indexCount defines the number of index to draw
  47313. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47314. */
  47315. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47316. /**
  47317. * Draw a list of indexed primitives
  47318. * @param fillMode defines the primitive to use
  47319. * @param indexStart defines the starting index
  47320. * @param indexCount defines the number of index to draw
  47321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47322. */
  47323. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47324. /**
  47325. * Draw a list of unindexed primitives
  47326. * @param fillMode defines the primitive to use
  47327. * @param verticesStart defines the index of first vertex to draw
  47328. * @param verticesCount defines the count of vertices to draw
  47329. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47330. */
  47331. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47332. /** @hidden */
  47333. _createTexture(): WebGLTexture;
  47334. /** @hidden */
  47335. _releaseTexture(texture: InternalTexture): void;
  47336. /**
  47337. * Usually called from Texture.ts.
  47338. * Passed information to create a WebGLTexture
  47339. * @param urlArg defines a value which contains one of the following:
  47340. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47341. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47342. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47343. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47344. * @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)
  47345. * @param scene needed for loading to the correct scene
  47346. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47347. * @param onLoad optional callback to be called upon successful completion
  47348. * @param onError optional callback to be called upon failure
  47349. * @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
  47350. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47351. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47352. * @param forcedExtension defines the extension to use to pick the right loader
  47353. * @param mimeType defines an optional mime type
  47354. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47355. */
  47356. 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;
  47357. /**
  47358. * Creates a new render target texture
  47359. * @param size defines the size of the texture
  47360. * @param options defines the options used to create the texture
  47361. * @returns a new render target texture stored in an InternalTexture
  47362. */
  47363. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47364. /**
  47365. * Update the sampling mode of a given texture
  47366. * @param samplingMode defines the required sampling mode
  47367. * @param texture defines the texture to update
  47368. */
  47369. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47370. /**
  47371. * Binds the frame buffer to the specified texture.
  47372. * @param texture The texture to render to or null for the default canvas
  47373. * @param faceIndex The face of the texture to render to in case of cube texture
  47374. * @param requiredWidth The width of the target to render to
  47375. * @param requiredHeight The height of the target to render to
  47376. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47377. * @param lodLevel defines le lod level to bind to the frame buffer
  47378. */
  47379. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47380. /**
  47381. * Unbind the current render target texture from the webGL context
  47382. * @param texture defines the render target texture to unbind
  47383. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47384. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47385. */
  47386. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47387. /**
  47388. * Creates a dynamic vertex buffer
  47389. * @param vertices the data for the dynamic vertex buffer
  47390. * @returns the new WebGL dynamic buffer
  47391. */
  47392. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47393. /**
  47394. * Update the content of a dynamic texture
  47395. * @param texture defines the texture to update
  47396. * @param canvas defines the canvas containing the source
  47397. * @param invertY defines if data must be stored with Y axis inverted
  47398. * @param premulAlpha defines if alpha is stored as premultiplied
  47399. * @param format defines the format of the data
  47400. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47401. */
  47402. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47403. /**
  47404. * Gets a boolean indicating if all created effects are ready
  47405. * @returns true if all effects are ready
  47406. */
  47407. areAllEffectsReady(): boolean;
  47408. /**
  47409. * @hidden
  47410. * Get the current error code of the webGL context
  47411. * @returns the error code
  47412. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47413. */
  47414. getError(): number;
  47415. /** @hidden */
  47416. _getUnpackAlignement(): number;
  47417. /** @hidden */
  47418. _unpackFlipY(value: boolean): void;
  47419. /**
  47420. * Update a dynamic index buffer
  47421. * @param indexBuffer defines the target index buffer
  47422. * @param indices defines the data to update
  47423. * @param offset defines the offset in the target index buffer where update should start
  47424. */
  47425. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47426. /**
  47427. * Updates a dynamic vertex buffer.
  47428. * @param vertexBuffer the vertex buffer to update
  47429. * @param vertices the data used to update the vertex buffer
  47430. * @param byteOffset the byte offset of the data (optional)
  47431. * @param byteLength the byte length of the data (optional)
  47432. */
  47433. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47434. /** @hidden */
  47435. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47436. /** @hidden */
  47437. _bindTexture(channel: number, texture: InternalTexture): void;
  47438. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47439. /**
  47440. * 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
  47441. */
  47442. releaseEffects(): void;
  47443. displayLoadingUI(): void;
  47444. hideLoadingUI(): void;
  47445. /** @hidden */
  47446. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47447. /** @hidden */
  47448. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47449. /** @hidden */
  47450. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47451. /** @hidden */
  47452. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47453. }
  47454. }
  47455. declare module BABYLON {
  47456. /**
  47457. * @hidden
  47458. **/
  47459. export class _TimeToken {
  47460. _startTimeQuery: Nullable<WebGLQuery>;
  47461. _endTimeQuery: Nullable<WebGLQuery>;
  47462. _timeElapsedQuery: Nullable<WebGLQuery>;
  47463. _timeElapsedQueryEnded: boolean;
  47464. }
  47465. }
  47466. declare module BABYLON {
  47467. /** @hidden */
  47468. export class _OcclusionDataStorage {
  47469. /** @hidden */
  47470. occlusionInternalRetryCounter: number;
  47471. /** @hidden */
  47472. isOcclusionQueryInProgress: boolean;
  47473. /** @hidden */
  47474. isOccluded: boolean;
  47475. /** @hidden */
  47476. occlusionRetryCount: number;
  47477. /** @hidden */
  47478. occlusionType: number;
  47479. /** @hidden */
  47480. occlusionQueryAlgorithmType: number;
  47481. }
  47482. interface Engine {
  47483. /**
  47484. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47485. * @return the new query
  47486. */
  47487. createQuery(): WebGLQuery;
  47488. /**
  47489. * Delete and release a webGL query
  47490. * @param query defines the query to delete
  47491. * @return the current engine
  47492. */
  47493. deleteQuery(query: WebGLQuery): Engine;
  47494. /**
  47495. * Check if a given query has resolved and got its value
  47496. * @param query defines the query to check
  47497. * @returns true if the query got its value
  47498. */
  47499. isQueryResultAvailable(query: WebGLQuery): boolean;
  47500. /**
  47501. * Gets the value of a given query
  47502. * @param query defines the query to check
  47503. * @returns the value of the query
  47504. */
  47505. getQueryResult(query: WebGLQuery): number;
  47506. /**
  47507. * Initiates an occlusion query
  47508. * @param algorithmType defines the algorithm to use
  47509. * @param query defines the query to use
  47510. * @returns the current engine
  47511. * @see http://doc.babylonjs.com/features/occlusionquery
  47512. */
  47513. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47514. /**
  47515. * Ends an occlusion query
  47516. * @see http://doc.babylonjs.com/features/occlusionquery
  47517. * @param algorithmType defines the algorithm to use
  47518. * @returns the current engine
  47519. */
  47520. endOcclusionQuery(algorithmType: number): Engine;
  47521. /**
  47522. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47523. * Please note that only one query can be issued at a time
  47524. * @returns a time token used to track the time span
  47525. */
  47526. startTimeQuery(): Nullable<_TimeToken>;
  47527. /**
  47528. * Ends a time query
  47529. * @param token defines the token used to measure the time span
  47530. * @returns the time spent (in ns)
  47531. */
  47532. endTimeQuery(token: _TimeToken): int;
  47533. /** @hidden */
  47534. _currentNonTimestampToken: Nullable<_TimeToken>;
  47535. /** @hidden */
  47536. _createTimeQuery(): WebGLQuery;
  47537. /** @hidden */
  47538. _deleteTimeQuery(query: WebGLQuery): void;
  47539. /** @hidden */
  47540. _getGlAlgorithmType(algorithmType: number): number;
  47541. /** @hidden */
  47542. _getTimeQueryResult(query: WebGLQuery): any;
  47543. /** @hidden */
  47544. _getTimeQueryAvailability(query: WebGLQuery): any;
  47545. }
  47546. interface AbstractMesh {
  47547. /**
  47548. * Backing filed
  47549. * @hidden
  47550. */
  47551. __occlusionDataStorage: _OcclusionDataStorage;
  47552. /**
  47553. * Access property
  47554. * @hidden
  47555. */
  47556. _occlusionDataStorage: _OcclusionDataStorage;
  47557. /**
  47558. * 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.
  47559. * The default value is -1 which means don't break the query and wait till the result
  47560. * @see http://doc.babylonjs.com/features/occlusionquery
  47561. */
  47562. occlusionRetryCount: number;
  47563. /**
  47564. * 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:
  47565. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47566. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47567. * * 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.
  47568. * @see http://doc.babylonjs.com/features/occlusionquery
  47569. */
  47570. occlusionType: number;
  47571. /**
  47572. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47573. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47574. * * 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.
  47575. * @see http://doc.babylonjs.com/features/occlusionquery
  47576. */
  47577. occlusionQueryAlgorithmType: number;
  47578. /**
  47579. * 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
  47580. * @see http://doc.babylonjs.com/features/occlusionquery
  47581. */
  47582. isOccluded: boolean;
  47583. /**
  47584. * Flag to check the progress status of the query
  47585. * @see http://doc.babylonjs.com/features/occlusionquery
  47586. */
  47587. isOcclusionQueryInProgress: boolean;
  47588. }
  47589. }
  47590. declare module BABYLON {
  47591. /** @hidden */
  47592. export var _forceTransformFeedbackToBundle: boolean;
  47593. interface Engine {
  47594. /**
  47595. * Creates a webGL transform feedback object
  47596. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47597. * @returns the webGL transform feedback object
  47598. */
  47599. createTransformFeedback(): WebGLTransformFeedback;
  47600. /**
  47601. * Delete a webGL transform feedback object
  47602. * @param value defines the webGL transform feedback object to delete
  47603. */
  47604. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47605. /**
  47606. * Bind a webGL transform feedback object to the webgl context
  47607. * @param value defines the webGL transform feedback object to bind
  47608. */
  47609. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47610. /**
  47611. * Begins a transform feedback operation
  47612. * @param usePoints defines if points or triangles must be used
  47613. */
  47614. beginTransformFeedback(usePoints: boolean): void;
  47615. /**
  47616. * Ends a transform feedback operation
  47617. */
  47618. endTransformFeedback(): void;
  47619. /**
  47620. * Specify the varyings to use with transform feedback
  47621. * @param program defines the associated webGL program
  47622. * @param value defines the list of strings representing the varying names
  47623. */
  47624. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47625. /**
  47626. * Bind a webGL buffer for a transform feedback operation
  47627. * @param value defines the webGL buffer to bind
  47628. */
  47629. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47630. }
  47631. }
  47632. declare module BABYLON {
  47633. /**
  47634. * Creation options of the multi render target texture.
  47635. */
  47636. export interface IMultiRenderTargetOptions {
  47637. /**
  47638. * Define if the texture needs to create mip maps after render.
  47639. */
  47640. generateMipMaps?: boolean;
  47641. /**
  47642. * Define the types of all the draw buffers we want to create
  47643. */
  47644. types?: number[];
  47645. /**
  47646. * Define the sampling modes of all the draw buffers we want to create
  47647. */
  47648. samplingModes?: number[];
  47649. /**
  47650. * Define if a depth buffer is required
  47651. */
  47652. generateDepthBuffer?: boolean;
  47653. /**
  47654. * Define if a stencil buffer is required
  47655. */
  47656. generateStencilBuffer?: boolean;
  47657. /**
  47658. * Define if a depth texture is required instead of a depth buffer
  47659. */
  47660. generateDepthTexture?: boolean;
  47661. /**
  47662. * Define the number of desired draw buffers
  47663. */
  47664. textureCount?: number;
  47665. /**
  47666. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47667. */
  47668. doNotChangeAspectRatio?: boolean;
  47669. /**
  47670. * Define the default type of the buffers we are creating
  47671. */
  47672. defaultType?: number;
  47673. }
  47674. /**
  47675. * A multi render target, like a render target provides the ability to render to a texture.
  47676. * Unlike the render target, it can render to several draw buffers in one draw.
  47677. * This is specially interesting in deferred rendering or for any effects requiring more than
  47678. * just one color from a single pass.
  47679. */
  47680. export class MultiRenderTarget extends RenderTargetTexture {
  47681. private _internalTextures;
  47682. private _textures;
  47683. private _multiRenderTargetOptions;
  47684. /**
  47685. * Get if draw buffers are currently supported by the used hardware and browser.
  47686. */
  47687. get isSupported(): boolean;
  47688. /**
  47689. * Get the list of textures generated by the multi render target.
  47690. */
  47691. get textures(): Texture[];
  47692. /**
  47693. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47694. */
  47695. get depthTexture(): Texture;
  47696. /**
  47697. * Set the wrapping mode on U of all the textures we are rendering to.
  47698. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47699. */
  47700. set wrapU(wrap: number);
  47701. /**
  47702. * Set the wrapping mode on V of all the textures we are rendering to.
  47703. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47704. */
  47705. set wrapV(wrap: number);
  47706. /**
  47707. * Instantiate a new multi render target texture.
  47708. * A multi render target, like a render target provides the ability to render to a texture.
  47709. * Unlike the render target, it can render to several draw buffers in one draw.
  47710. * This is specially interesting in deferred rendering or for any effects requiring more than
  47711. * just one color from a single pass.
  47712. * @param name Define the name of the texture
  47713. * @param size Define the size of the buffers to render to
  47714. * @param count Define the number of target we are rendering into
  47715. * @param scene Define the scene the texture belongs to
  47716. * @param options Define the options used to create the multi render target
  47717. */
  47718. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47719. /** @hidden */
  47720. _rebuild(): void;
  47721. private _createInternalTextures;
  47722. private _createTextures;
  47723. /**
  47724. * Define the number of samples used if MSAA is enabled.
  47725. */
  47726. get samples(): number;
  47727. set samples(value: number);
  47728. /**
  47729. * Resize all the textures in the multi render target.
  47730. * Be carrefull as it will recreate all the data in the new texture.
  47731. * @param size Define the new size
  47732. */
  47733. resize(size: any): void;
  47734. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47735. /**
  47736. * Dispose the render targets and their associated resources
  47737. */
  47738. dispose(): void;
  47739. /**
  47740. * Release all the underlying texture used as draw buffers.
  47741. */
  47742. releaseInternalTextures(): void;
  47743. }
  47744. }
  47745. declare module BABYLON {
  47746. interface ThinEngine {
  47747. /**
  47748. * Unbind a list of render target textures from the webGL context
  47749. * This is used only when drawBuffer extension or webGL2 are active
  47750. * @param textures defines the render target textures to unbind
  47751. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47752. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47753. */
  47754. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47755. /**
  47756. * Create a multi render target texture
  47757. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47758. * @param size defines the size of the texture
  47759. * @param options defines the creation options
  47760. * @returns the cube texture as an InternalTexture
  47761. */
  47762. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47763. /**
  47764. * Update the sample count for a given multiple render target texture
  47765. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47766. * @param textures defines the textures to update
  47767. * @param samples defines the sample count to set
  47768. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47769. */
  47770. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47771. }
  47772. }
  47773. declare module BABYLON {
  47774. /**
  47775. * Class used to define an additional view for the engine
  47776. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47777. */
  47778. export class EngineView {
  47779. /** Defines the canvas where to render the view */
  47780. target: HTMLCanvasElement;
  47781. /** Defines an optional camera used to render the view (will use active camera else) */
  47782. camera?: Camera;
  47783. }
  47784. interface Engine {
  47785. /**
  47786. * Gets or sets the HTML element to use for attaching events
  47787. */
  47788. inputElement: Nullable<HTMLElement>;
  47789. /**
  47790. * Gets the current engine view
  47791. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47792. */
  47793. activeView: Nullable<EngineView>;
  47794. /** Gets or sets the list of views */
  47795. views: EngineView[];
  47796. /**
  47797. * Register a new child canvas
  47798. * @param canvas defines the canvas to register
  47799. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47800. * @returns the associated view
  47801. */
  47802. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47803. /**
  47804. * Remove a registered child canvas
  47805. * @param canvas defines the canvas to remove
  47806. * @returns the current engine
  47807. */
  47808. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47809. }
  47810. }
  47811. declare module BABYLON {
  47812. interface Engine {
  47813. /** @hidden */
  47814. _excludedCompressedTextures: string[];
  47815. /** @hidden */
  47816. _textureFormatInUse: string;
  47817. /**
  47818. * Gets the list of texture formats supported
  47819. */
  47820. readonly texturesSupported: Array<string>;
  47821. /**
  47822. * Gets the texture format in use
  47823. */
  47824. readonly textureFormatInUse: Nullable<string>;
  47825. /**
  47826. * Set the compressed texture extensions or file names to skip.
  47827. *
  47828. * @param skippedFiles defines the list of those texture files you want to skip
  47829. * Example: [".dds", ".env", "myfile.png"]
  47830. */
  47831. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47832. /**
  47833. * Set the compressed texture format to use, based on the formats you have, and the formats
  47834. * supported by the hardware / browser.
  47835. *
  47836. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47837. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47838. * to API arguments needed to compressed textures. This puts the burden on the container
  47839. * generator to house the arcane code for determining these for current & future formats.
  47840. *
  47841. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47842. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47843. *
  47844. * Note: The result of this call is not taken into account when a texture is base64.
  47845. *
  47846. * @param formatsAvailable defines the list of those format families you have created
  47847. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47848. *
  47849. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47850. * @returns The extension selected.
  47851. */
  47852. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47853. }
  47854. }
  47855. declare module BABYLON {
  47856. /**
  47857. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47858. */
  47859. export interface CubeMapInfo {
  47860. /**
  47861. * The pixel array for the front face.
  47862. * This is stored in format, left to right, up to down format.
  47863. */
  47864. front: Nullable<ArrayBufferView>;
  47865. /**
  47866. * The pixel array for the back face.
  47867. * This is stored in format, left to right, up to down format.
  47868. */
  47869. back: Nullable<ArrayBufferView>;
  47870. /**
  47871. * The pixel array for the left face.
  47872. * This is stored in format, left to right, up to down format.
  47873. */
  47874. left: Nullable<ArrayBufferView>;
  47875. /**
  47876. * The pixel array for the right face.
  47877. * This is stored in format, left to right, up to down format.
  47878. */
  47879. right: Nullable<ArrayBufferView>;
  47880. /**
  47881. * The pixel array for the up face.
  47882. * This is stored in format, left to right, up to down format.
  47883. */
  47884. up: Nullable<ArrayBufferView>;
  47885. /**
  47886. * The pixel array for the down face.
  47887. * This is stored in format, left to right, up to down format.
  47888. */
  47889. down: Nullable<ArrayBufferView>;
  47890. /**
  47891. * The size of the cubemap stored.
  47892. *
  47893. * Each faces will be size * size pixels.
  47894. */
  47895. size: number;
  47896. /**
  47897. * The format of the texture.
  47898. *
  47899. * RGBA, RGB.
  47900. */
  47901. format: number;
  47902. /**
  47903. * The type of the texture data.
  47904. *
  47905. * UNSIGNED_INT, FLOAT.
  47906. */
  47907. type: number;
  47908. /**
  47909. * Specifies whether the texture is in gamma space.
  47910. */
  47911. gammaSpace: boolean;
  47912. }
  47913. /**
  47914. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47915. */
  47916. export class PanoramaToCubeMapTools {
  47917. private static FACE_FRONT;
  47918. private static FACE_BACK;
  47919. private static FACE_RIGHT;
  47920. private static FACE_LEFT;
  47921. private static FACE_DOWN;
  47922. private static FACE_UP;
  47923. /**
  47924. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47925. *
  47926. * @param float32Array The source data.
  47927. * @param inputWidth The width of the input panorama.
  47928. * @param inputHeight The height of the input panorama.
  47929. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47930. * @return The cubemap data
  47931. */
  47932. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47933. private static CreateCubemapTexture;
  47934. private static CalcProjectionSpherical;
  47935. }
  47936. }
  47937. declare module BABYLON {
  47938. /**
  47939. * Helper class dealing with the extraction of spherical polynomial dataArray
  47940. * from a cube map.
  47941. */
  47942. export class CubeMapToSphericalPolynomialTools {
  47943. private static FileFaces;
  47944. /**
  47945. * Converts a texture to the according Spherical Polynomial data.
  47946. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47947. *
  47948. * @param texture The texture to extract the information from.
  47949. * @return The Spherical Polynomial data.
  47950. */
  47951. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47952. /**
  47953. * Converts a cubemap to the according Spherical Polynomial data.
  47954. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47955. *
  47956. * @param cubeInfo The Cube map to extract the information from.
  47957. * @return The Spherical Polynomial data.
  47958. */
  47959. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47960. }
  47961. }
  47962. declare module BABYLON {
  47963. interface BaseTexture {
  47964. /**
  47965. * Get the polynomial representation of the texture data.
  47966. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47967. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47968. */
  47969. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47970. }
  47971. }
  47972. declare module BABYLON {
  47973. /** @hidden */
  47974. export var rgbdEncodePixelShader: {
  47975. name: string;
  47976. shader: string;
  47977. };
  47978. }
  47979. declare module BABYLON {
  47980. /** @hidden */
  47981. export var rgbdDecodePixelShader: {
  47982. name: string;
  47983. shader: string;
  47984. };
  47985. }
  47986. declare module BABYLON {
  47987. /**
  47988. * Raw texture data and descriptor sufficient for WebGL texture upload
  47989. */
  47990. export interface EnvironmentTextureInfo {
  47991. /**
  47992. * Version of the environment map
  47993. */
  47994. version: number;
  47995. /**
  47996. * Width of image
  47997. */
  47998. width: number;
  47999. /**
  48000. * Irradiance information stored in the file.
  48001. */
  48002. irradiance: any;
  48003. /**
  48004. * Specular information stored in the file.
  48005. */
  48006. specular: any;
  48007. }
  48008. /**
  48009. * Defines One Image in the file. It requires only the position in the file
  48010. * as well as the length.
  48011. */
  48012. interface BufferImageData {
  48013. /**
  48014. * Length of the image data.
  48015. */
  48016. length: number;
  48017. /**
  48018. * Position of the data from the null terminator delimiting the end of the JSON.
  48019. */
  48020. position: number;
  48021. }
  48022. /**
  48023. * Defines the specular data enclosed in the file.
  48024. * This corresponds to the version 1 of the data.
  48025. */
  48026. export interface EnvironmentTextureSpecularInfoV1 {
  48027. /**
  48028. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48029. */
  48030. specularDataPosition?: number;
  48031. /**
  48032. * This contains all the images data needed to reconstruct the cubemap.
  48033. */
  48034. mipmaps: Array<BufferImageData>;
  48035. /**
  48036. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48037. */
  48038. lodGenerationScale: number;
  48039. }
  48040. /**
  48041. * Sets of helpers addressing the serialization and deserialization of environment texture
  48042. * stored in a BabylonJS env file.
  48043. * Those files are usually stored as .env files.
  48044. */
  48045. export class EnvironmentTextureTools {
  48046. /**
  48047. * Magic number identifying the env file.
  48048. */
  48049. private static _MagicBytes;
  48050. /**
  48051. * Gets the environment info from an env file.
  48052. * @param data The array buffer containing the .env bytes.
  48053. * @returns the environment file info (the json header) if successfully parsed.
  48054. */
  48055. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48056. /**
  48057. * Creates an environment texture from a loaded cube texture.
  48058. * @param texture defines the cube texture to convert in env file
  48059. * @return a promise containing the environment data if succesfull.
  48060. */
  48061. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48062. /**
  48063. * Creates a JSON representation of the spherical data.
  48064. * @param texture defines the texture containing the polynomials
  48065. * @return the JSON representation of the spherical info
  48066. */
  48067. private static _CreateEnvTextureIrradiance;
  48068. /**
  48069. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48070. * @param data the image data
  48071. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48072. * @return the views described by info providing access to the underlying buffer
  48073. */
  48074. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48075. /**
  48076. * Uploads the texture info contained in the env file to the GPU.
  48077. * @param texture defines the internal texture to upload to
  48078. * @param data defines the data to load
  48079. * @param info defines the texture info retrieved through the GetEnvInfo method
  48080. * @returns a promise
  48081. */
  48082. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48083. private static _OnImageReadyAsync;
  48084. /**
  48085. * Uploads the levels of image data to the GPU.
  48086. * @param texture defines the internal texture to upload to
  48087. * @param imageData defines the array buffer views of image data [mipmap][face]
  48088. * @returns a promise
  48089. */
  48090. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48091. /**
  48092. * Uploads spherical polynomials information to the texture.
  48093. * @param texture defines the texture we are trying to upload the information to
  48094. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48095. */
  48096. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48097. /** @hidden */
  48098. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48099. }
  48100. }
  48101. declare module BABYLON {
  48102. /**
  48103. * Contains position and normal vectors for a vertex
  48104. */
  48105. export class PositionNormalVertex {
  48106. /** the position of the vertex (defaut: 0,0,0) */
  48107. position: Vector3;
  48108. /** the normal of the vertex (defaut: 0,1,0) */
  48109. normal: Vector3;
  48110. /**
  48111. * Creates a PositionNormalVertex
  48112. * @param position the position of the vertex (defaut: 0,0,0)
  48113. * @param normal the normal of the vertex (defaut: 0,1,0)
  48114. */
  48115. constructor(
  48116. /** the position of the vertex (defaut: 0,0,0) */
  48117. position?: Vector3,
  48118. /** the normal of the vertex (defaut: 0,1,0) */
  48119. normal?: Vector3);
  48120. /**
  48121. * Clones the PositionNormalVertex
  48122. * @returns the cloned PositionNormalVertex
  48123. */
  48124. clone(): PositionNormalVertex;
  48125. }
  48126. /**
  48127. * Contains position, normal and uv vectors for a vertex
  48128. */
  48129. export class PositionNormalTextureVertex {
  48130. /** the position of the vertex (defaut: 0,0,0) */
  48131. position: Vector3;
  48132. /** the normal of the vertex (defaut: 0,1,0) */
  48133. normal: Vector3;
  48134. /** the uv of the vertex (default: 0,0) */
  48135. uv: Vector2;
  48136. /**
  48137. * Creates a PositionNormalTextureVertex
  48138. * @param position the position of the vertex (defaut: 0,0,0)
  48139. * @param normal the normal of the vertex (defaut: 0,1,0)
  48140. * @param uv the uv of the vertex (default: 0,0)
  48141. */
  48142. constructor(
  48143. /** the position of the vertex (defaut: 0,0,0) */
  48144. position?: Vector3,
  48145. /** the normal of the vertex (defaut: 0,1,0) */
  48146. normal?: Vector3,
  48147. /** the uv of the vertex (default: 0,0) */
  48148. uv?: Vector2);
  48149. /**
  48150. * Clones the PositionNormalTextureVertex
  48151. * @returns the cloned PositionNormalTextureVertex
  48152. */
  48153. clone(): PositionNormalTextureVertex;
  48154. }
  48155. }
  48156. declare module BABYLON {
  48157. /** @hidden */
  48158. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48159. private _genericAttributeLocation;
  48160. private _varyingLocationCount;
  48161. private _varyingLocationMap;
  48162. private _replacements;
  48163. private _textureCount;
  48164. private _uniforms;
  48165. lineProcessor(line: string): string;
  48166. attributeProcessor(attribute: string): string;
  48167. varyingProcessor(varying: string, isFragment: boolean): string;
  48168. uniformProcessor(uniform: string): string;
  48169. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48170. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48171. }
  48172. }
  48173. declare module BABYLON {
  48174. /**
  48175. * Container for accessors for natively-stored mesh data buffers.
  48176. */
  48177. class NativeDataBuffer extends DataBuffer {
  48178. /**
  48179. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48180. */
  48181. nativeIndexBuffer?: any;
  48182. /**
  48183. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48184. */
  48185. nativeVertexBuffer?: any;
  48186. }
  48187. /** @hidden */
  48188. class NativeTexture extends InternalTexture {
  48189. getInternalTexture(): InternalTexture;
  48190. getViewCount(): number;
  48191. }
  48192. /** @hidden */
  48193. export class NativeEngine extends Engine {
  48194. private readonly _native;
  48195. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48196. private readonly INVALID_HANDLE;
  48197. getHardwareScalingLevel(): number;
  48198. constructor();
  48199. dispose(): void;
  48200. /**
  48201. * Can be used to override the current requestAnimationFrame requester.
  48202. * @hidden
  48203. */
  48204. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48205. /**
  48206. * Override default engine behavior.
  48207. * @param color
  48208. * @param backBuffer
  48209. * @param depth
  48210. * @param stencil
  48211. */
  48212. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48213. /**
  48214. * Gets host document
  48215. * @returns the host document object
  48216. */
  48217. getHostDocument(): Nullable<Document>;
  48218. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48219. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48220. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48221. recordVertexArrayObject(vertexBuffers: {
  48222. [key: string]: VertexBuffer;
  48223. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48224. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48225. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48226. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48227. /**
  48228. * Draw a list of indexed primitives
  48229. * @param fillMode defines the primitive to use
  48230. * @param indexStart defines the starting index
  48231. * @param indexCount defines the number of index to draw
  48232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48233. */
  48234. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48235. /**
  48236. * Draw a list of unindexed primitives
  48237. * @param fillMode defines the primitive to use
  48238. * @param verticesStart defines the index of first vertex to draw
  48239. * @param verticesCount defines the count of vertices to draw
  48240. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48241. */
  48242. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48243. createPipelineContext(): IPipelineContext;
  48244. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48245. /** @hidden */
  48246. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48247. /** @hidden */
  48248. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48249. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48250. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48251. protected _setProgram(program: WebGLProgram): void;
  48252. _releaseEffect(effect: Effect): void;
  48253. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48254. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48255. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48256. bindSamplers(effect: Effect): void;
  48257. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48258. getRenderWidth(useScreen?: boolean): number;
  48259. getRenderHeight(useScreen?: boolean): number;
  48260. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48261. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48262. /**
  48263. * Set the z offset to apply to current rendering
  48264. * @param value defines the offset to apply
  48265. */
  48266. setZOffset(value: number): void;
  48267. /**
  48268. * Gets the current value of the zOffset
  48269. * @returns the current zOffset state
  48270. */
  48271. getZOffset(): number;
  48272. /**
  48273. * Enable or disable depth buffering
  48274. * @param enable defines the state to set
  48275. */
  48276. setDepthBuffer(enable: boolean): void;
  48277. /**
  48278. * Gets a boolean indicating if depth writing is enabled
  48279. * @returns the current depth writing state
  48280. */
  48281. getDepthWrite(): boolean;
  48282. /**
  48283. * Enable or disable depth writing
  48284. * @param enable defines the state to set
  48285. */
  48286. setDepthWrite(enable: boolean): void;
  48287. /**
  48288. * Enable or disable color writing
  48289. * @param enable defines the state to set
  48290. */
  48291. setColorWrite(enable: boolean): void;
  48292. /**
  48293. * Gets a boolean indicating if color writing is enabled
  48294. * @returns the current color writing state
  48295. */
  48296. getColorWrite(): boolean;
  48297. /**
  48298. * Sets alpha constants used by some alpha blending modes
  48299. * @param r defines the red component
  48300. * @param g defines the green component
  48301. * @param b defines the blue component
  48302. * @param a defines the alpha component
  48303. */
  48304. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48305. /**
  48306. * Sets the current alpha mode
  48307. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48308. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48309. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48310. */
  48311. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48312. /**
  48313. * Gets the current alpha mode
  48314. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48315. * @returns the current alpha mode
  48316. */
  48317. getAlphaMode(): number;
  48318. setInt(uniform: WebGLUniformLocation, int: number): void;
  48319. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48320. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48321. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48322. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48323. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48324. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48325. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48326. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48327. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48328. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48329. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48330. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48331. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48332. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48333. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48334. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48335. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48336. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48337. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48338. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48339. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48340. wipeCaches(bruteForce?: boolean): void;
  48341. _createTexture(): WebGLTexture;
  48342. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48343. /**
  48344. * Usually called from Texture.ts.
  48345. * Passed information to create a WebGLTexture
  48346. * @param url defines a value which contains one of the following:
  48347. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48348. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48349. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48350. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48351. * @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)
  48352. * @param scene needed for loading to the correct scene
  48353. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48354. * @param onLoad optional callback to be called upon successful completion
  48355. * @param onError optional callback to be called upon failure
  48356. * @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
  48357. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48358. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48359. * @param forcedExtension defines the extension to use to pick the right loader
  48360. * @param mimeType defines an optional mime type
  48361. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48362. */
  48363. 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;
  48364. /**
  48365. * Creates a cube texture
  48366. * @param rootUrl defines the url where the files to load is located
  48367. * @param scene defines the current scene
  48368. * @param files defines the list of files to load (1 per face)
  48369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48370. * @param onLoad defines an optional callback raised when the texture is loaded
  48371. * @param onError defines an optional callback raised if there is an issue to load the texture
  48372. * @param format defines the format of the data
  48373. * @param forcedExtension defines the extension to use to pick the right loader
  48374. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48375. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48376. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48377. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48378. * @returns the cube texture as an InternalTexture
  48379. */
  48380. 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;
  48381. private _getSamplingFilter;
  48382. private static _GetNativeTextureFormat;
  48383. createRenderTargetTexture(size: number | {
  48384. width: number;
  48385. height: number;
  48386. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48387. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48388. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48389. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48390. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48391. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48392. /**
  48393. * Updates a dynamic vertex buffer.
  48394. * @param vertexBuffer the vertex buffer to update
  48395. * @param data the data used to update the vertex buffer
  48396. * @param byteOffset the byte offset of the data (optional)
  48397. * @param byteLength the byte length of the data (optional)
  48398. */
  48399. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48400. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48401. private _updateAnisotropicLevel;
  48402. private _getAddressMode;
  48403. /** @hidden */
  48404. _bindTexture(channel: number, texture: InternalTexture): void;
  48405. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48406. releaseEffects(): void;
  48407. /** @hidden */
  48408. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48409. /** @hidden */
  48410. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48411. /** @hidden */
  48412. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48413. /** @hidden */
  48414. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48415. }
  48416. }
  48417. declare module BABYLON {
  48418. /**
  48419. * Gather the list of clipboard event types as constants.
  48420. */
  48421. export class ClipboardEventTypes {
  48422. /**
  48423. * The clipboard event is fired when a copy command is active (pressed).
  48424. */
  48425. static readonly COPY: number;
  48426. /**
  48427. * The clipboard event is fired when a cut command is active (pressed).
  48428. */
  48429. static readonly CUT: number;
  48430. /**
  48431. * The clipboard event is fired when a paste command is active (pressed).
  48432. */
  48433. static readonly PASTE: number;
  48434. }
  48435. /**
  48436. * This class is used to store clipboard related info for the onClipboardObservable event.
  48437. */
  48438. export class ClipboardInfo {
  48439. /**
  48440. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48441. */
  48442. type: number;
  48443. /**
  48444. * Defines the related dom event
  48445. */
  48446. event: ClipboardEvent;
  48447. /**
  48448. *Creates an instance of ClipboardInfo.
  48449. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48450. * @param event Defines the related dom event
  48451. */
  48452. constructor(
  48453. /**
  48454. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48455. */
  48456. type: number,
  48457. /**
  48458. * Defines the related dom event
  48459. */
  48460. event: ClipboardEvent);
  48461. /**
  48462. * Get the clipboard event's type from the keycode.
  48463. * @param keyCode Defines the keyCode for the current keyboard event.
  48464. * @return {number}
  48465. */
  48466. static GetTypeFromCharacter(keyCode: number): number;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /**
  48471. * Google Daydream controller
  48472. */
  48473. export class DaydreamController extends WebVRController {
  48474. /**
  48475. * Base Url for the controller model.
  48476. */
  48477. static MODEL_BASE_URL: string;
  48478. /**
  48479. * File name for the controller model.
  48480. */
  48481. static MODEL_FILENAME: string;
  48482. /**
  48483. * Gamepad Id prefix used to identify Daydream Controller.
  48484. */
  48485. static readonly GAMEPAD_ID_PREFIX: string;
  48486. /**
  48487. * Creates a new DaydreamController from a gamepad
  48488. * @param vrGamepad the gamepad that the controller should be created from
  48489. */
  48490. constructor(vrGamepad: any);
  48491. /**
  48492. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48493. * @param scene scene in which to add meshes
  48494. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48495. */
  48496. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48497. /**
  48498. * Called once for each button that changed state since the last frame
  48499. * @param buttonIdx Which button index changed
  48500. * @param state New state of the button
  48501. * @param changes Which properties on the state changed since last frame
  48502. */
  48503. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48504. }
  48505. }
  48506. declare module BABYLON {
  48507. /**
  48508. * Gear VR Controller
  48509. */
  48510. export class GearVRController extends WebVRController {
  48511. /**
  48512. * Base Url for the controller model.
  48513. */
  48514. static MODEL_BASE_URL: string;
  48515. /**
  48516. * File name for the controller model.
  48517. */
  48518. static MODEL_FILENAME: string;
  48519. /**
  48520. * Gamepad Id prefix used to identify this controller.
  48521. */
  48522. static readonly GAMEPAD_ID_PREFIX: string;
  48523. private readonly _buttonIndexToObservableNameMap;
  48524. /**
  48525. * Creates a new GearVRController from a gamepad
  48526. * @param vrGamepad the gamepad that the controller should be created from
  48527. */
  48528. constructor(vrGamepad: any);
  48529. /**
  48530. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48531. * @param scene scene in which to add meshes
  48532. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48533. */
  48534. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48535. /**
  48536. * Called once for each button that changed state since the last frame
  48537. * @param buttonIdx Which button index changed
  48538. * @param state New state of the button
  48539. * @param changes Which properties on the state changed since last frame
  48540. */
  48541. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48542. }
  48543. }
  48544. declare module BABYLON {
  48545. /**
  48546. * Generic Controller
  48547. */
  48548. export class GenericController extends WebVRController {
  48549. /**
  48550. * Base Url for the controller model.
  48551. */
  48552. static readonly MODEL_BASE_URL: string;
  48553. /**
  48554. * File name for the controller model.
  48555. */
  48556. static readonly MODEL_FILENAME: string;
  48557. /**
  48558. * Creates a new GenericController from a gamepad
  48559. * @param vrGamepad the gamepad that the controller should be created from
  48560. */
  48561. constructor(vrGamepad: any);
  48562. /**
  48563. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48564. * @param scene scene in which to add meshes
  48565. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48566. */
  48567. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48568. /**
  48569. * Called once for each button that changed state since the last frame
  48570. * @param buttonIdx Which button index changed
  48571. * @param state New state of the button
  48572. * @param changes Which properties on the state changed since last frame
  48573. */
  48574. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48575. }
  48576. }
  48577. declare module BABYLON {
  48578. /**
  48579. * Oculus Touch Controller
  48580. */
  48581. export class OculusTouchController extends WebVRController {
  48582. /**
  48583. * Base Url for the controller model.
  48584. */
  48585. static MODEL_BASE_URL: string;
  48586. /**
  48587. * File name for the left controller model.
  48588. */
  48589. static MODEL_LEFT_FILENAME: string;
  48590. /**
  48591. * File name for the right controller model.
  48592. */
  48593. static MODEL_RIGHT_FILENAME: string;
  48594. /**
  48595. * Base Url for the Quest controller model.
  48596. */
  48597. static QUEST_MODEL_BASE_URL: string;
  48598. /**
  48599. * @hidden
  48600. * If the controllers are running on a device that needs the updated Quest controller models
  48601. */
  48602. static _IsQuest: boolean;
  48603. /**
  48604. * Fired when the secondary trigger on this controller is modified
  48605. */
  48606. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48607. /**
  48608. * Fired when the thumb rest on this controller is modified
  48609. */
  48610. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48611. /**
  48612. * Creates a new OculusTouchController from a gamepad
  48613. * @param vrGamepad the gamepad that the controller should be created from
  48614. */
  48615. constructor(vrGamepad: any);
  48616. /**
  48617. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48618. * @param scene scene in which to add meshes
  48619. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48620. */
  48621. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48622. /**
  48623. * Fired when the A button on this controller is modified
  48624. */
  48625. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48626. /**
  48627. * Fired when the B button on this controller is modified
  48628. */
  48629. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48630. /**
  48631. * Fired when the X button on this controller is modified
  48632. */
  48633. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48634. /**
  48635. * Fired when the Y button on this controller is modified
  48636. */
  48637. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48638. /**
  48639. * Called once for each button that changed state since the last frame
  48640. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48641. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48642. * 2) secondary trigger (same)
  48643. * 3) A (right) X (left), touch, pressed = value
  48644. * 4) B / Y
  48645. * 5) thumb rest
  48646. * @param buttonIdx Which button index changed
  48647. * @param state New state of the button
  48648. * @param changes Which properties on the state changed since last frame
  48649. */
  48650. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48651. }
  48652. }
  48653. declare module BABYLON {
  48654. /**
  48655. * Vive Controller
  48656. */
  48657. export class ViveController extends WebVRController {
  48658. /**
  48659. * Base Url for the controller model.
  48660. */
  48661. static MODEL_BASE_URL: string;
  48662. /**
  48663. * File name for the controller model.
  48664. */
  48665. static MODEL_FILENAME: string;
  48666. /**
  48667. * Creates a new ViveController from a gamepad
  48668. * @param vrGamepad the gamepad that the controller should be created from
  48669. */
  48670. constructor(vrGamepad: any);
  48671. /**
  48672. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48673. * @param scene scene in which to add meshes
  48674. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48675. */
  48676. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48677. /**
  48678. * Fired when the left button on this controller is modified
  48679. */
  48680. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48681. /**
  48682. * Fired when the right button on this controller is modified
  48683. */
  48684. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48685. /**
  48686. * Fired when the menu button on this controller is modified
  48687. */
  48688. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48689. /**
  48690. * Called once for each button that changed state since the last frame
  48691. * Vive mapping:
  48692. * 0: touchpad
  48693. * 1: trigger
  48694. * 2: left AND right buttons
  48695. * 3: menu button
  48696. * @param buttonIdx Which button index changed
  48697. * @param state New state of the button
  48698. * @param changes Which properties on the state changed since last frame
  48699. */
  48700. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48701. }
  48702. }
  48703. declare module BABYLON {
  48704. /**
  48705. * Defines the WindowsMotionController object that the state of the windows motion controller
  48706. */
  48707. export class WindowsMotionController extends WebVRController {
  48708. /**
  48709. * The base url used to load the left and right controller models
  48710. */
  48711. static MODEL_BASE_URL: string;
  48712. /**
  48713. * The name of the left controller model file
  48714. */
  48715. static MODEL_LEFT_FILENAME: string;
  48716. /**
  48717. * The name of the right controller model file
  48718. */
  48719. static MODEL_RIGHT_FILENAME: string;
  48720. /**
  48721. * The controller name prefix for this controller type
  48722. */
  48723. static readonly GAMEPAD_ID_PREFIX: string;
  48724. /**
  48725. * The controller id pattern for this controller type
  48726. */
  48727. private static readonly GAMEPAD_ID_PATTERN;
  48728. private _loadedMeshInfo;
  48729. protected readonly _mapping: {
  48730. buttons: string[];
  48731. buttonMeshNames: {
  48732. trigger: string;
  48733. menu: string;
  48734. grip: string;
  48735. thumbstick: string;
  48736. trackpad: string;
  48737. };
  48738. buttonObservableNames: {
  48739. trigger: string;
  48740. menu: string;
  48741. grip: string;
  48742. thumbstick: string;
  48743. trackpad: string;
  48744. };
  48745. axisMeshNames: string[];
  48746. pointingPoseMeshName: string;
  48747. };
  48748. /**
  48749. * Fired when the trackpad on this controller is clicked
  48750. */
  48751. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48752. /**
  48753. * Fired when the trackpad on this controller is modified
  48754. */
  48755. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48756. /**
  48757. * The current x and y values of this controller's trackpad
  48758. */
  48759. trackpad: StickValues;
  48760. /**
  48761. * Creates a new WindowsMotionController from a gamepad
  48762. * @param vrGamepad the gamepad that the controller should be created from
  48763. */
  48764. constructor(vrGamepad: any);
  48765. /**
  48766. * Fired when the trigger on this controller is modified
  48767. */
  48768. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48769. /**
  48770. * Fired when the menu button on this controller is modified
  48771. */
  48772. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48773. /**
  48774. * Fired when the grip button on this controller is modified
  48775. */
  48776. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48777. /**
  48778. * Fired when the thumbstick button on this controller is modified
  48779. */
  48780. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48781. /**
  48782. * Fired when the touchpad button on this controller is modified
  48783. */
  48784. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48785. /**
  48786. * Fired when the touchpad values on this controller are modified
  48787. */
  48788. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48789. protected _updateTrackpad(): void;
  48790. /**
  48791. * Called once per frame by the engine.
  48792. */
  48793. update(): void;
  48794. /**
  48795. * Called once for each button that changed state since the last frame
  48796. * @param buttonIdx Which button index changed
  48797. * @param state New state of the button
  48798. * @param changes Which properties on the state changed since last frame
  48799. */
  48800. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48801. /**
  48802. * Moves the buttons on the controller mesh based on their current state
  48803. * @param buttonName the name of the button to move
  48804. * @param buttonValue the value of the button which determines the buttons new position
  48805. */
  48806. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48807. /**
  48808. * Moves the axis on the controller mesh based on its current state
  48809. * @param axis the index of the axis
  48810. * @param axisValue the value of the axis which determines the meshes new position
  48811. * @hidden
  48812. */
  48813. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48814. /**
  48815. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48816. * @param scene scene in which to add meshes
  48817. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48818. */
  48819. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48820. /**
  48821. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48822. * can be transformed by button presses and axes values, based on this._mapping.
  48823. *
  48824. * @param scene scene in which the meshes exist
  48825. * @param meshes list of meshes that make up the controller model to process
  48826. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48827. */
  48828. private processModel;
  48829. private createMeshInfo;
  48830. /**
  48831. * Gets the ray of the controller in the direction the controller is pointing
  48832. * @param length the length the resulting ray should be
  48833. * @returns a ray in the direction the controller is pointing
  48834. */
  48835. getForwardRay(length?: number): Ray;
  48836. /**
  48837. * Disposes of the controller
  48838. */
  48839. dispose(): void;
  48840. }
  48841. /**
  48842. * This class represents a new windows motion controller in XR.
  48843. */
  48844. export class XRWindowsMotionController extends WindowsMotionController {
  48845. /**
  48846. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48847. */
  48848. protected readonly _mapping: {
  48849. buttons: string[];
  48850. buttonMeshNames: {
  48851. trigger: string;
  48852. menu: string;
  48853. grip: string;
  48854. thumbstick: string;
  48855. trackpad: string;
  48856. };
  48857. buttonObservableNames: {
  48858. trigger: string;
  48859. menu: string;
  48860. grip: string;
  48861. thumbstick: string;
  48862. trackpad: string;
  48863. };
  48864. axisMeshNames: string[];
  48865. pointingPoseMeshName: string;
  48866. };
  48867. /**
  48868. * Construct a new XR-Based windows motion controller
  48869. *
  48870. * @param gamepadInfo the gamepad object from the browser
  48871. */
  48872. constructor(gamepadInfo: any);
  48873. /**
  48874. * holds the thumbstick values (X,Y)
  48875. */
  48876. thumbstickValues: StickValues;
  48877. /**
  48878. * Fired when the thumbstick on this controller is clicked
  48879. */
  48880. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48881. /**
  48882. * Fired when the thumbstick on this controller is modified
  48883. */
  48884. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48885. /**
  48886. * Fired when the touchpad button on this controller is modified
  48887. */
  48888. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48889. /**
  48890. * Fired when the touchpad values on this controller are modified
  48891. */
  48892. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48893. /**
  48894. * Fired when the thumbstick button on this controller is modified
  48895. * here to prevent breaking changes
  48896. */
  48897. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48898. /**
  48899. * updating the thumbstick(!) and not the trackpad.
  48900. * This is named this way due to the difference between WebVR and XR and to avoid
  48901. * changing the parent class.
  48902. */
  48903. protected _updateTrackpad(): void;
  48904. /**
  48905. * Disposes the class with joy
  48906. */
  48907. dispose(): void;
  48908. }
  48909. }
  48910. declare module BABYLON {
  48911. /**
  48912. * Class containing static functions to help procedurally build meshes
  48913. */
  48914. export class PolyhedronBuilder {
  48915. /**
  48916. * Creates a polyhedron mesh
  48917. * * 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
  48918. * * The parameter `size` (positive float, default 1) sets the polygon size
  48919. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48920. * * 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`
  48921. * * 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
  48922. * * 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)`)
  48923. * * 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
  48924. * * 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
  48925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48926. * * 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
  48927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48928. * @param name defines the name of the mesh
  48929. * @param options defines the options used to create the mesh
  48930. * @param scene defines the hosting scene
  48931. * @returns the polyhedron mesh
  48932. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48933. */
  48934. static CreatePolyhedron(name: string, options: {
  48935. type?: number;
  48936. size?: number;
  48937. sizeX?: number;
  48938. sizeY?: number;
  48939. sizeZ?: number;
  48940. custom?: any;
  48941. faceUV?: Vector4[];
  48942. faceColors?: Color4[];
  48943. flat?: boolean;
  48944. updatable?: boolean;
  48945. sideOrientation?: number;
  48946. frontUVs?: Vector4;
  48947. backUVs?: Vector4;
  48948. }, scene?: Nullable<Scene>): Mesh;
  48949. }
  48950. }
  48951. declare module BABYLON {
  48952. /**
  48953. * Gizmo that enables scaling a mesh along 3 axis
  48954. */
  48955. export class ScaleGizmo extends Gizmo {
  48956. /**
  48957. * Internal gizmo used for interactions on the x axis
  48958. */
  48959. xGizmo: AxisScaleGizmo;
  48960. /**
  48961. * Internal gizmo used for interactions on the y axis
  48962. */
  48963. yGizmo: AxisScaleGizmo;
  48964. /**
  48965. * Internal gizmo used for interactions on the z axis
  48966. */
  48967. zGizmo: AxisScaleGizmo;
  48968. /**
  48969. * Internal gizmo used to scale all axis equally
  48970. */
  48971. uniformScaleGizmo: AxisScaleGizmo;
  48972. private _meshAttached;
  48973. private _updateGizmoRotationToMatchAttachedMesh;
  48974. private _snapDistance;
  48975. private _scaleRatio;
  48976. private _uniformScalingMesh;
  48977. private _octahedron;
  48978. private _sensitivity;
  48979. /** Fires an event when any of it's sub gizmos are dragged */
  48980. onDragStartObservable: Observable<unknown>;
  48981. /** Fires an event when any of it's sub gizmos are released from dragging */
  48982. onDragEndObservable: Observable<unknown>;
  48983. get attachedMesh(): Nullable<AbstractMesh>;
  48984. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48985. /**
  48986. * Creates a ScaleGizmo
  48987. * @param gizmoLayer The utility layer the gizmo will be added to
  48988. */
  48989. constructor(gizmoLayer?: UtilityLayerRenderer);
  48990. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48991. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48992. /**
  48993. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48994. */
  48995. set snapDistance(value: number);
  48996. get snapDistance(): number;
  48997. /**
  48998. * Ratio for the scale of the gizmo (Default: 1)
  48999. */
  49000. set scaleRatio(value: number);
  49001. get scaleRatio(): number;
  49002. /**
  49003. * Sensitivity factor for dragging (Default: 1)
  49004. */
  49005. set sensitivity(value: number);
  49006. get sensitivity(): number;
  49007. /**
  49008. * Disposes of the gizmo
  49009. */
  49010. dispose(): void;
  49011. }
  49012. }
  49013. declare module BABYLON {
  49014. /**
  49015. * Single axis scale gizmo
  49016. */
  49017. export class AxisScaleGizmo extends Gizmo {
  49018. /**
  49019. * Drag behavior responsible for the gizmos dragging interactions
  49020. */
  49021. dragBehavior: PointerDragBehavior;
  49022. private _pointerObserver;
  49023. /**
  49024. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49025. */
  49026. snapDistance: number;
  49027. /**
  49028. * Event that fires each time the gizmo snaps to a new location.
  49029. * * snapDistance is the the change in distance
  49030. */
  49031. onSnapObservable: Observable<{
  49032. snapDistance: number;
  49033. }>;
  49034. /**
  49035. * If the scaling operation should be done on all axis (default: false)
  49036. */
  49037. uniformScaling: boolean;
  49038. /**
  49039. * Custom sensitivity value for the drag strength
  49040. */
  49041. sensitivity: number;
  49042. private _isEnabled;
  49043. private _parent;
  49044. private _arrow;
  49045. private _coloredMaterial;
  49046. private _hoverMaterial;
  49047. /**
  49048. * Creates an AxisScaleGizmo
  49049. * @param gizmoLayer The utility layer the gizmo will be added to
  49050. * @param dragAxis The axis which the gizmo will be able to scale on
  49051. * @param color The color of the gizmo
  49052. */
  49053. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49054. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49055. /**
  49056. * If the gizmo is enabled
  49057. */
  49058. set isEnabled(value: boolean);
  49059. get isEnabled(): boolean;
  49060. /**
  49061. * Disposes of the gizmo
  49062. */
  49063. dispose(): void;
  49064. /**
  49065. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49066. * @param mesh The mesh to replace the default mesh of the gizmo
  49067. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49068. */
  49069. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49070. }
  49071. }
  49072. declare module BABYLON {
  49073. /**
  49074. * Bounding box gizmo
  49075. */
  49076. export class BoundingBoxGizmo extends Gizmo {
  49077. private _lineBoundingBox;
  49078. private _rotateSpheresParent;
  49079. private _scaleBoxesParent;
  49080. private _boundingDimensions;
  49081. private _renderObserver;
  49082. private _pointerObserver;
  49083. private _scaleDragSpeed;
  49084. private _tmpQuaternion;
  49085. private _tmpVector;
  49086. private _tmpRotationMatrix;
  49087. /**
  49088. * 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)
  49089. */
  49090. ignoreChildren: boolean;
  49091. /**
  49092. * 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)
  49093. */
  49094. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49095. /**
  49096. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49097. */
  49098. rotationSphereSize: number;
  49099. /**
  49100. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49101. */
  49102. scaleBoxSize: number;
  49103. /**
  49104. * 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)
  49105. */
  49106. fixedDragMeshScreenSize: boolean;
  49107. /**
  49108. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49109. */
  49110. fixedDragMeshScreenSizeDistanceFactor: number;
  49111. /**
  49112. * Fired when a rotation sphere or scale box is dragged
  49113. */
  49114. onDragStartObservable: Observable<{}>;
  49115. /**
  49116. * Fired when a scale box is dragged
  49117. */
  49118. onScaleBoxDragObservable: Observable<{}>;
  49119. /**
  49120. * Fired when a scale box drag is ended
  49121. */
  49122. onScaleBoxDragEndObservable: Observable<{}>;
  49123. /**
  49124. * Fired when a rotation sphere is dragged
  49125. */
  49126. onRotationSphereDragObservable: Observable<{}>;
  49127. /**
  49128. * Fired when a rotation sphere drag is ended
  49129. */
  49130. onRotationSphereDragEndObservable: Observable<{}>;
  49131. /**
  49132. * 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)
  49133. */
  49134. scalePivot: Nullable<Vector3>;
  49135. /**
  49136. * Mesh used as a pivot to rotate the attached mesh
  49137. */
  49138. private _anchorMesh;
  49139. private _existingMeshScale;
  49140. private _dragMesh;
  49141. private pointerDragBehavior;
  49142. private coloredMaterial;
  49143. private hoverColoredMaterial;
  49144. /**
  49145. * Sets the color of the bounding box gizmo
  49146. * @param color the color to set
  49147. */
  49148. setColor(color: Color3): void;
  49149. /**
  49150. * Creates an BoundingBoxGizmo
  49151. * @param gizmoLayer The utility layer the gizmo will be added to
  49152. * @param color The color of the gizmo
  49153. */
  49154. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49155. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49156. private _selectNode;
  49157. /**
  49158. * Updates the bounding box information for the Gizmo
  49159. */
  49160. updateBoundingBox(): void;
  49161. private _updateRotationSpheres;
  49162. private _updateScaleBoxes;
  49163. /**
  49164. * Enables rotation on the specified axis and disables rotation on the others
  49165. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49166. */
  49167. setEnabledRotationAxis(axis: string): void;
  49168. /**
  49169. * Enables/disables scaling
  49170. * @param enable if scaling should be enabled
  49171. * @param homogeneousScaling defines if scaling should only be homogeneous
  49172. */
  49173. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49174. private _updateDummy;
  49175. /**
  49176. * Enables a pointer drag behavior on the bounding box of the gizmo
  49177. */
  49178. enableDragBehavior(): void;
  49179. /**
  49180. * Disposes of the gizmo
  49181. */
  49182. dispose(): void;
  49183. /**
  49184. * 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)
  49185. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49186. * @returns the bounding box mesh with the passed in mesh as a child
  49187. */
  49188. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49189. /**
  49190. * CustomMeshes are not supported by this gizmo
  49191. * @param mesh The mesh to replace the default mesh of the gizmo
  49192. */
  49193. setCustomMesh(mesh: Mesh): void;
  49194. }
  49195. }
  49196. declare module BABYLON {
  49197. /**
  49198. * Single plane rotation gizmo
  49199. */
  49200. export class PlaneRotationGizmo extends Gizmo {
  49201. /**
  49202. * Drag behavior responsible for the gizmos dragging interactions
  49203. */
  49204. dragBehavior: PointerDragBehavior;
  49205. private _pointerObserver;
  49206. /**
  49207. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49208. */
  49209. snapDistance: number;
  49210. /**
  49211. * Event that fires each time the gizmo snaps to a new location.
  49212. * * snapDistance is the the change in distance
  49213. */
  49214. onSnapObservable: Observable<{
  49215. snapDistance: number;
  49216. }>;
  49217. private _isEnabled;
  49218. private _parent;
  49219. /**
  49220. * Creates a PlaneRotationGizmo
  49221. * @param gizmoLayer The utility layer the gizmo will be added to
  49222. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49223. * @param color The color of the gizmo
  49224. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49225. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49226. */
  49227. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49228. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49229. /**
  49230. * If the gizmo is enabled
  49231. */
  49232. set isEnabled(value: boolean);
  49233. get isEnabled(): boolean;
  49234. /**
  49235. * Disposes of the gizmo
  49236. */
  49237. dispose(): void;
  49238. }
  49239. }
  49240. declare module BABYLON {
  49241. /**
  49242. * Gizmo that enables rotating a mesh along 3 axis
  49243. */
  49244. export class RotationGizmo extends Gizmo {
  49245. /**
  49246. * Internal gizmo used for interactions on the x axis
  49247. */
  49248. xGizmo: PlaneRotationGizmo;
  49249. /**
  49250. * Internal gizmo used for interactions on the y axis
  49251. */
  49252. yGizmo: PlaneRotationGizmo;
  49253. /**
  49254. * Internal gizmo used for interactions on the z axis
  49255. */
  49256. zGizmo: PlaneRotationGizmo;
  49257. /** Fires an event when any of it's sub gizmos are dragged */
  49258. onDragStartObservable: Observable<unknown>;
  49259. /** Fires an event when any of it's sub gizmos are released from dragging */
  49260. onDragEndObservable: Observable<unknown>;
  49261. private _meshAttached;
  49262. get attachedMesh(): Nullable<AbstractMesh>;
  49263. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49264. /**
  49265. * Creates a RotationGizmo
  49266. * @param gizmoLayer The utility layer the gizmo will be added to
  49267. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49268. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49269. */
  49270. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49271. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49272. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49273. /**
  49274. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49275. */
  49276. set snapDistance(value: number);
  49277. get snapDistance(): number;
  49278. /**
  49279. * Ratio for the scale of the gizmo (Default: 1)
  49280. */
  49281. set scaleRatio(value: number);
  49282. get scaleRatio(): number;
  49283. /**
  49284. * Disposes of the gizmo
  49285. */
  49286. dispose(): void;
  49287. /**
  49288. * CustomMeshes are not supported by this gizmo
  49289. * @param mesh The mesh to replace the default mesh of the gizmo
  49290. */
  49291. setCustomMesh(mesh: Mesh): void;
  49292. }
  49293. }
  49294. declare module BABYLON {
  49295. /**
  49296. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49297. */
  49298. export class GizmoManager implements IDisposable {
  49299. private scene;
  49300. /**
  49301. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49302. */
  49303. gizmos: {
  49304. positionGizmo: Nullable<PositionGizmo>;
  49305. rotationGizmo: Nullable<RotationGizmo>;
  49306. scaleGizmo: Nullable<ScaleGizmo>;
  49307. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49308. };
  49309. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49310. clearGizmoOnEmptyPointerEvent: boolean;
  49311. /** Fires an event when the manager is attached to a mesh */
  49312. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49313. private _gizmosEnabled;
  49314. private _pointerObserver;
  49315. private _attachedMesh;
  49316. private _boundingBoxColor;
  49317. private _defaultUtilityLayer;
  49318. private _defaultKeepDepthUtilityLayer;
  49319. /**
  49320. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49321. */
  49322. boundingBoxDragBehavior: SixDofDragBehavior;
  49323. /**
  49324. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49325. */
  49326. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49327. /**
  49328. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49329. */
  49330. usePointerToAttachGizmos: boolean;
  49331. /**
  49332. * Utility layer that the bounding box gizmo belongs to
  49333. */
  49334. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49335. /**
  49336. * Utility layer that all gizmos besides bounding box belong to
  49337. */
  49338. get utilityLayer(): UtilityLayerRenderer;
  49339. /**
  49340. * Instatiates a gizmo manager
  49341. * @param scene the scene to overlay the gizmos on top of
  49342. */
  49343. constructor(scene: Scene);
  49344. /**
  49345. * Attaches a set of gizmos to the specified mesh
  49346. * @param mesh The mesh the gizmo's should be attached to
  49347. */
  49348. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49349. /**
  49350. * If the position gizmo is enabled
  49351. */
  49352. set positionGizmoEnabled(value: boolean);
  49353. get positionGizmoEnabled(): boolean;
  49354. /**
  49355. * If the rotation gizmo is enabled
  49356. */
  49357. set rotationGizmoEnabled(value: boolean);
  49358. get rotationGizmoEnabled(): boolean;
  49359. /**
  49360. * If the scale gizmo is enabled
  49361. */
  49362. set scaleGizmoEnabled(value: boolean);
  49363. get scaleGizmoEnabled(): boolean;
  49364. /**
  49365. * If the boundingBox gizmo is enabled
  49366. */
  49367. set boundingBoxGizmoEnabled(value: boolean);
  49368. get boundingBoxGizmoEnabled(): boolean;
  49369. /**
  49370. * Disposes of the gizmo manager
  49371. */
  49372. dispose(): void;
  49373. }
  49374. }
  49375. declare module BABYLON {
  49376. /**
  49377. * A directional light is defined by a direction (what a surprise!).
  49378. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49379. * 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.
  49380. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49381. */
  49382. export class DirectionalLight extends ShadowLight {
  49383. private _shadowFrustumSize;
  49384. /**
  49385. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49386. */
  49387. get shadowFrustumSize(): number;
  49388. /**
  49389. * Specifies a fix frustum size for the shadow generation.
  49390. */
  49391. set shadowFrustumSize(value: number);
  49392. private _shadowOrthoScale;
  49393. /**
  49394. * Gets 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. get shadowOrthoScale(): number;
  49399. /**
  49400. * Sets the shadow projection scale against the optimal computed one.
  49401. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49402. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49403. */
  49404. set shadowOrthoScale(value: number);
  49405. /**
  49406. * Automatically compute the projection matrix to best fit (including all the casters)
  49407. * on each frame.
  49408. */
  49409. autoUpdateExtends: boolean;
  49410. /**
  49411. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49412. * on each frame. autoUpdateExtends must be set to true for this to work
  49413. */
  49414. autoCalcShadowZBounds: boolean;
  49415. private _orthoLeft;
  49416. private _orthoRight;
  49417. private _orthoTop;
  49418. private _orthoBottom;
  49419. /**
  49420. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49421. * The directional light is emitted from everywhere in the given direction.
  49422. * It can cast shadows.
  49423. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49424. * @param name The friendly name of the light
  49425. * @param direction The direction of the light
  49426. * @param scene The scene the light belongs to
  49427. */
  49428. constructor(name: string, direction: Vector3, scene: Scene);
  49429. /**
  49430. * Returns the string "DirectionalLight".
  49431. * @return The class name
  49432. */
  49433. getClassName(): string;
  49434. /**
  49435. * Returns the integer 1.
  49436. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49437. */
  49438. getTypeID(): number;
  49439. /**
  49440. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49441. * Returns the DirectionalLight Shadow projection matrix.
  49442. */
  49443. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49444. /**
  49445. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49446. * Returns the DirectionalLight Shadow projection matrix.
  49447. */
  49448. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49449. /**
  49450. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49451. * Returns the DirectionalLight Shadow projection matrix.
  49452. */
  49453. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49454. protected _buildUniformLayout(): void;
  49455. /**
  49456. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49457. * @param effect The effect to update
  49458. * @param lightIndex The index of the light in the effect to update
  49459. * @returns The directional light
  49460. */
  49461. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49462. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49463. /**
  49464. * Gets the minZ used for shadow according to both the scene and the light.
  49465. *
  49466. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49467. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49468. * @param activeCamera The camera we are returning the min for
  49469. * @returns the depth min z
  49470. */
  49471. getDepthMinZ(activeCamera: Camera): number;
  49472. /**
  49473. * Gets the maxZ used for shadow according to both the scene and the light.
  49474. *
  49475. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49476. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49477. * @param activeCamera The camera we are returning the max for
  49478. * @returns the depth max z
  49479. */
  49480. getDepthMaxZ(activeCamera: Camera): number;
  49481. /**
  49482. * Prepares the list of defines specific to the light type.
  49483. * @param defines the list of defines
  49484. * @param lightIndex defines the index of the light for the effect
  49485. */
  49486. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49487. }
  49488. }
  49489. declare module BABYLON {
  49490. /**
  49491. * Class containing static functions to help procedurally build meshes
  49492. */
  49493. export class HemisphereBuilder {
  49494. /**
  49495. * Creates a hemisphere mesh
  49496. * @param name defines the name of the mesh
  49497. * @param options defines the options used to create the mesh
  49498. * @param scene defines the hosting scene
  49499. * @returns the hemisphere mesh
  49500. */
  49501. static CreateHemisphere(name: string, options: {
  49502. segments?: number;
  49503. diameter?: number;
  49504. sideOrientation?: number;
  49505. }, scene: any): Mesh;
  49506. }
  49507. }
  49508. declare module BABYLON {
  49509. /**
  49510. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49511. * These values define a cone of light starting from the position, emitting toward the direction.
  49512. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49513. * and the exponent defines the speed of the decay of the light with distance (reach).
  49514. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49515. */
  49516. export class SpotLight extends ShadowLight {
  49517. private _angle;
  49518. private _innerAngle;
  49519. private _cosHalfAngle;
  49520. private _lightAngleScale;
  49521. private _lightAngleOffset;
  49522. /**
  49523. * Gets the cone angle of the spot light in Radians.
  49524. */
  49525. get angle(): number;
  49526. /**
  49527. * Sets the cone angle of the spot light in Radians.
  49528. */
  49529. set angle(value: 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. get innerAngle(): number;
  49536. /**
  49537. * Only used in gltf falloff mode, this defines the angle where
  49538. * the directional falloff will start before cutting at angle which could be seen
  49539. * as outer angle.
  49540. */
  49541. set innerAngle(value: number);
  49542. private _shadowAngleScale;
  49543. /**
  49544. * Allows scaling the angle of the light for shadow generation only.
  49545. */
  49546. get shadowAngleScale(): number;
  49547. /**
  49548. * Allows scaling the angle of the light for shadow generation only.
  49549. */
  49550. set shadowAngleScale(value: number);
  49551. /**
  49552. * The light decay speed with the distance from the emission spot.
  49553. */
  49554. exponent: number;
  49555. private _projectionTextureMatrix;
  49556. /**
  49557. * Allows reading the projecton texture
  49558. */
  49559. get projectionTextureMatrix(): Matrix;
  49560. protected _projectionTextureLightNear: number;
  49561. /**
  49562. * Gets the near clip of the Spotlight for texture projection.
  49563. */
  49564. get projectionTextureLightNear(): number;
  49565. /**
  49566. * Sets the near clip of the Spotlight for texture projection.
  49567. */
  49568. set projectionTextureLightNear(value: number);
  49569. protected _projectionTextureLightFar: number;
  49570. /**
  49571. * Gets the far clip of the Spotlight for texture projection.
  49572. */
  49573. get projectionTextureLightFar(): number;
  49574. /**
  49575. * Sets the far clip of the Spotlight for texture projection.
  49576. */
  49577. set projectionTextureLightFar(value: number);
  49578. protected _projectionTextureUpDirection: Vector3;
  49579. /**
  49580. * Gets the Up vector of the Spotlight for texture projection.
  49581. */
  49582. get projectionTextureUpDirection(): Vector3;
  49583. /**
  49584. * Sets the Up vector of the Spotlight for texture projection.
  49585. */
  49586. set projectionTextureUpDirection(value: Vector3);
  49587. private _projectionTexture;
  49588. /**
  49589. * Gets the projection texture of the light.
  49590. */
  49591. get projectionTexture(): Nullable<BaseTexture>;
  49592. /**
  49593. * Sets the projection texture of the light.
  49594. */
  49595. set projectionTexture(value: Nullable<BaseTexture>);
  49596. private _projectionTextureViewLightDirty;
  49597. private _projectionTextureProjectionLightDirty;
  49598. private _projectionTextureDirty;
  49599. private _projectionTextureViewTargetVector;
  49600. private _projectionTextureViewLightMatrix;
  49601. private _projectionTextureProjectionLightMatrix;
  49602. private _projectionTextureScalingMatrix;
  49603. /**
  49604. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49605. * It can cast shadows.
  49606. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49607. * @param name The light friendly name
  49608. * @param position The position of the spot light in the scene
  49609. * @param direction The direction of the light in the scene
  49610. * @param angle The cone angle of the light in Radians
  49611. * @param exponent The light decay speed with the distance from the emission spot
  49612. * @param scene The scene the lights belongs to
  49613. */
  49614. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49615. /**
  49616. * Returns the string "SpotLight".
  49617. * @returns the class name
  49618. */
  49619. getClassName(): string;
  49620. /**
  49621. * Returns the integer 2.
  49622. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49623. */
  49624. getTypeID(): number;
  49625. /**
  49626. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49627. */
  49628. protected _setDirection(value: Vector3): void;
  49629. /**
  49630. * Overrides the position setter to recompute the projection texture view light Matrix.
  49631. */
  49632. protected _setPosition(value: Vector3): void;
  49633. /**
  49634. * 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.
  49635. * Returns the SpotLight.
  49636. */
  49637. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49638. protected _computeProjectionTextureViewLightMatrix(): void;
  49639. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49640. /**
  49641. * Main function for light texture projection matrix computing.
  49642. */
  49643. protected _computeProjectionTextureMatrix(): void;
  49644. protected _buildUniformLayout(): void;
  49645. private _computeAngleValues;
  49646. /**
  49647. * Sets the passed Effect "effect" with the Light textures.
  49648. * @param effect The effect to update
  49649. * @param lightIndex The index of the light in the effect to update
  49650. * @returns The light
  49651. */
  49652. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49653. /**
  49654. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49655. * @param effect The effect to update
  49656. * @param lightIndex The index of the light in the effect to update
  49657. * @returns The spot light
  49658. */
  49659. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49660. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49661. /**
  49662. * Disposes the light and the associated resources.
  49663. */
  49664. dispose(): void;
  49665. /**
  49666. * Prepares the list of defines specific to the light type.
  49667. * @param defines the list of defines
  49668. * @param lightIndex defines the index of the light for the effect
  49669. */
  49670. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49671. }
  49672. }
  49673. declare module BABYLON {
  49674. /**
  49675. * Gizmo that enables viewing a light
  49676. */
  49677. export class LightGizmo extends Gizmo {
  49678. private _lightMesh;
  49679. private _material;
  49680. private _cachedPosition;
  49681. private _cachedForward;
  49682. private _attachedMeshParent;
  49683. /**
  49684. * Creates a LightGizmo
  49685. * @param gizmoLayer The utility layer the gizmo will be added to
  49686. */
  49687. constructor(gizmoLayer?: UtilityLayerRenderer);
  49688. private _light;
  49689. /**
  49690. * The light that the gizmo is attached to
  49691. */
  49692. set light(light: Nullable<Light>);
  49693. get light(): Nullable<Light>;
  49694. /**
  49695. * Gets the material used to render the light gizmo
  49696. */
  49697. get material(): StandardMaterial;
  49698. /**
  49699. * @hidden
  49700. * Updates the gizmo to match the attached mesh's position/rotation
  49701. */
  49702. protected _update(): void;
  49703. private static _Scale;
  49704. /**
  49705. * Creates the lines for a light mesh
  49706. */
  49707. private static _CreateLightLines;
  49708. /**
  49709. * Disposes of the light gizmo
  49710. */
  49711. dispose(): void;
  49712. private static _CreateHemisphericLightMesh;
  49713. private static _CreatePointLightMesh;
  49714. private static _CreateSpotLightMesh;
  49715. private static _CreateDirectionalLightMesh;
  49716. }
  49717. }
  49718. declare module BABYLON {
  49719. /** @hidden */
  49720. export var backgroundFragmentDeclaration: {
  49721. name: string;
  49722. shader: string;
  49723. };
  49724. }
  49725. declare module BABYLON {
  49726. /** @hidden */
  49727. export var backgroundUboDeclaration: {
  49728. name: string;
  49729. shader: string;
  49730. };
  49731. }
  49732. declare module BABYLON {
  49733. /** @hidden */
  49734. export var backgroundPixelShader: {
  49735. name: string;
  49736. shader: string;
  49737. };
  49738. }
  49739. declare module BABYLON {
  49740. /** @hidden */
  49741. export var backgroundVertexDeclaration: {
  49742. name: string;
  49743. shader: string;
  49744. };
  49745. }
  49746. declare module BABYLON {
  49747. /** @hidden */
  49748. export var backgroundVertexShader: {
  49749. name: string;
  49750. shader: string;
  49751. };
  49752. }
  49753. declare module BABYLON {
  49754. /**
  49755. * Background material used to create an efficient environement around your scene.
  49756. */
  49757. export class BackgroundMaterial extends PushMaterial {
  49758. /**
  49759. * Standard reflectance value at parallel view angle.
  49760. */
  49761. static StandardReflectance0: number;
  49762. /**
  49763. * Standard reflectance value at grazing angle.
  49764. */
  49765. static StandardReflectance90: number;
  49766. protected _primaryColor: Color3;
  49767. /**
  49768. * Key light Color (multiply against the environement texture)
  49769. */
  49770. primaryColor: Color3;
  49771. protected __perceptualColor: Nullable<Color3>;
  49772. /**
  49773. * Experimental Internal Use Only.
  49774. *
  49775. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49776. * This acts as a helper to set the primary color to a more "human friendly" value.
  49777. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49778. * output color as close as possible from the chosen value.
  49779. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49780. * part of lighting setup.)
  49781. */
  49782. get _perceptualColor(): Nullable<Color3>;
  49783. set _perceptualColor(value: Nullable<Color3>);
  49784. protected _primaryColorShadowLevel: float;
  49785. /**
  49786. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49787. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49788. */
  49789. get primaryColorShadowLevel(): float;
  49790. set primaryColorShadowLevel(value: float);
  49791. protected _primaryColorHighlightLevel: float;
  49792. /**
  49793. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49794. * The primary color is used at the level chosen to define what the white area would look.
  49795. */
  49796. get primaryColorHighlightLevel(): float;
  49797. set primaryColorHighlightLevel(value: float);
  49798. protected _reflectionTexture: Nullable<BaseTexture>;
  49799. /**
  49800. * Reflection Texture used in the material.
  49801. * Should be author in a specific way for the best result (refer to the documentation).
  49802. */
  49803. reflectionTexture: Nullable<BaseTexture>;
  49804. protected _reflectionBlur: float;
  49805. /**
  49806. * Reflection Texture level of blur.
  49807. *
  49808. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49809. * texture twice.
  49810. */
  49811. reflectionBlur: float;
  49812. protected _diffuseTexture: Nullable<BaseTexture>;
  49813. /**
  49814. * Diffuse Texture used in the material.
  49815. * Should be author in a specific way for the best result (refer to the documentation).
  49816. */
  49817. diffuseTexture: Nullable<BaseTexture>;
  49818. protected _shadowLights: Nullable<IShadowLight[]>;
  49819. /**
  49820. * Specify the list of lights casting shadow on the material.
  49821. * All scene shadow lights will be included if null.
  49822. */
  49823. shadowLights: Nullable<IShadowLight[]>;
  49824. protected _shadowLevel: float;
  49825. /**
  49826. * Helps adjusting the shadow to a softer level if required.
  49827. * 0 means black shadows and 1 means no shadows.
  49828. */
  49829. shadowLevel: float;
  49830. protected _sceneCenter: Vector3;
  49831. /**
  49832. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49833. * It is usually zero but might be interesting to modify according to your setup.
  49834. */
  49835. sceneCenter: Vector3;
  49836. protected _opacityFresnel: boolean;
  49837. /**
  49838. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49839. * This helps ensuring a nice transition when the camera goes under the ground.
  49840. */
  49841. opacityFresnel: boolean;
  49842. protected _reflectionFresnel: boolean;
  49843. /**
  49844. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49845. * This helps adding a mirror texture on the ground.
  49846. */
  49847. reflectionFresnel: boolean;
  49848. protected _reflectionFalloffDistance: number;
  49849. /**
  49850. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49851. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49852. */
  49853. reflectionFalloffDistance: number;
  49854. protected _reflectionAmount: number;
  49855. /**
  49856. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49857. */
  49858. reflectionAmount: number;
  49859. protected _reflectionReflectance0: number;
  49860. /**
  49861. * This specifies the weight of the reflection at grazing angle.
  49862. */
  49863. reflectionReflectance0: number;
  49864. protected _reflectionReflectance90: number;
  49865. /**
  49866. * This specifies the weight of the reflection at a perpendicular point of view.
  49867. */
  49868. reflectionReflectance90: number;
  49869. /**
  49870. * Sets the reflection reflectance fresnel values according to the default standard
  49871. * empirically know to work well :-)
  49872. */
  49873. set reflectionStandardFresnelWeight(value: number);
  49874. protected _useRGBColor: boolean;
  49875. /**
  49876. * Helps to directly use the maps channels instead of their level.
  49877. */
  49878. useRGBColor: boolean;
  49879. protected _enableNoise: boolean;
  49880. /**
  49881. * This helps reducing the banding effect that could occur on the background.
  49882. */
  49883. enableNoise: boolean;
  49884. /**
  49885. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49886. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49887. * Recommended to be keep at 1.0 except for special cases.
  49888. */
  49889. get fovMultiplier(): number;
  49890. set fovMultiplier(value: number);
  49891. private _fovMultiplier;
  49892. /**
  49893. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49894. */
  49895. useEquirectangularFOV: boolean;
  49896. private _maxSimultaneousLights;
  49897. /**
  49898. * Number of Simultaneous lights allowed on the material.
  49899. */
  49900. maxSimultaneousLights: int;
  49901. /**
  49902. * Default configuration related to image processing available in the Background Material.
  49903. */
  49904. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49905. /**
  49906. * Keep track of the image processing observer to allow dispose and replace.
  49907. */
  49908. private _imageProcessingObserver;
  49909. /**
  49910. * Attaches a new image processing configuration to the PBR Material.
  49911. * @param configuration (if null the scene configuration will be use)
  49912. */
  49913. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49914. /**
  49915. * Gets the image processing configuration used either in this material.
  49916. */
  49917. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49918. /**
  49919. * Sets the Default image processing configuration used either in the this material.
  49920. *
  49921. * If sets to null, the scene one is in use.
  49922. */
  49923. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49924. /**
  49925. * Gets wether the color curves effect is enabled.
  49926. */
  49927. get cameraColorCurvesEnabled(): boolean;
  49928. /**
  49929. * Sets wether the color curves effect is enabled.
  49930. */
  49931. set cameraColorCurvesEnabled(value: boolean);
  49932. /**
  49933. * Gets wether the color grading effect is enabled.
  49934. */
  49935. get cameraColorGradingEnabled(): boolean;
  49936. /**
  49937. * Gets wether the color grading effect is enabled.
  49938. */
  49939. set cameraColorGradingEnabled(value: boolean);
  49940. /**
  49941. * Gets wether tonemapping is enabled or not.
  49942. */
  49943. get cameraToneMappingEnabled(): boolean;
  49944. /**
  49945. * Sets wether tonemapping is enabled or not
  49946. */
  49947. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): float;
  49954. /**
  49955. * The camera exposure used on this material.
  49956. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49957. * This corresponds to a photographic exposure.
  49958. */
  49959. set cameraExposure(value: float);
  49960. /**
  49961. * Gets The camera contrast used on this material.
  49962. */
  49963. get cameraContrast(): float;
  49964. /**
  49965. * Sets The camera contrast used on this material.
  49966. */
  49967. set cameraContrast(value: float);
  49968. /**
  49969. * Gets the Color Grading 2D Lookup Texture.
  49970. */
  49971. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49972. /**
  49973. * Sets the Color Grading 2D Lookup Texture.
  49974. */
  49975. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49976. /**
  49977. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49978. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49979. * 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;
  49980. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49981. */
  49982. get cameraColorCurves(): Nullable<ColorCurves>;
  49983. /**
  49984. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49985. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49986. * 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;
  49987. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49988. */
  49989. set cameraColorCurves(value: Nullable<ColorCurves>);
  49990. /**
  49991. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49992. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49993. */
  49994. switchToBGR: boolean;
  49995. private _renderTargets;
  49996. private _reflectionControls;
  49997. private _white;
  49998. private _primaryShadowColor;
  49999. private _primaryHighlightColor;
  50000. /**
  50001. * Instantiates a Background Material in the given scene
  50002. * @param name The friendly name of the material
  50003. * @param scene The scene to add the material to
  50004. */
  50005. constructor(name: string, scene: Scene);
  50006. /**
  50007. * Gets a boolean indicating that current material needs to register RTT
  50008. */
  50009. get hasRenderTargetTextures(): boolean;
  50010. /**
  50011. * The entire material has been created in order to prevent overdraw.
  50012. * @returns false
  50013. */
  50014. needAlphaTesting(): boolean;
  50015. /**
  50016. * The entire material has been created in order to prevent overdraw.
  50017. * @returns true if blending is enable
  50018. */
  50019. needAlphaBlending(): boolean;
  50020. /**
  50021. * Checks wether the material is ready to be rendered for a given mesh.
  50022. * @param mesh The mesh to render
  50023. * @param subMesh The submesh to check against
  50024. * @param useInstances Specify wether or not the material is used with instances
  50025. * @returns true if all the dependencies are ready (Textures, Effects...)
  50026. */
  50027. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50028. /**
  50029. * Compute the primary color according to the chosen perceptual color.
  50030. */
  50031. private _computePrimaryColorFromPerceptualColor;
  50032. /**
  50033. * Compute the highlights and shadow colors according to their chosen levels.
  50034. */
  50035. private _computePrimaryColors;
  50036. /**
  50037. * Build the uniform buffer used in the material.
  50038. */
  50039. buildUniformLayout(): void;
  50040. /**
  50041. * Unbind the material.
  50042. */
  50043. unbind(): void;
  50044. /**
  50045. * Bind only the world matrix to the material.
  50046. * @param world The world matrix to bind.
  50047. */
  50048. bindOnlyWorldMatrix(world: Matrix): void;
  50049. /**
  50050. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50051. * @param world The world matrix to bind.
  50052. * @param subMesh The submesh to bind for.
  50053. */
  50054. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50055. /**
  50056. * Checks to see if a texture is used in the material.
  50057. * @param texture - Base texture to use.
  50058. * @returns - Boolean specifying if a texture is used in the material.
  50059. */
  50060. hasTexture(texture: BaseTexture): boolean;
  50061. /**
  50062. * Dispose the material.
  50063. * @param forceDisposeEffect Force disposal of the associated effect.
  50064. * @param forceDisposeTextures Force disposal of the associated textures.
  50065. */
  50066. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50067. /**
  50068. * Clones the material.
  50069. * @param name The cloned name.
  50070. * @returns The cloned material.
  50071. */
  50072. clone(name: string): BackgroundMaterial;
  50073. /**
  50074. * Serializes the current material to its JSON representation.
  50075. * @returns The JSON representation.
  50076. */
  50077. serialize(): any;
  50078. /**
  50079. * Gets the class name of the material
  50080. * @returns "BackgroundMaterial"
  50081. */
  50082. getClassName(): string;
  50083. /**
  50084. * Parse a JSON input to create back a background material.
  50085. * @param source The JSON data to parse
  50086. * @param scene The scene to create the parsed material in
  50087. * @param rootUrl The root url of the assets the material depends upon
  50088. * @returns the instantiated BackgroundMaterial.
  50089. */
  50090. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50091. }
  50092. }
  50093. declare module BABYLON {
  50094. /**
  50095. * Represents the different options available during the creation of
  50096. * a Environment helper.
  50097. *
  50098. * This can control the default ground, skybox and image processing setup of your scene.
  50099. */
  50100. export interface IEnvironmentHelperOptions {
  50101. /**
  50102. * Specifies whether or not to create a ground.
  50103. * True by default.
  50104. */
  50105. createGround: boolean;
  50106. /**
  50107. * Specifies the ground size.
  50108. * 15 by default.
  50109. */
  50110. groundSize: number;
  50111. /**
  50112. * The texture used on the ground for the main color.
  50113. * Comes from the BabylonJS CDN by default.
  50114. *
  50115. * Remarks: Can be either a texture or a url.
  50116. */
  50117. groundTexture: string | BaseTexture;
  50118. /**
  50119. * The color mixed in the ground texture by default.
  50120. * BabylonJS clearColor by default.
  50121. */
  50122. groundColor: Color3;
  50123. /**
  50124. * Specifies the ground opacity.
  50125. * 1 by default.
  50126. */
  50127. groundOpacity: number;
  50128. /**
  50129. * Enables the ground to receive shadows.
  50130. * True by default.
  50131. */
  50132. enableGroundShadow: boolean;
  50133. /**
  50134. * Helps preventing the shadow to be fully black on the ground.
  50135. * 0.5 by default.
  50136. */
  50137. groundShadowLevel: number;
  50138. /**
  50139. * Creates a mirror texture attach to the ground.
  50140. * false by default.
  50141. */
  50142. enableGroundMirror: boolean;
  50143. /**
  50144. * Specifies the ground mirror size ratio.
  50145. * 0.3 by default as the default kernel is 64.
  50146. */
  50147. groundMirrorSizeRatio: number;
  50148. /**
  50149. * Specifies the ground mirror blur kernel size.
  50150. * 64 by default.
  50151. */
  50152. groundMirrorBlurKernel: number;
  50153. /**
  50154. * Specifies the ground mirror visibility amount.
  50155. * 1 by default
  50156. */
  50157. groundMirrorAmount: number;
  50158. /**
  50159. * Specifies the ground mirror reflectance weight.
  50160. * This uses the standard weight of the background material to setup the fresnel effect
  50161. * of the mirror.
  50162. * 1 by default.
  50163. */
  50164. groundMirrorFresnelWeight: number;
  50165. /**
  50166. * Specifies the ground mirror Falloff distance.
  50167. * This can helps reducing the size of the reflection.
  50168. * 0 by Default.
  50169. */
  50170. groundMirrorFallOffDistance: number;
  50171. /**
  50172. * Specifies the ground mirror texture type.
  50173. * Unsigned Int by Default.
  50174. */
  50175. groundMirrorTextureType: number;
  50176. /**
  50177. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50178. * the shown objects.
  50179. */
  50180. groundYBias: number;
  50181. /**
  50182. * Specifies whether or not to create a skybox.
  50183. * True by default.
  50184. */
  50185. createSkybox: boolean;
  50186. /**
  50187. * Specifies the skybox size.
  50188. * 20 by default.
  50189. */
  50190. skyboxSize: number;
  50191. /**
  50192. * The texture used on the skybox for the main color.
  50193. * Comes from the BabylonJS CDN by default.
  50194. *
  50195. * Remarks: Can be either a texture or a url.
  50196. */
  50197. skyboxTexture: string | BaseTexture;
  50198. /**
  50199. * The color mixed in the skybox texture by default.
  50200. * BabylonJS clearColor by default.
  50201. */
  50202. skyboxColor: Color3;
  50203. /**
  50204. * The background rotation around the Y axis of the scene.
  50205. * This helps aligning the key lights of your scene with the background.
  50206. * 0 by default.
  50207. */
  50208. backgroundYRotation: number;
  50209. /**
  50210. * Compute automatically the size of the elements to best fit with the scene.
  50211. */
  50212. sizeAuto: boolean;
  50213. /**
  50214. * Default position of the rootMesh if autoSize is not true.
  50215. */
  50216. rootPosition: Vector3;
  50217. /**
  50218. * Sets up the image processing in the scene.
  50219. * true by default.
  50220. */
  50221. setupImageProcessing: boolean;
  50222. /**
  50223. * The texture used as your environment texture in the scene.
  50224. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50225. *
  50226. * Remarks: Can be either a texture or a url.
  50227. */
  50228. environmentTexture: string | BaseTexture;
  50229. /**
  50230. * The value of the exposure to apply to the scene.
  50231. * 0.6 by default if setupImageProcessing is true.
  50232. */
  50233. cameraExposure: number;
  50234. /**
  50235. * The value of the contrast to apply to the scene.
  50236. * 1.6 by default if setupImageProcessing is true.
  50237. */
  50238. cameraContrast: number;
  50239. /**
  50240. * Specifies whether or not tonemapping should be enabled in the scene.
  50241. * true by default if setupImageProcessing is true.
  50242. */
  50243. toneMappingEnabled: boolean;
  50244. }
  50245. /**
  50246. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50247. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50248. * It also helps with the default setup of your imageProcessing configuration.
  50249. */
  50250. export class EnvironmentHelper {
  50251. /**
  50252. * Default ground texture URL.
  50253. */
  50254. private static _groundTextureCDNUrl;
  50255. /**
  50256. * Default skybox texture URL.
  50257. */
  50258. private static _skyboxTextureCDNUrl;
  50259. /**
  50260. * Default environment texture URL.
  50261. */
  50262. private static _environmentTextureCDNUrl;
  50263. /**
  50264. * Creates the default options for the helper.
  50265. */
  50266. private static _getDefaultOptions;
  50267. private _rootMesh;
  50268. /**
  50269. * Gets the root mesh created by the helper.
  50270. */
  50271. get rootMesh(): Mesh;
  50272. private _skybox;
  50273. /**
  50274. * Gets the skybox created by the helper.
  50275. */
  50276. get skybox(): Nullable<Mesh>;
  50277. private _skyboxTexture;
  50278. /**
  50279. * Gets the skybox texture created by the helper.
  50280. */
  50281. get skyboxTexture(): Nullable<BaseTexture>;
  50282. private _skyboxMaterial;
  50283. /**
  50284. * Gets the skybox material created by the helper.
  50285. */
  50286. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50287. private _ground;
  50288. /**
  50289. * Gets the ground mesh created by the helper.
  50290. */
  50291. get ground(): Nullable<Mesh>;
  50292. private _groundTexture;
  50293. /**
  50294. * Gets the ground texture created by the helper.
  50295. */
  50296. get groundTexture(): Nullable<BaseTexture>;
  50297. private _groundMirror;
  50298. /**
  50299. * Gets the ground mirror created by the helper.
  50300. */
  50301. get groundMirror(): Nullable<MirrorTexture>;
  50302. /**
  50303. * Gets the ground mirror render list to helps pushing the meshes
  50304. * you wish in the ground reflection.
  50305. */
  50306. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50307. private _groundMaterial;
  50308. /**
  50309. * Gets the ground material created by the helper.
  50310. */
  50311. get groundMaterial(): Nullable<BackgroundMaterial>;
  50312. /**
  50313. * Stores the creation options.
  50314. */
  50315. private readonly _scene;
  50316. private _options;
  50317. /**
  50318. * This observable will be notified with any error during the creation of the environment,
  50319. * mainly texture creation errors.
  50320. */
  50321. onErrorObservable: Observable<{
  50322. message?: string;
  50323. exception?: any;
  50324. }>;
  50325. /**
  50326. * constructor
  50327. * @param options Defines the options we want to customize the helper
  50328. * @param scene The scene to add the material to
  50329. */
  50330. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50331. /**
  50332. * Updates the background according to the new options
  50333. * @param options
  50334. */
  50335. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50336. /**
  50337. * Sets the primary color of all the available elements.
  50338. * @param color the main color to affect to the ground and the background
  50339. */
  50340. setMainColor(color: Color3): void;
  50341. /**
  50342. * Setup the image processing according to the specified options.
  50343. */
  50344. private _setupImageProcessing;
  50345. /**
  50346. * Setup the environment texture according to the specified options.
  50347. */
  50348. private _setupEnvironmentTexture;
  50349. /**
  50350. * Setup the background according to the specified options.
  50351. */
  50352. private _setupBackground;
  50353. /**
  50354. * Get the scene sizes according to the setup.
  50355. */
  50356. private _getSceneSize;
  50357. /**
  50358. * Setup the ground according to the specified options.
  50359. */
  50360. private _setupGround;
  50361. /**
  50362. * Setup the ground material according to the specified options.
  50363. */
  50364. private _setupGroundMaterial;
  50365. /**
  50366. * Setup the ground diffuse texture according to the specified options.
  50367. */
  50368. private _setupGroundDiffuseTexture;
  50369. /**
  50370. * Setup the ground mirror texture according to the specified options.
  50371. */
  50372. private _setupGroundMirrorTexture;
  50373. /**
  50374. * Setup the ground to receive the mirror texture.
  50375. */
  50376. private _setupMirrorInGroundMaterial;
  50377. /**
  50378. * Setup the skybox according to the specified options.
  50379. */
  50380. private _setupSkybox;
  50381. /**
  50382. * Setup the skybox material according to the specified options.
  50383. */
  50384. private _setupSkyboxMaterial;
  50385. /**
  50386. * Setup the skybox reflection texture according to the specified options.
  50387. */
  50388. private _setupSkyboxReflectionTexture;
  50389. private _errorHandler;
  50390. /**
  50391. * Dispose all the elements created by the Helper.
  50392. */
  50393. dispose(): void;
  50394. }
  50395. }
  50396. declare module BABYLON {
  50397. /**
  50398. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50399. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50400. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50401. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50402. */
  50403. export class PhotoDome extends TransformNode {
  50404. /**
  50405. * Define the image as a Monoscopic panoramic 360 image.
  50406. */
  50407. static readonly MODE_MONOSCOPIC: number;
  50408. /**
  50409. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50410. */
  50411. static readonly MODE_TOPBOTTOM: number;
  50412. /**
  50413. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50414. */
  50415. static readonly MODE_SIDEBYSIDE: number;
  50416. private _useDirectMapping;
  50417. /**
  50418. * The texture being displayed on the sphere
  50419. */
  50420. protected _photoTexture: Texture;
  50421. /**
  50422. * Gets or sets the texture being displayed on the sphere
  50423. */
  50424. get photoTexture(): Texture;
  50425. set photoTexture(value: Texture);
  50426. /**
  50427. * Observable raised when an error occured while loading the 360 image
  50428. */
  50429. onLoadErrorObservable: Observable<string>;
  50430. /**
  50431. * The skybox material
  50432. */
  50433. protected _material: BackgroundMaterial;
  50434. /**
  50435. * The surface used for the skybox
  50436. */
  50437. protected _mesh: Mesh;
  50438. /**
  50439. * Gets the mesh used for the skybox.
  50440. */
  50441. get mesh(): Mesh;
  50442. /**
  50443. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50444. * Also see the options.resolution property.
  50445. */
  50446. get fovMultiplier(): number;
  50447. set fovMultiplier(value: number);
  50448. private _imageMode;
  50449. /**
  50450. * Gets or set the current video mode for the video. It can be:
  50451. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50452. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50453. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50454. */
  50455. get imageMode(): number;
  50456. set imageMode(value: number);
  50457. /**
  50458. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50459. * @param name Element's name, child elements will append suffixes for their own names.
  50460. * @param urlsOfPhoto defines the url of the photo to display
  50461. * @param options defines an object containing optional or exposed sub element properties
  50462. * @param onError defines a callback called when an error occured while loading the texture
  50463. */
  50464. constructor(name: string, urlOfPhoto: string, options: {
  50465. resolution?: number;
  50466. size?: number;
  50467. useDirectMapping?: boolean;
  50468. faceForward?: boolean;
  50469. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50470. private _onBeforeCameraRenderObserver;
  50471. private _changeImageMode;
  50472. /**
  50473. * Releases resources associated with this node.
  50474. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50475. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50476. */
  50477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50478. }
  50479. }
  50480. declare module BABYLON {
  50481. /**
  50482. * Class used to host RGBD texture specific utilities
  50483. */
  50484. export class RGBDTextureTools {
  50485. /**
  50486. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50487. * @param texture the texture to expand.
  50488. */
  50489. static ExpandRGBDTexture(texture: Texture): void;
  50490. }
  50491. }
  50492. declare module BABYLON {
  50493. /**
  50494. * Class used to host texture specific utilities
  50495. */
  50496. export class BRDFTextureTools {
  50497. /**
  50498. * Prevents texture cache collision
  50499. */
  50500. private static _instanceNumber;
  50501. /**
  50502. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50503. * @param scene defines the hosting scene
  50504. * @returns the environment BRDF texture
  50505. */
  50506. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50507. private static _environmentBRDFBase64Texture;
  50508. }
  50509. }
  50510. declare module BABYLON {
  50511. /**
  50512. * @hidden
  50513. */
  50514. export interface IMaterialClearCoatDefines {
  50515. CLEARCOAT: boolean;
  50516. CLEARCOAT_DEFAULTIOR: boolean;
  50517. CLEARCOAT_TEXTURE: boolean;
  50518. CLEARCOAT_TEXTUREDIRECTUV: number;
  50519. CLEARCOAT_BUMP: boolean;
  50520. CLEARCOAT_BUMPDIRECTUV: number;
  50521. CLEARCOAT_TINT: boolean;
  50522. CLEARCOAT_TINT_TEXTURE: boolean;
  50523. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50524. /** @hidden */
  50525. _areTexturesDirty: boolean;
  50526. }
  50527. /**
  50528. * Define the code related to the clear coat parameters of the pbr material.
  50529. */
  50530. export class PBRClearCoatConfiguration {
  50531. /**
  50532. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50533. * The default fits with a polyurethane material.
  50534. */
  50535. private static readonly _DefaultIndexOfRefraction;
  50536. private _isEnabled;
  50537. /**
  50538. * Defines if the clear coat is enabled in the material.
  50539. */
  50540. isEnabled: boolean;
  50541. /**
  50542. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50543. */
  50544. intensity: number;
  50545. /**
  50546. * Defines the clear coat layer roughness.
  50547. */
  50548. roughness: number;
  50549. private _indexOfRefraction;
  50550. /**
  50551. * Defines the index of refraction of the clear coat.
  50552. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50553. * The default fits with a polyurethane material.
  50554. * Changing the default value is more performance intensive.
  50555. */
  50556. indexOfRefraction: number;
  50557. private _texture;
  50558. /**
  50559. * Stores the clear coat values in a texture.
  50560. */
  50561. texture: Nullable<BaseTexture>;
  50562. private _bumpTexture;
  50563. /**
  50564. * Define the clear coat specific bump texture.
  50565. */
  50566. bumpTexture: Nullable<BaseTexture>;
  50567. private _isTintEnabled;
  50568. /**
  50569. * Defines if the clear coat tint is enabled in the material.
  50570. */
  50571. isTintEnabled: boolean;
  50572. /**
  50573. * Defines the clear coat tint of the material.
  50574. * This is only use if tint is enabled
  50575. */
  50576. tintColor: Color3;
  50577. /**
  50578. * Defines the distance at which the tint color should be found in the
  50579. * clear coat media.
  50580. * This is only use if tint is enabled
  50581. */
  50582. tintColorAtDistance: number;
  50583. /**
  50584. * Defines the clear coat layer thickness.
  50585. * This is only use if tint is enabled
  50586. */
  50587. tintThickness: number;
  50588. private _tintTexture;
  50589. /**
  50590. * Stores the clear tint values in a texture.
  50591. * rgb is tint
  50592. * a is a thickness factor
  50593. */
  50594. tintTexture: Nullable<BaseTexture>;
  50595. /** @hidden */
  50596. private _internalMarkAllSubMeshesAsTexturesDirty;
  50597. /** @hidden */
  50598. _markAllSubMeshesAsTexturesDirty(): void;
  50599. /**
  50600. * Instantiate a new istance of clear coat configuration.
  50601. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50602. */
  50603. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50604. /**
  50605. * Gets wehter the submesh is ready to be used or not.
  50606. * @param defines the list of "defines" to update.
  50607. * @param scene defines the scene the material belongs to.
  50608. * @param engine defines the engine the material belongs to.
  50609. * @param disableBumpMap defines wether the material disables bump or not.
  50610. * @returns - boolean indicating that the submesh is ready or not.
  50611. */
  50612. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50613. /**
  50614. * Checks to see if a texture is used in the material.
  50615. * @param defines the list of "defines" to update.
  50616. * @param scene defines the scene to the material belongs to.
  50617. */
  50618. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50619. /**
  50620. * Binds the material data.
  50621. * @param uniformBuffer defines the Uniform buffer to fill in.
  50622. * @param scene defines the scene the material belongs to.
  50623. * @param engine defines the engine the material belongs to.
  50624. * @param disableBumpMap defines wether the material disables bump or not.
  50625. * @param isFrozen defines wether the material is frozen or not.
  50626. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50627. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50628. */
  50629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50630. /**
  50631. * Checks to see if a texture is used in the material.
  50632. * @param texture - Base texture to use.
  50633. * @returns - Boolean specifying if a texture is used in the material.
  50634. */
  50635. hasTexture(texture: BaseTexture): boolean;
  50636. /**
  50637. * Returns an array of the actively used textures.
  50638. * @param activeTextures Array of BaseTextures
  50639. */
  50640. getActiveTextures(activeTextures: BaseTexture[]): void;
  50641. /**
  50642. * Returns the animatable textures.
  50643. * @param animatables Array of animatable textures.
  50644. */
  50645. getAnimatables(animatables: IAnimatable[]): void;
  50646. /**
  50647. * Disposes the resources of the material.
  50648. * @param forceDisposeTextures - Forces the disposal of all textures.
  50649. */
  50650. dispose(forceDisposeTextures?: boolean): void;
  50651. /**
  50652. * Get the current class name of the texture useful for serialization or dynamic coding.
  50653. * @returns "PBRClearCoatConfiguration"
  50654. */
  50655. getClassName(): string;
  50656. /**
  50657. * Add fallbacks to the effect fallbacks list.
  50658. * @param defines defines the Base texture to use.
  50659. * @param fallbacks defines the current fallback list.
  50660. * @param currentRank defines the current fallback rank.
  50661. * @returns the new fallback rank.
  50662. */
  50663. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50664. /**
  50665. * Add the required uniforms to the current list.
  50666. * @param uniforms defines the current uniform list.
  50667. */
  50668. static AddUniforms(uniforms: string[]): void;
  50669. /**
  50670. * Add the required samplers to the current list.
  50671. * @param samplers defines the current sampler list.
  50672. */
  50673. static AddSamplers(samplers: string[]): void;
  50674. /**
  50675. * Add the required uniforms to the current buffer.
  50676. * @param uniformBuffer defines the current uniform buffer.
  50677. */
  50678. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50679. /**
  50680. * Makes a duplicate of the current configuration into another one.
  50681. * @param clearCoatConfiguration define the config where to copy the info
  50682. */
  50683. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50684. /**
  50685. * Serializes this clear coat configuration.
  50686. * @returns - An object with the serialized config.
  50687. */
  50688. serialize(): any;
  50689. /**
  50690. * Parses a anisotropy Configuration from a serialized object.
  50691. * @param source - Serialized object.
  50692. * @param scene Defines the scene we are parsing for
  50693. * @param rootUrl Defines the rootUrl to load from
  50694. */
  50695. parse(source: any, scene: Scene, rootUrl: string): void;
  50696. }
  50697. }
  50698. declare module BABYLON {
  50699. /**
  50700. * @hidden
  50701. */
  50702. export interface IMaterialAnisotropicDefines {
  50703. ANISOTROPIC: boolean;
  50704. ANISOTROPIC_TEXTURE: boolean;
  50705. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50706. MAINUV1: boolean;
  50707. _areTexturesDirty: boolean;
  50708. _needUVs: boolean;
  50709. }
  50710. /**
  50711. * Define the code related to the anisotropic parameters of the pbr material.
  50712. */
  50713. export class PBRAnisotropicConfiguration {
  50714. private _isEnabled;
  50715. /**
  50716. * Defines if the anisotropy is enabled in the material.
  50717. */
  50718. isEnabled: boolean;
  50719. /**
  50720. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50721. */
  50722. intensity: number;
  50723. /**
  50724. * Defines if the effect is along the tangents, bitangents or in between.
  50725. * By default, the effect is "strectching" the highlights along the tangents.
  50726. */
  50727. direction: Vector2;
  50728. private _texture;
  50729. /**
  50730. * Stores the anisotropy values in a texture.
  50731. * rg is direction (like normal from -1 to 1)
  50732. * b is a intensity
  50733. */
  50734. texture: Nullable<BaseTexture>;
  50735. /** @hidden */
  50736. private _internalMarkAllSubMeshesAsTexturesDirty;
  50737. /** @hidden */
  50738. _markAllSubMeshesAsTexturesDirty(): void;
  50739. /**
  50740. * Instantiate a new istance of anisotropy configuration.
  50741. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50742. */
  50743. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50744. /**
  50745. * Specifies that the submesh is ready to be used.
  50746. * @param defines the list of "defines" to update.
  50747. * @param scene defines the scene the material belongs to.
  50748. * @returns - boolean indicating that the submesh is ready or not.
  50749. */
  50750. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50751. /**
  50752. * Checks to see if a texture is used in the material.
  50753. * @param defines the list of "defines" to update.
  50754. * @param mesh the mesh we are preparing the defines for.
  50755. * @param scene defines the scene the material belongs to.
  50756. */
  50757. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50758. /**
  50759. * Binds the material data.
  50760. * @param uniformBuffer defines the Uniform buffer to fill in.
  50761. * @param scene defines the scene the material belongs to.
  50762. * @param isFrozen defines wether the material is frozen or not.
  50763. */
  50764. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50765. /**
  50766. * Checks to see if a texture is used in the material.
  50767. * @param texture - Base texture to use.
  50768. * @returns - Boolean specifying if a texture is used in the material.
  50769. */
  50770. hasTexture(texture: BaseTexture): boolean;
  50771. /**
  50772. * Returns an array of the actively used textures.
  50773. * @param activeTextures Array of BaseTextures
  50774. */
  50775. getActiveTextures(activeTextures: BaseTexture[]): void;
  50776. /**
  50777. * Returns the animatable textures.
  50778. * @param animatables Array of animatable textures.
  50779. */
  50780. getAnimatables(animatables: IAnimatable[]): void;
  50781. /**
  50782. * Disposes the resources of the material.
  50783. * @param forceDisposeTextures - Forces the disposal of all textures.
  50784. */
  50785. dispose(forceDisposeTextures?: boolean): void;
  50786. /**
  50787. * Get the current class name of the texture useful for serialization or dynamic coding.
  50788. * @returns "PBRAnisotropicConfiguration"
  50789. */
  50790. getClassName(): string;
  50791. /**
  50792. * Add fallbacks to the effect fallbacks list.
  50793. * @param defines defines the Base texture to use.
  50794. * @param fallbacks defines the current fallback list.
  50795. * @param currentRank defines the current fallback rank.
  50796. * @returns the new fallback rank.
  50797. */
  50798. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50799. /**
  50800. * Add the required uniforms to the current list.
  50801. * @param uniforms defines the current uniform list.
  50802. */
  50803. static AddUniforms(uniforms: string[]): void;
  50804. /**
  50805. * Add the required uniforms to the current buffer.
  50806. * @param uniformBuffer defines the current uniform buffer.
  50807. */
  50808. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50809. /**
  50810. * Add the required samplers to the current list.
  50811. * @param samplers defines the current sampler list.
  50812. */
  50813. static AddSamplers(samplers: string[]): void;
  50814. /**
  50815. * Makes a duplicate of the current configuration into another one.
  50816. * @param anisotropicConfiguration define the config where to copy the info
  50817. */
  50818. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50819. /**
  50820. * Serializes this anisotropy configuration.
  50821. * @returns - An object with the serialized config.
  50822. */
  50823. serialize(): any;
  50824. /**
  50825. * Parses a anisotropy Configuration from a serialized object.
  50826. * @param source - Serialized object.
  50827. * @param scene Defines the scene we are parsing for
  50828. * @param rootUrl Defines the rootUrl to load from
  50829. */
  50830. parse(source: any, scene: Scene, rootUrl: string): void;
  50831. }
  50832. }
  50833. declare module BABYLON {
  50834. /**
  50835. * @hidden
  50836. */
  50837. export interface IMaterialBRDFDefines {
  50838. BRDF_V_HEIGHT_CORRELATED: boolean;
  50839. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50840. SPHERICAL_HARMONICS: boolean;
  50841. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50842. /** @hidden */
  50843. _areMiscDirty: boolean;
  50844. }
  50845. /**
  50846. * Define the code related to the BRDF parameters of the pbr material.
  50847. */
  50848. export class PBRBRDFConfiguration {
  50849. /**
  50850. * Default value used for the energy conservation.
  50851. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50852. */
  50853. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50854. /**
  50855. * Default value used for the Smith Visibility Height Correlated mode.
  50856. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50857. */
  50858. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50859. /**
  50860. * Default value used for the IBL diffuse part.
  50861. * This can help switching back to the polynomials mode globally which is a tiny bit
  50862. * less GPU intensive at the drawback of a lower quality.
  50863. */
  50864. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50865. /**
  50866. * Default value used for activating energy conservation for the specular workflow.
  50867. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50868. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50869. */
  50870. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50871. private _useEnergyConservation;
  50872. /**
  50873. * Defines if the material uses energy conservation.
  50874. */
  50875. useEnergyConservation: boolean;
  50876. private _useSmithVisibilityHeightCorrelated;
  50877. /**
  50878. * LEGACY Mode set to false
  50879. * Defines if the material uses height smith correlated visibility term.
  50880. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50881. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50882. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50883. * Not relying on height correlated will also disable energy conservation.
  50884. */
  50885. useSmithVisibilityHeightCorrelated: boolean;
  50886. private _useSphericalHarmonics;
  50887. /**
  50888. * LEGACY Mode set to false
  50889. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50890. * diffuse part of the IBL.
  50891. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50892. * to the ground truth.
  50893. */
  50894. useSphericalHarmonics: boolean;
  50895. private _useSpecularGlossinessInputEnergyConservation;
  50896. /**
  50897. * Defines if the material uses energy conservation, when the specular workflow is active.
  50898. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50899. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50900. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50901. */
  50902. useSpecularGlossinessInputEnergyConservation: boolean;
  50903. /** @hidden */
  50904. private _internalMarkAllSubMeshesAsMiscDirty;
  50905. /** @hidden */
  50906. _markAllSubMeshesAsMiscDirty(): void;
  50907. /**
  50908. * Instantiate a new istance of clear coat configuration.
  50909. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50910. */
  50911. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50912. /**
  50913. * Checks to see if a texture is used in the material.
  50914. * @param defines the list of "defines" to update.
  50915. */
  50916. prepareDefines(defines: IMaterialBRDFDefines): void;
  50917. /**
  50918. * Get the current class name of the texture useful for serialization or dynamic coding.
  50919. * @returns "PBRClearCoatConfiguration"
  50920. */
  50921. getClassName(): string;
  50922. /**
  50923. * Makes a duplicate of the current configuration into another one.
  50924. * @param brdfConfiguration define the config where to copy the info
  50925. */
  50926. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50927. /**
  50928. * Serializes this BRDF configuration.
  50929. * @returns - An object with the serialized config.
  50930. */
  50931. serialize(): any;
  50932. /**
  50933. * Parses a anisotropy Configuration from a serialized object.
  50934. * @param source - Serialized object.
  50935. * @param scene Defines the scene we are parsing for
  50936. * @param rootUrl Defines the rootUrl to load from
  50937. */
  50938. parse(source: any, scene: Scene, rootUrl: string): void;
  50939. }
  50940. }
  50941. declare module BABYLON {
  50942. /**
  50943. * @hidden
  50944. */
  50945. export interface IMaterialSheenDefines {
  50946. SHEEN: boolean;
  50947. SHEEN_TEXTURE: boolean;
  50948. SHEEN_TEXTUREDIRECTUV: number;
  50949. SHEEN_LINKWITHALBEDO: boolean;
  50950. SHEEN_ROUGHNESS: boolean;
  50951. SHEEN_ALBEDOSCALING: boolean;
  50952. /** @hidden */
  50953. _areTexturesDirty: boolean;
  50954. }
  50955. /**
  50956. * Define the code related to the Sheen parameters of the pbr material.
  50957. */
  50958. export class PBRSheenConfiguration {
  50959. private _isEnabled;
  50960. /**
  50961. * Defines if the material uses sheen.
  50962. */
  50963. isEnabled: boolean;
  50964. private _linkSheenWithAlbedo;
  50965. /**
  50966. * Defines if the sheen is linked to the sheen color.
  50967. */
  50968. linkSheenWithAlbedo: boolean;
  50969. /**
  50970. * Defines the sheen intensity.
  50971. */
  50972. intensity: number;
  50973. /**
  50974. * Defines the sheen color.
  50975. */
  50976. color: Color3;
  50977. private _texture;
  50978. /**
  50979. * Stores the sheen tint values in a texture.
  50980. * rgb is tint
  50981. * a is a intensity
  50982. */
  50983. texture: Nullable<BaseTexture>;
  50984. private _roughness;
  50985. /**
  50986. * Defines the sheen roughness.
  50987. * It is not taken into account if linkSheenWithAlbedo is true.
  50988. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50989. */
  50990. roughness: Nullable<number>;
  50991. private _albedoScaling;
  50992. /**
  50993. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50994. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50995. * making it easier to setup and tweak the effect
  50996. */
  50997. albedoScaling: boolean;
  50998. /** @hidden */
  50999. private _internalMarkAllSubMeshesAsTexturesDirty;
  51000. /** @hidden */
  51001. _markAllSubMeshesAsTexturesDirty(): void;
  51002. /**
  51003. * Instantiate a new istance of clear coat configuration.
  51004. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51005. */
  51006. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51007. /**
  51008. * Specifies that the submesh is ready to be used.
  51009. * @param defines the list of "defines" to update.
  51010. * @param scene defines the scene the material belongs to.
  51011. * @returns - boolean indicating that the submesh is ready or not.
  51012. */
  51013. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51014. /**
  51015. * Checks to see if a texture is used in the material.
  51016. * @param defines the list of "defines" to update.
  51017. * @param scene defines the scene the material belongs to.
  51018. */
  51019. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51020. /**
  51021. * Binds the material data.
  51022. * @param uniformBuffer defines the Uniform buffer to fill in.
  51023. * @param scene defines the scene the material belongs to.
  51024. * @param isFrozen defines wether the material is frozen or not.
  51025. */
  51026. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51027. /**
  51028. * Checks to see if a texture is used in the material.
  51029. * @param texture - Base texture to use.
  51030. * @returns - Boolean specifying if a texture is used in the material.
  51031. */
  51032. hasTexture(texture: BaseTexture): boolean;
  51033. /**
  51034. * Returns an array of the actively used textures.
  51035. * @param activeTextures Array of BaseTextures
  51036. */
  51037. getActiveTextures(activeTextures: BaseTexture[]): void;
  51038. /**
  51039. * Returns the animatable textures.
  51040. * @param animatables Array of animatable textures.
  51041. */
  51042. getAnimatables(animatables: IAnimatable[]): void;
  51043. /**
  51044. * Disposes the resources of the material.
  51045. * @param forceDisposeTextures - Forces the disposal of all textures.
  51046. */
  51047. dispose(forceDisposeTextures?: boolean): void;
  51048. /**
  51049. * Get the current class name of the texture useful for serialization or dynamic coding.
  51050. * @returns "PBRSheenConfiguration"
  51051. */
  51052. getClassName(): string;
  51053. /**
  51054. * Add fallbacks to the effect fallbacks list.
  51055. * @param defines defines the Base texture to use.
  51056. * @param fallbacks defines the current fallback list.
  51057. * @param currentRank defines the current fallback rank.
  51058. * @returns the new fallback rank.
  51059. */
  51060. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51061. /**
  51062. * Add the required uniforms to the current list.
  51063. * @param uniforms defines the current uniform list.
  51064. */
  51065. static AddUniforms(uniforms: string[]): void;
  51066. /**
  51067. * Add the required uniforms to the current buffer.
  51068. * @param uniformBuffer defines the current uniform buffer.
  51069. */
  51070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51071. /**
  51072. * Add the required samplers to the current list.
  51073. * @param samplers defines the current sampler list.
  51074. */
  51075. static AddSamplers(samplers: string[]): void;
  51076. /**
  51077. * Makes a duplicate of the current configuration into another one.
  51078. * @param sheenConfiguration define the config where to copy the info
  51079. */
  51080. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51081. /**
  51082. * Serializes this BRDF configuration.
  51083. * @returns - An object with the serialized config.
  51084. */
  51085. serialize(): any;
  51086. /**
  51087. * Parses a anisotropy Configuration from a serialized object.
  51088. * @param source - Serialized object.
  51089. * @param scene Defines the scene we are parsing for
  51090. * @param rootUrl Defines the rootUrl to load from
  51091. */
  51092. parse(source: any, scene: Scene, rootUrl: string): void;
  51093. }
  51094. }
  51095. declare module BABYLON {
  51096. /**
  51097. * @hidden
  51098. */
  51099. export interface IMaterialSubSurfaceDefines {
  51100. SUBSURFACE: boolean;
  51101. SS_REFRACTION: boolean;
  51102. SS_TRANSLUCENCY: boolean;
  51103. SS_SCATERRING: boolean;
  51104. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51105. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51106. SS_REFRACTIONMAP_3D: boolean;
  51107. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51108. SS_LODINREFRACTIONALPHA: boolean;
  51109. SS_GAMMAREFRACTION: boolean;
  51110. SS_RGBDREFRACTION: boolean;
  51111. SS_LINEARSPECULARREFRACTION: boolean;
  51112. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51113. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51114. /** @hidden */
  51115. _areTexturesDirty: boolean;
  51116. }
  51117. /**
  51118. * Define the code related to the sub surface parameters of the pbr material.
  51119. */
  51120. export class PBRSubSurfaceConfiguration {
  51121. private _isRefractionEnabled;
  51122. /**
  51123. * Defines if the refraction is enabled in the material.
  51124. */
  51125. isRefractionEnabled: boolean;
  51126. private _isTranslucencyEnabled;
  51127. /**
  51128. * Defines if the translucency is enabled in the material.
  51129. */
  51130. isTranslucencyEnabled: boolean;
  51131. private _isScatteringEnabled;
  51132. /**
  51133. * Defines the refraction intensity of the material.
  51134. * The refraction when enabled replaces the Diffuse part of the material.
  51135. * The intensity helps transitionning between diffuse and refraction.
  51136. */
  51137. refractionIntensity: number;
  51138. /**
  51139. * Defines the translucency intensity of the material.
  51140. * When translucency has been enabled, this defines how much of the "translucency"
  51141. * is addded to the diffuse part of the material.
  51142. */
  51143. translucencyIntensity: number;
  51144. /**
  51145. * Defines the scattering intensity of the material.
  51146. * When scattering has been enabled, this defines how much of the "scattered light"
  51147. * is addded to the diffuse part of the material.
  51148. */
  51149. scatteringIntensity: number;
  51150. private _thicknessTexture;
  51151. /**
  51152. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51153. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51154. * 0 would mean minimumThickness
  51155. * 1 would mean maximumThickness
  51156. * The other channels might be use as a mask to vary the different effects intensity.
  51157. */
  51158. thicknessTexture: Nullable<BaseTexture>;
  51159. private _refractionTexture;
  51160. /**
  51161. * Defines the texture to use for refraction.
  51162. */
  51163. refractionTexture: Nullable<BaseTexture>;
  51164. private _indexOfRefraction;
  51165. /**
  51166. * Defines the index of refraction used in the material.
  51167. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51168. */
  51169. indexOfRefraction: number;
  51170. private _invertRefractionY;
  51171. /**
  51172. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51173. */
  51174. invertRefractionY: boolean;
  51175. private _linkRefractionWithTransparency;
  51176. /**
  51177. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51178. * Materials half opaque for instance using refraction could benefit from this control.
  51179. */
  51180. linkRefractionWithTransparency: boolean;
  51181. /**
  51182. * Defines the minimum thickness stored in the thickness map.
  51183. * If no thickness map is defined, this value will be used to simulate thickness.
  51184. */
  51185. minimumThickness: number;
  51186. /**
  51187. * Defines the maximum thickness stored in the thickness map.
  51188. */
  51189. maximumThickness: number;
  51190. /**
  51191. * Defines the volume tint of the material.
  51192. * This is used for both translucency and scattering.
  51193. */
  51194. tintColor: Color3;
  51195. /**
  51196. * Defines the distance at which the tint color should be found in the media.
  51197. * This is used for refraction only.
  51198. */
  51199. tintColorAtDistance: number;
  51200. /**
  51201. * Defines how far each channel transmit through the media.
  51202. * It is defined as a color to simplify it selection.
  51203. */
  51204. diffusionDistance: Color3;
  51205. private _useMaskFromThicknessTexture;
  51206. /**
  51207. * Stores the intensity of the different subsurface effects in the thickness texture.
  51208. * * the green channel is the translucency intensity.
  51209. * * the blue channel is the scattering intensity.
  51210. * * the alpha channel is the refraction intensity.
  51211. */
  51212. useMaskFromThicknessTexture: boolean;
  51213. /** @hidden */
  51214. private _internalMarkAllSubMeshesAsTexturesDirty;
  51215. /** @hidden */
  51216. _markAllSubMeshesAsTexturesDirty(): void;
  51217. /**
  51218. * Instantiate a new istance of sub surface configuration.
  51219. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51220. */
  51221. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51222. /**
  51223. * Gets wehter the submesh is ready to be used or not.
  51224. * @param defines the list of "defines" to update.
  51225. * @param scene defines the scene the material belongs to.
  51226. * @returns - boolean indicating that the submesh is ready or not.
  51227. */
  51228. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51229. /**
  51230. * Checks to see if a texture is used in the material.
  51231. * @param defines the list of "defines" to update.
  51232. * @param scene defines the scene to the material belongs to.
  51233. */
  51234. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51235. /**
  51236. * Binds the material data.
  51237. * @param uniformBuffer defines the Uniform buffer to fill in.
  51238. * @param scene defines the scene the material belongs to.
  51239. * @param engine defines the engine the material belongs to.
  51240. * @param isFrozen defines wether the material is frozen or not.
  51241. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51242. */
  51243. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51244. /**
  51245. * Unbinds the material from the mesh.
  51246. * @param activeEffect defines the effect that should be unbound from.
  51247. * @returns true if unbound, otherwise false
  51248. */
  51249. unbind(activeEffect: Effect): boolean;
  51250. /**
  51251. * Returns the texture used for refraction or null if none is used.
  51252. * @param scene defines the scene the material belongs to.
  51253. * @returns - Refraction texture if present. If no refraction texture and refraction
  51254. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51255. */
  51256. private _getRefractionTexture;
  51257. /**
  51258. * Returns true if alpha blending should be disabled.
  51259. */
  51260. get disableAlphaBlending(): boolean;
  51261. /**
  51262. * Fills the list of render target textures.
  51263. * @param renderTargets the list of render targets to update
  51264. */
  51265. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51266. /**
  51267. * Checks to see if a texture is used in the material.
  51268. * @param texture - Base texture to use.
  51269. * @returns - Boolean specifying if a texture is used in the material.
  51270. */
  51271. hasTexture(texture: BaseTexture): boolean;
  51272. /**
  51273. * Gets a boolean indicating that current material needs to register RTT
  51274. * @returns true if this uses a render target otherwise false.
  51275. */
  51276. hasRenderTargetTextures(): boolean;
  51277. /**
  51278. * Returns an array of the actively used textures.
  51279. * @param activeTextures Array of BaseTextures
  51280. */
  51281. getActiveTextures(activeTextures: BaseTexture[]): void;
  51282. /**
  51283. * Returns the animatable textures.
  51284. * @param animatables Array of animatable textures.
  51285. */
  51286. getAnimatables(animatables: IAnimatable[]): void;
  51287. /**
  51288. * Disposes the resources of the material.
  51289. * @param forceDisposeTextures - Forces the disposal of all textures.
  51290. */
  51291. dispose(forceDisposeTextures?: boolean): void;
  51292. /**
  51293. * Get the current class name of the texture useful for serialization or dynamic coding.
  51294. * @returns "PBRSubSurfaceConfiguration"
  51295. */
  51296. getClassName(): string;
  51297. /**
  51298. * Add fallbacks to the effect fallbacks list.
  51299. * @param defines defines the Base texture to use.
  51300. * @param fallbacks defines the current fallback list.
  51301. * @param currentRank defines the current fallback rank.
  51302. * @returns the new fallback rank.
  51303. */
  51304. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51305. /**
  51306. * Add the required uniforms to the current list.
  51307. * @param uniforms defines the current uniform list.
  51308. */
  51309. static AddUniforms(uniforms: string[]): void;
  51310. /**
  51311. * Add the required samplers to the current list.
  51312. * @param samplers defines the current sampler list.
  51313. */
  51314. static AddSamplers(samplers: string[]): void;
  51315. /**
  51316. * Add the required uniforms to the current buffer.
  51317. * @param uniformBuffer defines the current uniform buffer.
  51318. */
  51319. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51320. /**
  51321. * Makes a duplicate of the current configuration into another one.
  51322. * @param configuration define the config where to copy the info
  51323. */
  51324. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51325. /**
  51326. * Serializes this Sub Surface configuration.
  51327. * @returns - An object with the serialized config.
  51328. */
  51329. serialize(): any;
  51330. /**
  51331. * Parses a anisotropy Configuration from a serialized object.
  51332. * @param source - Serialized object.
  51333. * @param scene Defines the scene we are parsing for
  51334. * @param rootUrl Defines the rootUrl to load from
  51335. */
  51336. parse(source: any, scene: Scene, rootUrl: string): void;
  51337. }
  51338. }
  51339. declare module BABYLON {
  51340. /** @hidden */
  51341. export var pbrFragmentDeclaration: {
  51342. name: string;
  51343. shader: string;
  51344. };
  51345. }
  51346. declare module BABYLON {
  51347. /** @hidden */
  51348. export var pbrUboDeclaration: {
  51349. name: string;
  51350. shader: string;
  51351. };
  51352. }
  51353. declare module BABYLON {
  51354. /** @hidden */
  51355. export var pbrFragmentExtraDeclaration: {
  51356. name: string;
  51357. shader: string;
  51358. };
  51359. }
  51360. declare module BABYLON {
  51361. /** @hidden */
  51362. export var pbrFragmentSamplersDeclaration: {
  51363. name: string;
  51364. shader: string;
  51365. };
  51366. }
  51367. declare module BABYLON {
  51368. /** @hidden */
  51369. export var pbrHelperFunctions: {
  51370. name: string;
  51371. shader: string;
  51372. };
  51373. }
  51374. declare module BABYLON {
  51375. /** @hidden */
  51376. export var harmonicsFunctions: {
  51377. name: string;
  51378. shader: string;
  51379. };
  51380. }
  51381. declare module BABYLON {
  51382. /** @hidden */
  51383. export var pbrDirectLightingSetupFunctions: {
  51384. name: string;
  51385. shader: string;
  51386. };
  51387. }
  51388. declare module BABYLON {
  51389. /** @hidden */
  51390. export var pbrDirectLightingFalloffFunctions: {
  51391. name: string;
  51392. shader: string;
  51393. };
  51394. }
  51395. declare module BABYLON {
  51396. /** @hidden */
  51397. export var pbrBRDFFunctions: {
  51398. name: string;
  51399. shader: string;
  51400. };
  51401. }
  51402. declare module BABYLON {
  51403. /** @hidden */
  51404. export var pbrDirectLightingFunctions: {
  51405. name: string;
  51406. shader: string;
  51407. };
  51408. }
  51409. declare module BABYLON {
  51410. /** @hidden */
  51411. export var pbrIBLFunctions: {
  51412. name: string;
  51413. shader: string;
  51414. };
  51415. }
  51416. declare module BABYLON {
  51417. /** @hidden */
  51418. export var pbrBlockAlbedoOpacity: {
  51419. name: string;
  51420. shader: string;
  51421. };
  51422. }
  51423. declare module BABYLON {
  51424. /** @hidden */
  51425. export var pbrBlockReflectivity: {
  51426. name: string;
  51427. shader: string;
  51428. };
  51429. }
  51430. declare module BABYLON {
  51431. /** @hidden */
  51432. export var pbrBlockAmbientOcclusion: {
  51433. name: string;
  51434. shader: string;
  51435. };
  51436. }
  51437. declare module BABYLON {
  51438. /** @hidden */
  51439. export var pbrBlockAlphaFresnel: {
  51440. name: string;
  51441. shader: string;
  51442. };
  51443. }
  51444. declare module BABYLON {
  51445. /** @hidden */
  51446. export var pbrBlockAnisotropic: {
  51447. name: string;
  51448. shader: string;
  51449. };
  51450. }
  51451. declare module BABYLON {
  51452. /** @hidden */
  51453. export var pbrBlockReflection: {
  51454. name: string;
  51455. shader: string;
  51456. };
  51457. }
  51458. declare module BABYLON {
  51459. /** @hidden */
  51460. export var pbrBlockSheen: {
  51461. name: string;
  51462. shader: string;
  51463. };
  51464. }
  51465. declare module BABYLON {
  51466. /** @hidden */
  51467. export var pbrBlockClearcoat: {
  51468. name: string;
  51469. shader: string;
  51470. };
  51471. }
  51472. declare module BABYLON {
  51473. /** @hidden */
  51474. export var pbrBlockSubSurface: {
  51475. name: string;
  51476. shader: string;
  51477. };
  51478. }
  51479. declare module BABYLON {
  51480. /** @hidden */
  51481. export var pbrBlockNormalGeometric: {
  51482. name: string;
  51483. shader: string;
  51484. };
  51485. }
  51486. declare module BABYLON {
  51487. /** @hidden */
  51488. export var pbrBlockNormalFinal: {
  51489. name: string;
  51490. shader: string;
  51491. };
  51492. }
  51493. declare module BABYLON {
  51494. /** @hidden */
  51495. export var pbrBlockGeometryInfo: {
  51496. name: string;
  51497. shader: string;
  51498. };
  51499. }
  51500. declare module BABYLON {
  51501. /** @hidden */
  51502. export var pbrBlockReflectance0: {
  51503. name: string;
  51504. shader: string;
  51505. };
  51506. }
  51507. declare module BABYLON {
  51508. /** @hidden */
  51509. export var pbrBlockReflectance: {
  51510. name: string;
  51511. shader: string;
  51512. };
  51513. }
  51514. declare module BABYLON {
  51515. /** @hidden */
  51516. export var pbrBlockDirectLighting: {
  51517. name: string;
  51518. shader: string;
  51519. };
  51520. }
  51521. declare module BABYLON {
  51522. /** @hidden */
  51523. export var pbrBlockFinalLitComponents: {
  51524. name: string;
  51525. shader: string;
  51526. };
  51527. }
  51528. declare module BABYLON {
  51529. /** @hidden */
  51530. export var pbrBlockFinalUnlitComponents: {
  51531. name: string;
  51532. shader: string;
  51533. };
  51534. }
  51535. declare module BABYLON {
  51536. /** @hidden */
  51537. export var pbrBlockFinalColorComposition: {
  51538. name: string;
  51539. shader: string;
  51540. };
  51541. }
  51542. declare module BABYLON {
  51543. /** @hidden */
  51544. export var pbrBlockImageProcessing: {
  51545. name: string;
  51546. shader: string;
  51547. };
  51548. }
  51549. declare module BABYLON {
  51550. /** @hidden */
  51551. export var pbrDebug: {
  51552. name: string;
  51553. shader: string;
  51554. };
  51555. }
  51556. declare module BABYLON {
  51557. /** @hidden */
  51558. export var pbrPixelShader: {
  51559. name: string;
  51560. shader: string;
  51561. };
  51562. }
  51563. declare module BABYLON {
  51564. /** @hidden */
  51565. export var pbrVertexDeclaration: {
  51566. name: string;
  51567. shader: string;
  51568. };
  51569. }
  51570. declare module BABYLON {
  51571. /** @hidden */
  51572. export var pbrVertexShader: {
  51573. name: string;
  51574. shader: string;
  51575. };
  51576. }
  51577. declare module BABYLON {
  51578. /**
  51579. * Manages the defines for the PBR Material.
  51580. * @hidden
  51581. */
  51582. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51583. PBR: boolean;
  51584. MAINUV1: boolean;
  51585. MAINUV2: boolean;
  51586. UV1: boolean;
  51587. UV2: boolean;
  51588. ALBEDO: boolean;
  51589. GAMMAALBEDO: boolean;
  51590. ALBEDODIRECTUV: number;
  51591. VERTEXCOLOR: boolean;
  51592. AMBIENT: boolean;
  51593. AMBIENTDIRECTUV: number;
  51594. AMBIENTINGRAYSCALE: boolean;
  51595. OPACITY: boolean;
  51596. VERTEXALPHA: boolean;
  51597. OPACITYDIRECTUV: number;
  51598. OPACITYRGB: boolean;
  51599. ALPHATEST: boolean;
  51600. DEPTHPREPASS: boolean;
  51601. ALPHABLEND: boolean;
  51602. ALPHAFROMALBEDO: boolean;
  51603. ALPHATESTVALUE: string;
  51604. SPECULAROVERALPHA: boolean;
  51605. RADIANCEOVERALPHA: boolean;
  51606. ALPHAFRESNEL: boolean;
  51607. LINEARALPHAFRESNEL: boolean;
  51608. PREMULTIPLYALPHA: boolean;
  51609. EMISSIVE: boolean;
  51610. EMISSIVEDIRECTUV: number;
  51611. REFLECTIVITY: boolean;
  51612. REFLECTIVITYDIRECTUV: number;
  51613. SPECULARTERM: boolean;
  51614. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51615. MICROSURFACEAUTOMATIC: boolean;
  51616. LODBASEDMICROSFURACE: boolean;
  51617. MICROSURFACEMAP: boolean;
  51618. MICROSURFACEMAPDIRECTUV: number;
  51619. METALLICWORKFLOW: boolean;
  51620. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51621. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51622. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51623. AOSTOREINMETALMAPRED: boolean;
  51624. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51625. ENVIRONMENTBRDF: boolean;
  51626. ENVIRONMENTBRDF_RGBD: boolean;
  51627. NORMAL: boolean;
  51628. TANGENT: boolean;
  51629. BUMP: boolean;
  51630. BUMPDIRECTUV: number;
  51631. OBJECTSPACE_NORMALMAP: boolean;
  51632. PARALLAX: boolean;
  51633. PARALLAXOCCLUSION: boolean;
  51634. NORMALXYSCALE: boolean;
  51635. LIGHTMAP: boolean;
  51636. LIGHTMAPDIRECTUV: number;
  51637. USELIGHTMAPASSHADOWMAP: boolean;
  51638. GAMMALIGHTMAP: boolean;
  51639. RGBDLIGHTMAP: boolean;
  51640. REFLECTION: boolean;
  51641. REFLECTIONMAP_3D: boolean;
  51642. REFLECTIONMAP_SPHERICAL: boolean;
  51643. REFLECTIONMAP_PLANAR: boolean;
  51644. REFLECTIONMAP_CUBIC: boolean;
  51645. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51646. REFLECTIONMAP_PROJECTION: boolean;
  51647. REFLECTIONMAP_SKYBOX: boolean;
  51648. REFLECTIONMAP_EXPLICIT: boolean;
  51649. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51650. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51651. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51652. INVERTCUBICMAP: boolean;
  51653. USESPHERICALFROMREFLECTIONMAP: boolean;
  51654. USEIRRADIANCEMAP: boolean;
  51655. SPHERICAL_HARMONICS: boolean;
  51656. USESPHERICALINVERTEX: boolean;
  51657. REFLECTIONMAP_OPPOSITEZ: boolean;
  51658. LODINREFLECTIONALPHA: boolean;
  51659. GAMMAREFLECTION: boolean;
  51660. RGBDREFLECTION: boolean;
  51661. LINEARSPECULARREFLECTION: boolean;
  51662. RADIANCEOCCLUSION: boolean;
  51663. HORIZONOCCLUSION: boolean;
  51664. INSTANCES: boolean;
  51665. NUM_BONE_INFLUENCERS: number;
  51666. BonesPerMesh: number;
  51667. BONETEXTURE: boolean;
  51668. NONUNIFORMSCALING: boolean;
  51669. MORPHTARGETS: boolean;
  51670. MORPHTARGETS_NORMAL: boolean;
  51671. MORPHTARGETS_TANGENT: boolean;
  51672. MORPHTARGETS_UV: boolean;
  51673. NUM_MORPH_INFLUENCERS: number;
  51674. IMAGEPROCESSING: boolean;
  51675. VIGNETTE: boolean;
  51676. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51677. VIGNETTEBLENDMODEOPAQUE: boolean;
  51678. TONEMAPPING: boolean;
  51679. TONEMAPPING_ACES: boolean;
  51680. CONTRAST: boolean;
  51681. COLORCURVES: boolean;
  51682. COLORGRADING: boolean;
  51683. COLORGRADING3D: boolean;
  51684. SAMPLER3DGREENDEPTH: boolean;
  51685. SAMPLER3DBGRMAP: boolean;
  51686. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51687. EXPOSURE: boolean;
  51688. MULTIVIEW: boolean;
  51689. USEPHYSICALLIGHTFALLOFF: boolean;
  51690. USEGLTFLIGHTFALLOFF: boolean;
  51691. TWOSIDEDLIGHTING: boolean;
  51692. SHADOWFLOAT: boolean;
  51693. CLIPPLANE: boolean;
  51694. CLIPPLANE2: boolean;
  51695. CLIPPLANE3: boolean;
  51696. CLIPPLANE4: boolean;
  51697. CLIPPLANE5: boolean;
  51698. CLIPPLANE6: boolean;
  51699. POINTSIZE: boolean;
  51700. FOG: boolean;
  51701. LOGARITHMICDEPTH: boolean;
  51702. FORCENORMALFORWARD: boolean;
  51703. SPECULARAA: boolean;
  51704. CLEARCOAT: boolean;
  51705. CLEARCOAT_DEFAULTIOR: boolean;
  51706. CLEARCOAT_TEXTURE: boolean;
  51707. CLEARCOAT_TEXTUREDIRECTUV: number;
  51708. CLEARCOAT_BUMP: boolean;
  51709. CLEARCOAT_BUMPDIRECTUV: number;
  51710. CLEARCOAT_TINT: boolean;
  51711. CLEARCOAT_TINT_TEXTURE: boolean;
  51712. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51713. ANISOTROPIC: boolean;
  51714. ANISOTROPIC_TEXTURE: boolean;
  51715. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51716. BRDF_V_HEIGHT_CORRELATED: boolean;
  51717. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51718. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51719. SHEEN: boolean;
  51720. SHEEN_TEXTURE: boolean;
  51721. SHEEN_TEXTUREDIRECTUV: number;
  51722. SHEEN_LINKWITHALBEDO: boolean;
  51723. SHEEN_ROUGHNESS: boolean;
  51724. SHEEN_ALBEDOSCALING: boolean;
  51725. SUBSURFACE: boolean;
  51726. SS_REFRACTION: boolean;
  51727. SS_TRANSLUCENCY: boolean;
  51728. SS_SCATERRING: boolean;
  51729. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51730. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51731. SS_REFRACTIONMAP_3D: boolean;
  51732. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51733. SS_LODINREFRACTIONALPHA: boolean;
  51734. SS_GAMMAREFRACTION: boolean;
  51735. SS_RGBDREFRACTION: boolean;
  51736. SS_LINEARSPECULARREFRACTION: boolean;
  51737. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51738. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51739. UNLIT: boolean;
  51740. DEBUGMODE: number;
  51741. /**
  51742. * Initializes the PBR Material defines.
  51743. */
  51744. constructor();
  51745. /**
  51746. * Resets the PBR Material defines.
  51747. */
  51748. reset(): void;
  51749. }
  51750. /**
  51751. * The Physically based material base class of BJS.
  51752. *
  51753. * This offers the main features of a standard PBR material.
  51754. * For more information, please refer to the documentation :
  51755. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51756. */
  51757. export abstract class PBRBaseMaterial extends PushMaterial {
  51758. /**
  51759. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51760. */
  51761. static readonly PBRMATERIAL_OPAQUE: number;
  51762. /**
  51763. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51764. */
  51765. static readonly PBRMATERIAL_ALPHATEST: number;
  51766. /**
  51767. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51768. */
  51769. static readonly PBRMATERIAL_ALPHABLEND: number;
  51770. /**
  51771. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51772. * They are also discarded below the alpha cutoff threshold to improve performances.
  51773. */
  51774. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51775. /**
  51776. * Defines the default value of how much AO map is occluding the analytical lights
  51777. * (point spot...).
  51778. */
  51779. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51780. /**
  51781. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51782. */
  51783. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51784. /**
  51785. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51786. * to enhance interoperability with other engines.
  51787. */
  51788. static readonly LIGHTFALLOFF_GLTF: number;
  51789. /**
  51790. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51791. * to enhance interoperability with other materials.
  51792. */
  51793. static readonly LIGHTFALLOFF_STANDARD: number;
  51794. /**
  51795. * Intensity of the direct lights e.g. the four lights available in your scene.
  51796. * This impacts both the direct diffuse and specular highlights.
  51797. */
  51798. protected _directIntensity: number;
  51799. /**
  51800. * Intensity of the emissive part of the material.
  51801. * This helps controlling the emissive effect without modifying the emissive color.
  51802. */
  51803. protected _emissiveIntensity: number;
  51804. /**
  51805. * Intensity of the environment e.g. how much the environment will light the object
  51806. * either through harmonics for rough material or through the refelction for shiny ones.
  51807. */
  51808. protected _environmentIntensity: number;
  51809. /**
  51810. * This is a special control allowing the reduction of the specular highlights coming from the
  51811. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51812. */
  51813. protected _specularIntensity: number;
  51814. /**
  51815. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51816. */
  51817. private _lightingInfos;
  51818. /**
  51819. * Debug Control allowing disabling the bump map on this material.
  51820. */
  51821. protected _disableBumpMap: boolean;
  51822. /**
  51823. * AKA Diffuse Texture in standard nomenclature.
  51824. */
  51825. protected _albedoTexture: Nullable<BaseTexture>;
  51826. /**
  51827. * AKA Occlusion Texture in other nomenclature.
  51828. */
  51829. protected _ambientTexture: Nullable<BaseTexture>;
  51830. /**
  51831. * AKA Occlusion Texture Intensity in other nomenclature.
  51832. */
  51833. protected _ambientTextureStrength: number;
  51834. /**
  51835. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51836. * 1 means it completely occludes it
  51837. * 0 mean it has no impact
  51838. */
  51839. protected _ambientTextureImpactOnAnalyticalLights: number;
  51840. /**
  51841. * Stores the alpha values in a texture.
  51842. */
  51843. protected _opacityTexture: Nullable<BaseTexture>;
  51844. /**
  51845. * Stores the reflection values in a texture.
  51846. */
  51847. protected _reflectionTexture: Nullable<BaseTexture>;
  51848. /**
  51849. * Stores the emissive values in a texture.
  51850. */
  51851. protected _emissiveTexture: Nullable<BaseTexture>;
  51852. /**
  51853. * AKA Specular texture in other nomenclature.
  51854. */
  51855. protected _reflectivityTexture: Nullable<BaseTexture>;
  51856. /**
  51857. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51858. */
  51859. protected _metallicTexture: Nullable<BaseTexture>;
  51860. /**
  51861. * Specifies the metallic scalar of the metallic/roughness workflow.
  51862. * Can also be used to scale the metalness values of the metallic texture.
  51863. */
  51864. protected _metallic: Nullable<number>;
  51865. /**
  51866. * Specifies the roughness scalar of the metallic/roughness workflow.
  51867. * Can also be used to scale the roughness values of the metallic texture.
  51868. */
  51869. protected _roughness: Nullable<number>;
  51870. /**
  51871. * Specifies the an F0 factor to help configuring the material F0.
  51872. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51873. * to 0.5 the previously hard coded value stays the same.
  51874. * Can also be used to scale the F0 values of the metallic texture.
  51875. */
  51876. protected _metallicF0Factor: number;
  51877. /**
  51878. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51879. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51880. * your expectation as it multiplies with the texture data.
  51881. */
  51882. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51883. /**
  51884. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51885. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51886. */
  51887. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51888. /**
  51889. * Stores surface normal data used to displace a mesh in a texture.
  51890. */
  51891. protected _bumpTexture: Nullable<BaseTexture>;
  51892. /**
  51893. * Stores the pre-calculated light information of a mesh in a texture.
  51894. */
  51895. protected _lightmapTexture: Nullable<BaseTexture>;
  51896. /**
  51897. * The color of a material in ambient lighting.
  51898. */
  51899. protected _ambientColor: Color3;
  51900. /**
  51901. * AKA Diffuse Color in other nomenclature.
  51902. */
  51903. protected _albedoColor: Color3;
  51904. /**
  51905. * AKA Specular Color in other nomenclature.
  51906. */
  51907. protected _reflectivityColor: Color3;
  51908. /**
  51909. * The color applied when light is reflected from a material.
  51910. */
  51911. protected _reflectionColor: Color3;
  51912. /**
  51913. * The color applied when light is emitted from a material.
  51914. */
  51915. protected _emissiveColor: Color3;
  51916. /**
  51917. * AKA Glossiness in other nomenclature.
  51918. */
  51919. protected _microSurface: number;
  51920. /**
  51921. * Specifies that the material will use the light map as a show map.
  51922. */
  51923. protected _useLightmapAsShadowmap: boolean;
  51924. /**
  51925. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51926. * makes the reflect vector face the model (under horizon).
  51927. */
  51928. protected _useHorizonOcclusion: boolean;
  51929. /**
  51930. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51931. * too much the area relying on ambient texture to define their ambient occlusion.
  51932. */
  51933. protected _useRadianceOcclusion: boolean;
  51934. /**
  51935. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51936. */
  51937. protected _useAlphaFromAlbedoTexture: boolean;
  51938. /**
  51939. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51940. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51941. */
  51942. protected _useSpecularOverAlpha: boolean;
  51943. /**
  51944. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51945. */
  51946. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51947. /**
  51948. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51949. */
  51950. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51951. /**
  51952. * Specifies if the metallic texture contains the roughness information in its green channel.
  51953. */
  51954. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51955. /**
  51956. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51957. */
  51958. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51959. /**
  51960. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51961. */
  51962. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51963. /**
  51964. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51965. */
  51966. protected _useAmbientInGrayScale: boolean;
  51967. /**
  51968. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51969. * The material will try to infer what glossiness each pixel should be.
  51970. */
  51971. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51972. /**
  51973. * Defines the falloff type used in this material.
  51974. * It by default is Physical.
  51975. */
  51976. protected _lightFalloff: number;
  51977. /**
  51978. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51979. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51980. */
  51981. protected _useRadianceOverAlpha: boolean;
  51982. /**
  51983. * Allows using an object space normal map (instead of tangent space).
  51984. */
  51985. protected _useObjectSpaceNormalMap: boolean;
  51986. /**
  51987. * Allows using the bump map in parallax mode.
  51988. */
  51989. protected _useParallax: boolean;
  51990. /**
  51991. * Allows using the bump map in parallax occlusion mode.
  51992. */
  51993. protected _useParallaxOcclusion: boolean;
  51994. /**
  51995. * Controls the scale bias of the parallax mode.
  51996. */
  51997. protected _parallaxScaleBias: number;
  51998. /**
  51999. * If sets to true, disables all the lights affecting the material.
  52000. */
  52001. protected _disableLighting: boolean;
  52002. /**
  52003. * Number of Simultaneous lights allowed on the material.
  52004. */
  52005. protected _maxSimultaneousLights: number;
  52006. /**
  52007. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52008. */
  52009. protected _invertNormalMapX: boolean;
  52010. /**
  52011. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52012. */
  52013. protected _invertNormalMapY: boolean;
  52014. /**
  52015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52016. */
  52017. protected _twoSidedLighting: boolean;
  52018. /**
  52019. * Defines the alpha limits in alpha test mode.
  52020. */
  52021. protected _alphaCutOff: number;
  52022. /**
  52023. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52024. */
  52025. protected _forceAlphaTest: boolean;
  52026. /**
  52027. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52028. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52029. */
  52030. protected _useAlphaFresnel: boolean;
  52031. /**
  52032. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52033. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52034. */
  52035. protected _useLinearAlphaFresnel: boolean;
  52036. /**
  52037. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52038. * from cos thetav and roughness:
  52039. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52040. */
  52041. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52042. /**
  52043. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52044. */
  52045. protected _forceIrradianceInFragment: boolean;
  52046. /**
  52047. * Force normal to face away from face.
  52048. */
  52049. protected _forceNormalForward: boolean;
  52050. /**
  52051. * Enables specular anti aliasing in the PBR shader.
  52052. * It will both interacts on the Geometry for analytical and IBL lighting.
  52053. * It also prefilter the roughness map based on the bump values.
  52054. */
  52055. protected _enableSpecularAntiAliasing: boolean;
  52056. /**
  52057. * Default configuration related to image processing available in the PBR Material.
  52058. */
  52059. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52060. /**
  52061. * Keep track of the image processing observer to allow dispose and replace.
  52062. */
  52063. private _imageProcessingObserver;
  52064. /**
  52065. * Attaches a new image processing configuration to the PBR Material.
  52066. * @param configuration
  52067. */
  52068. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52069. /**
  52070. * Stores the available render targets.
  52071. */
  52072. private _renderTargets;
  52073. /**
  52074. * Sets the global ambient color for the material used in lighting calculations.
  52075. */
  52076. private _globalAmbientColor;
  52077. /**
  52078. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52079. */
  52080. private _useLogarithmicDepth;
  52081. /**
  52082. * If set to true, no lighting calculations will be applied.
  52083. */
  52084. private _unlit;
  52085. private _debugMode;
  52086. /**
  52087. * @hidden
  52088. * This is reserved for the inspector.
  52089. * Defines the material debug mode.
  52090. * It helps seeing only some components of the material while troubleshooting.
  52091. */
  52092. debugMode: number;
  52093. /**
  52094. * @hidden
  52095. * This is reserved for the inspector.
  52096. * Specify from where on screen the debug mode should start.
  52097. * The value goes from -1 (full screen) to 1 (not visible)
  52098. * It helps with side by side comparison against the final render
  52099. * This defaults to -1
  52100. */
  52101. private debugLimit;
  52102. /**
  52103. * @hidden
  52104. * This is reserved for the inspector.
  52105. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52106. * You can use the factor to better multiply the final value.
  52107. */
  52108. private debugFactor;
  52109. /**
  52110. * Defines the clear coat layer parameters for the material.
  52111. */
  52112. readonly clearCoat: PBRClearCoatConfiguration;
  52113. /**
  52114. * Defines the anisotropic parameters for the material.
  52115. */
  52116. readonly anisotropy: PBRAnisotropicConfiguration;
  52117. /**
  52118. * Defines the BRDF parameters for the material.
  52119. */
  52120. readonly brdf: PBRBRDFConfiguration;
  52121. /**
  52122. * Defines the Sheen parameters for the material.
  52123. */
  52124. readonly sheen: PBRSheenConfiguration;
  52125. /**
  52126. * Defines the SubSurface parameters for the material.
  52127. */
  52128. readonly subSurface: PBRSubSurfaceConfiguration;
  52129. protected _rebuildInParallel: boolean;
  52130. /**
  52131. * Instantiates a new PBRMaterial instance.
  52132. *
  52133. * @param name The material name
  52134. * @param scene The scene the material will be use in.
  52135. */
  52136. constructor(name: string, scene: Scene);
  52137. /**
  52138. * Gets a boolean indicating that current material needs to register RTT
  52139. */
  52140. get hasRenderTargetTextures(): boolean;
  52141. /**
  52142. * Gets the name of the material class.
  52143. */
  52144. getClassName(): string;
  52145. /**
  52146. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52147. */
  52148. get useLogarithmicDepth(): boolean;
  52149. /**
  52150. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52151. */
  52152. set useLogarithmicDepth(value: boolean);
  52153. /**
  52154. * Returns true if alpha blending should be disabled.
  52155. */
  52156. protected get _disableAlphaBlending(): boolean;
  52157. /**
  52158. * Specifies whether or not this material should be rendered in alpha blend mode.
  52159. */
  52160. needAlphaBlending(): boolean;
  52161. /**
  52162. * Specifies whether or not this material should be rendered in alpha test mode.
  52163. */
  52164. needAlphaTesting(): boolean;
  52165. /**
  52166. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52167. */
  52168. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52169. /**
  52170. * Gets the texture used for the alpha test.
  52171. */
  52172. getAlphaTestTexture(): Nullable<BaseTexture>;
  52173. /**
  52174. * Specifies that the submesh is ready to be used.
  52175. * @param mesh - BJS mesh.
  52176. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52177. * @param useInstances - Specifies that instances should be used.
  52178. * @returns - boolean indicating that the submesh is ready or not.
  52179. */
  52180. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52181. /**
  52182. * Specifies if the material uses metallic roughness workflow.
  52183. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52184. */
  52185. isMetallicWorkflow(): boolean;
  52186. private _prepareEffect;
  52187. private _prepareDefines;
  52188. /**
  52189. * Force shader compilation
  52190. */
  52191. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52192. /**
  52193. * Initializes the uniform buffer layout for the shader.
  52194. */
  52195. buildUniformLayout(): void;
  52196. /**
  52197. * Unbinds the material from the mesh
  52198. */
  52199. unbind(): void;
  52200. /**
  52201. * Binds the submesh data.
  52202. * @param world - The world matrix.
  52203. * @param mesh - The BJS mesh.
  52204. * @param subMesh - A submesh of the BJS mesh.
  52205. */
  52206. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52207. /**
  52208. * Returns the animatable textures.
  52209. * @returns - Array of animatable textures.
  52210. */
  52211. getAnimatables(): IAnimatable[];
  52212. /**
  52213. * Returns the texture used for reflections.
  52214. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52215. */
  52216. private _getReflectionTexture;
  52217. /**
  52218. * Returns an array of the actively used textures.
  52219. * @returns - Array of BaseTextures
  52220. */
  52221. getActiveTextures(): BaseTexture[];
  52222. /**
  52223. * Checks to see if a texture is used in the material.
  52224. * @param texture - Base texture to use.
  52225. * @returns - Boolean specifying if a texture is used in the material.
  52226. */
  52227. hasTexture(texture: BaseTexture): boolean;
  52228. /**
  52229. * Disposes the resources of the material.
  52230. * @param forceDisposeEffect - Forces the disposal of effects.
  52231. * @param forceDisposeTextures - Forces the disposal of all textures.
  52232. */
  52233. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52234. }
  52235. }
  52236. declare module BABYLON {
  52237. /**
  52238. * The Physically based material of BJS.
  52239. *
  52240. * This offers the main features of a standard PBR material.
  52241. * For more information, please refer to the documentation :
  52242. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52243. */
  52244. export class PBRMaterial extends PBRBaseMaterial {
  52245. /**
  52246. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52247. */
  52248. static readonly PBRMATERIAL_OPAQUE: number;
  52249. /**
  52250. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52251. */
  52252. static readonly PBRMATERIAL_ALPHATEST: number;
  52253. /**
  52254. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52255. */
  52256. static readonly PBRMATERIAL_ALPHABLEND: number;
  52257. /**
  52258. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52259. * They are also discarded below the alpha cutoff threshold to improve performances.
  52260. */
  52261. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52262. /**
  52263. * Defines the default value of how much AO map is occluding the analytical lights
  52264. * (point spot...).
  52265. */
  52266. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52267. /**
  52268. * Intensity of the direct lights e.g. the four lights available in your scene.
  52269. * This impacts both the direct diffuse and specular highlights.
  52270. */
  52271. directIntensity: number;
  52272. /**
  52273. * Intensity of the emissive part of the material.
  52274. * This helps controlling the emissive effect without modifying the emissive color.
  52275. */
  52276. emissiveIntensity: number;
  52277. /**
  52278. * Intensity of the environment e.g. how much the environment will light the object
  52279. * either through harmonics for rough material or through the refelction for shiny ones.
  52280. */
  52281. environmentIntensity: number;
  52282. /**
  52283. * This is a special control allowing the reduction of the specular highlights coming from the
  52284. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52285. */
  52286. specularIntensity: number;
  52287. /**
  52288. * Debug Control allowing disabling the bump map on this material.
  52289. */
  52290. disableBumpMap: boolean;
  52291. /**
  52292. * AKA Diffuse Texture in standard nomenclature.
  52293. */
  52294. albedoTexture: BaseTexture;
  52295. /**
  52296. * AKA Occlusion Texture in other nomenclature.
  52297. */
  52298. ambientTexture: BaseTexture;
  52299. /**
  52300. * AKA Occlusion Texture Intensity in other nomenclature.
  52301. */
  52302. ambientTextureStrength: number;
  52303. /**
  52304. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52305. * 1 means it completely occludes it
  52306. * 0 mean it has no impact
  52307. */
  52308. ambientTextureImpactOnAnalyticalLights: number;
  52309. /**
  52310. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52311. */
  52312. opacityTexture: BaseTexture;
  52313. /**
  52314. * Stores the reflection values in a texture.
  52315. */
  52316. reflectionTexture: Nullable<BaseTexture>;
  52317. /**
  52318. * Stores the emissive values in a texture.
  52319. */
  52320. emissiveTexture: BaseTexture;
  52321. /**
  52322. * AKA Specular texture in other nomenclature.
  52323. */
  52324. reflectivityTexture: BaseTexture;
  52325. /**
  52326. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52327. */
  52328. metallicTexture: BaseTexture;
  52329. /**
  52330. * Specifies the metallic scalar of the metallic/roughness workflow.
  52331. * Can also be used to scale the metalness values of the metallic texture.
  52332. */
  52333. metallic: Nullable<number>;
  52334. /**
  52335. * Specifies the roughness scalar of the metallic/roughness workflow.
  52336. * Can also be used to scale the roughness values of the metallic texture.
  52337. */
  52338. roughness: Nullable<number>;
  52339. /**
  52340. * Specifies the an F0 factor to help configuring the material F0.
  52341. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52342. * to 0.5 the previously hard coded value stays the same.
  52343. * Can also be used to scale the F0 values of the metallic texture.
  52344. */
  52345. metallicF0Factor: number;
  52346. /**
  52347. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52348. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52349. * your expectation as it multiplies with the texture data.
  52350. */
  52351. useMetallicF0FactorFromMetallicTexture: boolean;
  52352. /**
  52353. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52354. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52355. */
  52356. microSurfaceTexture: BaseTexture;
  52357. /**
  52358. * Stores surface normal data used to displace a mesh in a texture.
  52359. */
  52360. bumpTexture: BaseTexture;
  52361. /**
  52362. * Stores the pre-calculated light information of a mesh in a texture.
  52363. */
  52364. lightmapTexture: BaseTexture;
  52365. /**
  52366. * Stores the refracted light information in a texture.
  52367. */
  52368. get refractionTexture(): Nullable<BaseTexture>;
  52369. set refractionTexture(value: Nullable<BaseTexture>);
  52370. /**
  52371. * The color of a material in ambient lighting.
  52372. */
  52373. ambientColor: Color3;
  52374. /**
  52375. * AKA Diffuse Color in other nomenclature.
  52376. */
  52377. albedoColor: Color3;
  52378. /**
  52379. * AKA Specular Color in other nomenclature.
  52380. */
  52381. reflectivityColor: Color3;
  52382. /**
  52383. * The color reflected from the material.
  52384. */
  52385. reflectionColor: Color3;
  52386. /**
  52387. * The color emitted from the material.
  52388. */
  52389. emissiveColor: Color3;
  52390. /**
  52391. * AKA Glossiness in other nomenclature.
  52392. */
  52393. microSurface: number;
  52394. /**
  52395. * source material index of refraction (IOR)' / 'destination material IOR.
  52396. */
  52397. get indexOfRefraction(): number;
  52398. set indexOfRefraction(value: number);
  52399. /**
  52400. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52401. */
  52402. get invertRefractionY(): boolean;
  52403. set invertRefractionY(value: boolean);
  52404. /**
  52405. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52406. * Materials half opaque for instance using refraction could benefit from this control.
  52407. */
  52408. get linkRefractionWithTransparency(): boolean;
  52409. set linkRefractionWithTransparency(value: boolean);
  52410. /**
  52411. * If true, the light map contains occlusion information instead of lighting info.
  52412. */
  52413. useLightmapAsShadowmap: boolean;
  52414. /**
  52415. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52416. */
  52417. useAlphaFromAlbedoTexture: boolean;
  52418. /**
  52419. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52420. */
  52421. forceAlphaTest: boolean;
  52422. /**
  52423. * Defines the alpha limits in alpha test mode.
  52424. */
  52425. alphaCutOff: number;
  52426. /**
  52427. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52428. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52429. */
  52430. useSpecularOverAlpha: boolean;
  52431. /**
  52432. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52433. */
  52434. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52435. /**
  52436. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52437. */
  52438. useRoughnessFromMetallicTextureAlpha: boolean;
  52439. /**
  52440. * Specifies if the metallic texture contains the roughness information in its green channel.
  52441. */
  52442. useRoughnessFromMetallicTextureGreen: boolean;
  52443. /**
  52444. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52445. */
  52446. useMetallnessFromMetallicTextureBlue: boolean;
  52447. /**
  52448. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52449. */
  52450. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52451. /**
  52452. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52453. */
  52454. useAmbientInGrayScale: boolean;
  52455. /**
  52456. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52457. * The material will try to infer what glossiness each pixel should be.
  52458. */
  52459. useAutoMicroSurfaceFromReflectivityMap: 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. get usePhysicalLightFalloff(): boolean;
  52466. /**
  52467. * BJS is using an harcoded light falloff based on a manually sets up range.
  52468. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52469. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52470. */
  52471. set usePhysicalLightFalloff(value: boolean);
  52472. /**
  52473. * In order to support the falloff compatibility with gltf, a special mode has been added
  52474. * to reproduce the gltf light falloff.
  52475. */
  52476. get useGLTFLightFalloff(): boolean;
  52477. /**
  52478. * In order to support the falloff compatibility with gltf, a special mode has been added
  52479. * to reproduce the gltf light falloff.
  52480. */
  52481. set useGLTFLightFalloff(value: boolean);
  52482. /**
  52483. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52484. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52485. */
  52486. useRadianceOverAlpha: boolean;
  52487. /**
  52488. * Allows using an object space normal map (instead of tangent space).
  52489. */
  52490. useObjectSpaceNormalMap: boolean;
  52491. /**
  52492. * Allows using the bump map in parallax mode.
  52493. */
  52494. useParallax: boolean;
  52495. /**
  52496. * Allows using the bump map in parallax occlusion mode.
  52497. */
  52498. useParallaxOcclusion: boolean;
  52499. /**
  52500. * Controls the scale bias of the parallax mode.
  52501. */
  52502. parallaxScaleBias: number;
  52503. /**
  52504. * If sets to true, disables all the lights affecting the material.
  52505. */
  52506. disableLighting: boolean;
  52507. /**
  52508. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52509. */
  52510. forceIrradianceInFragment: boolean;
  52511. /**
  52512. * Number of Simultaneous lights allowed on the material.
  52513. */
  52514. maxSimultaneousLights: number;
  52515. /**
  52516. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52517. */
  52518. invertNormalMapX: boolean;
  52519. /**
  52520. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52521. */
  52522. invertNormalMapY: boolean;
  52523. /**
  52524. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52525. */
  52526. twoSidedLighting: boolean;
  52527. /**
  52528. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52529. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52530. */
  52531. useAlphaFresnel: boolean;
  52532. /**
  52533. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52534. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52535. */
  52536. useLinearAlphaFresnel: boolean;
  52537. /**
  52538. * Let user defines the brdf lookup texture used for IBL.
  52539. * A default 8bit version is embedded but you could point at :
  52540. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52541. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52542. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52543. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52544. */
  52545. environmentBRDFTexture: Nullable<BaseTexture>;
  52546. /**
  52547. * Force normal to face away from face.
  52548. */
  52549. forceNormalForward: boolean;
  52550. /**
  52551. * Enables specular anti aliasing in the PBR shader.
  52552. * It will both interacts on the Geometry for analytical and IBL lighting.
  52553. * It also prefilter the roughness map based on the bump values.
  52554. */
  52555. enableSpecularAntiAliasing: boolean;
  52556. /**
  52557. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52558. * makes the reflect vector face the model (under horizon).
  52559. */
  52560. useHorizonOcclusion: boolean;
  52561. /**
  52562. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52563. * too much the area relying on ambient texture to define their ambient occlusion.
  52564. */
  52565. useRadianceOcclusion: boolean;
  52566. /**
  52567. * If set to true, no lighting calculations will be applied.
  52568. */
  52569. unlit: boolean;
  52570. /**
  52571. * Gets the image processing configuration used either in this material.
  52572. */
  52573. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52574. /**
  52575. * Sets the Default image processing configuration used either in the this material.
  52576. *
  52577. * If sets to null, the scene one is in use.
  52578. */
  52579. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52580. /**
  52581. * Gets wether the color curves effect is enabled.
  52582. */
  52583. get cameraColorCurvesEnabled(): boolean;
  52584. /**
  52585. * Sets wether the color curves effect is enabled.
  52586. */
  52587. set cameraColorCurvesEnabled(value: boolean);
  52588. /**
  52589. * Gets wether the color grading effect is enabled.
  52590. */
  52591. get cameraColorGradingEnabled(): boolean;
  52592. /**
  52593. * Gets wether the color grading effect is enabled.
  52594. */
  52595. set cameraColorGradingEnabled(value: boolean);
  52596. /**
  52597. * Gets wether tonemapping is enabled or not.
  52598. */
  52599. get cameraToneMappingEnabled(): boolean;
  52600. /**
  52601. * Sets wether tonemapping is enabled or not
  52602. */
  52603. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): number;
  52610. /**
  52611. * The camera exposure used on this material.
  52612. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52613. * This corresponds to a photographic exposure.
  52614. */
  52615. set cameraExposure(value: number);
  52616. /**
  52617. * Gets The camera contrast used on this material.
  52618. */
  52619. get cameraContrast(): number;
  52620. /**
  52621. * Sets The camera contrast used on this material.
  52622. */
  52623. set cameraContrast(value: number);
  52624. /**
  52625. * Gets the Color Grading 2D Lookup Texture.
  52626. */
  52627. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52628. /**
  52629. * Sets the Color Grading 2D Lookup Texture.
  52630. */
  52631. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52632. /**
  52633. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52634. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52635. * 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;
  52636. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52637. */
  52638. get cameraColorCurves(): Nullable<ColorCurves>;
  52639. /**
  52640. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52641. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52642. * 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;
  52643. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52644. */
  52645. set cameraColorCurves(value: Nullable<ColorCurves>);
  52646. /**
  52647. * Instantiates a new PBRMaterial instance.
  52648. *
  52649. * @param name The material name
  52650. * @param scene The scene the material will be use in.
  52651. */
  52652. constructor(name: string, scene: Scene);
  52653. /**
  52654. * Returns the name of this material class.
  52655. */
  52656. getClassName(): string;
  52657. /**
  52658. * Makes a duplicate of the current material.
  52659. * @param name - name to use for the new material.
  52660. */
  52661. clone(name: string): PBRMaterial;
  52662. /**
  52663. * Serializes this PBR Material.
  52664. * @returns - An object with the serialized material.
  52665. */
  52666. serialize(): any;
  52667. /**
  52668. * Parses a PBR Material from a serialized object.
  52669. * @param source - Serialized object.
  52670. * @param scene - BJS scene instance.
  52671. * @param rootUrl - url for the scene object
  52672. * @returns - PBRMaterial
  52673. */
  52674. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52675. }
  52676. }
  52677. declare module BABYLON {
  52678. /**
  52679. * Direct draw surface info
  52680. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52681. */
  52682. export interface DDSInfo {
  52683. /**
  52684. * Width of the texture
  52685. */
  52686. width: number;
  52687. /**
  52688. * Width of the texture
  52689. */
  52690. height: number;
  52691. /**
  52692. * Number of Mipmaps for the texture
  52693. * @see https://en.wikipedia.org/wiki/Mipmap
  52694. */
  52695. mipmapCount: number;
  52696. /**
  52697. * If the textures format is a known fourCC format
  52698. * @see https://www.fourcc.org/
  52699. */
  52700. isFourCC: boolean;
  52701. /**
  52702. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52703. */
  52704. isRGB: boolean;
  52705. /**
  52706. * If the texture is a lumincance format
  52707. */
  52708. isLuminance: boolean;
  52709. /**
  52710. * If this is a cube texture
  52711. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52712. */
  52713. isCube: boolean;
  52714. /**
  52715. * If the texture is a compressed format eg. FOURCC_DXT1
  52716. */
  52717. isCompressed: boolean;
  52718. /**
  52719. * The dxgiFormat of the texture
  52720. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52721. */
  52722. dxgiFormat: number;
  52723. /**
  52724. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52725. */
  52726. textureType: number;
  52727. /**
  52728. * Sphericle polynomial created for the dds texture
  52729. */
  52730. sphericalPolynomial?: SphericalPolynomial;
  52731. }
  52732. /**
  52733. * Class used to provide DDS decompression tools
  52734. */
  52735. export class DDSTools {
  52736. /**
  52737. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52738. */
  52739. static StoreLODInAlphaChannel: boolean;
  52740. /**
  52741. * Gets DDS information from an array buffer
  52742. * @param data defines the array buffer view to read data from
  52743. * @returns the DDS information
  52744. */
  52745. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52746. private static _FloatView;
  52747. private static _Int32View;
  52748. private static _ToHalfFloat;
  52749. private static _FromHalfFloat;
  52750. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52751. private static _GetHalfFloatRGBAArrayBuffer;
  52752. private static _GetFloatRGBAArrayBuffer;
  52753. private static _GetFloatAsUIntRGBAArrayBuffer;
  52754. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52755. private static _GetRGBAArrayBuffer;
  52756. private static _ExtractLongWordOrder;
  52757. private static _GetRGBArrayBuffer;
  52758. private static _GetLuminanceArrayBuffer;
  52759. /**
  52760. * Uploads DDS Levels to a Babylon Texture
  52761. * @hidden
  52762. */
  52763. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52764. }
  52765. interface ThinEngine {
  52766. /**
  52767. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52768. * @param rootUrl defines the url where the file to load is located
  52769. * @param scene defines the current scene
  52770. * @param lodScale defines scale to apply to the mip map selection
  52771. * @param lodOffset defines offset to apply to the mip map selection
  52772. * @param onLoad defines an optional callback raised when the texture is loaded
  52773. * @param onError defines an optional callback raised if there is an issue to load the texture
  52774. * @param format defines the format of the data
  52775. * @param forcedExtension defines the extension to use to pick the right loader
  52776. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52777. * @returns the cube texture as an InternalTexture
  52778. */
  52779. 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;
  52780. }
  52781. }
  52782. declare module BABYLON {
  52783. /**
  52784. * Implementation of the DDS Texture Loader.
  52785. * @hidden
  52786. */
  52787. export class _DDSTextureLoader implements IInternalTextureLoader {
  52788. /**
  52789. * Defines wether the loader supports cascade loading the different faces.
  52790. */
  52791. readonly supportCascades: boolean;
  52792. /**
  52793. * This returns if the loader support the current file information.
  52794. * @param extension defines the file extension of the file being loaded
  52795. * @returns true if the loader can load the specified file
  52796. */
  52797. canLoad(extension: string): boolean;
  52798. /**
  52799. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52800. * @param data contains the texture data
  52801. * @param texture defines the BabylonJS internal texture
  52802. * @param createPolynomials will be true if polynomials have been requested
  52803. * @param onLoad defines the callback to trigger once the texture is ready
  52804. * @param onError defines the callback to trigger in case of error
  52805. */
  52806. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52807. /**
  52808. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52809. * @param data contains the texture data
  52810. * @param texture defines the BabylonJS internal texture
  52811. * @param callback defines the method to call once ready to upload
  52812. */
  52813. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52814. }
  52815. }
  52816. declare module BABYLON {
  52817. /**
  52818. * Implementation of the ENV Texture Loader.
  52819. * @hidden
  52820. */
  52821. export class _ENVTextureLoader implements IInternalTextureLoader {
  52822. /**
  52823. * Defines wether the loader supports cascade loading the different faces.
  52824. */
  52825. readonly supportCascades: boolean;
  52826. /**
  52827. * This returns if the loader support the current file information.
  52828. * @param extension defines the file extension of the file being loaded
  52829. * @returns true if the loader can load the specified file
  52830. */
  52831. canLoad(extension: string): boolean;
  52832. /**
  52833. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52834. * @param data contains the texture data
  52835. * @param texture defines the BabylonJS internal texture
  52836. * @param createPolynomials will be true if polynomials have been requested
  52837. * @param onLoad defines the callback to trigger once the texture is ready
  52838. * @param onError defines the callback to trigger in case of error
  52839. */
  52840. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52841. /**
  52842. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52843. * @param data contains the texture data
  52844. * @param texture defines the BabylonJS internal texture
  52845. * @param callback defines the method to call once ready to upload
  52846. */
  52847. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52848. }
  52849. }
  52850. declare module BABYLON {
  52851. /**
  52852. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52853. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52854. */
  52855. export class KhronosTextureContainer {
  52856. /** contents of the KTX container file */
  52857. data: ArrayBufferView;
  52858. private static HEADER_LEN;
  52859. private static COMPRESSED_2D;
  52860. private static COMPRESSED_3D;
  52861. private static TEX_2D;
  52862. private static TEX_3D;
  52863. /**
  52864. * Gets the openGL type
  52865. */
  52866. glType: number;
  52867. /**
  52868. * Gets the openGL type size
  52869. */
  52870. glTypeSize: number;
  52871. /**
  52872. * Gets the openGL format
  52873. */
  52874. glFormat: number;
  52875. /**
  52876. * Gets the openGL internal format
  52877. */
  52878. glInternalFormat: number;
  52879. /**
  52880. * Gets the base internal format
  52881. */
  52882. glBaseInternalFormat: number;
  52883. /**
  52884. * Gets image width in pixel
  52885. */
  52886. pixelWidth: number;
  52887. /**
  52888. * Gets image height in pixel
  52889. */
  52890. pixelHeight: number;
  52891. /**
  52892. * Gets image depth in pixels
  52893. */
  52894. pixelDepth: number;
  52895. /**
  52896. * Gets the number of array elements
  52897. */
  52898. numberOfArrayElements: number;
  52899. /**
  52900. * Gets the number of faces
  52901. */
  52902. numberOfFaces: number;
  52903. /**
  52904. * Gets the number of mipmap levels
  52905. */
  52906. numberOfMipmapLevels: number;
  52907. /**
  52908. * Gets the bytes of key value data
  52909. */
  52910. bytesOfKeyValueData: number;
  52911. /**
  52912. * Gets the load type
  52913. */
  52914. loadType: number;
  52915. /**
  52916. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52917. */
  52918. isInvalid: boolean;
  52919. /**
  52920. * Creates a new KhronosTextureContainer
  52921. * @param data contents of the KTX container file
  52922. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52923. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52924. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52925. */
  52926. constructor(
  52927. /** contents of the KTX container file */
  52928. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52929. /**
  52930. * Uploads KTX content to a Babylon Texture.
  52931. * It is assumed that the texture has already been created & is currently bound
  52932. * @hidden
  52933. */
  52934. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52935. private _upload2DCompressedLevels;
  52936. /**
  52937. * Checks if the given data starts with a KTX file identifier.
  52938. * @param data the data to check
  52939. * @returns true if the data is a KTX file or false otherwise
  52940. */
  52941. static IsValid(data: ArrayBufferView): boolean;
  52942. }
  52943. }
  52944. declare module BABYLON {
  52945. /**
  52946. * Class for loading KTX2 files
  52947. * !!! Experimental Extension Subject to Changes !!!
  52948. * @hidden
  52949. */
  52950. export class KhronosTextureContainer2 {
  52951. private static _ModulePromise;
  52952. private static _TranscodeFormat;
  52953. constructor(engine: ThinEngine);
  52954. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52955. private _determineTranscodeFormat;
  52956. /**
  52957. * Checks if the given data starts with a KTX2 file identifier.
  52958. * @param data the data to check
  52959. * @returns true if the data is a KTX2 file or false otherwise
  52960. */
  52961. static IsValid(data: ArrayBufferView): boolean;
  52962. }
  52963. }
  52964. declare module BABYLON {
  52965. /**
  52966. * Implementation of the KTX Texture Loader.
  52967. * @hidden
  52968. */
  52969. export class _KTXTextureLoader implements IInternalTextureLoader {
  52970. /**
  52971. * Defines wether the loader supports cascade loading the different faces.
  52972. */
  52973. readonly supportCascades: boolean;
  52974. /**
  52975. * This returns if the loader support the current file information.
  52976. * @param extension defines the file extension of the file being loaded
  52977. * @returns true if the loader can load the specified file
  52978. */
  52979. canLoad(extension: string): boolean;
  52980. /**
  52981. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52982. * @param data contains the texture data
  52983. * @param texture defines the BabylonJS internal texture
  52984. * @param createPolynomials will be true if polynomials have been requested
  52985. * @param onLoad defines the callback to trigger once the texture is ready
  52986. * @param onError defines the callback to trigger in case of error
  52987. */
  52988. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52989. /**
  52990. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52991. * @param data contains the texture data
  52992. * @param texture defines the BabylonJS internal texture
  52993. * @param callback defines the method to call once ready to upload
  52994. */
  52995. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52996. }
  52997. }
  52998. declare module BABYLON {
  52999. /** @hidden */
  53000. export var _forceSceneHelpersToBundle: boolean;
  53001. interface Scene {
  53002. /**
  53003. * Creates a default light for the scene.
  53004. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53005. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53006. */
  53007. createDefaultLight(replace?: boolean): void;
  53008. /**
  53009. * Creates a default camera for the scene.
  53010. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53011. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53012. * @param replace has default false, when true replaces the active camera in the scene
  53013. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53014. */
  53015. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53016. /**
  53017. * Creates a default camera and a default light.
  53018. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53019. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53020. * @param replace has the default false, when true replaces the active camera/light in the scene
  53021. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53022. */
  53023. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53024. /**
  53025. * Creates a new sky box
  53026. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53027. * @param environmentTexture defines the texture to use as environment texture
  53028. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53029. * @param scale defines the overall scale of the skybox
  53030. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53031. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53032. * @returns a new mesh holding the sky box
  53033. */
  53034. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53035. /**
  53036. * Creates a new environment
  53037. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53038. * @param options defines the options you can use to configure the environment
  53039. * @returns the new EnvironmentHelper
  53040. */
  53041. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53042. /**
  53043. * Creates a new VREXperienceHelper
  53044. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53045. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53046. * @returns a new VREXperienceHelper
  53047. */
  53048. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53049. /**
  53050. * Creates a new WebXRDefaultExperience
  53051. * @see http://doc.babylonjs.com/how_to/webxr
  53052. * @param options experience options
  53053. * @returns a promise for a new WebXRDefaultExperience
  53054. */
  53055. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53056. }
  53057. }
  53058. declare module BABYLON {
  53059. /**
  53060. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53061. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53062. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53063. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53064. */
  53065. export class VideoDome extends TransformNode {
  53066. /**
  53067. * Define the video source as a Monoscopic panoramic 360 video.
  53068. */
  53069. static readonly MODE_MONOSCOPIC: number;
  53070. /**
  53071. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53072. */
  53073. static readonly MODE_TOPBOTTOM: number;
  53074. /**
  53075. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53076. */
  53077. static readonly MODE_SIDEBYSIDE: number;
  53078. private _halfDome;
  53079. private _useDirectMapping;
  53080. /**
  53081. * The video texture being displayed on the sphere
  53082. */
  53083. protected _videoTexture: VideoTexture;
  53084. /**
  53085. * Gets the video texture being displayed on the sphere
  53086. */
  53087. get videoTexture(): VideoTexture;
  53088. /**
  53089. * The skybox material
  53090. */
  53091. protected _material: BackgroundMaterial;
  53092. /**
  53093. * The surface used for the skybox
  53094. */
  53095. protected _mesh: Mesh;
  53096. /**
  53097. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53098. */
  53099. private _halfDomeMask;
  53100. /**
  53101. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53102. * Also see the options.resolution property.
  53103. */
  53104. get fovMultiplier(): number;
  53105. set fovMultiplier(value: number);
  53106. private _videoMode;
  53107. /**
  53108. * Gets or set the current video mode for the video. It can be:
  53109. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53110. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53111. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53112. */
  53113. get videoMode(): number;
  53114. set videoMode(value: number);
  53115. /**
  53116. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53117. *
  53118. */
  53119. get halfDome(): boolean;
  53120. /**
  53121. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53122. */
  53123. set halfDome(enabled: boolean);
  53124. /**
  53125. * Oberserver used in Stereoscopic VR Mode.
  53126. */
  53127. private _onBeforeCameraRenderObserver;
  53128. /**
  53129. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53130. * @param name Element's name, child elements will append suffixes for their own names.
  53131. * @param urlsOrVideo defines the url(s) or the video element to use
  53132. * @param options An object containing optional or exposed sub element properties
  53133. */
  53134. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53135. resolution?: number;
  53136. clickToPlay?: boolean;
  53137. autoPlay?: boolean;
  53138. loop?: boolean;
  53139. size?: number;
  53140. poster?: string;
  53141. faceForward?: boolean;
  53142. useDirectMapping?: boolean;
  53143. halfDomeMode?: boolean;
  53144. }, scene: Scene);
  53145. private _changeVideoMode;
  53146. /**
  53147. * Releases resources associated with this node.
  53148. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53149. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53150. */
  53151. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53152. }
  53153. }
  53154. declare module BABYLON {
  53155. /**
  53156. * This class can be used to get instrumentation data from a Babylon engine
  53157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53158. */
  53159. export class EngineInstrumentation implements IDisposable {
  53160. /**
  53161. * Define the instrumented engine.
  53162. */
  53163. engine: Engine;
  53164. private _captureGPUFrameTime;
  53165. private _gpuFrameTimeToken;
  53166. private _gpuFrameTime;
  53167. private _captureShaderCompilationTime;
  53168. private _shaderCompilationTime;
  53169. private _onBeginFrameObserver;
  53170. private _onEndFrameObserver;
  53171. private _onBeforeShaderCompilationObserver;
  53172. private _onAfterShaderCompilationObserver;
  53173. /**
  53174. * Gets the perf counter used for GPU frame time
  53175. */
  53176. get gpuFrameTimeCounter(): PerfCounter;
  53177. /**
  53178. * Gets the GPU frame time capture status
  53179. */
  53180. get captureGPUFrameTime(): boolean;
  53181. /**
  53182. * Enable or disable the GPU frame time capture
  53183. */
  53184. set captureGPUFrameTime(value: boolean);
  53185. /**
  53186. * Gets the perf counter used for shader compilation time
  53187. */
  53188. get shaderCompilationTimeCounter(): PerfCounter;
  53189. /**
  53190. * Gets the shader compilation time capture status
  53191. */
  53192. get captureShaderCompilationTime(): boolean;
  53193. /**
  53194. * Enable or disable the shader compilation time capture
  53195. */
  53196. set captureShaderCompilationTime(value: boolean);
  53197. /**
  53198. * Instantiates a new engine instrumentation.
  53199. * This class can be used to get instrumentation data from a Babylon engine
  53200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53201. * @param engine Defines the engine to instrument
  53202. */
  53203. constructor(
  53204. /**
  53205. * Define the instrumented engine.
  53206. */
  53207. engine: Engine);
  53208. /**
  53209. * Dispose and release associated resources.
  53210. */
  53211. dispose(): void;
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * This class can be used to get instrumentation data from a Babylon engine
  53217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53218. */
  53219. export class SceneInstrumentation implements IDisposable {
  53220. /**
  53221. * Defines the scene to instrument
  53222. */
  53223. scene: Scene;
  53224. private _captureActiveMeshesEvaluationTime;
  53225. private _activeMeshesEvaluationTime;
  53226. private _captureRenderTargetsRenderTime;
  53227. private _renderTargetsRenderTime;
  53228. private _captureFrameTime;
  53229. private _frameTime;
  53230. private _captureRenderTime;
  53231. private _renderTime;
  53232. private _captureInterFrameTime;
  53233. private _interFrameTime;
  53234. private _captureParticlesRenderTime;
  53235. private _particlesRenderTime;
  53236. private _captureSpritesRenderTime;
  53237. private _spritesRenderTime;
  53238. private _capturePhysicsTime;
  53239. private _physicsTime;
  53240. private _captureAnimationsTime;
  53241. private _animationsTime;
  53242. private _captureCameraRenderTime;
  53243. private _cameraRenderTime;
  53244. private _onBeforeActiveMeshesEvaluationObserver;
  53245. private _onAfterActiveMeshesEvaluationObserver;
  53246. private _onBeforeRenderTargetsRenderObserver;
  53247. private _onAfterRenderTargetsRenderObserver;
  53248. private _onAfterRenderObserver;
  53249. private _onBeforeDrawPhaseObserver;
  53250. private _onAfterDrawPhaseObserver;
  53251. private _onBeforeAnimationsObserver;
  53252. private _onBeforeParticlesRenderingObserver;
  53253. private _onAfterParticlesRenderingObserver;
  53254. private _onBeforeSpritesRenderingObserver;
  53255. private _onAfterSpritesRenderingObserver;
  53256. private _onBeforePhysicsObserver;
  53257. private _onAfterPhysicsObserver;
  53258. private _onAfterAnimationsObserver;
  53259. private _onBeforeCameraRenderObserver;
  53260. private _onAfterCameraRenderObserver;
  53261. /**
  53262. * Gets the perf counter used for active meshes evaluation time
  53263. */
  53264. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53265. /**
  53266. * Gets the active meshes evaluation time capture status
  53267. */
  53268. get captureActiveMeshesEvaluationTime(): boolean;
  53269. /**
  53270. * Enable or disable the active meshes evaluation time capture
  53271. */
  53272. set captureActiveMeshesEvaluationTime(value: boolean);
  53273. /**
  53274. * Gets the perf counter used for render targets render time
  53275. */
  53276. get renderTargetsRenderTimeCounter(): PerfCounter;
  53277. /**
  53278. * Gets the render targets render time capture status
  53279. */
  53280. get captureRenderTargetsRenderTime(): boolean;
  53281. /**
  53282. * Enable or disable the render targets render time capture
  53283. */
  53284. set captureRenderTargetsRenderTime(value: boolean);
  53285. /**
  53286. * Gets the perf counter used for particles render time
  53287. */
  53288. get particlesRenderTimeCounter(): PerfCounter;
  53289. /**
  53290. * Gets the particles render time capture status
  53291. */
  53292. get captureParticlesRenderTime(): boolean;
  53293. /**
  53294. * Enable or disable the particles render time capture
  53295. */
  53296. set captureParticlesRenderTime(value: boolean);
  53297. /**
  53298. * Gets the perf counter used for sprites render time
  53299. */
  53300. get spritesRenderTimeCounter(): PerfCounter;
  53301. /**
  53302. * Gets the sprites render time capture status
  53303. */
  53304. get captureSpritesRenderTime(): boolean;
  53305. /**
  53306. * Enable or disable the sprites render time capture
  53307. */
  53308. set captureSpritesRenderTime(value: boolean);
  53309. /**
  53310. * Gets the perf counter used for physics time
  53311. */
  53312. get physicsTimeCounter(): PerfCounter;
  53313. /**
  53314. * Gets the physics time capture status
  53315. */
  53316. get capturePhysicsTime(): boolean;
  53317. /**
  53318. * Enable or disable the physics time capture
  53319. */
  53320. set capturePhysicsTime(value: boolean);
  53321. /**
  53322. * Gets the perf counter used for animations time
  53323. */
  53324. get animationsTimeCounter(): PerfCounter;
  53325. /**
  53326. * Gets the animations time capture status
  53327. */
  53328. get captureAnimationsTime(): boolean;
  53329. /**
  53330. * Enable or disable the animations time capture
  53331. */
  53332. set captureAnimationsTime(value: boolean);
  53333. /**
  53334. * Gets the perf counter used for frame time capture
  53335. */
  53336. get frameTimeCounter(): PerfCounter;
  53337. /**
  53338. * Gets the frame time capture status
  53339. */
  53340. get captureFrameTime(): boolean;
  53341. /**
  53342. * Enable or disable the frame time capture
  53343. */
  53344. set captureFrameTime(value: boolean);
  53345. /**
  53346. * Gets the perf counter used for inter-frames time capture
  53347. */
  53348. get interFrameTimeCounter(): PerfCounter;
  53349. /**
  53350. * Gets the inter-frames time capture status
  53351. */
  53352. get captureInterFrameTime(): boolean;
  53353. /**
  53354. * Enable or disable the inter-frames time capture
  53355. */
  53356. set captureInterFrameTime(value: boolean);
  53357. /**
  53358. * Gets the perf counter used for render time capture
  53359. */
  53360. get renderTimeCounter(): PerfCounter;
  53361. /**
  53362. * Gets the render time capture status
  53363. */
  53364. get captureRenderTime(): boolean;
  53365. /**
  53366. * Enable or disable the render time capture
  53367. */
  53368. set captureRenderTime(value: boolean);
  53369. /**
  53370. * Gets the perf counter used for camera render time capture
  53371. */
  53372. get cameraRenderTimeCounter(): PerfCounter;
  53373. /**
  53374. * Gets the camera render time capture status
  53375. */
  53376. get captureCameraRenderTime(): boolean;
  53377. /**
  53378. * Enable or disable the camera render time capture
  53379. */
  53380. set captureCameraRenderTime(value: boolean);
  53381. /**
  53382. * Gets the perf counter used for draw calls
  53383. */
  53384. get drawCallsCounter(): PerfCounter;
  53385. /**
  53386. * Instantiates a new scene instrumentation.
  53387. * This class can be used to get instrumentation data from a Babylon engine
  53388. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53389. * @param scene Defines the scene to instrument
  53390. */
  53391. constructor(
  53392. /**
  53393. * Defines the scene to instrument
  53394. */
  53395. scene: Scene);
  53396. /**
  53397. * Dispose and release associated resources.
  53398. */
  53399. dispose(): void;
  53400. }
  53401. }
  53402. declare module BABYLON {
  53403. /** @hidden */
  53404. export var glowMapGenerationPixelShader: {
  53405. name: string;
  53406. shader: string;
  53407. };
  53408. }
  53409. declare module BABYLON {
  53410. /** @hidden */
  53411. export var glowMapGenerationVertexShader: {
  53412. name: string;
  53413. shader: string;
  53414. };
  53415. }
  53416. declare module BABYLON {
  53417. /**
  53418. * Effect layer options. This helps customizing the behaviour
  53419. * of the effect layer.
  53420. */
  53421. export interface IEffectLayerOptions {
  53422. /**
  53423. * Multiplication factor apply to the canvas size to compute the render target size
  53424. * used to generated the objects (the smaller the faster).
  53425. */
  53426. mainTextureRatio: number;
  53427. /**
  53428. * Enforces a fixed size texture to ensure effect stability across devices.
  53429. */
  53430. mainTextureFixedSize?: number;
  53431. /**
  53432. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53433. */
  53434. alphaBlendingMode: number;
  53435. /**
  53436. * The camera attached to the layer.
  53437. */
  53438. camera: Nullable<Camera>;
  53439. /**
  53440. * The rendering group to draw the layer in.
  53441. */
  53442. renderingGroupId: number;
  53443. }
  53444. /**
  53445. * The effect layer Helps adding post process effect blended with the main pass.
  53446. *
  53447. * This can be for instance use to generate glow or higlight effects on the scene.
  53448. *
  53449. * The effect layer class can not be used directly and is intented to inherited from to be
  53450. * customized per effects.
  53451. */
  53452. export abstract class EffectLayer {
  53453. private _vertexBuffers;
  53454. private _indexBuffer;
  53455. private _cachedDefines;
  53456. private _effectLayerMapGenerationEffect;
  53457. private _effectLayerOptions;
  53458. private _mergeEffect;
  53459. protected _scene: Scene;
  53460. protected _engine: Engine;
  53461. protected _maxSize: number;
  53462. protected _mainTextureDesiredSize: ISize;
  53463. protected _mainTexture: RenderTargetTexture;
  53464. protected _shouldRender: boolean;
  53465. protected _postProcesses: PostProcess[];
  53466. protected _textures: BaseTexture[];
  53467. protected _emissiveTextureAndColor: {
  53468. texture: Nullable<BaseTexture>;
  53469. color: Color4;
  53470. };
  53471. /**
  53472. * The name of the layer
  53473. */
  53474. name: string;
  53475. /**
  53476. * The clear color of the texture used to generate the glow map.
  53477. */
  53478. neutralColor: Color4;
  53479. /**
  53480. * Specifies whether the highlight layer is enabled or not.
  53481. */
  53482. isEnabled: boolean;
  53483. /**
  53484. * Gets the camera attached to the layer.
  53485. */
  53486. get camera(): Nullable<Camera>;
  53487. /**
  53488. * Gets the rendering group id the layer should render in.
  53489. */
  53490. get renderingGroupId(): number;
  53491. set renderingGroupId(renderingGroupId: number);
  53492. /**
  53493. * An event triggered when the effect layer has been disposed.
  53494. */
  53495. onDisposeObservable: Observable<EffectLayer>;
  53496. /**
  53497. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53498. */
  53499. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53500. /**
  53501. * An event triggered when the generated texture is being merged in the scene.
  53502. */
  53503. onBeforeComposeObservable: Observable<EffectLayer>;
  53504. /**
  53505. * An event triggered when the mesh is rendered into the effect render target.
  53506. */
  53507. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53508. /**
  53509. * An event triggered after the mesh has been rendered into the effect render target.
  53510. */
  53511. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53512. /**
  53513. * An event triggered when the generated texture has been merged in the scene.
  53514. */
  53515. onAfterComposeObservable: Observable<EffectLayer>;
  53516. /**
  53517. * An event triggered when the efffect layer changes its size.
  53518. */
  53519. onSizeChangedObservable: Observable<EffectLayer>;
  53520. /** @hidden */
  53521. static _SceneComponentInitialization: (scene: Scene) => void;
  53522. /**
  53523. * Instantiates a new effect Layer and references it in the scene.
  53524. * @param name The name of the layer
  53525. * @param scene The scene to use the layer in
  53526. */
  53527. constructor(
  53528. /** The Friendly of the effect in the scene */
  53529. name: string, scene: Scene);
  53530. /**
  53531. * Get the effect name of the layer.
  53532. * @return The effect name
  53533. */
  53534. abstract getEffectName(): string;
  53535. /**
  53536. * Checks for the readiness of the element composing the layer.
  53537. * @param subMesh the mesh to check for
  53538. * @param useInstances specify whether or not to use instances to render the mesh
  53539. * @return true if ready otherwise, false
  53540. */
  53541. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53542. /**
  53543. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53544. * @returns true if the effect requires stencil during the main canvas render pass.
  53545. */
  53546. abstract needStencil(): boolean;
  53547. /**
  53548. * Create the merge effect. This is the shader use to blit the information back
  53549. * to the main canvas at the end of the scene rendering.
  53550. * @returns The effect containing the shader used to merge the effect on the main canvas
  53551. */
  53552. protected abstract _createMergeEffect(): Effect;
  53553. /**
  53554. * Creates the render target textures and post processes used in the effect layer.
  53555. */
  53556. protected abstract _createTextureAndPostProcesses(): void;
  53557. /**
  53558. * Implementation specific of rendering the generating effect on the main canvas.
  53559. * @param effect The effect used to render through
  53560. */
  53561. protected abstract _internalRender(effect: Effect): void;
  53562. /**
  53563. * Sets the required values for both the emissive texture and and the main color.
  53564. */
  53565. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53566. /**
  53567. * Free any resources and references associated to a mesh.
  53568. * Internal use
  53569. * @param mesh The mesh to free.
  53570. */
  53571. abstract _disposeMesh(mesh: Mesh): void;
  53572. /**
  53573. * Serializes this layer (Glow or Highlight for example)
  53574. * @returns a serialized layer object
  53575. */
  53576. abstract serialize?(): any;
  53577. /**
  53578. * Initializes the effect layer with the required options.
  53579. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53580. */
  53581. protected _init(options: Partial<IEffectLayerOptions>): void;
  53582. /**
  53583. * Generates the index buffer of the full screen quad blending to the main canvas.
  53584. */
  53585. private _generateIndexBuffer;
  53586. /**
  53587. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53588. */
  53589. private _generateVertexBuffer;
  53590. /**
  53591. * Sets the main texture desired size which is the closest power of two
  53592. * of the engine canvas size.
  53593. */
  53594. private _setMainTextureSize;
  53595. /**
  53596. * Creates the main texture for the effect layer.
  53597. */
  53598. protected _createMainTexture(): void;
  53599. /**
  53600. * Adds specific effects defines.
  53601. * @param defines The defines to add specifics to.
  53602. */
  53603. protected _addCustomEffectDefines(defines: string[]): void;
  53604. /**
  53605. * Checks for the readiness of the element composing the layer.
  53606. * @param subMesh the mesh to check for
  53607. * @param useInstances specify whether or not to use instances to render the mesh
  53608. * @param emissiveTexture the associated emissive texture used to generate the glow
  53609. * @return true if ready otherwise, false
  53610. */
  53611. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53612. /**
  53613. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53614. */
  53615. render(): void;
  53616. /**
  53617. * Determine if a given mesh will be used in the current effect.
  53618. * @param mesh mesh to test
  53619. * @returns true if the mesh will be used
  53620. */
  53621. hasMesh(mesh: AbstractMesh): boolean;
  53622. /**
  53623. * Returns true if the layer contains information to display, otherwise false.
  53624. * @returns true if the glow layer should be rendered
  53625. */
  53626. shouldRender(): boolean;
  53627. /**
  53628. * Returns true if the mesh should render, otherwise false.
  53629. * @param mesh The mesh to render
  53630. * @returns true if it should render otherwise false
  53631. */
  53632. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53633. /**
  53634. * Returns true if the mesh can be rendered, otherwise false.
  53635. * @param mesh The mesh to render
  53636. * @param material The material used on the mesh
  53637. * @returns true if it can be rendered otherwise false
  53638. */
  53639. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53640. /**
  53641. * Returns true if the mesh should render, otherwise false.
  53642. * @param mesh The mesh to render
  53643. * @returns true if it should render otherwise false
  53644. */
  53645. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53646. /**
  53647. * Renders the submesh passed in parameter to the generation map.
  53648. */
  53649. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53650. /**
  53651. * Defines whether the current material of the mesh should be use to render the effect.
  53652. * @param mesh defines the current mesh to render
  53653. */
  53654. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53655. /**
  53656. * Rebuild the required buffers.
  53657. * @hidden Internal use only.
  53658. */
  53659. _rebuild(): void;
  53660. /**
  53661. * Dispose only the render target textures and post process.
  53662. */
  53663. private _disposeTextureAndPostProcesses;
  53664. /**
  53665. * Dispose the highlight layer and free resources.
  53666. */
  53667. dispose(): void;
  53668. /**
  53669. * Gets the class name of the effect layer
  53670. * @returns the string with the class name of the effect layer
  53671. */
  53672. getClassName(): string;
  53673. /**
  53674. * Creates an effect layer from parsed effect layer data
  53675. * @param parsedEffectLayer defines effect layer data
  53676. * @param scene defines the current scene
  53677. * @param rootUrl defines the root URL containing the effect layer information
  53678. * @returns a parsed effect Layer
  53679. */
  53680. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53681. }
  53682. }
  53683. declare module BABYLON {
  53684. interface AbstractScene {
  53685. /**
  53686. * The list of effect layers (highlights/glow) added to the scene
  53687. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53688. * @see http://doc.babylonjs.com/how_to/glow_layer
  53689. */
  53690. effectLayers: Array<EffectLayer>;
  53691. /**
  53692. * Removes the given effect layer from this scene.
  53693. * @param toRemove defines the effect layer to remove
  53694. * @returns the index of the removed effect layer
  53695. */
  53696. removeEffectLayer(toRemove: EffectLayer): number;
  53697. /**
  53698. * Adds the given effect layer to this scene
  53699. * @param newEffectLayer defines the effect layer to add
  53700. */
  53701. addEffectLayer(newEffectLayer: EffectLayer): void;
  53702. }
  53703. /**
  53704. * Defines the layer scene component responsible to manage any effect layers
  53705. * in a given scene.
  53706. */
  53707. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53708. /**
  53709. * The component name helpfull to identify the component in the list of scene components.
  53710. */
  53711. readonly name: string;
  53712. /**
  53713. * The scene the component belongs to.
  53714. */
  53715. scene: Scene;
  53716. private _engine;
  53717. private _renderEffects;
  53718. private _needStencil;
  53719. private _previousStencilState;
  53720. /**
  53721. * Creates a new instance of the component for the given scene
  53722. * @param scene Defines the scene to register the component in
  53723. */
  53724. constructor(scene: Scene);
  53725. /**
  53726. * Registers the component in a given scene
  53727. */
  53728. register(): void;
  53729. /**
  53730. * Rebuilds the elements related to this component in case of
  53731. * context lost for instance.
  53732. */
  53733. rebuild(): void;
  53734. /**
  53735. * Serializes the component data to the specified json object
  53736. * @param serializationObject The object to serialize to
  53737. */
  53738. serialize(serializationObject: any): void;
  53739. /**
  53740. * Adds all the elements from the container to the scene
  53741. * @param container the container holding the elements
  53742. */
  53743. addFromContainer(container: AbstractScene): void;
  53744. /**
  53745. * Removes all the elements in the container from the scene
  53746. * @param container contains the elements to remove
  53747. * @param dispose if the removed element should be disposed (default: false)
  53748. */
  53749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53750. /**
  53751. * Disposes the component and the associated ressources.
  53752. */
  53753. dispose(): void;
  53754. private _isReadyForMesh;
  53755. private _renderMainTexture;
  53756. private _setStencil;
  53757. private _setStencilBack;
  53758. private _draw;
  53759. private _drawCamera;
  53760. private _drawRenderingGroup;
  53761. }
  53762. }
  53763. declare module BABYLON {
  53764. /** @hidden */
  53765. export var glowMapMergePixelShader: {
  53766. name: string;
  53767. shader: string;
  53768. };
  53769. }
  53770. declare module BABYLON {
  53771. /** @hidden */
  53772. export var glowMapMergeVertexShader: {
  53773. name: string;
  53774. shader: string;
  53775. };
  53776. }
  53777. declare module BABYLON {
  53778. interface AbstractScene {
  53779. /**
  53780. * Return a the first highlight layer of the scene with a given name.
  53781. * @param name The name of the highlight layer to look for.
  53782. * @return The highlight layer if found otherwise null.
  53783. */
  53784. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53785. }
  53786. /**
  53787. * Glow layer options. This helps customizing the behaviour
  53788. * of the glow layer.
  53789. */
  53790. export interface IGlowLayerOptions {
  53791. /**
  53792. * Multiplication factor apply to the canvas size to compute the render target size
  53793. * used to generated the glowing objects (the smaller the faster).
  53794. */
  53795. mainTextureRatio: number;
  53796. /**
  53797. * Enforces a fixed size texture to ensure resize independant blur.
  53798. */
  53799. mainTextureFixedSize?: number;
  53800. /**
  53801. * How big is the kernel of the blur texture.
  53802. */
  53803. blurKernelSize: number;
  53804. /**
  53805. * The camera attached to the layer.
  53806. */
  53807. camera: Nullable<Camera>;
  53808. /**
  53809. * Enable MSAA by chosing the number of samples.
  53810. */
  53811. mainTextureSamples?: number;
  53812. /**
  53813. * The rendering group to draw the layer in.
  53814. */
  53815. renderingGroupId: number;
  53816. }
  53817. /**
  53818. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53819. *
  53820. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53821. *
  53822. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53823. */
  53824. export class GlowLayer extends EffectLayer {
  53825. /**
  53826. * Effect Name of the layer.
  53827. */
  53828. static readonly EffectName: string;
  53829. /**
  53830. * The default blur kernel size used for the glow.
  53831. */
  53832. static DefaultBlurKernelSize: number;
  53833. /**
  53834. * The default texture size ratio used for the glow.
  53835. */
  53836. static DefaultTextureRatio: number;
  53837. /**
  53838. * Sets the kernel size of the blur.
  53839. */
  53840. set blurKernelSize(value: number);
  53841. /**
  53842. * Gets the kernel size of the blur.
  53843. */
  53844. get blurKernelSize(): number;
  53845. /**
  53846. * Sets the glow intensity.
  53847. */
  53848. set intensity(value: number);
  53849. /**
  53850. * Gets the glow intensity.
  53851. */
  53852. get intensity(): number;
  53853. private _options;
  53854. private _intensity;
  53855. private _horizontalBlurPostprocess1;
  53856. private _verticalBlurPostprocess1;
  53857. private _horizontalBlurPostprocess2;
  53858. private _verticalBlurPostprocess2;
  53859. private _blurTexture1;
  53860. private _blurTexture2;
  53861. private _postProcesses1;
  53862. private _postProcesses2;
  53863. private _includedOnlyMeshes;
  53864. private _excludedMeshes;
  53865. private _meshesUsingTheirOwnMaterials;
  53866. /**
  53867. * Callback used to let the user override the color selection on a per mesh basis
  53868. */
  53869. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53870. /**
  53871. * Callback used to let the user override the texture selection on a per mesh basis
  53872. */
  53873. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53874. /**
  53875. * Instantiates a new glow Layer and references it to the scene.
  53876. * @param name The name of the layer
  53877. * @param scene The scene to use the layer in
  53878. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53879. */
  53880. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53881. /**
  53882. * Get the effect name of the layer.
  53883. * @return The effect name
  53884. */
  53885. getEffectName(): string;
  53886. /**
  53887. * Create the merge effect. This is the shader use to blit the information back
  53888. * to the main canvas at the end of the scene rendering.
  53889. */
  53890. protected _createMergeEffect(): Effect;
  53891. /**
  53892. * Creates the render target textures and post processes used in the glow layer.
  53893. */
  53894. protected _createTextureAndPostProcesses(): void;
  53895. /**
  53896. * Checks for the readiness of the element composing the layer.
  53897. * @param subMesh the mesh to check for
  53898. * @param useInstances specify wether or not to use instances to render the mesh
  53899. * @param emissiveTexture the associated emissive texture used to generate the glow
  53900. * @return true if ready otherwise, false
  53901. */
  53902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53903. /**
  53904. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53905. */
  53906. needStencil(): boolean;
  53907. /**
  53908. * Returns true if the mesh can be rendered, otherwise false.
  53909. * @param mesh The mesh to render
  53910. * @param material The material used on the mesh
  53911. * @returns true if it can be rendered otherwise false
  53912. */
  53913. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53914. /**
  53915. * Implementation specific of rendering the generating effect on the main canvas.
  53916. * @param effect The effect used to render through
  53917. */
  53918. protected _internalRender(effect: Effect): void;
  53919. /**
  53920. * Sets the required values for both the emissive texture and and the main color.
  53921. */
  53922. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53923. /**
  53924. * Returns true if the mesh should render, otherwise false.
  53925. * @param mesh The mesh to render
  53926. * @returns true if it should render otherwise false
  53927. */
  53928. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53929. /**
  53930. * Adds specific effects defines.
  53931. * @param defines The defines to add specifics to.
  53932. */
  53933. protected _addCustomEffectDefines(defines: string[]): void;
  53934. /**
  53935. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53936. * @param mesh The mesh to exclude from the glow layer
  53937. */
  53938. addExcludedMesh(mesh: Mesh): void;
  53939. /**
  53940. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53941. * @param mesh The mesh to remove
  53942. */
  53943. removeExcludedMesh(mesh: Mesh): void;
  53944. /**
  53945. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53946. * @param mesh The mesh to include in the glow layer
  53947. */
  53948. addIncludedOnlyMesh(mesh: Mesh): void;
  53949. /**
  53950. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53951. * @param mesh The mesh to remove
  53952. */
  53953. removeIncludedOnlyMesh(mesh: Mesh): void;
  53954. /**
  53955. * Determine if a given mesh will be used in the glow layer
  53956. * @param mesh The mesh to test
  53957. * @returns true if the mesh will be highlighted by the current glow layer
  53958. */
  53959. hasMesh(mesh: AbstractMesh): boolean;
  53960. /**
  53961. * Defines whether the current material of the mesh should be use to render the effect.
  53962. * @param mesh defines the current mesh to render
  53963. */
  53964. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53965. /**
  53966. * Add a mesh to be rendered through its own material and not with emissive only.
  53967. * @param mesh The mesh for which we need to use its material
  53968. */
  53969. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53970. /**
  53971. * Remove a mesh from being rendered through its own material and not with emissive only.
  53972. * @param mesh The mesh for which we need to not use its material
  53973. */
  53974. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53975. /**
  53976. * Free any resources and references associated to a mesh.
  53977. * Internal use
  53978. * @param mesh The mesh to free.
  53979. * @hidden
  53980. */
  53981. _disposeMesh(mesh: Mesh): void;
  53982. /**
  53983. * Gets the class name of the effect layer
  53984. * @returns the string with the class name of the effect layer
  53985. */
  53986. getClassName(): string;
  53987. /**
  53988. * Serializes this glow layer
  53989. * @returns a serialized glow layer object
  53990. */
  53991. serialize(): any;
  53992. /**
  53993. * Creates a Glow Layer from parsed glow layer data
  53994. * @param parsedGlowLayer defines glow layer data
  53995. * @param scene defines the current scene
  53996. * @param rootUrl defines the root URL containing the glow layer information
  53997. * @returns a parsed Glow Layer
  53998. */
  53999. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54000. }
  54001. }
  54002. declare module BABYLON {
  54003. /** @hidden */
  54004. export var glowBlurPostProcessPixelShader: {
  54005. name: string;
  54006. shader: string;
  54007. };
  54008. }
  54009. declare module BABYLON {
  54010. interface AbstractScene {
  54011. /**
  54012. * Return a the first highlight layer of the scene with a given name.
  54013. * @param name The name of the highlight layer to look for.
  54014. * @return The highlight layer if found otherwise null.
  54015. */
  54016. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54017. }
  54018. /**
  54019. * Highlight layer options. This helps customizing the behaviour
  54020. * of the highlight layer.
  54021. */
  54022. export interface IHighlightLayerOptions {
  54023. /**
  54024. * Multiplication factor apply to the canvas size to compute the render target size
  54025. * used to generated the glowing objects (the smaller the faster).
  54026. */
  54027. mainTextureRatio: number;
  54028. /**
  54029. * Enforces a fixed size texture to ensure resize independant blur.
  54030. */
  54031. mainTextureFixedSize?: number;
  54032. /**
  54033. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54034. * of the picture to blur (the smaller the faster).
  54035. */
  54036. blurTextureSizeRatio: number;
  54037. /**
  54038. * How big in texel of the blur texture is the vertical blur.
  54039. */
  54040. blurVerticalSize: number;
  54041. /**
  54042. * How big in texel of the blur texture is the horizontal blur.
  54043. */
  54044. blurHorizontalSize: number;
  54045. /**
  54046. * Alpha blending mode used to apply the blur. Default is combine.
  54047. */
  54048. alphaBlendingMode: number;
  54049. /**
  54050. * The camera attached to the layer.
  54051. */
  54052. camera: Nullable<Camera>;
  54053. /**
  54054. * Should we display highlight as a solid stroke?
  54055. */
  54056. isStroke?: boolean;
  54057. /**
  54058. * The rendering group to draw the layer in.
  54059. */
  54060. renderingGroupId: number;
  54061. }
  54062. /**
  54063. * The highlight layer Helps adding a glow effect around a mesh.
  54064. *
  54065. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54066. * glowy meshes to your scene.
  54067. *
  54068. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54069. */
  54070. export class HighlightLayer extends EffectLayer {
  54071. name: string;
  54072. /**
  54073. * Effect Name of the highlight layer.
  54074. */
  54075. static readonly EffectName: string;
  54076. /**
  54077. * The neutral color used during the preparation of the glow effect.
  54078. * This is black by default as the blend operation is a blend operation.
  54079. */
  54080. static NeutralColor: Color4;
  54081. /**
  54082. * Stencil value used for glowing meshes.
  54083. */
  54084. static GlowingMeshStencilReference: number;
  54085. /**
  54086. * Stencil value used for the other meshes in the scene.
  54087. */
  54088. static NormalMeshStencilReference: number;
  54089. /**
  54090. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54091. */
  54092. innerGlow: boolean;
  54093. /**
  54094. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54095. */
  54096. outerGlow: boolean;
  54097. /**
  54098. * Specifies the horizontal size of the blur.
  54099. */
  54100. set blurHorizontalSize(value: number);
  54101. /**
  54102. * Specifies the vertical size of the blur.
  54103. */
  54104. set blurVerticalSize(value: number);
  54105. /**
  54106. * Gets the horizontal size of the blur.
  54107. */
  54108. get blurHorizontalSize(): number;
  54109. /**
  54110. * Gets the vertical size of the blur.
  54111. */
  54112. get blurVerticalSize(): number;
  54113. /**
  54114. * An event triggered when the highlight layer is being blurred.
  54115. */
  54116. onBeforeBlurObservable: Observable<HighlightLayer>;
  54117. /**
  54118. * An event triggered when the highlight layer has been blurred.
  54119. */
  54120. onAfterBlurObservable: Observable<HighlightLayer>;
  54121. private _instanceGlowingMeshStencilReference;
  54122. private _options;
  54123. private _downSamplePostprocess;
  54124. private _horizontalBlurPostprocess;
  54125. private _verticalBlurPostprocess;
  54126. private _blurTexture;
  54127. private _meshes;
  54128. private _excludedMeshes;
  54129. /**
  54130. * Instantiates a new highlight Layer and references it to the scene..
  54131. * @param name The name of the layer
  54132. * @param scene The scene to use the layer in
  54133. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54134. */
  54135. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54136. /**
  54137. * Get the effect name of the layer.
  54138. * @return The effect name
  54139. */
  54140. getEffectName(): string;
  54141. /**
  54142. * Create the merge effect. This is the shader use to blit the information back
  54143. * to the main canvas at the end of the scene rendering.
  54144. */
  54145. protected _createMergeEffect(): Effect;
  54146. /**
  54147. * Creates the render target textures and post processes used in the highlight layer.
  54148. */
  54149. protected _createTextureAndPostProcesses(): void;
  54150. /**
  54151. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54152. */
  54153. needStencil(): boolean;
  54154. /**
  54155. * Checks for the readiness of the element composing the layer.
  54156. * @param subMesh the mesh to check for
  54157. * @param useInstances specify wether or not to use instances to render the mesh
  54158. * @param emissiveTexture the associated emissive texture used to generate the glow
  54159. * @return true if ready otherwise, false
  54160. */
  54161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54162. /**
  54163. * Implementation specific of rendering the generating effect on the main canvas.
  54164. * @param effect The effect used to render through
  54165. */
  54166. protected _internalRender(effect: Effect): void;
  54167. /**
  54168. * Returns true if the layer contains information to display, otherwise false.
  54169. */
  54170. shouldRender(): boolean;
  54171. /**
  54172. * Returns true if the mesh should render, otherwise false.
  54173. * @param mesh The mesh to render
  54174. * @returns true if it should render otherwise false
  54175. */
  54176. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54177. /**
  54178. * Adds specific effects defines.
  54179. * @param defines The defines to add specifics to.
  54180. */
  54181. protected _addCustomEffectDefines(defines: string[]): void;
  54182. /**
  54183. * Sets the required values for both the emissive texture and and the main color.
  54184. */
  54185. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54186. /**
  54187. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54188. * @param mesh The mesh to exclude from the highlight layer
  54189. */
  54190. addExcludedMesh(mesh: Mesh): void;
  54191. /**
  54192. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54193. * @param mesh The mesh to highlight
  54194. */
  54195. removeExcludedMesh(mesh: Mesh): void;
  54196. /**
  54197. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54198. * @param mesh mesh to test
  54199. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54200. */
  54201. hasMesh(mesh: AbstractMesh): boolean;
  54202. /**
  54203. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54204. * @param mesh The mesh to highlight
  54205. * @param color The color of the highlight
  54206. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54207. */
  54208. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54209. /**
  54210. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54211. * @param mesh The mesh to highlight
  54212. */
  54213. removeMesh(mesh: Mesh): void;
  54214. /**
  54215. * Remove all the meshes currently referenced in the highlight layer
  54216. */
  54217. removeAllMeshes(): void;
  54218. /**
  54219. * Force the stencil to the normal expected value for none glowing parts
  54220. */
  54221. private _defaultStencilReference;
  54222. /**
  54223. * Free any resources and references associated to a mesh.
  54224. * Internal use
  54225. * @param mesh The mesh to free.
  54226. * @hidden
  54227. */
  54228. _disposeMesh(mesh: Mesh): void;
  54229. /**
  54230. * Dispose the highlight layer and free resources.
  54231. */
  54232. dispose(): void;
  54233. /**
  54234. * Gets the class name of the effect layer
  54235. * @returns the string with the class name of the effect layer
  54236. */
  54237. getClassName(): string;
  54238. /**
  54239. * Serializes this Highlight layer
  54240. * @returns a serialized Highlight layer object
  54241. */
  54242. serialize(): any;
  54243. /**
  54244. * Creates a Highlight layer from parsed Highlight layer data
  54245. * @param parsedHightlightLayer defines the Highlight layer data
  54246. * @param scene defines the current scene
  54247. * @param rootUrl defines the root URL containing the Highlight layer information
  54248. * @returns a parsed Highlight layer
  54249. */
  54250. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54251. }
  54252. }
  54253. declare module BABYLON {
  54254. interface AbstractScene {
  54255. /**
  54256. * The list of layers (background and foreground) of the scene
  54257. */
  54258. layers: Array<Layer>;
  54259. }
  54260. /**
  54261. * Defines the layer scene component responsible to manage any layers
  54262. * in a given scene.
  54263. */
  54264. export class LayerSceneComponent implements ISceneComponent {
  54265. /**
  54266. * The component name helpfull to identify the component in the list of scene components.
  54267. */
  54268. readonly name: string;
  54269. /**
  54270. * The scene the component belongs to.
  54271. */
  54272. scene: Scene;
  54273. private _engine;
  54274. /**
  54275. * Creates a new instance of the component for the given scene
  54276. * @param scene Defines the scene to register the component in
  54277. */
  54278. constructor(scene: Scene);
  54279. /**
  54280. * Registers the component in a given scene
  54281. */
  54282. register(): void;
  54283. /**
  54284. * Rebuilds the elements related to this component in case of
  54285. * context lost for instance.
  54286. */
  54287. rebuild(): void;
  54288. /**
  54289. * Disposes the component and the associated ressources.
  54290. */
  54291. dispose(): void;
  54292. private _draw;
  54293. private _drawCameraPredicate;
  54294. private _drawCameraBackground;
  54295. private _drawCameraForeground;
  54296. private _drawRenderTargetPredicate;
  54297. private _drawRenderTargetBackground;
  54298. private _drawRenderTargetForeground;
  54299. /**
  54300. * Adds all the elements from the container to the scene
  54301. * @param container the container holding the elements
  54302. */
  54303. addFromContainer(container: AbstractScene): void;
  54304. /**
  54305. * Removes all the elements in the container from the scene
  54306. * @param container contains the elements to remove
  54307. * @param dispose if the removed element should be disposed (default: false)
  54308. */
  54309. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54310. }
  54311. }
  54312. declare module BABYLON {
  54313. /** @hidden */
  54314. export var layerPixelShader: {
  54315. name: string;
  54316. shader: string;
  54317. };
  54318. }
  54319. declare module BABYLON {
  54320. /** @hidden */
  54321. export var layerVertexShader: {
  54322. name: string;
  54323. shader: string;
  54324. };
  54325. }
  54326. declare module BABYLON {
  54327. /**
  54328. * This represents a full screen 2d layer.
  54329. * This can be useful to display a picture in the background of your scene for instance.
  54330. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54331. */
  54332. export class Layer {
  54333. /**
  54334. * Define the name of the layer.
  54335. */
  54336. name: string;
  54337. /**
  54338. * Define the texture the layer should display.
  54339. */
  54340. texture: Nullable<Texture>;
  54341. /**
  54342. * Is the layer in background or foreground.
  54343. */
  54344. isBackground: boolean;
  54345. /**
  54346. * Define the color of the layer (instead of texture).
  54347. */
  54348. color: Color4;
  54349. /**
  54350. * Define the scale of the layer in order to zoom in out of the texture.
  54351. */
  54352. scale: Vector2;
  54353. /**
  54354. * Define an offset for the layer in order to shift the texture.
  54355. */
  54356. offset: Vector2;
  54357. /**
  54358. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54359. */
  54360. alphaBlendingMode: number;
  54361. /**
  54362. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54363. * Alpha test will not mix with the background color in case of transparency.
  54364. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54365. */
  54366. alphaTest: boolean;
  54367. /**
  54368. * Define a mask to restrict the layer to only some of the scene cameras.
  54369. */
  54370. layerMask: number;
  54371. /**
  54372. * Define the list of render target the layer is visible into.
  54373. */
  54374. renderTargetTextures: RenderTargetTexture[];
  54375. /**
  54376. * Define if the layer is only used in renderTarget or if it also
  54377. * renders in the main frame buffer of the canvas.
  54378. */
  54379. renderOnlyInRenderTargetTextures: boolean;
  54380. private _scene;
  54381. private _vertexBuffers;
  54382. private _indexBuffer;
  54383. private _effect;
  54384. private _previousDefines;
  54385. /**
  54386. * An event triggered when the layer is disposed.
  54387. */
  54388. onDisposeObservable: Observable<Layer>;
  54389. private _onDisposeObserver;
  54390. /**
  54391. * Back compatibility with callback before the onDisposeObservable existed.
  54392. * The set callback will be triggered when the layer has been disposed.
  54393. */
  54394. set onDispose(callback: () => void);
  54395. /**
  54396. * An event triggered before rendering the scene
  54397. */
  54398. onBeforeRenderObservable: Observable<Layer>;
  54399. private _onBeforeRenderObserver;
  54400. /**
  54401. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54402. * The set callback will be triggered just before rendering the layer.
  54403. */
  54404. set onBeforeRender(callback: () => void);
  54405. /**
  54406. * An event triggered after rendering the scene
  54407. */
  54408. onAfterRenderObservable: Observable<Layer>;
  54409. private _onAfterRenderObserver;
  54410. /**
  54411. * Back compatibility with callback before the onAfterRenderObservable existed.
  54412. * The set callback will be triggered just after rendering the layer.
  54413. */
  54414. set onAfterRender(callback: () => void);
  54415. /**
  54416. * Instantiates a new layer.
  54417. * This represents a full screen 2d layer.
  54418. * This can be useful to display a picture in the background of your scene for instance.
  54419. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54420. * @param name Define the name of the layer in the scene
  54421. * @param imgUrl Define the url of the texture to display in the layer
  54422. * @param scene Define the scene the layer belongs to
  54423. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54424. * @param color Defines a color for the layer
  54425. */
  54426. constructor(
  54427. /**
  54428. * Define the name of the layer.
  54429. */
  54430. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54431. private _createIndexBuffer;
  54432. /** @hidden */
  54433. _rebuild(): void;
  54434. /**
  54435. * Renders the layer in the scene.
  54436. */
  54437. render(): void;
  54438. /**
  54439. * Disposes and releases the associated ressources.
  54440. */
  54441. dispose(): void;
  54442. }
  54443. }
  54444. declare module BABYLON {
  54445. /** @hidden */
  54446. export var lensFlarePixelShader: {
  54447. name: string;
  54448. shader: string;
  54449. };
  54450. }
  54451. declare module BABYLON {
  54452. /** @hidden */
  54453. export var lensFlareVertexShader: {
  54454. name: string;
  54455. shader: string;
  54456. };
  54457. }
  54458. declare module BABYLON {
  54459. /**
  54460. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54461. * It is usually composed of several `lensFlare`.
  54462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54463. */
  54464. export class LensFlareSystem {
  54465. /**
  54466. * Define the name of the lens flare system
  54467. */
  54468. name: string;
  54469. /**
  54470. * List of lens flares used in this system.
  54471. */
  54472. lensFlares: LensFlare[];
  54473. /**
  54474. * Define a limit from the border the lens flare can be visible.
  54475. */
  54476. borderLimit: number;
  54477. /**
  54478. * Define a viewport border we do not want to see the lens flare in.
  54479. */
  54480. viewportBorder: number;
  54481. /**
  54482. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54483. */
  54484. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54485. /**
  54486. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54487. */
  54488. layerMask: number;
  54489. /**
  54490. * Define the id of the lens flare system in the scene.
  54491. * (equal to name by default)
  54492. */
  54493. id: string;
  54494. private _scene;
  54495. private _emitter;
  54496. private _vertexBuffers;
  54497. private _indexBuffer;
  54498. private _effect;
  54499. private _positionX;
  54500. private _positionY;
  54501. private _isEnabled;
  54502. /** @hidden */
  54503. static _SceneComponentInitialization: (scene: Scene) => void;
  54504. /**
  54505. * Instantiates a lens flare system.
  54506. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54507. * It is usually composed of several `lensFlare`.
  54508. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54509. * @param name Define the name of the lens flare system in the scene
  54510. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54511. * @param scene Define the scene the lens flare system belongs to
  54512. */
  54513. constructor(
  54514. /**
  54515. * Define the name of the lens flare system
  54516. */
  54517. name: string, emitter: any, scene: Scene);
  54518. /**
  54519. * Define if the lens flare system is enabled.
  54520. */
  54521. get isEnabled(): boolean;
  54522. set isEnabled(value: boolean);
  54523. /**
  54524. * Get the scene the effects belongs to.
  54525. * @returns the scene holding the lens flare system
  54526. */
  54527. getScene(): Scene;
  54528. /**
  54529. * Get 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. * @returns the emitter of the lens flare system
  54532. */
  54533. getEmitter(): any;
  54534. /**
  54535. * Set the emitter of the lens flare system.
  54536. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54537. * @param newEmitter Define the new emitter of the system
  54538. */
  54539. setEmitter(newEmitter: any): void;
  54540. /**
  54541. * Get the lens flare system emitter position.
  54542. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54543. * @returns the position
  54544. */
  54545. getEmitterPosition(): Vector3;
  54546. /**
  54547. * @hidden
  54548. */
  54549. computeEffectivePosition(globalViewport: Viewport): boolean;
  54550. /** @hidden */
  54551. _isVisible(): boolean;
  54552. /**
  54553. * @hidden
  54554. */
  54555. render(): boolean;
  54556. /**
  54557. * Dispose and release the lens flare with its associated resources.
  54558. */
  54559. dispose(): void;
  54560. /**
  54561. * Parse a lens flare system from a JSON repressentation
  54562. * @param parsedLensFlareSystem Define the JSON to parse
  54563. * @param scene Define the scene the parsed system should be instantiated in
  54564. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54565. * @returns the parsed system
  54566. */
  54567. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54568. /**
  54569. * Serialize the current Lens Flare System into a JSON representation.
  54570. * @returns the serialized JSON
  54571. */
  54572. serialize(): any;
  54573. }
  54574. }
  54575. declare module BABYLON {
  54576. /**
  54577. * This represents one of the lens effect in a `lensFlareSystem`.
  54578. * It controls one of the indiviual texture used in the effect.
  54579. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54580. */
  54581. export class LensFlare {
  54582. /**
  54583. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54584. */
  54585. size: number;
  54586. /**
  54587. * 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.
  54588. */
  54589. position: number;
  54590. /**
  54591. * Define the lens color.
  54592. */
  54593. color: Color3;
  54594. /**
  54595. * Define the lens texture.
  54596. */
  54597. texture: Nullable<Texture>;
  54598. /**
  54599. * Define the alpha mode to render this particular lens.
  54600. */
  54601. alphaMode: number;
  54602. private _system;
  54603. /**
  54604. * Creates a new Lens Flare.
  54605. * This represents one of the lens effect in a `lensFlareSystem`.
  54606. * It controls one of the indiviual texture used in the effect.
  54607. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54608. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54609. * @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.
  54610. * @param color Define the lens color
  54611. * @param imgUrl Define the lens texture url
  54612. * @param system Define the `lensFlareSystem` this flare is part of
  54613. * @returns The newly created Lens Flare
  54614. */
  54615. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54616. /**
  54617. * Instantiates a new Lens Flare.
  54618. * This represents one of the lens effect in a `lensFlareSystem`.
  54619. * It controls one of the indiviual texture used in the effect.
  54620. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54621. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54622. * @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.
  54623. * @param color Define the lens color
  54624. * @param imgUrl Define the lens texture url
  54625. * @param system Define the `lensFlareSystem` this flare is part of
  54626. */
  54627. constructor(
  54628. /**
  54629. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54630. */
  54631. size: number,
  54632. /**
  54633. * 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.
  54634. */
  54635. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54636. /**
  54637. * Dispose and release the lens flare with its associated resources.
  54638. */
  54639. dispose(): void;
  54640. }
  54641. }
  54642. declare module BABYLON {
  54643. interface AbstractScene {
  54644. /**
  54645. * The list of lens flare system added to the scene
  54646. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54647. */
  54648. lensFlareSystems: Array<LensFlareSystem>;
  54649. /**
  54650. * Removes the given lens flare system from this scene.
  54651. * @param toRemove The lens flare system to remove
  54652. * @returns The index of the removed lens flare system
  54653. */
  54654. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54655. /**
  54656. * Adds the given lens flare system to this scene
  54657. * @param newLensFlareSystem The lens flare system to add
  54658. */
  54659. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54660. /**
  54661. * Gets a lens flare system using its name
  54662. * @param name defines the name to look for
  54663. * @returns the lens flare system or null if not found
  54664. */
  54665. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54666. /**
  54667. * Gets a lens flare system using its id
  54668. * @param id defines the id to look for
  54669. * @returns the lens flare system or null if not found
  54670. */
  54671. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54672. }
  54673. /**
  54674. * Defines the lens flare scene component responsible to manage any lens flares
  54675. * in a given scene.
  54676. */
  54677. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54678. /**
  54679. * The component name helpfull to identify the component in the list of scene components.
  54680. */
  54681. readonly name: string;
  54682. /**
  54683. * The scene the component belongs to.
  54684. */
  54685. scene: Scene;
  54686. /**
  54687. * Creates a new instance of the component for the given scene
  54688. * @param scene Defines the scene to register the component in
  54689. */
  54690. constructor(scene: Scene);
  54691. /**
  54692. * Registers the component in a given scene
  54693. */
  54694. register(): void;
  54695. /**
  54696. * Rebuilds the elements related to this component in case of
  54697. * context lost for instance.
  54698. */
  54699. rebuild(): void;
  54700. /**
  54701. * Adds all the elements from the container to the scene
  54702. * @param container the container holding the elements
  54703. */
  54704. addFromContainer(container: AbstractScene): void;
  54705. /**
  54706. * Removes all the elements in the container from the scene
  54707. * @param container contains the elements to remove
  54708. * @param dispose if the removed element should be disposed (default: false)
  54709. */
  54710. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54711. /**
  54712. * Serializes the component data to the specified json object
  54713. * @param serializationObject The object to serialize to
  54714. */
  54715. serialize(serializationObject: any): void;
  54716. /**
  54717. * Disposes the component and the associated ressources.
  54718. */
  54719. dispose(): void;
  54720. private _draw;
  54721. }
  54722. }
  54723. declare module BABYLON {
  54724. /** @hidden */
  54725. export var depthPixelShader: {
  54726. name: string;
  54727. shader: string;
  54728. };
  54729. }
  54730. declare module BABYLON {
  54731. /** @hidden */
  54732. export var depthVertexShader: {
  54733. name: string;
  54734. shader: string;
  54735. };
  54736. }
  54737. declare module BABYLON {
  54738. /**
  54739. * This represents a depth renderer in Babylon.
  54740. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54741. */
  54742. export class DepthRenderer {
  54743. private _scene;
  54744. private _depthMap;
  54745. private _effect;
  54746. private readonly _storeNonLinearDepth;
  54747. private readonly _clearColor;
  54748. /** Get if the depth renderer is using packed depth or not */
  54749. readonly isPacked: boolean;
  54750. private _cachedDefines;
  54751. private _camera;
  54752. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54753. enabled: boolean;
  54754. /**
  54755. * Specifiess that the depth renderer will only be used within
  54756. * the camera it is created for.
  54757. * This can help forcing its rendering during the camera processing.
  54758. */
  54759. useOnlyInActiveCamera: boolean;
  54760. /** @hidden */
  54761. static _SceneComponentInitialization: (scene: Scene) => void;
  54762. /**
  54763. * Instantiates a depth renderer
  54764. * @param scene The scene the renderer belongs to
  54765. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54766. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54767. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54768. */
  54769. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54770. /**
  54771. * Creates the depth rendering effect and checks if the effect is ready.
  54772. * @param subMesh The submesh to be used to render the depth map of
  54773. * @param useInstances If multiple world instances should be used
  54774. * @returns if the depth renderer is ready to render the depth map
  54775. */
  54776. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54777. /**
  54778. * Gets the texture which the depth map will be written to.
  54779. * @returns The depth map texture
  54780. */
  54781. getDepthMap(): RenderTargetTexture;
  54782. /**
  54783. * Disposes of the depth renderer.
  54784. */
  54785. dispose(): void;
  54786. }
  54787. }
  54788. declare module BABYLON {
  54789. /** @hidden */
  54790. export var minmaxReduxPixelShader: {
  54791. name: string;
  54792. shader: string;
  54793. };
  54794. }
  54795. declare module BABYLON {
  54796. /**
  54797. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54798. * and maximum values from all values of the texture.
  54799. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54800. * The source values are read from the red channel of the texture.
  54801. */
  54802. export class MinMaxReducer {
  54803. /**
  54804. * Observable triggered when the computation has been performed
  54805. */
  54806. onAfterReductionPerformed: Observable<{
  54807. min: number;
  54808. max: number;
  54809. }>;
  54810. protected _camera: Camera;
  54811. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54812. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54813. protected _postProcessManager: PostProcessManager;
  54814. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54815. protected _forceFullscreenViewport: boolean;
  54816. /**
  54817. * Creates a min/max reducer
  54818. * @param camera The camera to use for the post processes
  54819. */
  54820. constructor(camera: Camera);
  54821. /**
  54822. * Gets the texture used to read the values from.
  54823. */
  54824. get sourceTexture(): Nullable<RenderTargetTexture>;
  54825. /**
  54826. * Sets the source texture to read the values from.
  54827. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54828. * because in such textures '1' value must not be taken into account to compute the maximum
  54829. * as this value is used to clear the texture.
  54830. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54831. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54832. * @param depthRedux Indicates if the texture is a depth texture or not
  54833. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54834. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54835. */
  54836. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54837. /**
  54838. * Defines the refresh rate of the computation.
  54839. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54840. */
  54841. get refreshRate(): number;
  54842. set refreshRate(value: number);
  54843. protected _activated: boolean;
  54844. /**
  54845. * Gets the activation status of the reducer
  54846. */
  54847. get activated(): boolean;
  54848. /**
  54849. * Activates the reduction computation.
  54850. * When activated, the observers registered in onAfterReductionPerformed are
  54851. * called after the compuation is performed
  54852. */
  54853. activate(): void;
  54854. /**
  54855. * Deactivates the reduction computation.
  54856. */
  54857. deactivate(): void;
  54858. /**
  54859. * Disposes the min/max reducer
  54860. * @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.
  54861. */
  54862. dispose(disposeAll?: boolean): void;
  54863. }
  54864. }
  54865. declare module BABYLON {
  54866. /**
  54867. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54868. */
  54869. export class DepthReducer extends MinMaxReducer {
  54870. private _depthRenderer;
  54871. private _depthRendererId;
  54872. /**
  54873. * Gets the depth renderer used for the computation.
  54874. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54875. */
  54876. get depthRenderer(): Nullable<DepthRenderer>;
  54877. /**
  54878. * Creates a depth reducer
  54879. * @param camera The camera used to render the depth texture
  54880. */
  54881. constructor(camera: Camera);
  54882. /**
  54883. * Sets the depth renderer to use to generate the depth map
  54884. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54885. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54886. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54887. */
  54888. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54889. /** @hidden */
  54890. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54891. /**
  54892. * Activates the reduction computation.
  54893. * When activated, the observers registered in onAfterReductionPerformed are
  54894. * called after the compuation is performed
  54895. */
  54896. activate(): void;
  54897. /**
  54898. * Deactivates the reduction computation.
  54899. */
  54900. deactivate(): void;
  54901. /**
  54902. * Disposes the depth reducer
  54903. * @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.
  54904. */
  54905. dispose(disposeAll?: boolean): void;
  54906. }
  54907. }
  54908. declare module BABYLON {
  54909. /**
  54910. * A CSM implementation allowing casting shadows on large scenes.
  54911. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54912. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54913. */
  54914. export class CascadedShadowGenerator extends ShadowGenerator {
  54915. private static readonly frustumCornersNDCSpace;
  54916. /**
  54917. * Name of the CSM class
  54918. */
  54919. static CLASSNAME: string;
  54920. /**
  54921. * Defines the default number of cascades used by the CSM.
  54922. */
  54923. static readonly DEFAULT_CASCADES_COUNT: number;
  54924. /**
  54925. * Defines the minimum number of cascades used by the CSM.
  54926. */
  54927. static readonly MIN_CASCADES_COUNT: number;
  54928. /**
  54929. * Defines the maximum number of cascades used by the CSM.
  54930. */
  54931. static readonly MAX_CASCADES_COUNT: number;
  54932. protected _validateFilter(filter: number): number;
  54933. /**
  54934. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54935. */
  54936. penumbraDarkness: number;
  54937. private _numCascades;
  54938. /**
  54939. * Gets or set the number of cascades used by the CSM.
  54940. */
  54941. get numCascades(): number;
  54942. set numCascades(value: number);
  54943. /**
  54944. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54945. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54946. */
  54947. stabilizeCascades: boolean;
  54948. private _freezeShadowCastersBoundingInfo;
  54949. private _freezeShadowCastersBoundingInfoObservable;
  54950. /**
  54951. * Enables or disables the shadow casters bounding info computation.
  54952. * If your shadow casters don't move, you can disable this feature.
  54953. * If it is enabled, the bounding box computation is done every frame.
  54954. */
  54955. get freezeShadowCastersBoundingInfo(): boolean;
  54956. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54957. private _scbiMin;
  54958. private _scbiMax;
  54959. protected _computeShadowCastersBoundingInfo(): void;
  54960. protected _shadowCastersBoundingInfo: BoundingInfo;
  54961. /**
  54962. * Gets or sets the shadow casters bounding info.
  54963. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54964. * so that the system won't overwrite the bounds you provide
  54965. */
  54966. get shadowCastersBoundingInfo(): BoundingInfo;
  54967. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54968. protected _breaksAreDirty: boolean;
  54969. protected _minDistance: number;
  54970. protected _maxDistance: number;
  54971. /**
  54972. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54973. *
  54974. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54975. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54976. * @param min minimal distance for the breaks (default to 0.)
  54977. * @param max maximal distance for the breaks (default to 1.)
  54978. */
  54979. setMinMaxDistance(min: number, max: number): void;
  54980. /** Gets the minimal distance used in the cascade break computation */
  54981. get minDistance(): number;
  54982. /** Gets the maximal distance used in the cascade break computation */
  54983. get maxDistance(): number;
  54984. /**
  54985. * Gets the class name of that object
  54986. * @returns "CascadedShadowGenerator"
  54987. */
  54988. getClassName(): string;
  54989. private _cascadeMinExtents;
  54990. private _cascadeMaxExtents;
  54991. /**
  54992. * Gets a cascade minimum extents
  54993. * @param cascadeIndex index of the cascade
  54994. * @returns the minimum cascade extents
  54995. */
  54996. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54997. /**
  54998. * Gets a cascade maximum extents
  54999. * @param cascadeIndex index of the cascade
  55000. * @returns the maximum cascade extents
  55001. */
  55002. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  55003. private _cascades;
  55004. private _currentLayer;
  55005. private _viewSpaceFrustumsZ;
  55006. private _viewMatrices;
  55007. private _projectionMatrices;
  55008. private _transformMatrices;
  55009. private _transformMatricesAsArray;
  55010. private _frustumLengths;
  55011. private _lightSizeUVCorrection;
  55012. private _depthCorrection;
  55013. private _frustumCornersWorldSpace;
  55014. private _frustumCenter;
  55015. private _shadowCameraPos;
  55016. private _shadowMaxZ;
  55017. /**
  55018. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55019. * It defaults to camera.maxZ
  55020. */
  55021. get shadowMaxZ(): number;
  55022. /**
  55023. * Sets the shadow max z distance.
  55024. */
  55025. set shadowMaxZ(value: number);
  55026. protected _debug: boolean;
  55027. /**
  55028. * Gets or sets the debug flag.
  55029. * When enabled, the cascades are materialized by different colors on the screen.
  55030. */
  55031. get debug(): boolean;
  55032. set debug(dbg: boolean);
  55033. private _depthClamp;
  55034. /**
  55035. * Gets or sets the depth clamping value.
  55036. *
  55037. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55038. * to account for the shadow casters far away.
  55039. *
  55040. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55041. */
  55042. get depthClamp(): boolean;
  55043. set depthClamp(value: boolean);
  55044. private _cascadeBlendPercentage;
  55045. /**
  55046. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55047. * It defaults to 0.1 (10% blending).
  55048. */
  55049. get cascadeBlendPercentage(): number;
  55050. set cascadeBlendPercentage(value: number);
  55051. private _lambda;
  55052. /**
  55053. * Gets or set the lambda parameter.
  55054. * This parameter is used to split the camera frustum and create the cascades.
  55055. * 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.
  55056. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55057. */
  55058. get lambda(): number;
  55059. set lambda(value: number);
  55060. /**
  55061. * Gets the view matrix corresponding to a given cascade
  55062. * @param cascadeNum cascade to retrieve the view matrix from
  55063. * @returns the cascade view matrix
  55064. */
  55065. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55066. /**
  55067. * Gets the projection matrix corresponding to a given cascade
  55068. * @param cascadeNum cascade to retrieve the projection matrix from
  55069. * @returns the cascade projection matrix
  55070. */
  55071. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55072. /**
  55073. * Gets the transformation matrix corresponding to a given cascade
  55074. * @param cascadeNum cascade to retrieve the transformation matrix from
  55075. * @returns the cascade transformation matrix
  55076. */
  55077. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55078. private _depthRenderer;
  55079. /**
  55080. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55081. *
  55082. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55083. *
  55084. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55085. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55086. * @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
  55087. */
  55088. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55089. private _depthReducer;
  55090. private _autoCalcDepthBounds;
  55091. /**
  55092. * Gets or sets the autoCalcDepthBounds property.
  55093. *
  55094. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55095. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55096. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55097. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55098. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55099. */
  55100. get autoCalcDepthBounds(): boolean;
  55101. set autoCalcDepthBounds(value: boolean);
  55102. /**
  55103. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55104. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55105. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55106. * for setting the refresh rate on the renderer yourself!
  55107. */
  55108. get autoCalcDepthBoundsRefreshRate(): number;
  55109. set autoCalcDepthBoundsRefreshRate(value: number);
  55110. /**
  55111. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55112. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55113. * you change the camera near/far planes!
  55114. */
  55115. splitFrustum(): void;
  55116. private _splitFrustum;
  55117. private _computeMatrices;
  55118. private _computeFrustumInWorldSpace;
  55119. private _computeCascadeFrustum;
  55120. /**
  55121. * Support test.
  55122. */
  55123. static get IsSupported(): boolean;
  55124. /** @hidden */
  55125. static _SceneComponentInitialization: (scene: Scene) => void;
  55126. /**
  55127. * Creates a Cascaded Shadow Generator object.
  55128. * A ShadowGenerator is the required tool to use the shadows.
  55129. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55130. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55131. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55132. * @param light The directional light object generating the shadows.
  55133. * @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.
  55134. */
  55135. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55136. protected _initializeGenerator(): void;
  55137. protected _createTargetRenderTexture(): void;
  55138. protected _initializeShadowMap(): void;
  55139. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55140. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55141. /**
  55142. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55143. * @param defines Defines of the material we want to update
  55144. * @param lightIndex Index of the light in the enabled light list of the material
  55145. */
  55146. prepareDefines(defines: any, lightIndex: number): void;
  55147. /**
  55148. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55149. * defined in the generator but impacting the effect).
  55150. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55151. * @param effect The effect we are binfing the information for
  55152. */
  55153. bindShadowLight(lightIndex: string, effect: Effect): void;
  55154. /**
  55155. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55156. * (eq to view projection * shadow projection matrices)
  55157. * @returns The transform matrix used to create the shadow map
  55158. */
  55159. getTransformMatrix(): Matrix;
  55160. /**
  55161. * Disposes the ShadowGenerator.
  55162. * Returns nothing.
  55163. */
  55164. dispose(): void;
  55165. /**
  55166. * Serializes the shadow generator setup to a json object.
  55167. * @returns The serialized JSON object
  55168. */
  55169. serialize(): any;
  55170. /**
  55171. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55172. * @param parsedShadowGenerator The JSON object to parse
  55173. * @param scene The scene to create the shadow map for
  55174. * @returns The parsed shadow generator
  55175. */
  55176. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55177. }
  55178. }
  55179. declare module BABYLON {
  55180. /**
  55181. * Defines the shadow generator component responsible to manage any shadow generators
  55182. * in a given scene.
  55183. */
  55184. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55185. /**
  55186. * The component name helpfull to identify the component in the list of scene components.
  55187. */
  55188. readonly name: string;
  55189. /**
  55190. * The scene the component belongs to.
  55191. */
  55192. scene: Scene;
  55193. /**
  55194. * Creates a new instance of the component for the given scene
  55195. * @param scene Defines the scene to register the component in
  55196. */
  55197. constructor(scene: Scene);
  55198. /**
  55199. * Registers the component in a given scene
  55200. */
  55201. register(): void;
  55202. /**
  55203. * Rebuilds the elements related to this component in case of
  55204. * context lost for instance.
  55205. */
  55206. rebuild(): void;
  55207. /**
  55208. * Serializes the component data to the specified json object
  55209. * @param serializationObject The object to serialize to
  55210. */
  55211. serialize(serializationObject: any): void;
  55212. /**
  55213. * Adds all the elements from the container to the scene
  55214. * @param container the container holding the elements
  55215. */
  55216. addFromContainer(container: AbstractScene): void;
  55217. /**
  55218. * Removes all the elements in the container from the scene
  55219. * @param container contains the elements to remove
  55220. * @param dispose if the removed element should be disposed (default: false)
  55221. */
  55222. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55223. /**
  55224. * Rebuilds the elements related to this component in case of
  55225. * context lost for instance.
  55226. */
  55227. dispose(): void;
  55228. private _gatherRenderTargets;
  55229. }
  55230. }
  55231. declare module BABYLON {
  55232. /**
  55233. * A point light is a light defined by an unique point in world space.
  55234. * The light is emitted in every direction from this point.
  55235. * A good example of a point light is a standard light bulb.
  55236. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55237. */
  55238. export class PointLight extends ShadowLight {
  55239. private _shadowAngle;
  55240. /**
  55241. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55242. * This specifies what angle the shadow will use to be created.
  55243. *
  55244. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55245. */
  55246. get shadowAngle(): number;
  55247. /**
  55248. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55249. * This specifies what angle the shadow will use to be created.
  55250. *
  55251. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55252. */
  55253. set shadowAngle(value: number);
  55254. /**
  55255. * Gets the direction if it has been set.
  55256. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55257. */
  55258. get direction(): Vector3;
  55259. /**
  55260. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55261. */
  55262. set direction(value: Vector3);
  55263. /**
  55264. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55265. * A PointLight emits the light in every direction.
  55266. * It can cast shadows.
  55267. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55268. * ```javascript
  55269. * var pointLight = new PointLight("pl", camera.position, scene);
  55270. * ```
  55271. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55272. * @param name The light friendly name
  55273. * @param position The position of the point light in the scene
  55274. * @param scene The scene the lights belongs to
  55275. */
  55276. constructor(name: string, position: Vector3, scene: Scene);
  55277. /**
  55278. * Returns the string "PointLight"
  55279. * @returns the class name
  55280. */
  55281. getClassName(): string;
  55282. /**
  55283. * Returns the integer 0.
  55284. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55285. */
  55286. getTypeID(): number;
  55287. /**
  55288. * Specifies wether or not the shadowmap should be a cube texture.
  55289. * @returns true if the shadowmap needs to be a cube texture.
  55290. */
  55291. needCube(): boolean;
  55292. /**
  55293. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55294. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55295. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55296. */
  55297. getShadowDirection(faceIndex?: number): Vector3;
  55298. /**
  55299. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55300. * - fov = PI / 2
  55301. * - aspect ratio : 1.0
  55302. * - z-near and far equal to the active camera minZ and maxZ.
  55303. * Returns the PointLight.
  55304. */
  55305. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55306. protected _buildUniformLayout(): void;
  55307. /**
  55308. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55309. * @param effect The effect to update
  55310. * @param lightIndex The index of the light in the effect to update
  55311. * @returns The point light
  55312. */
  55313. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55314. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55315. /**
  55316. * Prepares the list of defines specific to the light type.
  55317. * @param defines the list of defines
  55318. * @param lightIndex defines the index of the light for the effect
  55319. */
  55320. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55321. }
  55322. }
  55323. declare module BABYLON {
  55324. /**
  55325. * Header information of HDR texture files.
  55326. */
  55327. export interface HDRInfo {
  55328. /**
  55329. * The height of the texture in pixels.
  55330. */
  55331. height: number;
  55332. /**
  55333. * The width of the texture in pixels.
  55334. */
  55335. width: number;
  55336. /**
  55337. * The index of the beginning of the data in the binary file.
  55338. */
  55339. dataPosition: number;
  55340. }
  55341. /**
  55342. * This groups tools to convert HDR texture to native colors array.
  55343. */
  55344. export class HDRTools {
  55345. private static Ldexp;
  55346. private static Rgbe2float;
  55347. private static readStringLine;
  55348. /**
  55349. * Reads header information from an RGBE texture stored in a native array.
  55350. * More information on this format are available here:
  55351. * https://en.wikipedia.org/wiki/RGBE_image_format
  55352. *
  55353. * @param uint8array The binary file stored in native array.
  55354. * @return The header information.
  55355. */
  55356. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55357. /**
  55358. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55359. * This RGBE texture needs to store the information as a panorama.
  55360. *
  55361. * More information on this format are available here:
  55362. * https://en.wikipedia.org/wiki/RGBE_image_format
  55363. *
  55364. * @param buffer The binary file stored in an array buffer.
  55365. * @param size The expected size of the extracted cubemap.
  55366. * @return The Cube Map information.
  55367. */
  55368. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55369. /**
  55370. * Returns the pixels data extracted from an RGBE texture.
  55371. * This pixels will be stored left to right up to down in the R G B order in one array.
  55372. *
  55373. * More information on this format are available here:
  55374. * https://en.wikipedia.org/wiki/RGBE_image_format
  55375. *
  55376. * @param uint8array The binary file stored in an array buffer.
  55377. * @param hdrInfo The header information of the file.
  55378. * @return The pixels data in RGB right to left up to down order.
  55379. */
  55380. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55381. private static RGBE_ReadPixels_RLE;
  55382. }
  55383. }
  55384. declare module BABYLON {
  55385. /**
  55386. * This represents a texture coming from an HDR input.
  55387. *
  55388. * The only supported format is currently panorama picture stored in RGBE format.
  55389. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55390. */
  55391. export class HDRCubeTexture extends BaseTexture {
  55392. private static _facesMapping;
  55393. private _generateHarmonics;
  55394. private _noMipmap;
  55395. private _textureMatrix;
  55396. private _size;
  55397. private _onLoad;
  55398. private _onError;
  55399. /**
  55400. * The texture URL.
  55401. */
  55402. url: string;
  55403. /**
  55404. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55405. */
  55406. coordinatesMode: number;
  55407. protected _isBlocking: boolean;
  55408. /**
  55409. * Sets wether or not the texture is blocking during loading.
  55410. */
  55411. set isBlocking(value: boolean);
  55412. /**
  55413. * Gets wether or not the texture is blocking during loading.
  55414. */
  55415. get isBlocking(): boolean;
  55416. protected _rotationY: number;
  55417. /**
  55418. * Sets texture matrix rotation angle around Y axis in radians.
  55419. */
  55420. set rotationY(value: number);
  55421. /**
  55422. * Gets texture matrix rotation angle around Y axis radians.
  55423. */
  55424. get rotationY(): number;
  55425. /**
  55426. * Gets or sets the center of the bounding box associated with the cube texture
  55427. * It must define where the camera used to render the texture was set
  55428. */
  55429. boundingBoxPosition: Vector3;
  55430. private _boundingBoxSize;
  55431. /**
  55432. * Gets or sets the size of the bounding box associated with the cube texture
  55433. * When defined, the cubemap will switch to local mode
  55434. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55435. * @example https://www.babylonjs-playground.com/#RNASML
  55436. */
  55437. set boundingBoxSize(value: Vector3);
  55438. get boundingBoxSize(): Vector3;
  55439. /**
  55440. * Instantiates an HDRTexture from the following parameters.
  55441. *
  55442. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55443. * @param scene The scene the texture will be used in
  55444. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55445. * @param noMipmap Forces to not generate the mipmap if true
  55446. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55447. * @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)
  55448. * @param reserved Reserved flag for internal use.
  55449. */
  55450. 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>);
  55451. /**
  55452. * Get the current class name of the texture useful for serialization or dynamic coding.
  55453. * @returns "HDRCubeTexture"
  55454. */
  55455. getClassName(): string;
  55456. /**
  55457. * Occurs when the file is raw .hdr file.
  55458. */
  55459. private loadTexture;
  55460. clone(): HDRCubeTexture;
  55461. delayLoad(): void;
  55462. /**
  55463. * Get the texture reflection matrix used to rotate/transform the reflection.
  55464. * @returns the reflection matrix
  55465. */
  55466. getReflectionTextureMatrix(): Matrix;
  55467. /**
  55468. * Set the texture reflection matrix used to rotate/transform the reflection.
  55469. * @param value Define the reflection matrix to set
  55470. */
  55471. setReflectionTextureMatrix(value: Matrix): void;
  55472. /**
  55473. * Parses a JSON representation of an HDR Texture in order to create the texture
  55474. * @param parsedTexture Define the JSON representation
  55475. * @param scene Define the scene the texture should be created in
  55476. * @param rootUrl Define the root url in case we need to load relative dependencies
  55477. * @returns the newly created texture after parsing
  55478. */
  55479. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55480. serialize(): any;
  55481. }
  55482. }
  55483. declare module BABYLON {
  55484. /**
  55485. * Class used to control physics engine
  55486. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55487. */
  55488. export class PhysicsEngine implements IPhysicsEngine {
  55489. private _physicsPlugin;
  55490. /**
  55491. * Global value used to control the smallest number supported by the simulation
  55492. */
  55493. static Epsilon: number;
  55494. private _impostors;
  55495. private _joints;
  55496. private _subTimeStep;
  55497. /**
  55498. * Gets the gravity vector used by the simulation
  55499. */
  55500. gravity: Vector3;
  55501. /**
  55502. * Factory used to create the default physics plugin.
  55503. * @returns The default physics plugin
  55504. */
  55505. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55506. /**
  55507. * Creates a new Physics Engine
  55508. * @param gravity defines the gravity vector used by the simulation
  55509. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55510. */
  55511. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55512. /**
  55513. * Sets the gravity vector used by the simulation
  55514. * @param gravity defines the gravity vector to use
  55515. */
  55516. setGravity(gravity: Vector3): void;
  55517. /**
  55518. * Set the time step of the physics engine.
  55519. * Default is 1/60.
  55520. * To slow it down, enter 1/600 for example.
  55521. * To speed it up, 1/30
  55522. * @param newTimeStep defines the new timestep to apply to this world.
  55523. */
  55524. setTimeStep(newTimeStep?: number): void;
  55525. /**
  55526. * Get the time step of the physics engine.
  55527. * @returns the current time step
  55528. */
  55529. getTimeStep(): number;
  55530. /**
  55531. * Set the sub time step of the physics engine.
  55532. * Default is 0 meaning there is no sub steps
  55533. * To increase physics resolution precision, set a small value (like 1 ms)
  55534. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55535. */
  55536. setSubTimeStep(subTimeStep?: number): void;
  55537. /**
  55538. * Get the sub time step of the physics engine.
  55539. * @returns the current sub time step
  55540. */
  55541. getSubTimeStep(): number;
  55542. /**
  55543. * Release all resources
  55544. */
  55545. dispose(): void;
  55546. /**
  55547. * Gets the name of the current physics plugin
  55548. * @returns the name of the plugin
  55549. */
  55550. getPhysicsPluginName(): string;
  55551. /**
  55552. * Adding a new impostor for the impostor tracking.
  55553. * This will be done by the impostor itself.
  55554. * @param impostor the impostor to add
  55555. */
  55556. addImpostor(impostor: PhysicsImpostor): void;
  55557. /**
  55558. * Remove an impostor from the engine.
  55559. * This impostor and its mesh will not longer be updated by the physics engine.
  55560. * @param impostor the impostor to remove
  55561. */
  55562. removeImpostor(impostor: PhysicsImpostor): void;
  55563. /**
  55564. * Add a joint to the physics engine
  55565. * @param mainImpostor defines the main impostor to which the joint is added.
  55566. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55567. * @param joint defines the joint that will connect both impostors.
  55568. */
  55569. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55570. /**
  55571. * Removes a joint from the simulation
  55572. * @param mainImpostor defines the impostor used with the joint
  55573. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55574. * @param joint defines the joint to remove
  55575. */
  55576. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55577. /**
  55578. * Called by the scene. No need to call it.
  55579. * @param delta defines the timespam between frames
  55580. */
  55581. _step(delta: number): void;
  55582. /**
  55583. * Gets the current plugin used to run the simulation
  55584. * @returns current plugin
  55585. */
  55586. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55587. /**
  55588. * Gets the list of physic impostors
  55589. * @returns an array of PhysicsImpostor
  55590. */
  55591. getImpostors(): Array<PhysicsImpostor>;
  55592. /**
  55593. * Gets the impostor for a physics enabled object
  55594. * @param object defines the object impersonated by the impostor
  55595. * @returns the PhysicsImpostor or null if not found
  55596. */
  55597. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55598. /**
  55599. * Gets the impostor for a physics body object
  55600. * @param body defines physics body used by the impostor
  55601. * @returns the PhysicsImpostor or null if not found
  55602. */
  55603. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55604. /**
  55605. * Does a raycast in the physics world
  55606. * @param from when should the ray start?
  55607. * @param to when should the ray end?
  55608. * @returns PhysicsRaycastResult
  55609. */
  55610. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55611. }
  55612. }
  55613. declare module BABYLON {
  55614. /** @hidden */
  55615. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55616. private _useDeltaForWorldStep;
  55617. world: any;
  55618. name: string;
  55619. private _physicsMaterials;
  55620. private _fixedTimeStep;
  55621. private _cannonRaycastResult;
  55622. private _raycastResult;
  55623. private _physicsBodysToRemoveAfterStep;
  55624. BJSCANNON: any;
  55625. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55626. setGravity(gravity: Vector3): void;
  55627. setTimeStep(timeStep: number): void;
  55628. getTimeStep(): number;
  55629. executeStep(delta: number): void;
  55630. private _removeMarkedPhysicsBodiesFromWorld;
  55631. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55632. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55633. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55634. private _processChildMeshes;
  55635. removePhysicsBody(impostor: PhysicsImpostor): void;
  55636. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55637. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55638. private _addMaterial;
  55639. private _checkWithEpsilon;
  55640. private _createShape;
  55641. private _createHeightmap;
  55642. private _minus90X;
  55643. private _plus90X;
  55644. private _tmpPosition;
  55645. private _tmpDeltaPosition;
  55646. private _tmpUnityRotation;
  55647. private _updatePhysicsBodyTransformation;
  55648. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55649. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55650. isSupported(): boolean;
  55651. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55652. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55653. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55654. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55655. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55656. getBodyMass(impostor: PhysicsImpostor): number;
  55657. getBodyFriction(impostor: PhysicsImpostor): number;
  55658. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55659. getBodyRestitution(impostor: PhysicsImpostor): number;
  55660. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55661. sleepBody(impostor: PhysicsImpostor): void;
  55662. wakeUpBody(impostor: PhysicsImpostor): void;
  55663. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55664. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55665. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55666. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55667. getRadius(impostor: PhysicsImpostor): number;
  55668. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55669. dispose(): void;
  55670. private _extendNamespace;
  55671. /**
  55672. * Does a raycast in the physics world
  55673. * @param from when should the ray start?
  55674. * @param to when should the ray end?
  55675. * @returns PhysicsRaycastResult
  55676. */
  55677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55678. }
  55679. }
  55680. declare module BABYLON {
  55681. /** @hidden */
  55682. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55683. private _useDeltaForWorldStep;
  55684. world: any;
  55685. name: string;
  55686. BJSOIMO: any;
  55687. private _raycastResult;
  55688. private _fixedTimeStep;
  55689. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55690. setGravity(gravity: Vector3): void;
  55691. setTimeStep(timeStep: number): void;
  55692. getTimeStep(): number;
  55693. private _tmpImpostorsArray;
  55694. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55695. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55696. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55697. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55698. private _tmpPositionVector;
  55699. removePhysicsBody(impostor: PhysicsImpostor): void;
  55700. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55701. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55702. isSupported(): boolean;
  55703. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55704. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55705. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55706. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55707. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55708. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55709. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55710. getBodyMass(impostor: PhysicsImpostor): number;
  55711. getBodyFriction(impostor: PhysicsImpostor): number;
  55712. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55713. getBodyRestitution(impostor: PhysicsImpostor): number;
  55714. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55715. sleepBody(impostor: PhysicsImpostor): void;
  55716. wakeUpBody(impostor: PhysicsImpostor): void;
  55717. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55718. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55719. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55720. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55721. getRadius(impostor: PhysicsImpostor): number;
  55722. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55723. dispose(): void;
  55724. /**
  55725. * Does a raycast in the physics world
  55726. * @param from when should the ray start?
  55727. * @param to when should the ray end?
  55728. * @returns PhysicsRaycastResult
  55729. */
  55730. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55731. }
  55732. }
  55733. declare module BABYLON {
  55734. /**
  55735. * Class containing static functions to help procedurally build meshes
  55736. */
  55737. export class RibbonBuilder {
  55738. /**
  55739. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55740. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55741. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55742. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55743. * * 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
  55744. * * 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
  55745. * * 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
  55746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55747. * * 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
  55748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55749. * * 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
  55750. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55751. * * 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
  55752. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55754. * @param name defines the name of the mesh
  55755. * @param options defines the options used to create the mesh
  55756. * @param scene defines the hosting scene
  55757. * @returns the ribbon mesh
  55758. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55760. */
  55761. static CreateRibbon(name: string, options: {
  55762. pathArray: Vector3[][];
  55763. closeArray?: boolean;
  55764. closePath?: boolean;
  55765. offset?: number;
  55766. updatable?: boolean;
  55767. sideOrientation?: number;
  55768. frontUVs?: Vector4;
  55769. backUVs?: Vector4;
  55770. instance?: Mesh;
  55771. invertUV?: boolean;
  55772. uvs?: Vector2[];
  55773. colors?: Color4[];
  55774. }, scene?: Nullable<Scene>): Mesh;
  55775. }
  55776. }
  55777. declare module BABYLON {
  55778. /**
  55779. * Class containing static functions to help procedurally build meshes
  55780. */
  55781. export class ShapeBuilder {
  55782. /**
  55783. * 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.
  55784. * * 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.
  55785. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55786. * * 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.
  55787. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55788. * * 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
  55789. * * 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
  55790. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55792. * * 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
  55793. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55795. * @param name defines the name of the mesh
  55796. * @param options defines the options used to create the mesh
  55797. * @param scene defines the hosting scene
  55798. * @returns the extruded shape mesh
  55799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55801. */
  55802. static ExtrudeShape(name: string, options: {
  55803. shape: Vector3[];
  55804. path: Vector3[];
  55805. scale?: number;
  55806. rotation?: number;
  55807. cap?: number;
  55808. updatable?: boolean;
  55809. sideOrientation?: number;
  55810. frontUVs?: Vector4;
  55811. backUVs?: Vector4;
  55812. instance?: Mesh;
  55813. invertUV?: boolean;
  55814. }, scene?: Nullable<Scene>): Mesh;
  55815. /**
  55816. * Creates an custom extruded shape mesh.
  55817. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55818. * * 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.
  55819. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55820. * * 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
  55821. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55822. * * 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
  55823. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55824. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55825. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55826. * * 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
  55827. * * 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
  55828. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55830. * * 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
  55831. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55833. * @param name defines the name of the mesh
  55834. * @param options defines the options used to create the mesh
  55835. * @param scene defines the hosting scene
  55836. * @returns the custom extruded shape mesh
  55837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55838. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55840. */
  55841. static ExtrudeShapeCustom(name: string, options: {
  55842. shape: Vector3[];
  55843. path: Vector3[];
  55844. scaleFunction?: any;
  55845. rotationFunction?: any;
  55846. ribbonCloseArray?: boolean;
  55847. ribbonClosePath?: boolean;
  55848. cap?: number;
  55849. updatable?: boolean;
  55850. sideOrientation?: number;
  55851. frontUVs?: Vector4;
  55852. backUVs?: Vector4;
  55853. instance?: Mesh;
  55854. invertUV?: boolean;
  55855. }, scene?: Nullable<Scene>): Mesh;
  55856. private static _ExtrudeShapeGeneric;
  55857. }
  55858. }
  55859. declare module BABYLON {
  55860. /**
  55861. * AmmoJS Physics plugin
  55862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55863. * @see https://github.com/kripken/ammo.js/
  55864. */
  55865. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55866. private _useDeltaForWorldStep;
  55867. /**
  55868. * Reference to the Ammo library
  55869. */
  55870. bjsAMMO: any;
  55871. /**
  55872. * Created ammoJS world which physics bodies are added to
  55873. */
  55874. world: any;
  55875. /**
  55876. * Name of the plugin
  55877. */
  55878. name: string;
  55879. private _timeStep;
  55880. private _fixedTimeStep;
  55881. private _maxSteps;
  55882. private _tmpQuaternion;
  55883. private _tmpAmmoTransform;
  55884. private _tmpAmmoQuaternion;
  55885. private _tmpAmmoConcreteContactResultCallback;
  55886. private _collisionConfiguration;
  55887. private _dispatcher;
  55888. private _overlappingPairCache;
  55889. private _solver;
  55890. private _softBodySolver;
  55891. private _tmpAmmoVectorA;
  55892. private _tmpAmmoVectorB;
  55893. private _tmpAmmoVectorC;
  55894. private _tmpAmmoVectorD;
  55895. private _tmpContactCallbackResult;
  55896. private _tmpAmmoVectorRCA;
  55897. private _tmpAmmoVectorRCB;
  55898. private _raycastResult;
  55899. private static readonly DISABLE_COLLISION_FLAG;
  55900. private static readonly KINEMATIC_FLAG;
  55901. private static readonly DISABLE_DEACTIVATION_FLAG;
  55902. /**
  55903. * Initializes the ammoJS plugin
  55904. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55905. * @param ammoInjection can be used to inject your own ammo reference
  55906. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55907. */
  55908. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55909. /**
  55910. * Sets the gravity of the physics world (m/(s^2))
  55911. * @param gravity Gravity to set
  55912. */
  55913. setGravity(gravity: Vector3): void;
  55914. /**
  55915. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55916. * @param timeStep timestep to use in seconds
  55917. */
  55918. setTimeStep(timeStep: number): void;
  55919. /**
  55920. * 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)
  55921. * @param fixedTimeStep fixedTimeStep to use in seconds
  55922. */
  55923. setFixedTimeStep(fixedTimeStep: number): void;
  55924. /**
  55925. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55926. * @param maxSteps the maximum number of steps by the physics engine per frame
  55927. */
  55928. setMaxSteps(maxSteps: number): void;
  55929. /**
  55930. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55931. * @returns the current timestep in seconds
  55932. */
  55933. getTimeStep(): number;
  55934. /**
  55935. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55936. */
  55937. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55938. private _isImpostorInContact;
  55939. private _isImpostorPairInContact;
  55940. private _stepSimulation;
  55941. /**
  55942. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55943. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55944. * After the step the babylon meshes are set to the position of the physics imposters
  55945. * @param delta amount of time to step forward
  55946. * @param impostors array of imposters to update before/after the step
  55947. */
  55948. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55949. /**
  55950. * Update babylon mesh to match physics world object
  55951. * @param impostor imposter to match
  55952. */
  55953. private _afterSoftStep;
  55954. /**
  55955. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55956. * @param impostor imposter to match
  55957. */
  55958. private _ropeStep;
  55959. /**
  55960. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55961. * @param impostor imposter to match
  55962. */
  55963. private _softbodyOrClothStep;
  55964. private _tmpMatrix;
  55965. /**
  55966. * Applies an impulse on the imposter
  55967. * @param impostor imposter to apply impulse to
  55968. * @param force amount of force to be applied to the imposter
  55969. * @param contactPoint the location to apply the impulse on the imposter
  55970. */
  55971. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55972. /**
  55973. * Applies a force on the imposter
  55974. * @param impostor imposter to apply force
  55975. * @param force amount of force to be applied to the imposter
  55976. * @param contactPoint the location to apply the force on the imposter
  55977. */
  55978. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55979. /**
  55980. * Creates a physics body using the plugin
  55981. * @param impostor the imposter to create the physics body on
  55982. */
  55983. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55984. /**
  55985. * Removes the physics body from the imposter and disposes of the body's memory
  55986. * @param impostor imposter to remove the physics body from
  55987. */
  55988. removePhysicsBody(impostor: PhysicsImpostor): void;
  55989. /**
  55990. * Generates a joint
  55991. * @param impostorJoint the imposter joint to create the joint with
  55992. */
  55993. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55994. /**
  55995. * Removes a joint
  55996. * @param impostorJoint the imposter joint to remove the joint from
  55997. */
  55998. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55999. private _addMeshVerts;
  56000. /**
  56001. * Initialise the soft body vertices to match its object's (mesh) vertices
  56002. * Softbody vertices (nodes) are in world space and to match this
  56003. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56004. * @param impostor to create the softbody for
  56005. */
  56006. private _softVertexData;
  56007. /**
  56008. * Create an impostor's soft body
  56009. * @param impostor to create the softbody for
  56010. */
  56011. private _createSoftbody;
  56012. /**
  56013. * Create cloth for an impostor
  56014. * @param impostor to create the softbody for
  56015. */
  56016. private _createCloth;
  56017. /**
  56018. * Create rope for an impostor
  56019. * @param impostor to create the softbody for
  56020. */
  56021. private _createRope;
  56022. /**
  56023. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56024. * @param impostor to create the custom physics shape for
  56025. */
  56026. private _createCustom;
  56027. private _addHullVerts;
  56028. private _createShape;
  56029. /**
  56030. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56031. * @param impostor imposter containing the physics body and babylon object
  56032. */
  56033. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56034. /**
  56035. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56036. * @param impostor imposter containing the physics body and babylon object
  56037. * @param newPosition new position
  56038. * @param newRotation new rotation
  56039. */
  56040. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56041. /**
  56042. * If this plugin is supported
  56043. * @returns true if its supported
  56044. */
  56045. isSupported(): boolean;
  56046. /**
  56047. * Sets the linear velocity of the physics body
  56048. * @param impostor imposter to set the velocity on
  56049. * @param velocity velocity to set
  56050. */
  56051. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56052. /**
  56053. * Sets the angular velocity of the physics body
  56054. * @param impostor imposter to set the velocity on
  56055. * @param velocity velocity to set
  56056. */
  56057. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56058. /**
  56059. * gets the linear velocity
  56060. * @param impostor imposter to get linear velocity from
  56061. * @returns linear velocity
  56062. */
  56063. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56064. /**
  56065. * gets the angular velocity
  56066. * @param impostor imposter to get angular velocity from
  56067. * @returns angular velocity
  56068. */
  56069. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56070. /**
  56071. * Sets the mass of physics body
  56072. * @param impostor imposter to set the mass on
  56073. * @param mass mass to set
  56074. */
  56075. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56076. /**
  56077. * Gets the mass of the physics body
  56078. * @param impostor imposter to get the mass from
  56079. * @returns mass
  56080. */
  56081. getBodyMass(impostor: PhysicsImpostor): number;
  56082. /**
  56083. * Gets friction of the impostor
  56084. * @param impostor impostor to get friction from
  56085. * @returns friction value
  56086. */
  56087. getBodyFriction(impostor: PhysicsImpostor): number;
  56088. /**
  56089. * Sets friction of the impostor
  56090. * @param impostor impostor to set friction on
  56091. * @param friction friction value
  56092. */
  56093. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56094. /**
  56095. * Gets restitution of the impostor
  56096. * @param impostor impostor to get restitution from
  56097. * @returns restitution value
  56098. */
  56099. getBodyRestitution(impostor: PhysicsImpostor): number;
  56100. /**
  56101. * Sets resitution of the impostor
  56102. * @param impostor impostor to set resitution on
  56103. * @param restitution resitution value
  56104. */
  56105. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56106. /**
  56107. * Gets pressure inside the impostor
  56108. * @param impostor impostor to get pressure from
  56109. * @returns pressure value
  56110. */
  56111. getBodyPressure(impostor: PhysicsImpostor): number;
  56112. /**
  56113. * Sets pressure inside a soft body impostor
  56114. * Cloth and rope must remain 0 pressure
  56115. * @param impostor impostor to set pressure on
  56116. * @param pressure pressure value
  56117. */
  56118. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56119. /**
  56120. * Gets stiffness of the impostor
  56121. * @param impostor impostor to get stiffness from
  56122. * @returns pressure value
  56123. */
  56124. getBodyStiffness(impostor: PhysicsImpostor): number;
  56125. /**
  56126. * Sets stiffness of the impostor
  56127. * @param impostor impostor to set stiffness on
  56128. * @param stiffness stiffness value from 0 to 1
  56129. */
  56130. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56131. /**
  56132. * Gets velocityIterations of the impostor
  56133. * @param impostor impostor to get velocity iterations from
  56134. * @returns velocityIterations value
  56135. */
  56136. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56137. /**
  56138. * Sets velocityIterations of the impostor
  56139. * @param impostor impostor to set velocity iterations on
  56140. * @param velocityIterations velocityIterations value
  56141. */
  56142. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56143. /**
  56144. * Gets positionIterations of the impostor
  56145. * @param impostor impostor to get position iterations from
  56146. * @returns positionIterations value
  56147. */
  56148. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56149. /**
  56150. * Sets positionIterations of the impostor
  56151. * @param impostor impostor to set position on
  56152. * @param positionIterations positionIterations value
  56153. */
  56154. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56155. /**
  56156. * Append an anchor to a cloth object
  56157. * @param impostor is the cloth impostor to add anchor to
  56158. * @param otherImpostor is the rigid impostor to anchor to
  56159. * @param width ratio across width from 0 to 1
  56160. * @param height ratio up height from 0 to 1
  56161. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56162. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56163. */
  56164. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56165. /**
  56166. * Append an hook to a rope object
  56167. * @param impostor is the rope impostor to add hook to
  56168. * @param otherImpostor is the rigid impostor to hook to
  56169. * @param length ratio along the rope from 0 to 1
  56170. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56171. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56172. */
  56173. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56174. /**
  56175. * Sleeps the physics body and stops it from being active
  56176. * @param impostor impostor to sleep
  56177. */
  56178. sleepBody(impostor: PhysicsImpostor): void;
  56179. /**
  56180. * Activates the physics body
  56181. * @param impostor impostor to activate
  56182. */
  56183. wakeUpBody(impostor: PhysicsImpostor): void;
  56184. /**
  56185. * Updates the distance parameters of the joint
  56186. * @param joint joint to update
  56187. * @param maxDistance maximum distance of the joint
  56188. * @param minDistance minimum distance of the joint
  56189. */
  56190. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56191. /**
  56192. * Sets a motor on the joint
  56193. * @param joint joint to set motor on
  56194. * @param speed speed of the motor
  56195. * @param maxForce maximum force of the motor
  56196. * @param motorIndex index of the motor
  56197. */
  56198. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56199. /**
  56200. * Sets the motors limit
  56201. * @param joint joint to set limit on
  56202. * @param upperLimit upper limit
  56203. * @param lowerLimit lower limit
  56204. */
  56205. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56206. /**
  56207. * Syncs the position and rotation of a mesh with the impostor
  56208. * @param mesh mesh to sync
  56209. * @param impostor impostor to update the mesh with
  56210. */
  56211. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56212. /**
  56213. * Gets the radius of the impostor
  56214. * @param impostor impostor to get radius from
  56215. * @returns the radius
  56216. */
  56217. getRadius(impostor: PhysicsImpostor): number;
  56218. /**
  56219. * Gets the box size of the impostor
  56220. * @param impostor impostor to get box size from
  56221. * @param result the resulting box size
  56222. */
  56223. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56224. /**
  56225. * Disposes of the impostor
  56226. */
  56227. dispose(): void;
  56228. /**
  56229. * Does a raycast in the physics world
  56230. * @param from when should the ray start?
  56231. * @param to when should the ray end?
  56232. * @returns PhysicsRaycastResult
  56233. */
  56234. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56235. }
  56236. }
  56237. declare module BABYLON {
  56238. interface AbstractScene {
  56239. /**
  56240. * The list of reflection probes added to the scene
  56241. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56242. */
  56243. reflectionProbes: Array<ReflectionProbe>;
  56244. /**
  56245. * Removes the given reflection probe from this scene.
  56246. * @param toRemove The reflection probe to remove
  56247. * @returns The index of the removed reflection probe
  56248. */
  56249. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56250. /**
  56251. * Adds the given reflection probe to this scene.
  56252. * @param newReflectionProbe The reflection probe to add
  56253. */
  56254. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56255. }
  56256. /**
  56257. * Class used to generate realtime reflection / refraction cube textures
  56258. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56259. */
  56260. export class ReflectionProbe {
  56261. /** defines the name of the probe */
  56262. name: string;
  56263. private _scene;
  56264. private _renderTargetTexture;
  56265. private _projectionMatrix;
  56266. private _viewMatrix;
  56267. private _target;
  56268. private _add;
  56269. private _attachedMesh;
  56270. private _invertYAxis;
  56271. /** Gets or sets probe position (center of the cube map) */
  56272. position: Vector3;
  56273. /**
  56274. * Creates a new reflection probe
  56275. * @param name defines the name of the probe
  56276. * @param size defines the texture resolution (for each face)
  56277. * @param scene defines the hosting scene
  56278. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56279. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56280. */
  56281. constructor(
  56282. /** defines the name of the probe */
  56283. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56284. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56285. get samples(): number;
  56286. set samples(value: number);
  56287. /** Gets or sets the refresh rate to use (on every frame by default) */
  56288. get refreshRate(): number;
  56289. set refreshRate(value: number);
  56290. /**
  56291. * Gets the hosting scene
  56292. * @returns a Scene
  56293. */
  56294. getScene(): Scene;
  56295. /** Gets the internal CubeTexture used to render to */
  56296. get cubeTexture(): RenderTargetTexture;
  56297. /** Gets the list of meshes to render */
  56298. get renderList(): Nullable<AbstractMesh[]>;
  56299. /**
  56300. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56301. * @param mesh defines the mesh to attach to
  56302. */
  56303. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56304. /**
  56305. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56306. * @param renderingGroupId The rendering group id corresponding to its index
  56307. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56308. */
  56309. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56310. /**
  56311. * Clean all associated resources
  56312. */
  56313. dispose(): void;
  56314. /**
  56315. * Converts the reflection probe information to a readable string for debug purpose.
  56316. * @param fullDetails Supports for multiple levels of logging within scene loading
  56317. * @returns the human readable reflection probe info
  56318. */
  56319. toString(fullDetails?: boolean): string;
  56320. /**
  56321. * Get the class name of the relfection probe.
  56322. * @returns "ReflectionProbe"
  56323. */
  56324. getClassName(): string;
  56325. /**
  56326. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56327. * @returns The JSON representation of the texture
  56328. */
  56329. serialize(): any;
  56330. /**
  56331. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56332. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56333. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56334. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56335. * @returns The parsed reflection probe if successful
  56336. */
  56337. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56338. }
  56339. }
  56340. declare module BABYLON {
  56341. /** @hidden */
  56342. export var _BabylonLoaderRegistered: boolean;
  56343. /**
  56344. * Helps setting up some configuration for the babylon file loader.
  56345. */
  56346. export class BabylonFileLoaderConfiguration {
  56347. /**
  56348. * The loader does not allow injecting custom physix engine into the plugins.
  56349. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56350. * So you could set this variable to your engine import to make it work.
  56351. */
  56352. static LoaderInjectedPhysicsEngine: any;
  56353. }
  56354. }
  56355. declare module BABYLON {
  56356. /**
  56357. * The Physically based simple base material of BJS.
  56358. *
  56359. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56360. * It is used as the base class for both the specGloss and metalRough conventions.
  56361. */
  56362. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56363. /**
  56364. * Number of Simultaneous lights allowed on the material.
  56365. */
  56366. maxSimultaneousLights: number;
  56367. /**
  56368. * If sets to true, disables all the lights affecting the material.
  56369. */
  56370. disableLighting: boolean;
  56371. /**
  56372. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56373. */
  56374. environmentTexture: BaseTexture;
  56375. /**
  56376. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56377. */
  56378. invertNormalMapX: boolean;
  56379. /**
  56380. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56381. */
  56382. invertNormalMapY: boolean;
  56383. /**
  56384. * Normal map used in the model.
  56385. */
  56386. normalTexture: BaseTexture;
  56387. /**
  56388. * Emissivie color used to self-illuminate the model.
  56389. */
  56390. emissiveColor: Color3;
  56391. /**
  56392. * Emissivie texture used to self-illuminate the model.
  56393. */
  56394. emissiveTexture: BaseTexture;
  56395. /**
  56396. * Occlusion Channel Strenght.
  56397. */
  56398. occlusionStrength: number;
  56399. /**
  56400. * Occlusion Texture of the material (adding extra occlusion effects).
  56401. */
  56402. occlusionTexture: BaseTexture;
  56403. /**
  56404. * Defines the alpha limits in alpha test mode.
  56405. */
  56406. alphaCutOff: number;
  56407. /**
  56408. * Gets the current double sided mode.
  56409. */
  56410. get doubleSided(): boolean;
  56411. /**
  56412. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56413. */
  56414. set doubleSided(value: boolean);
  56415. /**
  56416. * Stores the pre-calculated light information of a mesh in a texture.
  56417. */
  56418. lightmapTexture: BaseTexture;
  56419. /**
  56420. * If true, the light map contains occlusion information instead of lighting info.
  56421. */
  56422. useLightmapAsShadowmap: boolean;
  56423. /**
  56424. * Instantiates a new PBRMaterial instance.
  56425. *
  56426. * @param name The material name
  56427. * @param scene The scene the material will be use in.
  56428. */
  56429. constructor(name: string, scene: Scene);
  56430. getClassName(): string;
  56431. }
  56432. }
  56433. declare module BABYLON {
  56434. /**
  56435. * The PBR material of BJS following the metal roughness convention.
  56436. *
  56437. * This fits to the PBR convention in the GLTF definition:
  56438. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56439. */
  56440. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56441. /**
  56442. * The base color has two different interpretations depending on the value of metalness.
  56443. * When the material is a metal, the base color is the specific measured reflectance value
  56444. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56445. * of the material.
  56446. */
  56447. baseColor: Color3;
  56448. /**
  56449. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56450. * well as opacity information in the alpha channel.
  56451. */
  56452. baseTexture: BaseTexture;
  56453. /**
  56454. * Specifies the metallic scalar value of the material.
  56455. * Can also be used to scale the metalness values of the metallic texture.
  56456. */
  56457. metallic: number;
  56458. /**
  56459. * Specifies the roughness scalar value of the material.
  56460. * Can also be used to scale the roughness values of the metallic texture.
  56461. */
  56462. roughness: number;
  56463. /**
  56464. * Texture containing both the metallic value in the B channel and the
  56465. * roughness value in the G channel to keep better precision.
  56466. */
  56467. metallicRoughnessTexture: BaseTexture;
  56468. /**
  56469. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56470. *
  56471. * @param name The material name
  56472. * @param scene The scene the material will be use in.
  56473. */
  56474. constructor(name: string, scene: Scene);
  56475. /**
  56476. * Return the currrent class name of the material.
  56477. */
  56478. getClassName(): string;
  56479. /**
  56480. * Makes a duplicate of the current material.
  56481. * @param name - name to use for the new material.
  56482. */
  56483. clone(name: string): PBRMetallicRoughnessMaterial;
  56484. /**
  56485. * Serialize the material to a parsable JSON object.
  56486. */
  56487. serialize(): any;
  56488. /**
  56489. * Parses a JSON object correponding to the serialize function.
  56490. */
  56491. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56492. }
  56493. }
  56494. declare module BABYLON {
  56495. /**
  56496. * The PBR material of BJS following the specular glossiness convention.
  56497. *
  56498. * This fits to the PBR convention in the GLTF definition:
  56499. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56500. */
  56501. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56502. /**
  56503. * Specifies the diffuse color of the material.
  56504. */
  56505. diffuseColor: Color3;
  56506. /**
  56507. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56508. * channel.
  56509. */
  56510. diffuseTexture: BaseTexture;
  56511. /**
  56512. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56513. */
  56514. specularColor: Color3;
  56515. /**
  56516. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56517. */
  56518. glossiness: number;
  56519. /**
  56520. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56521. */
  56522. specularGlossinessTexture: BaseTexture;
  56523. /**
  56524. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56525. *
  56526. * @param name The material name
  56527. * @param scene The scene the material will be use in.
  56528. */
  56529. constructor(name: string, scene: Scene);
  56530. /**
  56531. * Return the currrent class name of the material.
  56532. */
  56533. getClassName(): string;
  56534. /**
  56535. * Makes a duplicate of the current material.
  56536. * @param name - name to use for the new material.
  56537. */
  56538. clone(name: string): PBRSpecularGlossinessMaterial;
  56539. /**
  56540. * Serialize the material to a parsable JSON object.
  56541. */
  56542. serialize(): any;
  56543. /**
  56544. * Parses a JSON object correponding to the serialize function.
  56545. */
  56546. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56547. }
  56548. }
  56549. declare module BABYLON {
  56550. /**
  56551. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56552. * It can help converting any input color in a desired output one. This can then be used to create effects
  56553. * from sepia, black and white to sixties or futuristic rendering...
  56554. *
  56555. * The only supported format is currently 3dl.
  56556. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56557. */
  56558. export class ColorGradingTexture extends BaseTexture {
  56559. /**
  56560. * The texture URL.
  56561. */
  56562. url: string;
  56563. /**
  56564. * Empty line regex stored for GC.
  56565. */
  56566. private static _noneEmptyLineRegex;
  56567. private _textureMatrix;
  56568. private _engine;
  56569. private _onLoad;
  56570. /**
  56571. * Instantiates a ColorGradingTexture from the following parameters.
  56572. *
  56573. * @param url The location of the color gradind data (currently only supporting 3dl)
  56574. * @param sceneOrEngine The scene or engine the texture will be used in
  56575. * @param onLoad defines a callback triggered when the texture has been loaded
  56576. */
  56577. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56578. /**
  56579. * Fires the onload event from the constructor if requested.
  56580. */
  56581. private _triggerOnLoad;
  56582. /**
  56583. * Returns the texture matrix used in most of the material.
  56584. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56585. */
  56586. getTextureMatrix(): Matrix;
  56587. /**
  56588. * Occurs when the file being loaded is a .3dl LUT file.
  56589. */
  56590. private load3dlTexture;
  56591. /**
  56592. * Starts the loading process of the texture.
  56593. */
  56594. private loadTexture;
  56595. /**
  56596. * Clones the color gradind texture.
  56597. */
  56598. clone(): ColorGradingTexture;
  56599. /**
  56600. * Called during delayed load for textures.
  56601. */
  56602. delayLoad(): void;
  56603. /**
  56604. * Parses a color grading texture serialized by Babylon.
  56605. * @param parsedTexture The texture information being parsedTexture
  56606. * @param scene The scene to load the texture in
  56607. * @param rootUrl The root url of the data assets to load
  56608. * @return A color gradind texture
  56609. */
  56610. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56611. /**
  56612. * Serializes the LUT texture to json format.
  56613. */
  56614. serialize(): any;
  56615. /**
  56616. * Returns true if the passed parameter is a scene object (can be use for typings)
  56617. * @param sceneOrEngine The object to test.
  56618. */
  56619. private static _isScene;
  56620. }
  56621. }
  56622. declare module BABYLON {
  56623. /**
  56624. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56625. */
  56626. export class EquiRectangularCubeTexture extends BaseTexture {
  56627. /** The six faces of the cube. */
  56628. private static _FacesMapping;
  56629. private _noMipmap;
  56630. private _onLoad;
  56631. private _onError;
  56632. /** The size of the cubemap. */
  56633. private _size;
  56634. /** The buffer of the image. */
  56635. private _buffer;
  56636. /** The width of the input image. */
  56637. private _width;
  56638. /** The height of the input image. */
  56639. private _height;
  56640. /** The URL to the image. */
  56641. url: string;
  56642. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56643. coordinatesMode: number;
  56644. /**
  56645. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56646. * @param url The location of the image
  56647. * @param scene The scene the texture will be used in
  56648. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56649. * @param noMipmap Forces to not generate the mipmap if true
  56650. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56651. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56652. * @param onLoad — defines a callback called when texture is loaded
  56653. * @param onError — defines a callback called if there is an error
  56654. */
  56655. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56656. /**
  56657. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56658. */
  56659. private loadImage;
  56660. /**
  56661. * Convert the image buffer into a cubemap and create a CubeTexture.
  56662. */
  56663. private loadTexture;
  56664. /**
  56665. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56666. * @param buffer The ArrayBuffer that should be converted.
  56667. * @returns The buffer as Float32Array.
  56668. */
  56669. private getFloat32ArrayFromArrayBuffer;
  56670. /**
  56671. * Get the current class name of the texture useful for serialization or dynamic coding.
  56672. * @returns "EquiRectangularCubeTexture"
  56673. */
  56674. getClassName(): string;
  56675. /**
  56676. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56677. * @returns A clone of the current EquiRectangularCubeTexture.
  56678. */
  56679. clone(): EquiRectangularCubeTexture;
  56680. }
  56681. }
  56682. declare module BABYLON {
  56683. /**
  56684. * Based on jsTGALoader - Javascript loader for TGA file
  56685. * By Vincent Thibault
  56686. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56687. */
  56688. export class TGATools {
  56689. private static _TYPE_INDEXED;
  56690. private static _TYPE_RGB;
  56691. private static _TYPE_GREY;
  56692. private static _TYPE_RLE_INDEXED;
  56693. private static _TYPE_RLE_RGB;
  56694. private static _TYPE_RLE_GREY;
  56695. private static _ORIGIN_MASK;
  56696. private static _ORIGIN_SHIFT;
  56697. private static _ORIGIN_BL;
  56698. private static _ORIGIN_BR;
  56699. private static _ORIGIN_UL;
  56700. private static _ORIGIN_UR;
  56701. /**
  56702. * Gets the header of a TGA file
  56703. * @param data defines the TGA data
  56704. * @returns the header
  56705. */
  56706. static GetTGAHeader(data: Uint8Array): any;
  56707. /**
  56708. * Uploads TGA content to a Babylon Texture
  56709. * @hidden
  56710. */
  56711. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56712. /** @hidden */
  56713. 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;
  56714. /** @hidden */
  56715. 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;
  56716. /** @hidden */
  56717. 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;
  56718. /** @hidden */
  56719. 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;
  56720. /** @hidden */
  56721. 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;
  56722. /** @hidden */
  56723. 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;
  56724. }
  56725. }
  56726. declare module BABYLON {
  56727. /**
  56728. * Implementation of the TGA Texture Loader.
  56729. * @hidden
  56730. */
  56731. export class _TGATextureLoader implements IInternalTextureLoader {
  56732. /**
  56733. * Defines wether the loader supports cascade loading the different faces.
  56734. */
  56735. readonly supportCascades: boolean;
  56736. /**
  56737. * This returns if the loader support the current file information.
  56738. * @param extension defines the file extension of the file being loaded
  56739. * @returns true if the loader can load the specified file
  56740. */
  56741. canLoad(extension: string): boolean;
  56742. /**
  56743. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56744. * @param data contains the texture data
  56745. * @param texture defines the BabylonJS internal texture
  56746. * @param createPolynomials will be true if polynomials have been requested
  56747. * @param onLoad defines the callback to trigger once the texture is ready
  56748. * @param onError defines the callback to trigger in case of error
  56749. */
  56750. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56751. /**
  56752. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56753. * @param data contains the texture data
  56754. * @param texture defines the BabylonJS internal texture
  56755. * @param callback defines the method to call once ready to upload
  56756. */
  56757. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56758. }
  56759. }
  56760. declare module BABYLON {
  56761. /**
  56762. * Info about the .basis files
  56763. */
  56764. class BasisFileInfo {
  56765. /**
  56766. * If the file has alpha
  56767. */
  56768. hasAlpha: boolean;
  56769. /**
  56770. * Info about each image of the basis file
  56771. */
  56772. images: Array<{
  56773. levels: Array<{
  56774. width: number;
  56775. height: number;
  56776. transcodedPixels: ArrayBufferView;
  56777. }>;
  56778. }>;
  56779. }
  56780. /**
  56781. * Result of transcoding a basis file
  56782. */
  56783. class TranscodeResult {
  56784. /**
  56785. * Info about the .basis file
  56786. */
  56787. fileInfo: BasisFileInfo;
  56788. /**
  56789. * Format to use when loading the file
  56790. */
  56791. format: number;
  56792. }
  56793. /**
  56794. * Configuration options for the Basis transcoder
  56795. */
  56796. export class BasisTranscodeConfiguration {
  56797. /**
  56798. * Supported compression formats used to determine the supported output format of the transcoder
  56799. */
  56800. supportedCompressionFormats?: {
  56801. /**
  56802. * etc1 compression format
  56803. */
  56804. etc1?: boolean;
  56805. /**
  56806. * s3tc compression format
  56807. */
  56808. s3tc?: boolean;
  56809. /**
  56810. * pvrtc compression format
  56811. */
  56812. pvrtc?: boolean;
  56813. /**
  56814. * etc2 compression format
  56815. */
  56816. etc2?: boolean;
  56817. };
  56818. /**
  56819. * If mipmap levels should be loaded for transcoded images (Default: true)
  56820. */
  56821. loadMipmapLevels?: boolean;
  56822. /**
  56823. * Index of a single image to load (Default: all images)
  56824. */
  56825. loadSingleImage?: number;
  56826. }
  56827. /**
  56828. * Used to load .Basis files
  56829. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56830. */
  56831. export class BasisTools {
  56832. private static _IgnoreSupportedFormats;
  56833. /**
  56834. * URL to use when loading the basis transcoder
  56835. */
  56836. static JSModuleURL: string;
  56837. /**
  56838. * URL to use when loading the wasm module for the transcoder
  56839. */
  56840. static WasmModuleURL: string;
  56841. /**
  56842. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56843. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56844. * @returns internal format corresponding to the Basis format
  56845. */
  56846. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56847. private static _WorkerPromise;
  56848. private static _Worker;
  56849. private static _actionId;
  56850. private static _CreateWorkerAsync;
  56851. /**
  56852. * Transcodes a loaded image file to compressed pixel data
  56853. * @param data image data to transcode
  56854. * @param config configuration options for the transcoding
  56855. * @returns a promise resulting in the transcoded image
  56856. */
  56857. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56858. /**
  56859. * Loads a texture from the transcode result
  56860. * @param texture texture load to
  56861. * @param transcodeResult the result of transcoding the basis file to load from
  56862. */
  56863. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56864. }
  56865. }
  56866. declare module BABYLON {
  56867. /**
  56868. * Loader for .basis file format
  56869. */
  56870. export class _BasisTextureLoader implements IInternalTextureLoader {
  56871. /**
  56872. * Defines whether the loader supports cascade loading the different faces.
  56873. */
  56874. readonly supportCascades: boolean;
  56875. /**
  56876. * This returns if the loader support the current file information.
  56877. * @param extension defines the file extension of the file being loaded
  56878. * @returns true if the loader can load the specified file
  56879. */
  56880. canLoad(extension: string): boolean;
  56881. /**
  56882. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56883. * @param data contains the texture data
  56884. * @param texture defines the BabylonJS internal texture
  56885. * @param createPolynomials will be true if polynomials have been requested
  56886. * @param onLoad defines the callback to trigger once the texture is ready
  56887. * @param onError defines the callback to trigger in case of error
  56888. */
  56889. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56890. /**
  56891. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56892. * @param data contains the texture data
  56893. * @param texture defines the BabylonJS internal texture
  56894. * @param callback defines the method to call once ready to upload
  56895. */
  56896. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56897. }
  56898. }
  56899. declare module BABYLON {
  56900. /**
  56901. * 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.
  56902. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56903. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56904. */
  56905. export class CustomProceduralTexture extends ProceduralTexture {
  56906. private _animate;
  56907. private _time;
  56908. private _config;
  56909. private _texturePath;
  56910. /**
  56911. * Instantiates a new Custom Procedural Texture.
  56912. * 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.
  56913. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56914. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56915. * @param name Define the name of the texture
  56916. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56917. * @param size Define the size of the texture to create
  56918. * @param scene Define the scene the texture belongs to
  56919. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56920. * @param generateMipMaps Define if the texture should creates mip maps or not
  56921. */
  56922. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56923. private _loadJson;
  56924. /**
  56925. * Is the texture ready to be used ? (rendered at least once)
  56926. * @returns true if ready, otherwise, false.
  56927. */
  56928. isReady(): boolean;
  56929. /**
  56930. * Render the texture to its associated render target.
  56931. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56932. */
  56933. render(useCameraPostProcess?: boolean): void;
  56934. /**
  56935. * Update the list of dependant textures samplers in the shader.
  56936. */
  56937. updateTextures(): void;
  56938. /**
  56939. * Update the uniform values of the procedural texture in the shader.
  56940. */
  56941. updateShaderUniforms(): void;
  56942. /**
  56943. * Define if the texture animates or not.
  56944. */
  56945. get animate(): boolean;
  56946. set animate(value: boolean);
  56947. }
  56948. }
  56949. declare module BABYLON {
  56950. /** @hidden */
  56951. export var noisePixelShader: {
  56952. name: string;
  56953. shader: string;
  56954. };
  56955. }
  56956. declare module BABYLON {
  56957. /**
  56958. * Class used to generate noise procedural textures
  56959. */
  56960. export class NoiseProceduralTexture extends ProceduralTexture {
  56961. private _time;
  56962. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56963. brightness: number;
  56964. /** Defines the number of octaves to process */
  56965. octaves: number;
  56966. /** Defines the level of persistence (0.8 by default) */
  56967. persistence: number;
  56968. /** Gets or sets animation speed factor (default is 1) */
  56969. animationSpeedFactor: number;
  56970. /**
  56971. * Creates a new NoiseProceduralTexture
  56972. * @param name defines the name fo the texture
  56973. * @param size defines the size of the texture (default is 256)
  56974. * @param scene defines the hosting scene
  56975. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56976. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56977. */
  56978. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56979. private _updateShaderUniforms;
  56980. protected _getDefines(): string;
  56981. /** Generate the current state of the procedural texture */
  56982. render(useCameraPostProcess?: boolean): void;
  56983. /**
  56984. * Serializes this noise procedural texture
  56985. * @returns a serialized noise procedural texture object
  56986. */
  56987. serialize(): any;
  56988. /**
  56989. * Clone the texture.
  56990. * @returns the cloned texture
  56991. */
  56992. clone(): NoiseProceduralTexture;
  56993. /**
  56994. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56995. * @param parsedTexture defines parsed texture data
  56996. * @param scene defines the current scene
  56997. * @param rootUrl defines the root URL containing noise procedural texture information
  56998. * @returns a parsed NoiseProceduralTexture
  56999. */
  57000. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57001. }
  57002. }
  57003. declare module BABYLON {
  57004. /**
  57005. * Raw cube texture where the raw buffers are passed in
  57006. */
  57007. export class RawCubeTexture extends CubeTexture {
  57008. /**
  57009. * Creates a cube texture where the raw buffers are passed in.
  57010. * @param scene defines the scene the texture is attached to
  57011. * @param data defines the array of data to use to create each face
  57012. * @param size defines the size of the textures
  57013. * @param format defines the format of the data
  57014. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57015. * @param generateMipMaps defines if the engine should generate the mip levels
  57016. * @param invertY defines if data must be stored with Y axis inverted
  57017. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57018. * @param compression defines the compression used (null by default)
  57019. */
  57020. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57021. /**
  57022. * Updates the raw cube texture.
  57023. * @param data defines the data to store
  57024. * @param format defines the data format
  57025. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57026. * @param invertY defines if data must be stored with Y axis inverted
  57027. * @param compression defines the compression used (null by default)
  57028. * @param level defines which level of the texture to update
  57029. */
  57030. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57031. /**
  57032. * Updates a raw cube texture with RGBD encoded data.
  57033. * @param data defines the array of data [mipmap][face] to use to create each face
  57034. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57035. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57036. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57037. * @returns a promsie that resolves when the operation is complete
  57038. */
  57039. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57040. /**
  57041. * Clones the raw cube texture.
  57042. * @return a new cube texture
  57043. */
  57044. clone(): CubeTexture;
  57045. /** @hidden */
  57046. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57047. }
  57048. }
  57049. declare module BABYLON {
  57050. /**
  57051. * Class used to store 3D textures containing user data
  57052. */
  57053. export class RawTexture3D extends Texture {
  57054. /** Gets or sets the texture format to use */
  57055. format: number;
  57056. private _engine;
  57057. /**
  57058. * Create a new RawTexture3D
  57059. * @param data defines the data of the texture
  57060. * @param width defines the width of the texture
  57061. * @param height defines the height of the texture
  57062. * @param depth defines the depth of the texture
  57063. * @param format defines the texture format to use
  57064. * @param scene defines the hosting scene
  57065. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57066. * @param invertY defines if texture must be stored with Y axis inverted
  57067. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57068. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57069. */
  57070. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57071. /** Gets or sets the texture format to use */
  57072. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57073. /**
  57074. * Update the texture with new data
  57075. * @param data defines the data to store in the texture
  57076. */
  57077. update(data: ArrayBufferView): void;
  57078. }
  57079. }
  57080. declare module BABYLON {
  57081. /**
  57082. * Class used to store 2D array textures containing user data
  57083. */
  57084. export class RawTexture2DArray extends Texture {
  57085. /** Gets or sets the texture format to use */
  57086. format: number;
  57087. private _engine;
  57088. /**
  57089. * Create a new RawTexture2DArray
  57090. * @param data defines the data of the texture
  57091. * @param width defines the width of the texture
  57092. * @param height defines the height of the texture
  57093. * @param depth defines the number of layers of the texture
  57094. * @param format defines the texture format to use
  57095. * @param scene defines the hosting scene
  57096. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57097. * @param invertY defines if texture must be stored with Y axis inverted
  57098. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57099. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57100. */
  57101. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57102. /** Gets or sets the texture format to use */
  57103. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57104. /**
  57105. * Update the texture with new data
  57106. * @param data defines the data to store in the texture
  57107. */
  57108. update(data: ArrayBufferView): void;
  57109. }
  57110. }
  57111. declare module BABYLON {
  57112. /**
  57113. * Creates a refraction texture used by refraction channel of the standard material.
  57114. * It is like a mirror but to see through a material.
  57115. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57116. */
  57117. export class RefractionTexture extends RenderTargetTexture {
  57118. /**
  57119. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57120. * 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.
  57121. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57122. */
  57123. refractionPlane: Plane;
  57124. /**
  57125. * Define how deep under the surface we should see.
  57126. */
  57127. depth: number;
  57128. /**
  57129. * Creates a refraction texture used by refraction channel of the standard material.
  57130. * It is like a mirror but to see through a material.
  57131. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57132. * @param name Define the texture name
  57133. * @param size Define the size of the underlying texture
  57134. * @param scene Define the scene the refraction belongs to
  57135. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57136. */
  57137. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57138. /**
  57139. * Clone the refraction texture.
  57140. * @returns the cloned texture
  57141. */
  57142. clone(): RefractionTexture;
  57143. /**
  57144. * Serialize the texture to a JSON representation you could use in Parse later on
  57145. * @returns the serialized JSON representation
  57146. */
  57147. serialize(): any;
  57148. }
  57149. }
  57150. declare module BABYLON {
  57151. /**
  57152. * Defines the options related to the creation of an HtmlElementTexture
  57153. */
  57154. export interface IHtmlElementTextureOptions {
  57155. /**
  57156. * Defines wether mip maps should be created or not.
  57157. */
  57158. generateMipMaps?: boolean;
  57159. /**
  57160. * Defines the sampling mode of the texture.
  57161. */
  57162. samplingMode?: number;
  57163. /**
  57164. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57165. */
  57166. engine: Nullable<ThinEngine>;
  57167. /**
  57168. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57169. */
  57170. scene: Nullable<Scene>;
  57171. }
  57172. /**
  57173. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57174. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57175. * is automatically managed.
  57176. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57177. * in your application.
  57178. *
  57179. * As the update is not automatic, you need to call them manually.
  57180. */
  57181. export class HtmlElementTexture extends BaseTexture {
  57182. /**
  57183. * The texture URL.
  57184. */
  57185. element: HTMLVideoElement | HTMLCanvasElement;
  57186. private static readonly DefaultOptions;
  57187. private _textureMatrix;
  57188. private _engine;
  57189. private _isVideo;
  57190. private _generateMipMaps;
  57191. private _samplingMode;
  57192. /**
  57193. * Instantiates a HtmlElementTexture from the following parameters.
  57194. *
  57195. * @param name Defines the name of the texture
  57196. * @param element Defines the video or canvas the texture is filled with
  57197. * @param options Defines the other none mandatory texture creation options
  57198. */
  57199. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57200. private _createInternalTexture;
  57201. /**
  57202. * Returns the texture matrix used in most of the material.
  57203. */
  57204. getTextureMatrix(): Matrix;
  57205. /**
  57206. * Updates the content of the texture.
  57207. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57208. */
  57209. update(invertY?: Nullable<boolean>): void;
  57210. }
  57211. }
  57212. declare module BABYLON {
  57213. /**
  57214. * Defines the basic options interface of a TexturePacker Frame
  57215. */
  57216. export interface ITexturePackerFrame {
  57217. /**
  57218. * The frame ID
  57219. */
  57220. id: number;
  57221. /**
  57222. * The frames Scale
  57223. */
  57224. scale: Vector2;
  57225. /**
  57226. * The Frames offset
  57227. */
  57228. offset: Vector2;
  57229. }
  57230. /**
  57231. * This is a support class for frame Data on texture packer sets.
  57232. */
  57233. export class TexturePackerFrame implements ITexturePackerFrame {
  57234. /**
  57235. * The frame ID
  57236. */
  57237. id: number;
  57238. /**
  57239. * The frames Scale
  57240. */
  57241. scale: Vector2;
  57242. /**
  57243. * The Frames offset
  57244. */
  57245. offset: Vector2;
  57246. /**
  57247. * Initializes a texture package frame.
  57248. * @param id The numerical frame identifier
  57249. * @param scale Scalar Vector2 for UV frame
  57250. * @param offset Vector2 for the frame position in UV units.
  57251. * @returns TexturePackerFrame
  57252. */
  57253. constructor(id: number, scale: Vector2, offset: Vector2);
  57254. }
  57255. }
  57256. declare module BABYLON {
  57257. /**
  57258. * Defines the basic options interface of a TexturePacker
  57259. */
  57260. export interface ITexturePackerOptions {
  57261. /**
  57262. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57263. */
  57264. map?: string[];
  57265. /**
  57266. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57267. */
  57268. uvsIn?: string;
  57269. /**
  57270. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57271. */
  57272. uvsOut?: string;
  57273. /**
  57274. * number representing the layout style. Defaults to LAYOUT_STRIP
  57275. */
  57276. layout?: number;
  57277. /**
  57278. * number of columns if using custom column count layout(2). This defaults to 4.
  57279. */
  57280. colnum?: number;
  57281. /**
  57282. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57283. */
  57284. updateInputMeshes?: boolean;
  57285. /**
  57286. * boolean flag to dispose all the source textures. Defaults to true.
  57287. */
  57288. disposeSources?: boolean;
  57289. /**
  57290. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57291. */
  57292. fillBlanks?: boolean;
  57293. /**
  57294. * string value representing the context fill style color. Defaults to 'black'.
  57295. */
  57296. customFillColor?: string;
  57297. /**
  57298. * Width and Height Value of each Frame in the TexturePacker Sets
  57299. */
  57300. frameSize?: number;
  57301. /**
  57302. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57303. */
  57304. paddingRatio?: number;
  57305. /**
  57306. * Number that declares the fill method for the padding gutter.
  57307. */
  57308. paddingMode?: number;
  57309. /**
  57310. * If in SUBUV_COLOR padding mode what color to use.
  57311. */
  57312. paddingColor?: Color3 | Color4;
  57313. }
  57314. /**
  57315. * Defines the basic interface of a TexturePacker JSON File
  57316. */
  57317. export interface ITexturePackerJSON {
  57318. /**
  57319. * The frame ID
  57320. */
  57321. name: string;
  57322. /**
  57323. * The base64 channel data
  57324. */
  57325. sets: any;
  57326. /**
  57327. * The options of the Packer
  57328. */
  57329. options: ITexturePackerOptions;
  57330. /**
  57331. * The frame data of the Packer
  57332. */
  57333. frames: Array<number>;
  57334. }
  57335. /**
  57336. * This is a support class that generates a series of packed texture sets.
  57337. * @see https://doc.babylonjs.com/babylon101/materials
  57338. */
  57339. export class TexturePacker {
  57340. /** Packer Layout Constant 0 */
  57341. static readonly LAYOUT_STRIP: number;
  57342. /** Packer Layout Constant 1 */
  57343. static readonly LAYOUT_POWER2: number;
  57344. /** Packer Layout Constant 2 */
  57345. static readonly LAYOUT_COLNUM: number;
  57346. /** Packer Layout Constant 0 */
  57347. static readonly SUBUV_WRAP: number;
  57348. /** Packer Layout Constant 1 */
  57349. static readonly SUBUV_EXTEND: number;
  57350. /** Packer Layout Constant 2 */
  57351. static readonly SUBUV_COLOR: number;
  57352. /** The Name of the Texture Package */
  57353. name: string;
  57354. /** The scene scope of the TexturePacker */
  57355. scene: Scene;
  57356. /** The Meshes to target */
  57357. meshes: AbstractMesh[];
  57358. /** Arguments passed with the Constructor */
  57359. options: ITexturePackerOptions;
  57360. /** The promise that is started upon initialization */
  57361. promise: Nullable<Promise<TexturePacker | string>>;
  57362. /** The Container object for the channel sets that are generated */
  57363. sets: object;
  57364. /** The Container array for the frames that are generated */
  57365. frames: TexturePackerFrame[];
  57366. /** The expected number of textures the system is parsing. */
  57367. private _expecting;
  57368. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57369. private _paddingValue;
  57370. /**
  57371. * Initializes a texture package series from an array of meshes or a single mesh.
  57372. * @param name The name of the package
  57373. * @param meshes The target meshes to compose the package from
  57374. * @param options The arguments that texture packer should follow while building.
  57375. * @param scene The scene which the textures are scoped to.
  57376. * @returns TexturePacker
  57377. */
  57378. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57379. /**
  57380. * Starts the package process
  57381. * @param resolve The promises resolution function
  57382. * @returns TexturePacker
  57383. */
  57384. private _createFrames;
  57385. /**
  57386. * Calculates the Size of the Channel Sets
  57387. * @returns Vector2
  57388. */
  57389. private _calculateSize;
  57390. /**
  57391. * Calculates the UV data for the frames.
  57392. * @param baseSize the base frameSize
  57393. * @param padding the base frame padding
  57394. * @param dtSize size of the Dynamic Texture for that channel
  57395. * @param dtUnits is 1/dtSize
  57396. * @param update flag to update the input meshes
  57397. */
  57398. private _calculateMeshUVFrames;
  57399. /**
  57400. * Calculates the frames Offset.
  57401. * @param index of the frame
  57402. * @returns Vector2
  57403. */
  57404. private _getFrameOffset;
  57405. /**
  57406. * Updates a Mesh to the frame data
  57407. * @param mesh that is the target
  57408. * @param frameID or the frame index
  57409. */
  57410. private _updateMeshUV;
  57411. /**
  57412. * Updates a Meshes materials to use the texture packer channels
  57413. * @param m is the mesh to target
  57414. * @param force all channels on the packer to be set.
  57415. */
  57416. private _updateTextureReferences;
  57417. /**
  57418. * Public method to set a Mesh to a frame
  57419. * @param m that is the target
  57420. * @param frameID or the frame index
  57421. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57422. */
  57423. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57424. /**
  57425. * Starts the async promise to compile the texture packer.
  57426. * @returns Promise<void>
  57427. */
  57428. processAsync(): Promise<void>;
  57429. /**
  57430. * Disposes all textures associated with this packer
  57431. */
  57432. dispose(): void;
  57433. /**
  57434. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57435. * @param imageType is the image type to use.
  57436. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57437. */
  57438. download(imageType?: string, quality?: number): void;
  57439. /**
  57440. * Public method to load a texturePacker JSON file.
  57441. * @param data of the JSON file in string format.
  57442. */
  57443. updateFromJSON(data: string): void;
  57444. }
  57445. }
  57446. declare module BABYLON {
  57447. /**
  57448. * Enum used to define the target of a block
  57449. */
  57450. export enum NodeMaterialBlockTargets {
  57451. /** Vertex shader */
  57452. Vertex = 1,
  57453. /** Fragment shader */
  57454. Fragment = 2,
  57455. /** Neutral */
  57456. Neutral = 4,
  57457. /** Vertex and Fragment */
  57458. VertexAndFragment = 3
  57459. }
  57460. }
  57461. declare module BABYLON {
  57462. /**
  57463. * Defines the kind of connection point for node based material
  57464. */
  57465. export enum NodeMaterialBlockConnectionPointTypes {
  57466. /** Float */
  57467. Float = 1,
  57468. /** Int */
  57469. Int = 2,
  57470. /** Vector2 */
  57471. Vector2 = 4,
  57472. /** Vector3 */
  57473. Vector3 = 8,
  57474. /** Vector4 */
  57475. Vector4 = 16,
  57476. /** Color3 */
  57477. Color3 = 32,
  57478. /** Color4 */
  57479. Color4 = 64,
  57480. /** Matrix */
  57481. Matrix = 128,
  57482. /** Detect type based on connection */
  57483. AutoDetect = 1024,
  57484. /** Output type that will be defined by input type */
  57485. BasedOnInput = 2048
  57486. }
  57487. }
  57488. declare module BABYLON {
  57489. /**
  57490. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57491. */
  57492. export enum NodeMaterialBlockConnectionPointMode {
  57493. /** Value is an uniform */
  57494. Uniform = 0,
  57495. /** Value is a mesh attribute */
  57496. Attribute = 1,
  57497. /** Value is a varying between vertex and fragment shaders */
  57498. Varying = 2,
  57499. /** Mode is undefined */
  57500. Undefined = 3
  57501. }
  57502. }
  57503. declare module BABYLON {
  57504. /**
  57505. * Enum used to define system values e.g. values automatically provided by the system
  57506. */
  57507. export enum NodeMaterialSystemValues {
  57508. /** World */
  57509. World = 1,
  57510. /** View */
  57511. View = 2,
  57512. /** Projection */
  57513. Projection = 3,
  57514. /** ViewProjection */
  57515. ViewProjection = 4,
  57516. /** WorldView */
  57517. WorldView = 5,
  57518. /** WorldViewProjection */
  57519. WorldViewProjection = 6,
  57520. /** CameraPosition */
  57521. CameraPosition = 7,
  57522. /** Fog Color */
  57523. FogColor = 8,
  57524. /** Delta time */
  57525. DeltaTime = 9
  57526. }
  57527. }
  57528. declare module BABYLON {
  57529. /**
  57530. * Root class for all node material optimizers
  57531. */
  57532. export class NodeMaterialOptimizer {
  57533. /**
  57534. * Function used to optimize a NodeMaterial graph
  57535. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57536. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57537. */
  57538. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57539. }
  57540. }
  57541. declare module BABYLON {
  57542. /**
  57543. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57544. */
  57545. export class TransformBlock extends NodeMaterialBlock {
  57546. /**
  57547. * Defines the value to use to complement W value to transform it to a Vector4
  57548. */
  57549. complementW: number;
  57550. /**
  57551. * Defines the value to use to complement z value to transform it to a Vector4
  57552. */
  57553. complementZ: number;
  57554. /**
  57555. * Creates a new TransformBlock
  57556. * @param name defines the block name
  57557. */
  57558. constructor(name: string);
  57559. /**
  57560. * Gets the current class name
  57561. * @returns the class name
  57562. */
  57563. getClassName(): string;
  57564. /**
  57565. * Gets the vector input
  57566. */
  57567. get vector(): NodeMaterialConnectionPoint;
  57568. /**
  57569. * Gets the output component
  57570. */
  57571. get output(): NodeMaterialConnectionPoint;
  57572. /**
  57573. * Gets the xyz output component
  57574. */
  57575. get xyz(): NodeMaterialConnectionPoint;
  57576. /**
  57577. * Gets the matrix transform input
  57578. */
  57579. get transform(): NodeMaterialConnectionPoint;
  57580. protected _buildBlock(state: NodeMaterialBuildState): this;
  57581. serialize(): any;
  57582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57583. protected _dumpPropertiesCode(): string;
  57584. }
  57585. }
  57586. declare module BABYLON {
  57587. /**
  57588. * Block used to output the vertex position
  57589. */
  57590. export class VertexOutputBlock extends NodeMaterialBlock {
  57591. /**
  57592. * Creates a new VertexOutputBlock
  57593. * @param name defines the block name
  57594. */
  57595. constructor(name: string);
  57596. /**
  57597. * Gets the current class name
  57598. * @returns the class name
  57599. */
  57600. getClassName(): string;
  57601. /**
  57602. * Gets the vector input component
  57603. */
  57604. get vector(): NodeMaterialConnectionPoint;
  57605. protected _buildBlock(state: NodeMaterialBuildState): this;
  57606. }
  57607. }
  57608. declare module BABYLON {
  57609. /**
  57610. * Block used to output the final color
  57611. */
  57612. export class FragmentOutputBlock extends NodeMaterialBlock {
  57613. /**
  57614. * Create a new FragmentOutputBlock
  57615. * @param name defines the block name
  57616. */
  57617. constructor(name: string);
  57618. /**
  57619. * Gets the current class name
  57620. * @returns the class name
  57621. */
  57622. getClassName(): string;
  57623. /**
  57624. * Gets the rgba input component
  57625. */
  57626. get rgba(): NodeMaterialConnectionPoint;
  57627. /**
  57628. * Gets the rgb input component
  57629. */
  57630. get rgb(): NodeMaterialConnectionPoint;
  57631. /**
  57632. * Gets the a input component
  57633. */
  57634. get a(): NodeMaterialConnectionPoint;
  57635. protected _buildBlock(state: NodeMaterialBuildState): this;
  57636. }
  57637. }
  57638. declare module BABYLON {
  57639. /**
  57640. * Block used to read a reflection texture from a sampler
  57641. */
  57642. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57643. private _define3DName;
  57644. private _defineCubicName;
  57645. private _defineExplicitName;
  57646. private _defineProjectionName;
  57647. private _defineLocalCubicName;
  57648. private _defineSphericalName;
  57649. private _definePlanarName;
  57650. private _defineEquirectangularName;
  57651. private _defineMirroredEquirectangularFixedName;
  57652. private _defineEquirectangularFixedName;
  57653. private _defineSkyboxName;
  57654. private _cubeSamplerName;
  57655. private _2DSamplerName;
  57656. private _positionUVWName;
  57657. private _directionWName;
  57658. private _reflectionCoordsName;
  57659. private _reflection2DCoordsName;
  57660. private _reflectionColorName;
  57661. private _reflectionMatrixName;
  57662. /**
  57663. * Gets or sets the texture associated with the node
  57664. */
  57665. texture: Nullable<BaseTexture>;
  57666. /**
  57667. * Create a new TextureBlock
  57668. * @param name defines the block name
  57669. */
  57670. constructor(name: string);
  57671. /**
  57672. * Gets the current class name
  57673. * @returns the class name
  57674. */
  57675. getClassName(): string;
  57676. /**
  57677. * Gets the world position input component
  57678. */
  57679. get position(): NodeMaterialConnectionPoint;
  57680. /**
  57681. * Gets the world position input component
  57682. */
  57683. get worldPosition(): NodeMaterialConnectionPoint;
  57684. /**
  57685. * Gets the world normal input component
  57686. */
  57687. get worldNormal(): NodeMaterialConnectionPoint;
  57688. /**
  57689. * Gets the world input component
  57690. */
  57691. get world(): NodeMaterialConnectionPoint;
  57692. /**
  57693. * Gets the camera (or eye) position component
  57694. */
  57695. get cameraPosition(): NodeMaterialConnectionPoint;
  57696. /**
  57697. * Gets the view input component
  57698. */
  57699. get view(): NodeMaterialConnectionPoint;
  57700. /**
  57701. * Gets the rgb output component
  57702. */
  57703. get rgb(): NodeMaterialConnectionPoint;
  57704. /**
  57705. * Gets the r output component
  57706. */
  57707. get r(): NodeMaterialConnectionPoint;
  57708. /**
  57709. * Gets the g output component
  57710. */
  57711. get g(): NodeMaterialConnectionPoint;
  57712. /**
  57713. * Gets the b output component
  57714. */
  57715. get b(): NodeMaterialConnectionPoint;
  57716. autoConfigure(material: NodeMaterial): void;
  57717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57718. isReady(): boolean;
  57719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57720. private _injectVertexCode;
  57721. private _writeOutput;
  57722. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57723. protected _dumpPropertiesCode(): string;
  57724. serialize(): any;
  57725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57726. }
  57727. }
  57728. declare module BABYLON {
  57729. /**
  57730. * Interface used to configure the node material editor
  57731. */
  57732. export interface INodeMaterialEditorOptions {
  57733. /** Define the URl to load node editor script */
  57734. editorURL?: string;
  57735. }
  57736. /** @hidden */
  57737. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57738. NORMAL: boolean;
  57739. TANGENT: boolean;
  57740. UV1: boolean;
  57741. /** BONES */
  57742. NUM_BONE_INFLUENCERS: number;
  57743. BonesPerMesh: number;
  57744. BONETEXTURE: boolean;
  57745. /** MORPH TARGETS */
  57746. MORPHTARGETS: boolean;
  57747. MORPHTARGETS_NORMAL: boolean;
  57748. MORPHTARGETS_TANGENT: boolean;
  57749. MORPHTARGETS_UV: boolean;
  57750. NUM_MORPH_INFLUENCERS: number;
  57751. /** IMAGE PROCESSING */
  57752. IMAGEPROCESSING: boolean;
  57753. VIGNETTE: boolean;
  57754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57755. VIGNETTEBLENDMODEOPAQUE: boolean;
  57756. TONEMAPPING: boolean;
  57757. TONEMAPPING_ACES: boolean;
  57758. CONTRAST: boolean;
  57759. EXPOSURE: boolean;
  57760. COLORCURVES: boolean;
  57761. COLORGRADING: boolean;
  57762. COLORGRADING3D: boolean;
  57763. SAMPLER3DGREENDEPTH: boolean;
  57764. SAMPLER3DBGRMAP: boolean;
  57765. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57766. /** MISC. */
  57767. BUMPDIRECTUV: number;
  57768. constructor();
  57769. setValue(name: string, value: boolean): void;
  57770. }
  57771. /**
  57772. * Class used to configure NodeMaterial
  57773. */
  57774. export interface INodeMaterialOptions {
  57775. /**
  57776. * Defines if blocks should emit comments
  57777. */
  57778. emitComments: boolean;
  57779. }
  57780. /**
  57781. * Class used to create a node based material built by assembling shader blocks
  57782. */
  57783. export class NodeMaterial extends PushMaterial {
  57784. private static _BuildIdGenerator;
  57785. private _options;
  57786. private _vertexCompilationState;
  57787. private _fragmentCompilationState;
  57788. private _sharedData;
  57789. private _buildId;
  57790. private _buildWasSuccessful;
  57791. private _cachedWorldViewMatrix;
  57792. private _cachedWorldViewProjectionMatrix;
  57793. private _optimizers;
  57794. private _animationFrame;
  57795. /** Define the Url to load node editor script */
  57796. static EditorURL: string;
  57797. /** Define the Url to load snippets */
  57798. static SnippetUrl: string;
  57799. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57800. static IgnoreTexturesAtLoadTime: boolean;
  57801. private BJSNODEMATERIALEDITOR;
  57802. /** Get the inspector from bundle or global */
  57803. private _getGlobalNodeMaterialEditor;
  57804. /**
  57805. * Snippet ID if the material was created from the snippet server
  57806. */
  57807. snippetId: string;
  57808. /**
  57809. * Gets or sets data used by visual editor
  57810. * @see https://nme.babylonjs.com
  57811. */
  57812. editorData: any;
  57813. /**
  57814. * 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)
  57815. */
  57816. ignoreAlpha: boolean;
  57817. /**
  57818. * Defines the maximum number of lights that can be used in the material
  57819. */
  57820. maxSimultaneousLights: number;
  57821. /**
  57822. * Observable raised when the material is built
  57823. */
  57824. onBuildObservable: Observable<NodeMaterial>;
  57825. /**
  57826. * Gets or sets the root nodes of the material vertex shader
  57827. */
  57828. _vertexOutputNodes: NodeMaterialBlock[];
  57829. /**
  57830. * Gets or sets the root nodes of the material fragment (pixel) shader
  57831. */
  57832. _fragmentOutputNodes: NodeMaterialBlock[];
  57833. /** Gets or sets options to control the node material overall behavior */
  57834. get options(): INodeMaterialOptions;
  57835. set options(options: INodeMaterialOptions);
  57836. /**
  57837. * Default configuration related to image processing available in the standard Material.
  57838. */
  57839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57840. /**
  57841. * Gets the image processing configuration used either in this material.
  57842. */
  57843. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57844. /**
  57845. * Sets the Default image processing configuration used either in the this material.
  57846. *
  57847. * If sets to null, the scene one is in use.
  57848. */
  57849. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57850. /**
  57851. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57852. */
  57853. attachedBlocks: NodeMaterialBlock[];
  57854. /**
  57855. * Create a new node based material
  57856. * @param name defines the material name
  57857. * @param scene defines the hosting scene
  57858. * @param options defines creation option
  57859. */
  57860. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57861. /**
  57862. * Gets the current class name of the material e.g. "NodeMaterial"
  57863. * @returns the class name
  57864. */
  57865. getClassName(): string;
  57866. /**
  57867. * Keep track of the image processing observer to allow dispose and replace.
  57868. */
  57869. private _imageProcessingObserver;
  57870. /**
  57871. * Attaches a new image processing configuration to the Standard Material.
  57872. * @param configuration
  57873. */
  57874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57875. /**
  57876. * Get a block by its name
  57877. * @param name defines the name of the block to retrieve
  57878. * @returns the required block or null if not found
  57879. */
  57880. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57881. /**
  57882. * Get a block by its name
  57883. * @param predicate defines the predicate used to find the good candidate
  57884. * @returns the required block or null if not found
  57885. */
  57886. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57887. /**
  57888. * Get an input block by its name
  57889. * @param predicate defines the predicate used to find the good candidate
  57890. * @returns the required input block or null if not found
  57891. */
  57892. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57893. /**
  57894. * Gets the list of input blocks attached to this material
  57895. * @returns an array of InputBlocks
  57896. */
  57897. getInputBlocks(): InputBlock[];
  57898. /**
  57899. * Adds a new optimizer to the list of optimizers
  57900. * @param optimizer defines the optimizers to add
  57901. * @returns the current material
  57902. */
  57903. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57904. /**
  57905. * Remove an optimizer from the list of optimizers
  57906. * @param optimizer defines the optimizers to remove
  57907. * @returns the current material
  57908. */
  57909. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57910. /**
  57911. * Add a new block to the list of output nodes
  57912. * @param node defines the node to add
  57913. * @returns the current material
  57914. */
  57915. addOutputNode(node: NodeMaterialBlock): this;
  57916. /**
  57917. * Remove a block from the list of root nodes
  57918. * @param node defines the node to remove
  57919. * @returns the current material
  57920. */
  57921. removeOutputNode(node: NodeMaterialBlock): this;
  57922. private _addVertexOutputNode;
  57923. private _removeVertexOutputNode;
  57924. private _addFragmentOutputNode;
  57925. private _removeFragmentOutputNode;
  57926. /**
  57927. * Specifies if the material will require alpha blending
  57928. * @returns a boolean specifying if alpha blending is needed
  57929. */
  57930. needAlphaBlending(): boolean;
  57931. /**
  57932. * Specifies if this material should be rendered in alpha test mode
  57933. * @returns a boolean specifying if an alpha test is needed.
  57934. */
  57935. needAlphaTesting(): boolean;
  57936. private _initializeBlock;
  57937. private _resetDualBlocks;
  57938. /**
  57939. * Remove a block from the current node material
  57940. * @param block defines the block to remove
  57941. */
  57942. removeBlock(block: NodeMaterialBlock): void;
  57943. /**
  57944. * Build the material and generates the inner effect
  57945. * @param verbose defines if the build should log activity
  57946. */
  57947. build(verbose?: boolean): void;
  57948. /**
  57949. * Runs an otpimization phase to try to improve the shader code
  57950. */
  57951. optimize(): void;
  57952. private _prepareDefinesForAttributes;
  57953. /**
  57954. * Get if the submesh is ready to be used and all its information available.
  57955. * Child classes can use it to update shaders
  57956. * @param mesh defines the mesh to check
  57957. * @param subMesh defines which submesh to check
  57958. * @param useInstances specifies that instances should be used
  57959. * @returns a boolean indicating that the submesh is ready or not
  57960. */
  57961. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57962. /**
  57963. * Get a string representing the shaders built by the current node graph
  57964. */
  57965. get compiledShaders(): string;
  57966. /**
  57967. * Binds the world matrix to the material
  57968. * @param world defines the world transformation matrix
  57969. */
  57970. bindOnlyWorldMatrix(world: Matrix): void;
  57971. /**
  57972. * Binds the submesh to this material by preparing the effect and shader to draw
  57973. * @param world defines the world transformation matrix
  57974. * @param mesh defines the mesh containing the submesh
  57975. * @param subMesh defines the submesh to bind the material to
  57976. */
  57977. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57978. /**
  57979. * Gets the active textures from the material
  57980. * @returns an array of textures
  57981. */
  57982. getActiveTextures(): BaseTexture[];
  57983. /**
  57984. * Gets the list of texture blocks
  57985. * @returns an array of texture blocks
  57986. */
  57987. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57988. /**
  57989. * Specifies if the material uses a texture
  57990. * @param texture defines the texture to check against the material
  57991. * @returns a boolean specifying if the material uses the texture
  57992. */
  57993. hasTexture(texture: BaseTexture): boolean;
  57994. /**
  57995. * Disposes the material
  57996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57998. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57999. */
  58000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58001. /** Creates the node editor window. */
  58002. private _createNodeEditor;
  58003. /**
  58004. * Launch the node material editor
  58005. * @param config Define the configuration of the editor
  58006. * @return a promise fulfilled when the node editor is visible
  58007. */
  58008. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58009. /**
  58010. * Clear the current material
  58011. */
  58012. clear(): void;
  58013. /**
  58014. * Clear the current material and set it to a default state
  58015. */
  58016. setToDefault(): void;
  58017. /**
  58018. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58019. * @param url defines the url to load from
  58020. * @returns a promise that will fullfil when the material is fully loaded
  58021. */
  58022. loadAsync(url: string): Promise<void>;
  58023. private _gatherBlocks;
  58024. /**
  58025. * Generate a string containing the code declaration required to create an equivalent of this material
  58026. * @returns a string
  58027. */
  58028. generateCode(): string;
  58029. /**
  58030. * Serializes this material in a JSON representation
  58031. * @returns the serialized material object
  58032. */
  58033. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58034. private _restoreConnections;
  58035. /**
  58036. * Clear the current graph and load a new one from a serialization object
  58037. * @param source defines the JSON representation of the material
  58038. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58039. */
  58040. loadFromSerialization(source: any, rootUrl?: string): void;
  58041. /**
  58042. * Makes a duplicate of the current material.
  58043. * @param name - name to use for the new material.
  58044. */
  58045. clone(name: string): NodeMaterial;
  58046. /**
  58047. * Creates a node material from parsed material data
  58048. * @param source defines the JSON representation of the material
  58049. * @param scene defines the hosting scene
  58050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58051. * @returns a new node material
  58052. */
  58053. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58054. /**
  58055. * Creates a node material from a snippet saved in a remote file
  58056. * @param name defines the name of the material to create
  58057. * @param url defines the url to load from
  58058. * @param scene defines the hosting scene
  58059. * @returns a promise that will resolve to the new node material
  58060. */
  58061. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58062. /**
  58063. * Creates a node material from a snippet saved by the node material editor
  58064. * @param snippetId defines the snippet to load
  58065. * @param scene defines the hosting scene
  58066. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58067. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58068. * @returns a promise that will resolve to the new node material
  58069. */
  58070. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58071. /**
  58072. * Creates a new node material set to default basic configuration
  58073. * @param name defines the name of the material
  58074. * @param scene defines the hosting scene
  58075. * @returns a new NodeMaterial
  58076. */
  58077. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58078. }
  58079. }
  58080. declare module BABYLON {
  58081. /**
  58082. * Block used to read a texture from a sampler
  58083. */
  58084. export class TextureBlock extends NodeMaterialBlock {
  58085. private _defineName;
  58086. private _linearDefineName;
  58087. private _tempTextureRead;
  58088. private _samplerName;
  58089. private _transformedUVName;
  58090. private _textureTransformName;
  58091. private _textureInfoName;
  58092. private _mainUVName;
  58093. private _mainUVDefineName;
  58094. /**
  58095. * Gets or sets the texture associated with the node
  58096. */
  58097. texture: Nullable<Texture>;
  58098. /**
  58099. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58100. */
  58101. convertToGammaSpace: boolean;
  58102. /**
  58103. * Create a new TextureBlock
  58104. * @param name defines the block name
  58105. */
  58106. constructor(name: string);
  58107. /**
  58108. * Gets the current class name
  58109. * @returns the class name
  58110. */
  58111. getClassName(): string;
  58112. /**
  58113. * Gets the uv input component
  58114. */
  58115. get uv(): NodeMaterialConnectionPoint;
  58116. /**
  58117. * Gets the rgba output component
  58118. */
  58119. get rgba(): NodeMaterialConnectionPoint;
  58120. /**
  58121. * Gets the rgb output component
  58122. */
  58123. get rgb(): NodeMaterialConnectionPoint;
  58124. /**
  58125. * Gets the r output component
  58126. */
  58127. get r(): NodeMaterialConnectionPoint;
  58128. /**
  58129. * Gets the g output component
  58130. */
  58131. get g(): NodeMaterialConnectionPoint;
  58132. /**
  58133. * Gets the b output component
  58134. */
  58135. get b(): NodeMaterialConnectionPoint;
  58136. /**
  58137. * Gets the a output component
  58138. */
  58139. get a(): NodeMaterialConnectionPoint;
  58140. get target(): NodeMaterialBlockTargets;
  58141. autoConfigure(material: NodeMaterial): void;
  58142. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58144. isReady(): boolean;
  58145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58146. private get _isMixed();
  58147. private _injectVertexCode;
  58148. private _writeTextureRead;
  58149. private _writeOutput;
  58150. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58151. protected _dumpPropertiesCode(): string;
  58152. serialize(): any;
  58153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58154. }
  58155. }
  58156. declare module BABYLON {
  58157. /**
  58158. * Class used to store shared data between 2 NodeMaterialBuildState
  58159. */
  58160. export class NodeMaterialBuildStateSharedData {
  58161. /**
  58162. * Gets the list of emitted varyings
  58163. */
  58164. temps: string[];
  58165. /**
  58166. * Gets the list of emitted varyings
  58167. */
  58168. varyings: string[];
  58169. /**
  58170. * Gets the varying declaration string
  58171. */
  58172. varyingDeclaration: string;
  58173. /**
  58174. * Input blocks
  58175. */
  58176. inputBlocks: InputBlock[];
  58177. /**
  58178. * Input blocks
  58179. */
  58180. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58181. /**
  58182. * Bindable blocks (Blocks that need to set data to the effect)
  58183. */
  58184. bindableBlocks: NodeMaterialBlock[];
  58185. /**
  58186. * List of blocks that can provide a compilation fallback
  58187. */
  58188. blocksWithFallbacks: NodeMaterialBlock[];
  58189. /**
  58190. * List of blocks that can provide a define update
  58191. */
  58192. blocksWithDefines: NodeMaterialBlock[];
  58193. /**
  58194. * List of blocks that can provide a repeatable content
  58195. */
  58196. repeatableContentBlocks: NodeMaterialBlock[];
  58197. /**
  58198. * List of blocks that can provide a dynamic list of uniforms
  58199. */
  58200. dynamicUniformBlocks: NodeMaterialBlock[];
  58201. /**
  58202. * List of blocks that can block the isReady function for the material
  58203. */
  58204. blockingBlocks: NodeMaterialBlock[];
  58205. /**
  58206. * Gets the list of animated inputs
  58207. */
  58208. animatedInputs: InputBlock[];
  58209. /**
  58210. * Build Id used to avoid multiple recompilations
  58211. */
  58212. buildId: number;
  58213. /** List of emitted variables */
  58214. variableNames: {
  58215. [key: string]: number;
  58216. };
  58217. /** List of emitted defines */
  58218. defineNames: {
  58219. [key: string]: number;
  58220. };
  58221. /** Should emit comments? */
  58222. emitComments: boolean;
  58223. /** Emit build activity */
  58224. verbose: boolean;
  58225. /** Gets or sets the hosting scene */
  58226. scene: Scene;
  58227. /**
  58228. * Gets the compilation hints emitted at compilation time
  58229. */
  58230. hints: {
  58231. needWorldViewMatrix: boolean;
  58232. needWorldViewProjectionMatrix: boolean;
  58233. needAlphaBlending: boolean;
  58234. needAlphaTesting: boolean;
  58235. };
  58236. /**
  58237. * List of compilation checks
  58238. */
  58239. checks: {
  58240. emitVertex: boolean;
  58241. emitFragment: boolean;
  58242. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58243. };
  58244. /** Creates a new shared data */
  58245. constructor();
  58246. /**
  58247. * Emits console errors and exceptions if there is a failing check
  58248. */
  58249. emitErrors(): void;
  58250. }
  58251. }
  58252. declare module BABYLON {
  58253. /**
  58254. * Class used to store node based material build state
  58255. */
  58256. export class NodeMaterialBuildState {
  58257. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58258. supportUniformBuffers: boolean;
  58259. /**
  58260. * Gets the list of emitted attributes
  58261. */
  58262. attributes: string[];
  58263. /**
  58264. * Gets the list of emitted uniforms
  58265. */
  58266. uniforms: string[];
  58267. /**
  58268. * Gets the list of emitted constants
  58269. */
  58270. constants: string[];
  58271. /**
  58272. * Gets the list of emitted samplers
  58273. */
  58274. samplers: string[];
  58275. /**
  58276. * Gets the list of emitted functions
  58277. */
  58278. functions: {
  58279. [key: string]: string;
  58280. };
  58281. /**
  58282. * Gets the list of emitted extensions
  58283. */
  58284. extensions: {
  58285. [key: string]: string;
  58286. };
  58287. /**
  58288. * Gets the target of the compilation state
  58289. */
  58290. target: NodeMaterialBlockTargets;
  58291. /**
  58292. * Gets the list of emitted counters
  58293. */
  58294. counters: {
  58295. [key: string]: number;
  58296. };
  58297. /**
  58298. * Shared data between multiple NodeMaterialBuildState instances
  58299. */
  58300. sharedData: NodeMaterialBuildStateSharedData;
  58301. /** @hidden */
  58302. _vertexState: NodeMaterialBuildState;
  58303. /** @hidden */
  58304. _attributeDeclaration: string;
  58305. /** @hidden */
  58306. _uniformDeclaration: string;
  58307. /** @hidden */
  58308. _constantDeclaration: string;
  58309. /** @hidden */
  58310. _samplerDeclaration: string;
  58311. /** @hidden */
  58312. _varyingTransfer: string;
  58313. private _repeatableContentAnchorIndex;
  58314. /** @hidden */
  58315. _builtCompilationString: string;
  58316. /**
  58317. * Gets the emitted compilation strings
  58318. */
  58319. compilationString: string;
  58320. /**
  58321. * Finalize the compilation strings
  58322. * @param state defines the current compilation state
  58323. */
  58324. finalize(state: NodeMaterialBuildState): void;
  58325. /** @hidden */
  58326. get _repeatableContentAnchor(): string;
  58327. /** @hidden */
  58328. _getFreeVariableName(prefix: string): string;
  58329. /** @hidden */
  58330. _getFreeDefineName(prefix: string): string;
  58331. /** @hidden */
  58332. _excludeVariableName(name: string): void;
  58333. /** @hidden */
  58334. _emit2DSampler(name: string): void;
  58335. /** @hidden */
  58336. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58337. /** @hidden */
  58338. _emitExtension(name: string, extension: string): void;
  58339. /** @hidden */
  58340. _emitFunction(name: string, code: string, comments: string): void;
  58341. /** @hidden */
  58342. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58343. replaceStrings?: {
  58344. search: RegExp;
  58345. replace: string;
  58346. }[];
  58347. repeatKey?: string;
  58348. }): string;
  58349. /** @hidden */
  58350. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58351. repeatKey?: string;
  58352. removeAttributes?: boolean;
  58353. removeUniforms?: boolean;
  58354. removeVaryings?: boolean;
  58355. removeIfDef?: boolean;
  58356. replaceStrings?: {
  58357. search: RegExp;
  58358. replace: string;
  58359. }[];
  58360. }, storeKey?: string): void;
  58361. /** @hidden */
  58362. _registerTempVariable(name: string): boolean;
  58363. /** @hidden */
  58364. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58365. /** @hidden */
  58366. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58367. /** @hidden */
  58368. _emitFloat(value: number): string;
  58369. }
  58370. }
  58371. declare module BABYLON {
  58372. /**
  58373. * Defines a block that can be used inside a node based material
  58374. */
  58375. export class NodeMaterialBlock {
  58376. private _buildId;
  58377. private _buildTarget;
  58378. private _target;
  58379. private _isFinalMerger;
  58380. private _isInput;
  58381. protected _isUnique: boolean;
  58382. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58383. inputsAreExclusive: boolean;
  58384. /** @hidden */
  58385. _codeVariableName: string;
  58386. /** @hidden */
  58387. _inputs: NodeMaterialConnectionPoint[];
  58388. /** @hidden */
  58389. _outputs: NodeMaterialConnectionPoint[];
  58390. /** @hidden */
  58391. _preparationId: number;
  58392. /**
  58393. * Gets or sets the name of the block
  58394. */
  58395. name: string;
  58396. /**
  58397. * Gets or sets the unique id of the node
  58398. */
  58399. uniqueId: number;
  58400. /**
  58401. * Gets or sets the comments associated with this block
  58402. */
  58403. comments: string;
  58404. /**
  58405. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58406. */
  58407. get isUnique(): boolean;
  58408. /**
  58409. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58410. */
  58411. get isFinalMerger(): boolean;
  58412. /**
  58413. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58414. */
  58415. get isInput(): boolean;
  58416. /**
  58417. * Gets or sets the build Id
  58418. */
  58419. get buildId(): number;
  58420. set buildId(value: number);
  58421. /**
  58422. * Gets or sets the target of the block
  58423. */
  58424. get target(): NodeMaterialBlockTargets;
  58425. set target(value: NodeMaterialBlockTargets);
  58426. /**
  58427. * Gets the list of input points
  58428. */
  58429. get inputs(): NodeMaterialConnectionPoint[];
  58430. /** Gets the list of output points */
  58431. get outputs(): NodeMaterialConnectionPoint[];
  58432. /**
  58433. * Find an input by its name
  58434. * @param name defines the name of the input to look for
  58435. * @returns the input or null if not found
  58436. */
  58437. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58438. /**
  58439. * Find an output by its name
  58440. * @param name defines the name of the outputto look for
  58441. * @returns the output or null if not found
  58442. */
  58443. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58444. /**
  58445. * Creates a new NodeMaterialBlock
  58446. * @param name defines the block name
  58447. * @param target defines the target of that block (Vertex by default)
  58448. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58449. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58450. */
  58451. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58452. /**
  58453. * Initialize the block and prepare the context for build
  58454. * @param state defines the state that will be used for the build
  58455. */
  58456. initialize(state: NodeMaterialBuildState): void;
  58457. /**
  58458. * Bind data to effect. Will only be called for blocks with isBindable === true
  58459. * @param effect defines the effect to bind data to
  58460. * @param nodeMaterial defines the hosting NodeMaterial
  58461. * @param mesh defines the mesh that will be rendered
  58462. */
  58463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58464. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58465. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58466. protected _writeFloat(value: number): string;
  58467. /**
  58468. * Gets the current class name e.g. "NodeMaterialBlock"
  58469. * @returns the class name
  58470. */
  58471. getClassName(): string;
  58472. /**
  58473. * Register a new input. Must be called inside a block constructor
  58474. * @param name defines the connection point name
  58475. * @param type defines the connection point type
  58476. * @param isOptional defines a boolean indicating that this input can be omitted
  58477. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58478. * @returns the current block
  58479. */
  58480. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58481. /**
  58482. * Register a new output. Must be called inside a block constructor
  58483. * @param name defines the connection point name
  58484. * @param type defines the connection point type
  58485. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58486. * @returns the current block
  58487. */
  58488. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58489. /**
  58490. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58491. * @param forOutput defines an optional connection point to check compatibility with
  58492. * @returns the first available input or null
  58493. */
  58494. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58495. /**
  58496. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58497. * @param forBlock defines an optional block to check compatibility with
  58498. * @returns the first available input or null
  58499. */
  58500. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58501. /**
  58502. * Gets the sibling of the given output
  58503. * @param current defines the current output
  58504. * @returns the next output in the list or null
  58505. */
  58506. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58507. /**
  58508. * Connect current block with another block
  58509. * @param other defines the block to connect with
  58510. * @param options define the various options to help pick the right connections
  58511. * @returns the current block
  58512. */
  58513. connectTo(other: NodeMaterialBlock, options?: {
  58514. input?: string;
  58515. output?: string;
  58516. outputSwizzle?: string;
  58517. }): this | undefined;
  58518. protected _buildBlock(state: NodeMaterialBuildState): void;
  58519. /**
  58520. * Add uniforms, samplers and uniform buffers at compilation time
  58521. * @param state defines the state to update
  58522. * @param nodeMaterial defines the node material requesting the update
  58523. * @param defines defines the material defines to update
  58524. * @param uniformBuffers defines the list of uniform buffer names
  58525. */
  58526. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58527. /**
  58528. * Add potential fallbacks if shader compilation fails
  58529. * @param mesh defines the mesh to be rendered
  58530. * @param fallbacks defines the current prioritized list of fallbacks
  58531. */
  58532. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58533. /**
  58534. * Initialize defines for shader compilation
  58535. * @param mesh defines the mesh to be rendered
  58536. * @param nodeMaterial defines the node material requesting the update
  58537. * @param defines defines the material defines to update
  58538. * @param useInstances specifies that instances should be used
  58539. */
  58540. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58541. /**
  58542. * Update defines for shader compilation
  58543. * @param mesh defines the mesh to be rendered
  58544. * @param nodeMaterial defines the node material requesting the update
  58545. * @param defines defines the material defines to update
  58546. * @param useInstances specifies that instances should be used
  58547. */
  58548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58549. /**
  58550. * Lets the block try to connect some inputs automatically
  58551. * @param material defines the hosting NodeMaterial
  58552. */
  58553. autoConfigure(material: NodeMaterial): void;
  58554. /**
  58555. * Function called when a block is declared as repeatable content generator
  58556. * @param vertexShaderState defines the current compilation state for the vertex shader
  58557. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58558. * @param mesh defines the mesh to be rendered
  58559. * @param defines defines the material defines to update
  58560. */
  58561. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58562. /**
  58563. * Checks if the block is ready
  58564. * @param mesh defines the mesh to be rendered
  58565. * @param nodeMaterial defines the node material requesting the update
  58566. * @param defines defines the material defines to update
  58567. * @param useInstances specifies that instances should be used
  58568. * @returns true if the block is ready
  58569. */
  58570. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58571. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58572. private _processBuild;
  58573. /**
  58574. * Compile the current node and generate the shader code
  58575. * @param state defines the current compilation state (uniforms, samplers, current string)
  58576. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58577. * @returns true if already built
  58578. */
  58579. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58580. protected _inputRename(name: string): string;
  58581. protected _outputRename(name: string): string;
  58582. protected _dumpPropertiesCode(): string;
  58583. /** @hidden */
  58584. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58585. /** @hidden */
  58586. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58587. /**
  58588. * Clone the current block to a new identical block
  58589. * @param scene defines the hosting scene
  58590. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58591. * @returns a copy of the current block
  58592. */
  58593. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58594. /**
  58595. * Serializes this block in a JSON representation
  58596. * @returns the serialized block object
  58597. */
  58598. serialize(): any;
  58599. /** @hidden */
  58600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58601. private _deserializePortDisplayNames;
  58602. /**
  58603. * Release resources
  58604. */
  58605. dispose(): void;
  58606. }
  58607. }
  58608. declare module BABYLON {
  58609. /**
  58610. * Enum defining the type of animations supported by InputBlock
  58611. */
  58612. export enum AnimatedInputBlockTypes {
  58613. /** No animation */
  58614. None = 0,
  58615. /** Time based animation. Will only work for floats */
  58616. Time = 1
  58617. }
  58618. }
  58619. declare module BABYLON {
  58620. /**
  58621. * Block used to expose an input value
  58622. */
  58623. export class InputBlock extends NodeMaterialBlock {
  58624. private _mode;
  58625. private _associatedVariableName;
  58626. private _storedValue;
  58627. private _valueCallback;
  58628. private _type;
  58629. private _animationType;
  58630. /** Gets or set a value used to limit the range of float values */
  58631. min: number;
  58632. /** Gets or set a value used to limit the range of float values */
  58633. max: number;
  58634. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58635. isBoolean: boolean;
  58636. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58637. matrixMode: number;
  58638. /** @hidden */
  58639. _systemValue: Nullable<NodeMaterialSystemValues>;
  58640. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58641. visibleInInspector: boolean;
  58642. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58643. isConstant: boolean;
  58644. /** Gets or sets the group to use to display this block in the Inspector */
  58645. groupInInspector: string;
  58646. /** Gets an observable raised when the value is changed */
  58647. onValueChangedObservable: Observable<InputBlock>;
  58648. /**
  58649. * Gets or sets the connection point type (default is float)
  58650. */
  58651. get type(): NodeMaterialBlockConnectionPointTypes;
  58652. /**
  58653. * Creates a new InputBlock
  58654. * @param name defines the block name
  58655. * @param target defines the target of that block (Vertex by default)
  58656. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58657. */
  58658. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58659. /**
  58660. * Gets the output component
  58661. */
  58662. get output(): NodeMaterialConnectionPoint;
  58663. /**
  58664. * Set the source of this connection point to a vertex attribute
  58665. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58666. * @returns the current connection point
  58667. */
  58668. setAsAttribute(attributeName?: string): InputBlock;
  58669. /**
  58670. * Set the source of this connection point to a system value
  58671. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58672. * @returns the current connection point
  58673. */
  58674. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58675. /**
  58676. * Gets or sets the value of that point.
  58677. * Please note that this value will be ignored if valueCallback is defined
  58678. */
  58679. get value(): any;
  58680. set value(value: any);
  58681. /**
  58682. * Gets or sets a callback used to get the value of that point.
  58683. * Please note that setting this value will force the connection point to ignore the value property
  58684. */
  58685. get valueCallback(): () => any;
  58686. set valueCallback(value: () => any);
  58687. /**
  58688. * Gets or sets the associated variable name in the shader
  58689. */
  58690. get associatedVariableName(): string;
  58691. set associatedVariableName(value: string);
  58692. /** Gets or sets the type of animation applied to the input */
  58693. get animationType(): AnimatedInputBlockTypes;
  58694. set animationType(value: AnimatedInputBlockTypes);
  58695. /**
  58696. * Gets a boolean indicating that this connection point not defined yet
  58697. */
  58698. get isUndefined(): boolean;
  58699. /**
  58700. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58701. * In this case the connection point name must be the name of the uniform to use.
  58702. * Can only be set on inputs
  58703. */
  58704. get isUniform(): boolean;
  58705. set isUniform(value: boolean);
  58706. /**
  58707. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58708. * In this case the connection point name must be the name of the attribute to use
  58709. * Can only be set on inputs
  58710. */
  58711. get isAttribute(): boolean;
  58712. set isAttribute(value: boolean);
  58713. /**
  58714. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58715. * Can only be set on exit points
  58716. */
  58717. get isVarying(): boolean;
  58718. set isVarying(value: boolean);
  58719. /**
  58720. * Gets a boolean indicating that the current connection point is a system value
  58721. */
  58722. get isSystemValue(): boolean;
  58723. /**
  58724. * Gets or sets the current well known value or null if not defined as a system value
  58725. */
  58726. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58727. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58728. /**
  58729. * Gets the current class name
  58730. * @returns the class name
  58731. */
  58732. getClassName(): string;
  58733. /**
  58734. * Animate the input if animationType !== None
  58735. * @param scene defines the rendering scene
  58736. */
  58737. animate(scene: Scene): void;
  58738. private _emitDefine;
  58739. initialize(state: NodeMaterialBuildState): void;
  58740. /**
  58741. * Set the input block to its default value (based on its type)
  58742. */
  58743. setDefaultValue(): void;
  58744. private _emitConstant;
  58745. private _emit;
  58746. /** @hidden */
  58747. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58748. /** @hidden */
  58749. _transmit(effect: Effect, scene: Scene): void;
  58750. protected _buildBlock(state: NodeMaterialBuildState): void;
  58751. protected _dumpPropertiesCode(): string;
  58752. dispose(): void;
  58753. serialize(): any;
  58754. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58755. }
  58756. }
  58757. declare module BABYLON {
  58758. /**
  58759. * Enum used to define the compatibility state between two connection points
  58760. */
  58761. export enum NodeMaterialConnectionPointCompatibilityStates {
  58762. /** Points are compatibles */
  58763. Compatible = 0,
  58764. /** Points are incompatible because of their types */
  58765. TypeIncompatible = 1,
  58766. /** Points are incompatible because of their targets (vertex vs fragment) */
  58767. TargetIncompatible = 2
  58768. }
  58769. /**
  58770. * Defines the direction of a connection point
  58771. */
  58772. export enum NodeMaterialConnectionPointDirection {
  58773. /** Input */
  58774. Input = 0,
  58775. /** Output */
  58776. Output = 1
  58777. }
  58778. /**
  58779. * Defines a connection point for a block
  58780. */
  58781. export class NodeMaterialConnectionPoint {
  58782. /** @hidden */
  58783. _ownerBlock: NodeMaterialBlock;
  58784. /** @hidden */
  58785. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58786. private _endpoints;
  58787. private _associatedVariableName;
  58788. private _direction;
  58789. /** @hidden */
  58790. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58791. /** @hidden */
  58792. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58793. private _type;
  58794. /** @hidden */
  58795. _enforceAssociatedVariableName: boolean;
  58796. /** Gets the direction of the point */
  58797. get direction(): NodeMaterialConnectionPointDirection;
  58798. /**
  58799. * Gets or sets the additional types supported by this connection point
  58800. */
  58801. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58802. /**
  58803. * Gets or sets the additional types excluded by this connection point
  58804. */
  58805. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58806. /**
  58807. * Observable triggered when this point is connected
  58808. */
  58809. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58810. /**
  58811. * Gets or sets the associated variable name in the shader
  58812. */
  58813. get associatedVariableName(): string;
  58814. set associatedVariableName(value: string);
  58815. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58816. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58817. /**
  58818. * Gets or sets the connection point type (default is float)
  58819. */
  58820. get type(): NodeMaterialBlockConnectionPointTypes;
  58821. set type(value: NodeMaterialBlockConnectionPointTypes);
  58822. /**
  58823. * Gets or sets the connection point name
  58824. */
  58825. name: string;
  58826. /**
  58827. * Gets or sets the connection point name
  58828. */
  58829. displayName: string;
  58830. /**
  58831. * Gets or sets a boolean indicating that this connection point can be omitted
  58832. */
  58833. isOptional: boolean;
  58834. /**
  58835. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58836. */
  58837. define: string;
  58838. /** @hidden */
  58839. _prioritizeVertex: boolean;
  58840. private _target;
  58841. /** Gets or sets the target of that connection point */
  58842. get target(): NodeMaterialBlockTargets;
  58843. set target(value: NodeMaterialBlockTargets);
  58844. /**
  58845. * Gets a boolean indicating that the current point is connected
  58846. */
  58847. get isConnected(): boolean;
  58848. /**
  58849. * Gets a boolean indicating that the current point is connected to an input block
  58850. */
  58851. get isConnectedToInputBlock(): boolean;
  58852. /**
  58853. * Gets a the connected input block (if any)
  58854. */
  58855. get connectInputBlock(): Nullable<InputBlock>;
  58856. /** Get the other side of the connection (if any) */
  58857. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58858. /** Get the block that owns this connection point */
  58859. get ownerBlock(): NodeMaterialBlock;
  58860. /** Get the block connected on the other side of this connection (if any) */
  58861. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58862. /** Get the block connected on the endpoints of this connection (if any) */
  58863. get connectedBlocks(): Array<NodeMaterialBlock>;
  58864. /** Gets the list of connected endpoints */
  58865. get endpoints(): NodeMaterialConnectionPoint[];
  58866. /** Gets a boolean indicating if that output point is connected to at least one input */
  58867. get hasEndpoints(): boolean;
  58868. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58869. get isConnectedInVertexShader(): boolean;
  58870. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58871. get isConnectedInFragmentShader(): boolean;
  58872. /**
  58873. * Creates a new connection point
  58874. * @param name defines the connection point name
  58875. * @param ownerBlock defines the block hosting this connection point
  58876. * @param direction defines the direction of the connection point
  58877. */
  58878. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58879. /**
  58880. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58881. * @returns the class name
  58882. */
  58883. getClassName(): string;
  58884. /**
  58885. * Gets a boolean indicating if the current point can be connected to another point
  58886. * @param connectionPoint defines the other connection point
  58887. * @returns a boolean
  58888. */
  58889. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58890. /**
  58891. * Gets a number indicating if the current point can be connected to another point
  58892. * @param connectionPoint defines the other connection point
  58893. * @returns a number defining the compatibility state
  58894. */
  58895. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58896. /**
  58897. * Connect this point to another connection point
  58898. * @param connectionPoint defines the other connection point
  58899. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58900. * @returns the current connection point
  58901. */
  58902. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58903. /**
  58904. * Disconnect this point from one of his endpoint
  58905. * @param endpoint defines the other connection point
  58906. * @returns the current connection point
  58907. */
  58908. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58909. /**
  58910. * Serializes this point in a JSON representation
  58911. * @param isInput defines if the connection point is an input (default is true)
  58912. * @returns the serialized point object
  58913. */
  58914. serialize(isInput?: boolean): any;
  58915. /**
  58916. * Release resources
  58917. */
  58918. dispose(): void;
  58919. }
  58920. }
  58921. declare module BABYLON {
  58922. /**
  58923. * Block used to add support for vertex skinning (bones)
  58924. */
  58925. export class BonesBlock extends NodeMaterialBlock {
  58926. /**
  58927. * Creates a new BonesBlock
  58928. * @param name defines the block name
  58929. */
  58930. constructor(name: string);
  58931. /**
  58932. * Initialize the block and prepare the context for build
  58933. * @param state defines the state that will be used for the build
  58934. */
  58935. initialize(state: NodeMaterialBuildState): void;
  58936. /**
  58937. * Gets the current class name
  58938. * @returns the class name
  58939. */
  58940. getClassName(): string;
  58941. /**
  58942. * Gets the matrix indices input component
  58943. */
  58944. get matricesIndices(): NodeMaterialConnectionPoint;
  58945. /**
  58946. * Gets the matrix weights input component
  58947. */
  58948. get matricesWeights(): NodeMaterialConnectionPoint;
  58949. /**
  58950. * Gets the extra matrix indices input component
  58951. */
  58952. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58953. /**
  58954. * Gets the extra matrix weights input component
  58955. */
  58956. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58957. /**
  58958. * Gets the world input component
  58959. */
  58960. get world(): NodeMaterialConnectionPoint;
  58961. /**
  58962. * Gets the output component
  58963. */
  58964. get output(): NodeMaterialConnectionPoint;
  58965. autoConfigure(material: NodeMaterial): void;
  58966. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58967. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58969. protected _buildBlock(state: NodeMaterialBuildState): this;
  58970. }
  58971. }
  58972. declare module BABYLON {
  58973. /**
  58974. * Block used to add support for instances
  58975. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58976. */
  58977. export class InstancesBlock extends NodeMaterialBlock {
  58978. /**
  58979. * Creates a new InstancesBlock
  58980. * @param name defines the block name
  58981. */
  58982. constructor(name: string);
  58983. /**
  58984. * Gets the current class name
  58985. * @returns the class name
  58986. */
  58987. getClassName(): string;
  58988. /**
  58989. * Gets the first world row input component
  58990. */
  58991. get world0(): NodeMaterialConnectionPoint;
  58992. /**
  58993. * Gets the second world row input component
  58994. */
  58995. get world1(): NodeMaterialConnectionPoint;
  58996. /**
  58997. * Gets the third world row input component
  58998. */
  58999. get world2(): NodeMaterialConnectionPoint;
  59000. /**
  59001. * Gets the forth world row input component
  59002. */
  59003. get world3(): NodeMaterialConnectionPoint;
  59004. /**
  59005. * Gets the world input component
  59006. */
  59007. get world(): NodeMaterialConnectionPoint;
  59008. /**
  59009. * Gets the output component
  59010. */
  59011. get output(): NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the isntanceID component
  59014. */
  59015. get instanceID(): NodeMaterialConnectionPoint;
  59016. autoConfigure(material: NodeMaterial): void;
  59017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59018. protected _buildBlock(state: NodeMaterialBuildState): this;
  59019. }
  59020. }
  59021. declare module BABYLON {
  59022. /**
  59023. * Block used to add morph targets support to vertex shader
  59024. */
  59025. export class MorphTargetsBlock extends NodeMaterialBlock {
  59026. private _repeatableContentAnchor;
  59027. /**
  59028. * Create a new MorphTargetsBlock
  59029. * @param name defines the block name
  59030. */
  59031. constructor(name: string);
  59032. /**
  59033. * Gets the current class name
  59034. * @returns the class name
  59035. */
  59036. getClassName(): string;
  59037. /**
  59038. * Gets the position input component
  59039. */
  59040. get position(): NodeMaterialConnectionPoint;
  59041. /**
  59042. * Gets the normal input component
  59043. */
  59044. get normal(): NodeMaterialConnectionPoint;
  59045. /**
  59046. * Gets the tangent input component
  59047. */
  59048. get tangent(): NodeMaterialConnectionPoint;
  59049. /**
  59050. * Gets the tangent input component
  59051. */
  59052. get uv(): NodeMaterialConnectionPoint;
  59053. /**
  59054. * Gets the position output component
  59055. */
  59056. get positionOutput(): NodeMaterialConnectionPoint;
  59057. /**
  59058. * Gets the normal output component
  59059. */
  59060. get normalOutput(): NodeMaterialConnectionPoint;
  59061. /**
  59062. * Gets the tangent output component
  59063. */
  59064. get tangentOutput(): NodeMaterialConnectionPoint;
  59065. /**
  59066. * Gets the tangent output component
  59067. */
  59068. get uvOutput(): NodeMaterialConnectionPoint;
  59069. initialize(state: NodeMaterialBuildState): void;
  59070. autoConfigure(material: NodeMaterial): void;
  59071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59072. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59073. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59074. protected _buildBlock(state: NodeMaterialBuildState): this;
  59075. }
  59076. }
  59077. declare module BABYLON {
  59078. /**
  59079. * Block used to get data information from a light
  59080. */
  59081. export class LightInformationBlock extends NodeMaterialBlock {
  59082. private _lightDataUniformName;
  59083. private _lightColorUniformName;
  59084. private _lightTypeDefineName;
  59085. /**
  59086. * Gets or sets the light associated with this block
  59087. */
  59088. light: Nullable<Light>;
  59089. /**
  59090. * Creates a new LightInformationBlock
  59091. * @param name defines the block name
  59092. */
  59093. constructor(name: string);
  59094. /**
  59095. * Gets the current class name
  59096. * @returns the class name
  59097. */
  59098. getClassName(): string;
  59099. /**
  59100. * Gets the world position input component
  59101. */
  59102. get worldPosition(): NodeMaterialConnectionPoint;
  59103. /**
  59104. * Gets the direction output component
  59105. */
  59106. get direction(): NodeMaterialConnectionPoint;
  59107. /**
  59108. * Gets the direction output component
  59109. */
  59110. get color(): NodeMaterialConnectionPoint;
  59111. /**
  59112. * Gets the direction output component
  59113. */
  59114. get intensity(): NodeMaterialConnectionPoint;
  59115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59117. protected _buildBlock(state: NodeMaterialBuildState): this;
  59118. serialize(): any;
  59119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59120. }
  59121. }
  59122. declare module BABYLON {
  59123. /**
  59124. * Block used to add image processing support to fragment shader
  59125. */
  59126. export class ImageProcessingBlock extends NodeMaterialBlock {
  59127. /**
  59128. * Create a new ImageProcessingBlock
  59129. * @param name defines the block name
  59130. */
  59131. constructor(name: string);
  59132. /**
  59133. * Gets the current class name
  59134. * @returns the class name
  59135. */
  59136. getClassName(): string;
  59137. /**
  59138. * Gets the color input component
  59139. */
  59140. get color(): NodeMaterialConnectionPoint;
  59141. /**
  59142. * Gets the output component
  59143. */
  59144. get output(): NodeMaterialConnectionPoint;
  59145. /**
  59146. * Initialize the block and prepare the context for build
  59147. * @param state defines the state that will be used for the build
  59148. */
  59149. initialize(state: NodeMaterialBuildState): void;
  59150. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59151. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59152. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59153. protected _buildBlock(state: NodeMaterialBuildState): this;
  59154. }
  59155. }
  59156. declare module BABYLON {
  59157. /**
  59158. * Block used to pertub normals based on a normal map
  59159. */
  59160. export class PerturbNormalBlock extends NodeMaterialBlock {
  59161. private _tangentSpaceParameterName;
  59162. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59163. invertX: boolean;
  59164. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59165. invertY: boolean;
  59166. /**
  59167. * Create a new PerturbNormalBlock
  59168. * @param name defines the block name
  59169. */
  59170. constructor(name: string);
  59171. /**
  59172. * Gets the current class name
  59173. * @returns the class name
  59174. */
  59175. getClassName(): string;
  59176. /**
  59177. * Gets the world position input component
  59178. */
  59179. get worldPosition(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the world normal input component
  59182. */
  59183. get worldNormal(): NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the world tangent input component
  59186. */
  59187. get worldTangent(): NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the uv input component
  59190. */
  59191. get uv(): NodeMaterialConnectionPoint;
  59192. /**
  59193. * Gets the normal map color input component
  59194. */
  59195. get normalMapColor(): NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the strength input component
  59198. */
  59199. get strength(): NodeMaterialConnectionPoint;
  59200. /**
  59201. * Gets the output component
  59202. */
  59203. get output(): NodeMaterialConnectionPoint;
  59204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59205. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59206. autoConfigure(material: NodeMaterial): void;
  59207. protected _buildBlock(state: NodeMaterialBuildState): this;
  59208. protected _dumpPropertiesCode(): string;
  59209. serialize(): any;
  59210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59211. }
  59212. }
  59213. declare module BABYLON {
  59214. /**
  59215. * Block used to discard a pixel if a value is smaller than a cutoff
  59216. */
  59217. export class DiscardBlock extends NodeMaterialBlock {
  59218. /**
  59219. * Create a new DiscardBlock
  59220. * @param name defines the block name
  59221. */
  59222. constructor(name: string);
  59223. /**
  59224. * Gets the current class name
  59225. * @returns the class name
  59226. */
  59227. getClassName(): string;
  59228. /**
  59229. * Gets the color input component
  59230. */
  59231. get value(): NodeMaterialConnectionPoint;
  59232. /**
  59233. * Gets the cutoff input component
  59234. */
  59235. get cutoff(): NodeMaterialConnectionPoint;
  59236. protected _buildBlock(state: NodeMaterialBuildState): this;
  59237. }
  59238. }
  59239. declare module BABYLON {
  59240. /**
  59241. * Block used to test if the fragment shader is front facing
  59242. */
  59243. export class FrontFacingBlock extends NodeMaterialBlock {
  59244. /**
  59245. * Creates a new FrontFacingBlock
  59246. * @param name defines the block name
  59247. */
  59248. constructor(name: string);
  59249. /**
  59250. * Gets the current class name
  59251. * @returns the class name
  59252. */
  59253. getClassName(): string;
  59254. /**
  59255. * Gets the output component
  59256. */
  59257. get output(): NodeMaterialConnectionPoint;
  59258. protected _buildBlock(state: NodeMaterialBuildState): this;
  59259. }
  59260. }
  59261. declare module BABYLON {
  59262. /**
  59263. * Block used to get the derivative value on x and y of a given input
  59264. */
  59265. export class DerivativeBlock extends NodeMaterialBlock {
  59266. /**
  59267. * Create a new DerivativeBlock
  59268. * @param name defines the block name
  59269. */
  59270. constructor(name: string);
  59271. /**
  59272. * Gets the current class name
  59273. * @returns the class name
  59274. */
  59275. getClassName(): string;
  59276. /**
  59277. * Gets the input component
  59278. */
  59279. get input(): NodeMaterialConnectionPoint;
  59280. /**
  59281. * Gets the derivative output on x
  59282. */
  59283. get dx(): NodeMaterialConnectionPoint;
  59284. /**
  59285. * Gets the derivative output on y
  59286. */
  59287. get dy(): NodeMaterialConnectionPoint;
  59288. protected _buildBlock(state: NodeMaterialBuildState): this;
  59289. }
  59290. }
  59291. declare module BABYLON {
  59292. /**
  59293. * Block used to add support for scene fog
  59294. */
  59295. export class FogBlock extends NodeMaterialBlock {
  59296. private _fogDistanceName;
  59297. private _fogParameters;
  59298. /**
  59299. * Create a new FogBlock
  59300. * @param name defines the block name
  59301. */
  59302. constructor(name: string);
  59303. /**
  59304. * Gets the current class name
  59305. * @returns the class name
  59306. */
  59307. getClassName(): string;
  59308. /**
  59309. * Gets the world position input component
  59310. */
  59311. get worldPosition(): NodeMaterialConnectionPoint;
  59312. /**
  59313. * Gets the view input component
  59314. */
  59315. get view(): NodeMaterialConnectionPoint;
  59316. /**
  59317. * Gets the color input component
  59318. */
  59319. get input(): NodeMaterialConnectionPoint;
  59320. /**
  59321. * Gets the fog color input component
  59322. */
  59323. get fogColor(): NodeMaterialConnectionPoint;
  59324. /**
  59325. * Gets the output component
  59326. */
  59327. get output(): NodeMaterialConnectionPoint;
  59328. autoConfigure(material: NodeMaterial): void;
  59329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59330. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59331. protected _buildBlock(state: NodeMaterialBuildState): this;
  59332. }
  59333. }
  59334. declare module BABYLON {
  59335. /**
  59336. * Block used to add light in the fragment shader
  59337. */
  59338. export class LightBlock extends NodeMaterialBlock {
  59339. private _lightId;
  59340. /**
  59341. * Gets or sets the light associated with this block
  59342. */
  59343. light: Nullable<Light>;
  59344. /**
  59345. * Create a new LightBlock
  59346. * @param name defines the block name
  59347. */
  59348. constructor(name: string);
  59349. /**
  59350. * Gets the current class name
  59351. * @returns the class name
  59352. */
  59353. getClassName(): string;
  59354. /**
  59355. * Gets the world position input component
  59356. */
  59357. get worldPosition(): NodeMaterialConnectionPoint;
  59358. /**
  59359. * Gets the world normal input component
  59360. */
  59361. get worldNormal(): NodeMaterialConnectionPoint;
  59362. /**
  59363. * Gets the camera (or eye) position component
  59364. */
  59365. get cameraPosition(): NodeMaterialConnectionPoint;
  59366. /**
  59367. * Gets the glossiness component
  59368. */
  59369. get glossiness(): NodeMaterialConnectionPoint;
  59370. /**
  59371. * Gets the glossinness power component
  59372. */
  59373. get glossPower(): NodeMaterialConnectionPoint;
  59374. /**
  59375. * Gets the diffuse color component
  59376. */
  59377. get diffuseColor(): NodeMaterialConnectionPoint;
  59378. /**
  59379. * Gets the specular color component
  59380. */
  59381. get specularColor(): NodeMaterialConnectionPoint;
  59382. /**
  59383. * Gets the diffuse output component
  59384. */
  59385. get diffuseOutput(): NodeMaterialConnectionPoint;
  59386. /**
  59387. * Gets the specular output component
  59388. */
  59389. get specularOutput(): NodeMaterialConnectionPoint;
  59390. /**
  59391. * Gets the shadow output component
  59392. */
  59393. get shadow(): NodeMaterialConnectionPoint;
  59394. autoConfigure(material: NodeMaterial): void;
  59395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59396. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59398. private _injectVertexCode;
  59399. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59400. serialize(): any;
  59401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59402. }
  59403. }
  59404. declare module BABYLON {
  59405. /**
  59406. * Block used to multiply 2 values
  59407. */
  59408. export class MultiplyBlock extends NodeMaterialBlock {
  59409. /**
  59410. * Creates a new MultiplyBlock
  59411. * @param name defines the block name
  59412. */
  59413. constructor(name: string);
  59414. /**
  59415. * Gets the current class name
  59416. * @returns the class name
  59417. */
  59418. getClassName(): string;
  59419. /**
  59420. * Gets the left operand input component
  59421. */
  59422. get left(): NodeMaterialConnectionPoint;
  59423. /**
  59424. * Gets the right operand input component
  59425. */
  59426. get right(): NodeMaterialConnectionPoint;
  59427. /**
  59428. * Gets the output component
  59429. */
  59430. get output(): NodeMaterialConnectionPoint;
  59431. protected _buildBlock(state: NodeMaterialBuildState): this;
  59432. }
  59433. }
  59434. declare module BABYLON {
  59435. /**
  59436. * Block used to add 2 vectors
  59437. */
  59438. export class AddBlock extends NodeMaterialBlock {
  59439. /**
  59440. * Creates a new AddBlock
  59441. * @param name defines the block name
  59442. */
  59443. constructor(name: string);
  59444. /**
  59445. * Gets the current class name
  59446. * @returns the class name
  59447. */
  59448. getClassName(): string;
  59449. /**
  59450. * Gets the left operand input component
  59451. */
  59452. get left(): NodeMaterialConnectionPoint;
  59453. /**
  59454. * Gets the right operand input component
  59455. */
  59456. get right(): NodeMaterialConnectionPoint;
  59457. /**
  59458. * Gets the output component
  59459. */
  59460. get output(): NodeMaterialConnectionPoint;
  59461. protected _buildBlock(state: NodeMaterialBuildState): this;
  59462. }
  59463. }
  59464. declare module BABYLON {
  59465. /**
  59466. * Block used to scale a vector by a float
  59467. */
  59468. export class ScaleBlock extends NodeMaterialBlock {
  59469. /**
  59470. * Creates a new ScaleBlock
  59471. * @param name defines the block name
  59472. */
  59473. constructor(name: string);
  59474. /**
  59475. * Gets the current class name
  59476. * @returns the class name
  59477. */
  59478. getClassName(): string;
  59479. /**
  59480. * Gets the input component
  59481. */
  59482. get input(): NodeMaterialConnectionPoint;
  59483. /**
  59484. * Gets the factor input component
  59485. */
  59486. get factor(): NodeMaterialConnectionPoint;
  59487. /**
  59488. * Gets the output component
  59489. */
  59490. get output(): NodeMaterialConnectionPoint;
  59491. protected _buildBlock(state: NodeMaterialBuildState): this;
  59492. }
  59493. }
  59494. declare module BABYLON {
  59495. /**
  59496. * Block used to clamp a float
  59497. */
  59498. export class ClampBlock extends NodeMaterialBlock {
  59499. /** Gets or sets the minimum range */
  59500. minimum: number;
  59501. /** Gets or sets the maximum range */
  59502. maximum: number;
  59503. /**
  59504. * Creates a new ClampBlock
  59505. * @param name defines the block name
  59506. */
  59507. constructor(name: string);
  59508. /**
  59509. * Gets the current class name
  59510. * @returns the class name
  59511. */
  59512. getClassName(): string;
  59513. /**
  59514. * Gets the value input component
  59515. */
  59516. get value(): NodeMaterialConnectionPoint;
  59517. /**
  59518. * Gets the output component
  59519. */
  59520. get output(): NodeMaterialConnectionPoint;
  59521. protected _buildBlock(state: NodeMaterialBuildState): this;
  59522. protected _dumpPropertiesCode(): string;
  59523. serialize(): any;
  59524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59525. }
  59526. }
  59527. declare module BABYLON {
  59528. /**
  59529. * Block used to apply a cross product between 2 vectors
  59530. */
  59531. export class CrossBlock extends NodeMaterialBlock {
  59532. /**
  59533. * Creates a new CrossBlock
  59534. * @param name defines the block name
  59535. */
  59536. constructor(name: string);
  59537. /**
  59538. * Gets the current class name
  59539. * @returns the class name
  59540. */
  59541. getClassName(): string;
  59542. /**
  59543. * Gets the left operand input component
  59544. */
  59545. get left(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the right operand input component
  59548. */
  59549. get right(): NodeMaterialConnectionPoint;
  59550. /**
  59551. * Gets the output component
  59552. */
  59553. get output(): NodeMaterialConnectionPoint;
  59554. protected _buildBlock(state: NodeMaterialBuildState): this;
  59555. }
  59556. }
  59557. declare module BABYLON {
  59558. /**
  59559. * Block used to apply a dot product between 2 vectors
  59560. */
  59561. export class DotBlock extends NodeMaterialBlock {
  59562. /**
  59563. * Creates a new DotBlock
  59564. * @param name defines the block name
  59565. */
  59566. constructor(name: string);
  59567. /**
  59568. * Gets the current class name
  59569. * @returns the class name
  59570. */
  59571. getClassName(): string;
  59572. /**
  59573. * Gets the left operand input component
  59574. */
  59575. get left(): NodeMaterialConnectionPoint;
  59576. /**
  59577. * Gets the right operand input component
  59578. */
  59579. get right(): NodeMaterialConnectionPoint;
  59580. /**
  59581. * Gets the output component
  59582. */
  59583. get output(): NodeMaterialConnectionPoint;
  59584. protected _buildBlock(state: NodeMaterialBuildState): this;
  59585. }
  59586. }
  59587. declare module BABYLON {
  59588. /**
  59589. * Block used to remap a float from a range to a new one
  59590. */
  59591. export class RemapBlock extends NodeMaterialBlock {
  59592. /**
  59593. * Gets or sets the source range
  59594. */
  59595. sourceRange: Vector2;
  59596. /**
  59597. * Gets or sets the target range
  59598. */
  59599. targetRange: Vector2;
  59600. /**
  59601. * Creates a new RemapBlock
  59602. * @param name defines the block name
  59603. */
  59604. constructor(name: string);
  59605. /**
  59606. * Gets the current class name
  59607. * @returns the class name
  59608. */
  59609. getClassName(): string;
  59610. /**
  59611. * Gets the input component
  59612. */
  59613. get input(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the source min input component
  59616. */
  59617. get sourceMin(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the source max input component
  59620. */
  59621. get sourceMax(): NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the target min input component
  59624. */
  59625. get targetMin(): NodeMaterialConnectionPoint;
  59626. /**
  59627. * Gets the target max input component
  59628. */
  59629. get targetMax(): NodeMaterialConnectionPoint;
  59630. /**
  59631. * Gets the output component
  59632. */
  59633. get output(): NodeMaterialConnectionPoint;
  59634. protected _buildBlock(state: NodeMaterialBuildState): this;
  59635. protected _dumpPropertiesCode(): string;
  59636. serialize(): any;
  59637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59638. }
  59639. }
  59640. declare module BABYLON {
  59641. /**
  59642. * Block used to normalize a vector
  59643. */
  59644. export class NormalizeBlock extends NodeMaterialBlock {
  59645. /**
  59646. * Creates a new NormalizeBlock
  59647. * @param name defines the block name
  59648. */
  59649. constructor(name: string);
  59650. /**
  59651. * Gets the current class name
  59652. * @returns the class name
  59653. */
  59654. getClassName(): string;
  59655. /**
  59656. * Gets the input component
  59657. */
  59658. get input(): NodeMaterialConnectionPoint;
  59659. /**
  59660. * Gets the output component
  59661. */
  59662. get output(): NodeMaterialConnectionPoint;
  59663. protected _buildBlock(state: NodeMaterialBuildState): this;
  59664. }
  59665. }
  59666. declare module BABYLON {
  59667. /**
  59668. * Operations supported by the Trigonometry block
  59669. */
  59670. export enum TrigonometryBlockOperations {
  59671. /** Cos */
  59672. Cos = 0,
  59673. /** Sin */
  59674. Sin = 1,
  59675. /** Abs */
  59676. Abs = 2,
  59677. /** Exp */
  59678. Exp = 3,
  59679. /** Exp2 */
  59680. Exp2 = 4,
  59681. /** Round */
  59682. Round = 5,
  59683. /** Floor */
  59684. Floor = 6,
  59685. /** Ceiling */
  59686. Ceiling = 7,
  59687. /** Square root */
  59688. Sqrt = 8,
  59689. /** Log */
  59690. Log = 9,
  59691. /** Tangent */
  59692. Tan = 10,
  59693. /** Arc tangent */
  59694. ArcTan = 11,
  59695. /** Arc cosinus */
  59696. ArcCos = 12,
  59697. /** Arc sinus */
  59698. ArcSin = 13,
  59699. /** Fraction */
  59700. Fract = 14,
  59701. /** Sign */
  59702. Sign = 15,
  59703. /** To radians (from degrees) */
  59704. Radians = 16,
  59705. /** To degrees (from radians) */
  59706. Degrees = 17
  59707. }
  59708. /**
  59709. * Block used to apply trigonometry operation to floats
  59710. */
  59711. export class TrigonometryBlock extends NodeMaterialBlock {
  59712. /**
  59713. * Gets or sets the operation applied by the block
  59714. */
  59715. operation: TrigonometryBlockOperations;
  59716. /**
  59717. * Creates a new TrigonometryBlock
  59718. * @param name defines the block name
  59719. */
  59720. constructor(name: string);
  59721. /**
  59722. * Gets the current class name
  59723. * @returns the class name
  59724. */
  59725. getClassName(): string;
  59726. /**
  59727. * Gets the input component
  59728. */
  59729. get input(): NodeMaterialConnectionPoint;
  59730. /**
  59731. * Gets the output component
  59732. */
  59733. get output(): NodeMaterialConnectionPoint;
  59734. protected _buildBlock(state: NodeMaterialBuildState): this;
  59735. serialize(): any;
  59736. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59737. protected _dumpPropertiesCode(): string;
  59738. }
  59739. }
  59740. declare module BABYLON {
  59741. /**
  59742. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59743. */
  59744. export class ColorMergerBlock extends NodeMaterialBlock {
  59745. /**
  59746. * Create a new ColorMergerBlock
  59747. * @param name defines the block name
  59748. */
  59749. constructor(name: string);
  59750. /**
  59751. * Gets the current class name
  59752. * @returns the class name
  59753. */
  59754. getClassName(): string;
  59755. /**
  59756. * Gets the rgb component (input)
  59757. */
  59758. get rgbIn(): NodeMaterialConnectionPoint;
  59759. /**
  59760. * Gets the r component (input)
  59761. */
  59762. get r(): NodeMaterialConnectionPoint;
  59763. /**
  59764. * Gets the g component (input)
  59765. */
  59766. get g(): NodeMaterialConnectionPoint;
  59767. /**
  59768. * Gets the b component (input)
  59769. */
  59770. get b(): NodeMaterialConnectionPoint;
  59771. /**
  59772. * Gets the a component (input)
  59773. */
  59774. get a(): NodeMaterialConnectionPoint;
  59775. /**
  59776. * Gets the rgba component (output)
  59777. */
  59778. get rgba(): NodeMaterialConnectionPoint;
  59779. /**
  59780. * Gets the rgb component (output)
  59781. */
  59782. get rgbOut(): NodeMaterialConnectionPoint;
  59783. /**
  59784. * Gets the rgb component (output)
  59785. * @deprecated Please use rgbOut instead.
  59786. */
  59787. get rgb(): NodeMaterialConnectionPoint;
  59788. protected _buildBlock(state: NodeMaterialBuildState): this;
  59789. }
  59790. }
  59791. declare module BABYLON {
  59792. /**
  59793. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59794. */
  59795. export class VectorMergerBlock extends NodeMaterialBlock {
  59796. /**
  59797. * Create a new VectorMergerBlock
  59798. * @param name defines the block name
  59799. */
  59800. constructor(name: string);
  59801. /**
  59802. * Gets the current class name
  59803. * @returns the class name
  59804. */
  59805. getClassName(): string;
  59806. /**
  59807. * Gets the xyz component (input)
  59808. */
  59809. get xyzIn(): NodeMaterialConnectionPoint;
  59810. /**
  59811. * Gets the xy component (input)
  59812. */
  59813. get xyIn(): NodeMaterialConnectionPoint;
  59814. /**
  59815. * Gets the x component (input)
  59816. */
  59817. get x(): NodeMaterialConnectionPoint;
  59818. /**
  59819. * Gets the y component (input)
  59820. */
  59821. get y(): NodeMaterialConnectionPoint;
  59822. /**
  59823. * Gets the z component (input)
  59824. */
  59825. get z(): NodeMaterialConnectionPoint;
  59826. /**
  59827. * Gets the w component (input)
  59828. */
  59829. get w(): NodeMaterialConnectionPoint;
  59830. /**
  59831. * Gets the xyzw component (output)
  59832. */
  59833. get xyzw(): NodeMaterialConnectionPoint;
  59834. /**
  59835. * Gets the xyz component (output)
  59836. */
  59837. get xyzOut(): NodeMaterialConnectionPoint;
  59838. /**
  59839. * Gets the xy component (output)
  59840. */
  59841. get xyOut(): NodeMaterialConnectionPoint;
  59842. /**
  59843. * Gets the xy component (output)
  59844. * @deprecated Please use xyOut instead.
  59845. */
  59846. get xy(): NodeMaterialConnectionPoint;
  59847. /**
  59848. * Gets the xyz component (output)
  59849. * @deprecated Please use xyzOut instead.
  59850. */
  59851. get xyz(): NodeMaterialConnectionPoint;
  59852. protected _buildBlock(state: NodeMaterialBuildState): this;
  59853. }
  59854. }
  59855. declare module BABYLON {
  59856. /**
  59857. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59858. */
  59859. export class ColorSplitterBlock extends NodeMaterialBlock {
  59860. /**
  59861. * Create a new ColorSplitterBlock
  59862. * @param name defines the block name
  59863. */
  59864. constructor(name: string);
  59865. /**
  59866. * Gets the current class name
  59867. * @returns the class name
  59868. */
  59869. getClassName(): string;
  59870. /**
  59871. * Gets the rgba component (input)
  59872. */
  59873. get rgba(): NodeMaterialConnectionPoint;
  59874. /**
  59875. * Gets the rgb component (input)
  59876. */
  59877. get rgbIn(): NodeMaterialConnectionPoint;
  59878. /**
  59879. * Gets the rgb component (output)
  59880. */
  59881. get rgbOut(): NodeMaterialConnectionPoint;
  59882. /**
  59883. * Gets the r component (output)
  59884. */
  59885. get r(): NodeMaterialConnectionPoint;
  59886. /**
  59887. * Gets the g component (output)
  59888. */
  59889. get g(): NodeMaterialConnectionPoint;
  59890. /**
  59891. * Gets the b component (output)
  59892. */
  59893. get b(): NodeMaterialConnectionPoint;
  59894. /**
  59895. * Gets the a component (output)
  59896. */
  59897. get a(): NodeMaterialConnectionPoint;
  59898. protected _inputRename(name: string): string;
  59899. protected _outputRename(name: string): string;
  59900. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59901. }
  59902. }
  59903. declare module BABYLON {
  59904. /**
  59905. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59906. */
  59907. export class VectorSplitterBlock extends NodeMaterialBlock {
  59908. /**
  59909. * Create a new VectorSplitterBlock
  59910. * @param name defines the block name
  59911. */
  59912. constructor(name: string);
  59913. /**
  59914. * Gets the current class name
  59915. * @returns the class name
  59916. */
  59917. getClassName(): string;
  59918. /**
  59919. * Gets the xyzw component (input)
  59920. */
  59921. get xyzw(): NodeMaterialConnectionPoint;
  59922. /**
  59923. * Gets the xyz component (input)
  59924. */
  59925. get xyzIn(): NodeMaterialConnectionPoint;
  59926. /**
  59927. * Gets the xy component (input)
  59928. */
  59929. get xyIn(): NodeMaterialConnectionPoint;
  59930. /**
  59931. * Gets the xyz component (output)
  59932. */
  59933. get xyzOut(): NodeMaterialConnectionPoint;
  59934. /**
  59935. * Gets the xy component (output)
  59936. */
  59937. get xyOut(): NodeMaterialConnectionPoint;
  59938. /**
  59939. * Gets the x component (output)
  59940. */
  59941. get x(): NodeMaterialConnectionPoint;
  59942. /**
  59943. * Gets the y component (output)
  59944. */
  59945. get y(): NodeMaterialConnectionPoint;
  59946. /**
  59947. * Gets the z component (output)
  59948. */
  59949. get z(): NodeMaterialConnectionPoint;
  59950. /**
  59951. * Gets the w component (output)
  59952. */
  59953. get w(): NodeMaterialConnectionPoint;
  59954. protected _inputRename(name: string): string;
  59955. protected _outputRename(name: string): string;
  59956. protected _buildBlock(state: NodeMaterialBuildState): this;
  59957. }
  59958. }
  59959. declare module BABYLON {
  59960. /**
  59961. * Block used to lerp between 2 values
  59962. */
  59963. export class LerpBlock extends NodeMaterialBlock {
  59964. /**
  59965. * Creates a new LerpBlock
  59966. * @param name defines the block name
  59967. */
  59968. constructor(name: string);
  59969. /**
  59970. * Gets the current class name
  59971. * @returns the class name
  59972. */
  59973. getClassName(): string;
  59974. /**
  59975. * Gets the left operand input component
  59976. */
  59977. get left(): NodeMaterialConnectionPoint;
  59978. /**
  59979. * Gets the right operand input component
  59980. */
  59981. get right(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the gradient operand input component
  59984. */
  59985. get gradient(): NodeMaterialConnectionPoint;
  59986. /**
  59987. * Gets the output component
  59988. */
  59989. get output(): NodeMaterialConnectionPoint;
  59990. protected _buildBlock(state: NodeMaterialBuildState): this;
  59991. }
  59992. }
  59993. declare module BABYLON {
  59994. /**
  59995. * Block used to divide 2 vectors
  59996. */
  59997. export class DivideBlock extends NodeMaterialBlock {
  59998. /**
  59999. * Creates a new DivideBlock
  60000. * @param name defines the block name
  60001. */
  60002. constructor(name: string);
  60003. /**
  60004. * Gets the current class name
  60005. * @returns the class name
  60006. */
  60007. getClassName(): string;
  60008. /**
  60009. * Gets the left operand input component
  60010. */
  60011. get left(): NodeMaterialConnectionPoint;
  60012. /**
  60013. * Gets the right operand input component
  60014. */
  60015. get right(): NodeMaterialConnectionPoint;
  60016. /**
  60017. * Gets the output component
  60018. */
  60019. get output(): NodeMaterialConnectionPoint;
  60020. protected _buildBlock(state: NodeMaterialBuildState): this;
  60021. }
  60022. }
  60023. declare module BABYLON {
  60024. /**
  60025. * Block used to subtract 2 vectors
  60026. */
  60027. export class SubtractBlock extends NodeMaterialBlock {
  60028. /**
  60029. * Creates a new SubtractBlock
  60030. * @param name defines the block name
  60031. */
  60032. constructor(name: string);
  60033. /**
  60034. * Gets the current class name
  60035. * @returns the class name
  60036. */
  60037. getClassName(): string;
  60038. /**
  60039. * Gets the left operand input component
  60040. */
  60041. get left(): NodeMaterialConnectionPoint;
  60042. /**
  60043. * Gets the right operand input component
  60044. */
  60045. get right(): NodeMaterialConnectionPoint;
  60046. /**
  60047. * Gets the output component
  60048. */
  60049. get output(): NodeMaterialConnectionPoint;
  60050. protected _buildBlock(state: NodeMaterialBuildState): this;
  60051. }
  60052. }
  60053. declare module BABYLON {
  60054. /**
  60055. * Block used to step a value
  60056. */
  60057. export class StepBlock extends NodeMaterialBlock {
  60058. /**
  60059. * Creates a new StepBlock
  60060. * @param name defines the block name
  60061. */
  60062. constructor(name: string);
  60063. /**
  60064. * Gets the current class name
  60065. * @returns the class name
  60066. */
  60067. getClassName(): string;
  60068. /**
  60069. * Gets the value operand input component
  60070. */
  60071. get value(): NodeMaterialConnectionPoint;
  60072. /**
  60073. * Gets the edge operand input component
  60074. */
  60075. get edge(): NodeMaterialConnectionPoint;
  60076. /**
  60077. * Gets the output component
  60078. */
  60079. get output(): NodeMaterialConnectionPoint;
  60080. protected _buildBlock(state: NodeMaterialBuildState): this;
  60081. }
  60082. }
  60083. declare module BABYLON {
  60084. /**
  60085. * Block used to get the opposite (1 - x) of a value
  60086. */
  60087. export class OneMinusBlock extends NodeMaterialBlock {
  60088. /**
  60089. * Creates a new OneMinusBlock
  60090. * @param name defines the block name
  60091. */
  60092. constructor(name: string);
  60093. /**
  60094. * Gets the current class name
  60095. * @returns the class name
  60096. */
  60097. getClassName(): string;
  60098. /**
  60099. * Gets the input component
  60100. */
  60101. get input(): NodeMaterialConnectionPoint;
  60102. /**
  60103. * Gets the output component
  60104. */
  60105. get output(): NodeMaterialConnectionPoint;
  60106. protected _buildBlock(state: NodeMaterialBuildState): this;
  60107. }
  60108. }
  60109. declare module BABYLON {
  60110. /**
  60111. * Block used to get the view direction
  60112. */
  60113. export class ViewDirectionBlock extends NodeMaterialBlock {
  60114. /**
  60115. * Creates a new ViewDirectionBlock
  60116. * @param name defines the block name
  60117. */
  60118. constructor(name: string);
  60119. /**
  60120. * Gets the current class name
  60121. * @returns the class name
  60122. */
  60123. getClassName(): string;
  60124. /**
  60125. * Gets the world position component
  60126. */
  60127. get worldPosition(): NodeMaterialConnectionPoint;
  60128. /**
  60129. * Gets the camera position component
  60130. */
  60131. get cameraPosition(): NodeMaterialConnectionPoint;
  60132. /**
  60133. * Gets the output component
  60134. */
  60135. get output(): NodeMaterialConnectionPoint;
  60136. autoConfigure(material: NodeMaterial): void;
  60137. protected _buildBlock(state: NodeMaterialBuildState): this;
  60138. }
  60139. }
  60140. declare module BABYLON {
  60141. /**
  60142. * Block used to compute fresnel value
  60143. */
  60144. export class FresnelBlock extends NodeMaterialBlock {
  60145. /**
  60146. * Create a new FresnelBlock
  60147. * @param name defines the block name
  60148. */
  60149. constructor(name: string);
  60150. /**
  60151. * Gets the current class name
  60152. * @returns the class name
  60153. */
  60154. getClassName(): string;
  60155. /**
  60156. * Gets the world normal input component
  60157. */
  60158. get worldNormal(): NodeMaterialConnectionPoint;
  60159. /**
  60160. * Gets the view direction input component
  60161. */
  60162. get viewDirection(): NodeMaterialConnectionPoint;
  60163. /**
  60164. * Gets the bias input component
  60165. */
  60166. get bias(): NodeMaterialConnectionPoint;
  60167. /**
  60168. * Gets the camera (or eye) position component
  60169. */
  60170. get power(): NodeMaterialConnectionPoint;
  60171. /**
  60172. * Gets the fresnel output component
  60173. */
  60174. get fresnel(): NodeMaterialConnectionPoint;
  60175. autoConfigure(material: NodeMaterial): void;
  60176. protected _buildBlock(state: NodeMaterialBuildState): this;
  60177. }
  60178. }
  60179. declare module BABYLON {
  60180. /**
  60181. * Block used to get the max of 2 values
  60182. */
  60183. export class MaxBlock extends NodeMaterialBlock {
  60184. /**
  60185. * Creates a new MaxBlock
  60186. * @param name defines the block name
  60187. */
  60188. constructor(name: string);
  60189. /**
  60190. * Gets the current class name
  60191. * @returns the class name
  60192. */
  60193. getClassName(): string;
  60194. /**
  60195. * Gets the left operand input component
  60196. */
  60197. get left(): NodeMaterialConnectionPoint;
  60198. /**
  60199. * Gets the right operand input component
  60200. */
  60201. get right(): NodeMaterialConnectionPoint;
  60202. /**
  60203. * Gets the output component
  60204. */
  60205. get output(): NodeMaterialConnectionPoint;
  60206. protected _buildBlock(state: NodeMaterialBuildState): this;
  60207. }
  60208. }
  60209. declare module BABYLON {
  60210. /**
  60211. * Block used to get the min of 2 values
  60212. */
  60213. export class MinBlock extends NodeMaterialBlock {
  60214. /**
  60215. * Creates a new MinBlock
  60216. * @param name defines the block name
  60217. */
  60218. constructor(name: string);
  60219. /**
  60220. * Gets the current class name
  60221. * @returns the class name
  60222. */
  60223. getClassName(): string;
  60224. /**
  60225. * Gets the left operand input component
  60226. */
  60227. get left(): NodeMaterialConnectionPoint;
  60228. /**
  60229. * Gets the right operand input component
  60230. */
  60231. get right(): NodeMaterialConnectionPoint;
  60232. /**
  60233. * Gets the output component
  60234. */
  60235. get output(): NodeMaterialConnectionPoint;
  60236. protected _buildBlock(state: NodeMaterialBuildState): this;
  60237. }
  60238. }
  60239. declare module BABYLON {
  60240. /**
  60241. * Block used to get the distance between 2 values
  60242. */
  60243. export class DistanceBlock extends NodeMaterialBlock {
  60244. /**
  60245. * Creates a new DistanceBlock
  60246. * @param name defines the block name
  60247. */
  60248. constructor(name: string);
  60249. /**
  60250. * Gets the current class name
  60251. * @returns the class name
  60252. */
  60253. getClassName(): string;
  60254. /**
  60255. * Gets the left operand input component
  60256. */
  60257. get left(): NodeMaterialConnectionPoint;
  60258. /**
  60259. * Gets the right operand input component
  60260. */
  60261. get right(): NodeMaterialConnectionPoint;
  60262. /**
  60263. * Gets the output component
  60264. */
  60265. get output(): NodeMaterialConnectionPoint;
  60266. protected _buildBlock(state: NodeMaterialBuildState): this;
  60267. }
  60268. }
  60269. declare module BABYLON {
  60270. /**
  60271. * Block used to get the length of a vector
  60272. */
  60273. export class LengthBlock extends NodeMaterialBlock {
  60274. /**
  60275. * Creates a new LengthBlock
  60276. * @param name defines the block name
  60277. */
  60278. constructor(name: string);
  60279. /**
  60280. * Gets the current class name
  60281. * @returns the class name
  60282. */
  60283. getClassName(): string;
  60284. /**
  60285. * Gets the value input component
  60286. */
  60287. get value(): NodeMaterialConnectionPoint;
  60288. /**
  60289. * Gets the output component
  60290. */
  60291. get output(): NodeMaterialConnectionPoint;
  60292. protected _buildBlock(state: NodeMaterialBuildState): this;
  60293. }
  60294. }
  60295. declare module BABYLON {
  60296. /**
  60297. * Block used to get negative version of a value (i.e. x * -1)
  60298. */
  60299. export class NegateBlock extends NodeMaterialBlock {
  60300. /**
  60301. * Creates a new NegateBlock
  60302. * @param name defines the block name
  60303. */
  60304. constructor(name: string);
  60305. /**
  60306. * Gets the current class name
  60307. * @returns the class name
  60308. */
  60309. getClassName(): string;
  60310. /**
  60311. * Gets the value input component
  60312. */
  60313. get value(): NodeMaterialConnectionPoint;
  60314. /**
  60315. * Gets the output component
  60316. */
  60317. get output(): NodeMaterialConnectionPoint;
  60318. protected _buildBlock(state: NodeMaterialBuildState): this;
  60319. }
  60320. }
  60321. declare module BABYLON {
  60322. /**
  60323. * Block used to get the value of the first parameter raised to the power of the second
  60324. */
  60325. export class PowBlock extends NodeMaterialBlock {
  60326. /**
  60327. * Creates a new PowBlock
  60328. * @param name defines the block name
  60329. */
  60330. constructor(name: string);
  60331. /**
  60332. * Gets the current class name
  60333. * @returns the class name
  60334. */
  60335. getClassName(): string;
  60336. /**
  60337. * Gets the value operand input component
  60338. */
  60339. get value(): NodeMaterialConnectionPoint;
  60340. /**
  60341. * Gets the power operand input component
  60342. */
  60343. get power(): NodeMaterialConnectionPoint;
  60344. /**
  60345. * Gets the output component
  60346. */
  60347. get output(): NodeMaterialConnectionPoint;
  60348. protected _buildBlock(state: NodeMaterialBuildState): this;
  60349. }
  60350. }
  60351. declare module BABYLON {
  60352. /**
  60353. * Block used to get a random number
  60354. */
  60355. export class RandomNumberBlock extends NodeMaterialBlock {
  60356. /**
  60357. * Creates a new RandomNumberBlock
  60358. * @param name defines the block name
  60359. */
  60360. constructor(name: string);
  60361. /**
  60362. * Gets the current class name
  60363. * @returns the class name
  60364. */
  60365. getClassName(): string;
  60366. /**
  60367. * Gets the seed input component
  60368. */
  60369. get seed(): NodeMaterialConnectionPoint;
  60370. /**
  60371. * Gets the output component
  60372. */
  60373. get output(): NodeMaterialConnectionPoint;
  60374. protected _buildBlock(state: NodeMaterialBuildState): this;
  60375. }
  60376. }
  60377. declare module BABYLON {
  60378. /**
  60379. * Block used to compute arc tangent of 2 values
  60380. */
  60381. export class ArcTan2Block extends NodeMaterialBlock {
  60382. /**
  60383. * Creates a new ArcTan2Block
  60384. * @param name defines the block name
  60385. */
  60386. constructor(name: string);
  60387. /**
  60388. * Gets the current class name
  60389. * @returns the class name
  60390. */
  60391. getClassName(): string;
  60392. /**
  60393. * Gets the x operand input component
  60394. */
  60395. get x(): NodeMaterialConnectionPoint;
  60396. /**
  60397. * Gets the y operand input component
  60398. */
  60399. get y(): NodeMaterialConnectionPoint;
  60400. /**
  60401. * Gets the output component
  60402. */
  60403. get output(): NodeMaterialConnectionPoint;
  60404. protected _buildBlock(state: NodeMaterialBuildState): this;
  60405. }
  60406. }
  60407. declare module BABYLON {
  60408. /**
  60409. * Block used to smooth step a value
  60410. */
  60411. export class SmoothStepBlock extends NodeMaterialBlock {
  60412. /**
  60413. * Creates a new SmoothStepBlock
  60414. * @param name defines the block name
  60415. */
  60416. constructor(name: string);
  60417. /**
  60418. * Gets the current class name
  60419. * @returns the class name
  60420. */
  60421. getClassName(): string;
  60422. /**
  60423. * Gets the value operand input component
  60424. */
  60425. get value(): NodeMaterialConnectionPoint;
  60426. /**
  60427. * Gets the first edge operand input component
  60428. */
  60429. get edge0(): NodeMaterialConnectionPoint;
  60430. /**
  60431. * Gets the second edge operand input component
  60432. */
  60433. get edge1(): NodeMaterialConnectionPoint;
  60434. /**
  60435. * Gets the output component
  60436. */
  60437. get output(): NodeMaterialConnectionPoint;
  60438. protected _buildBlock(state: NodeMaterialBuildState): this;
  60439. }
  60440. }
  60441. declare module BABYLON {
  60442. /**
  60443. * Block used to get the reciprocal (1 / x) of a value
  60444. */
  60445. export class ReciprocalBlock extends NodeMaterialBlock {
  60446. /**
  60447. * Creates a new ReciprocalBlock
  60448. * @param name defines the block name
  60449. */
  60450. constructor(name: string);
  60451. /**
  60452. * Gets the current class name
  60453. * @returns the class name
  60454. */
  60455. getClassName(): string;
  60456. /**
  60457. * Gets the input component
  60458. */
  60459. get input(): NodeMaterialConnectionPoint;
  60460. /**
  60461. * Gets the output component
  60462. */
  60463. get output(): NodeMaterialConnectionPoint;
  60464. protected _buildBlock(state: NodeMaterialBuildState): this;
  60465. }
  60466. }
  60467. declare module BABYLON {
  60468. /**
  60469. * Block used to replace a color by another one
  60470. */
  60471. export class ReplaceColorBlock extends NodeMaterialBlock {
  60472. /**
  60473. * Creates a new ReplaceColorBlock
  60474. * @param name defines the block name
  60475. */
  60476. constructor(name: string);
  60477. /**
  60478. * Gets the current class name
  60479. * @returns the class name
  60480. */
  60481. getClassName(): string;
  60482. /**
  60483. * Gets the value input component
  60484. */
  60485. get value(): NodeMaterialConnectionPoint;
  60486. /**
  60487. * Gets the reference input component
  60488. */
  60489. get reference(): NodeMaterialConnectionPoint;
  60490. /**
  60491. * Gets the distance input component
  60492. */
  60493. get distance(): NodeMaterialConnectionPoint;
  60494. /**
  60495. * Gets the replacement input component
  60496. */
  60497. get replacement(): NodeMaterialConnectionPoint;
  60498. /**
  60499. * Gets the output component
  60500. */
  60501. get output(): NodeMaterialConnectionPoint;
  60502. protected _buildBlock(state: NodeMaterialBuildState): this;
  60503. }
  60504. }
  60505. declare module BABYLON {
  60506. /**
  60507. * Block used to posterize a value
  60508. * @see https://en.wikipedia.org/wiki/Posterization
  60509. */
  60510. export class PosterizeBlock extends NodeMaterialBlock {
  60511. /**
  60512. * Creates a new PosterizeBlock
  60513. * @param name defines the block name
  60514. */
  60515. constructor(name: string);
  60516. /**
  60517. * Gets the current class name
  60518. * @returns the class name
  60519. */
  60520. getClassName(): string;
  60521. /**
  60522. * Gets the value input component
  60523. */
  60524. get value(): NodeMaterialConnectionPoint;
  60525. /**
  60526. * Gets the steps input component
  60527. */
  60528. get steps(): NodeMaterialConnectionPoint;
  60529. /**
  60530. * Gets the output component
  60531. */
  60532. get output(): NodeMaterialConnectionPoint;
  60533. protected _buildBlock(state: NodeMaterialBuildState): this;
  60534. }
  60535. }
  60536. declare module BABYLON {
  60537. /**
  60538. * Operations supported by the Wave block
  60539. */
  60540. export enum WaveBlockKind {
  60541. /** SawTooth */
  60542. SawTooth = 0,
  60543. /** Square */
  60544. Square = 1,
  60545. /** Triangle */
  60546. Triangle = 2
  60547. }
  60548. /**
  60549. * Block used to apply wave operation to floats
  60550. */
  60551. export class WaveBlock extends NodeMaterialBlock {
  60552. /**
  60553. * Gets or sets the kibnd of wave to be applied by the block
  60554. */
  60555. kind: WaveBlockKind;
  60556. /**
  60557. * Creates a new WaveBlock
  60558. * @param name defines the block name
  60559. */
  60560. constructor(name: string);
  60561. /**
  60562. * Gets the current class name
  60563. * @returns the class name
  60564. */
  60565. getClassName(): string;
  60566. /**
  60567. * Gets the input component
  60568. */
  60569. get input(): NodeMaterialConnectionPoint;
  60570. /**
  60571. * Gets the output component
  60572. */
  60573. get output(): NodeMaterialConnectionPoint;
  60574. protected _buildBlock(state: NodeMaterialBuildState): this;
  60575. serialize(): any;
  60576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60577. }
  60578. }
  60579. declare module BABYLON {
  60580. /**
  60581. * Class used to store a color step for the GradientBlock
  60582. */
  60583. export class GradientBlockColorStep {
  60584. /**
  60585. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60586. */
  60587. step: number;
  60588. /**
  60589. * Gets or sets the color associated with this step
  60590. */
  60591. color: Color3;
  60592. /**
  60593. * Creates a new GradientBlockColorStep
  60594. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60595. * @param color defines the color associated with this step
  60596. */
  60597. constructor(
  60598. /**
  60599. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60600. */
  60601. step: number,
  60602. /**
  60603. * Gets or sets the color associated with this step
  60604. */
  60605. color: Color3);
  60606. }
  60607. /**
  60608. * Block used to return a color from a gradient based on an input value between 0 and 1
  60609. */
  60610. export class GradientBlock extends NodeMaterialBlock {
  60611. /**
  60612. * Gets or sets the list of color steps
  60613. */
  60614. colorSteps: GradientBlockColorStep[];
  60615. /**
  60616. * Creates a new GradientBlock
  60617. * @param name defines the block name
  60618. */
  60619. constructor(name: string);
  60620. /**
  60621. * Gets the current class name
  60622. * @returns the class name
  60623. */
  60624. getClassName(): string;
  60625. /**
  60626. * Gets the gradient input component
  60627. */
  60628. get gradient(): NodeMaterialConnectionPoint;
  60629. /**
  60630. * Gets the output component
  60631. */
  60632. get output(): NodeMaterialConnectionPoint;
  60633. private _writeColorConstant;
  60634. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60635. serialize(): any;
  60636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60637. protected _dumpPropertiesCode(): string;
  60638. }
  60639. }
  60640. declare module BABYLON {
  60641. /**
  60642. * Block used to normalize lerp between 2 values
  60643. */
  60644. export class NLerpBlock extends NodeMaterialBlock {
  60645. /**
  60646. * Creates a new NLerpBlock
  60647. * @param name defines the block name
  60648. */
  60649. constructor(name: string);
  60650. /**
  60651. * Gets the current class name
  60652. * @returns the class name
  60653. */
  60654. getClassName(): string;
  60655. /**
  60656. * Gets the left operand input component
  60657. */
  60658. get left(): NodeMaterialConnectionPoint;
  60659. /**
  60660. * Gets the right operand input component
  60661. */
  60662. get right(): NodeMaterialConnectionPoint;
  60663. /**
  60664. * Gets the gradient operand input component
  60665. */
  60666. get gradient(): NodeMaterialConnectionPoint;
  60667. /**
  60668. * Gets the output component
  60669. */
  60670. get output(): NodeMaterialConnectionPoint;
  60671. protected _buildBlock(state: NodeMaterialBuildState): this;
  60672. }
  60673. }
  60674. declare module BABYLON {
  60675. /**
  60676. * block used to Generate a Worley Noise 3D Noise Pattern
  60677. */
  60678. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60679. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60680. manhattanDistance: boolean;
  60681. /**
  60682. * Creates a new WorleyNoise3DBlock
  60683. * @param name defines the block name
  60684. */
  60685. constructor(name: string);
  60686. /**
  60687. * Gets the current class name
  60688. * @returns the class name
  60689. */
  60690. getClassName(): string;
  60691. /**
  60692. * Gets the seed input component
  60693. */
  60694. get seed(): NodeMaterialConnectionPoint;
  60695. /**
  60696. * Gets the jitter input component
  60697. */
  60698. get jitter(): NodeMaterialConnectionPoint;
  60699. /**
  60700. * Gets the output component
  60701. */
  60702. get output(): NodeMaterialConnectionPoint;
  60703. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60704. /**
  60705. * Exposes the properties to the UI?
  60706. */
  60707. protected _dumpPropertiesCode(): string;
  60708. /**
  60709. * Exposes the properties to the Seralize?
  60710. */
  60711. serialize(): any;
  60712. /**
  60713. * Exposes the properties to the deseralize?
  60714. */
  60715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60716. }
  60717. }
  60718. declare module BABYLON {
  60719. /**
  60720. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60721. */
  60722. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60723. /**
  60724. * Creates a new SimplexPerlin3DBlock
  60725. * @param name defines the block name
  60726. */
  60727. constructor(name: string);
  60728. /**
  60729. * Gets the current class name
  60730. * @returns the class name
  60731. */
  60732. getClassName(): string;
  60733. /**
  60734. * Gets the seed operand input component
  60735. */
  60736. get seed(): NodeMaterialConnectionPoint;
  60737. /**
  60738. * Gets the output component
  60739. */
  60740. get output(): NodeMaterialConnectionPoint;
  60741. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60742. }
  60743. }
  60744. declare module BABYLON {
  60745. /**
  60746. * Block used to blend normals
  60747. */
  60748. export class NormalBlendBlock extends NodeMaterialBlock {
  60749. /**
  60750. * Creates a new NormalBlendBlock
  60751. * @param name defines the block name
  60752. */
  60753. constructor(name: string);
  60754. /**
  60755. * Gets the current class name
  60756. * @returns the class name
  60757. */
  60758. getClassName(): string;
  60759. /**
  60760. * Gets the first input component
  60761. */
  60762. get normalMap0(): NodeMaterialConnectionPoint;
  60763. /**
  60764. * Gets the second input component
  60765. */
  60766. get normalMap1(): NodeMaterialConnectionPoint;
  60767. /**
  60768. * Gets the output component
  60769. */
  60770. get output(): NodeMaterialConnectionPoint;
  60771. protected _buildBlock(state: NodeMaterialBuildState): this;
  60772. }
  60773. }
  60774. declare module BABYLON {
  60775. /**
  60776. * Block used to rotate a 2d vector by a given angle
  60777. */
  60778. export class Rotate2dBlock extends NodeMaterialBlock {
  60779. /**
  60780. * Creates a new Rotate2dBlock
  60781. * @param name defines the block name
  60782. */
  60783. constructor(name: string);
  60784. /**
  60785. * Gets the current class name
  60786. * @returns the class name
  60787. */
  60788. getClassName(): string;
  60789. /**
  60790. * Gets the input vector
  60791. */
  60792. get input(): NodeMaterialConnectionPoint;
  60793. /**
  60794. * Gets the input angle
  60795. */
  60796. get angle(): NodeMaterialConnectionPoint;
  60797. /**
  60798. * Gets the output component
  60799. */
  60800. get output(): NodeMaterialConnectionPoint;
  60801. autoConfigure(material: NodeMaterial): void;
  60802. protected _buildBlock(state: NodeMaterialBuildState): this;
  60803. }
  60804. }
  60805. declare module BABYLON {
  60806. /**
  60807. * Block used to get the reflected vector from a direction and a normal
  60808. */
  60809. export class ReflectBlock extends NodeMaterialBlock {
  60810. /**
  60811. * Creates a new ReflectBlock
  60812. * @param name defines the block name
  60813. */
  60814. constructor(name: string);
  60815. /**
  60816. * Gets the current class name
  60817. * @returns the class name
  60818. */
  60819. getClassName(): string;
  60820. /**
  60821. * Gets the incident component
  60822. */
  60823. get incident(): NodeMaterialConnectionPoint;
  60824. /**
  60825. * Gets the normal component
  60826. */
  60827. get normal(): NodeMaterialConnectionPoint;
  60828. /**
  60829. * Gets the output component
  60830. */
  60831. get output(): NodeMaterialConnectionPoint;
  60832. protected _buildBlock(state: NodeMaterialBuildState): this;
  60833. }
  60834. }
  60835. declare module BABYLON {
  60836. /**
  60837. * Block used to get the refracted vector from a direction and a normal
  60838. */
  60839. export class RefractBlock extends NodeMaterialBlock {
  60840. /**
  60841. * Creates a new RefractBlock
  60842. * @param name defines the block name
  60843. */
  60844. constructor(name: string);
  60845. /**
  60846. * Gets the current class name
  60847. * @returns the class name
  60848. */
  60849. getClassName(): string;
  60850. /**
  60851. * Gets the incident component
  60852. */
  60853. get incident(): NodeMaterialConnectionPoint;
  60854. /**
  60855. * Gets the normal component
  60856. */
  60857. get normal(): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Gets the index of refraction component
  60860. */
  60861. get ior(): NodeMaterialConnectionPoint;
  60862. /**
  60863. * Gets the output component
  60864. */
  60865. get output(): NodeMaterialConnectionPoint;
  60866. protected _buildBlock(state: NodeMaterialBuildState): this;
  60867. }
  60868. }
  60869. declare module BABYLON {
  60870. /**
  60871. * Block used to desaturate a color
  60872. */
  60873. export class DesaturateBlock extends NodeMaterialBlock {
  60874. /**
  60875. * Creates a new DesaturateBlock
  60876. * @param name defines the block name
  60877. */
  60878. constructor(name: string);
  60879. /**
  60880. * Gets the current class name
  60881. * @returns the class name
  60882. */
  60883. getClassName(): string;
  60884. /**
  60885. * Gets the color operand input component
  60886. */
  60887. get color(): NodeMaterialConnectionPoint;
  60888. /**
  60889. * Gets the level operand input component
  60890. */
  60891. get level(): NodeMaterialConnectionPoint;
  60892. /**
  60893. * Gets the output component
  60894. */
  60895. get output(): NodeMaterialConnectionPoint;
  60896. protected _buildBlock(state: NodeMaterialBuildState): this;
  60897. }
  60898. }
  60899. declare module BABYLON {
  60900. /**
  60901. * Effect Render Options
  60902. */
  60903. export interface IEffectRendererOptions {
  60904. /**
  60905. * Defines the vertices positions.
  60906. */
  60907. positions?: number[];
  60908. /**
  60909. * Defines the indices.
  60910. */
  60911. indices?: number[];
  60912. }
  60913. /**
  60914. * Helper class to render one or more effects.
  60915. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60916. */
  60917. export class EffectRenderer {
  60918. private engine;
  60919. private static _DefaultOptions;
  60920. private _vertexBuffers;
  60921. private _indexBuffer;
  60922. private _fullscreenViewport;
  60923. /**
  60924. * Creates an effect renderer
  60925. * @param engine the engine to use for rendering
  60926. * @param options defines the options of the effect renderer
  60927. */
  60928. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60929. /**
  60930. * Sets the current viewport in normalized coordinates 0-1
  60931. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60932. */
  60933. setViewport(viewport?: Viewport): void;
  60934. /**
  60935. * Binds the embedded attributes buffer to the effect.
  60936. * @param effect Defines the effect to bind the attributes for
  60937. */
  60938. bindBuffers(effect: Effect): void;
  60939. /**
  60940. * Sets the current effect wrapper to use during draw.
  60941. * The effect needs to be ready before calling this api.
  60942. * This also sets the default full screen position attribute.
  60943. * @param effectWrapper Defines the effect to draw with
  60944. */
  60945. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60946. /**
  60947. * Draws a full screen quad.
  60948. */
  60949. draw(): void;
  60950. private isRenderTargetTexture;
  60951. /**
  60952. * renders one or more effects to a specified texture
  60953. * @param effectWrapper the effect to renderer
  60954. * @param outputTexture texture to draw to, if null it will render to the screen.
  60955. */
  60956. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60957. /**
  60958. * Disposes of the effect renderer
  60959. */
  60960. dispose(): void;
  60961. }
  60962. /**
  60963. * Options to create an EffectWrapper
  60964. */
  60965. interface EffectWrapperCreationOptions {
  60966. /**
  60967. * Engine to use to create the effect
  60968. */
  60969. engine: ThinEngine;
  60970. /**
  60971. * Fragment shader for the effect
  60972. */
  60973. fragmentShader: string;
  60974. /**
  60975. * Vertex shader for the effect
  60976. */
  60977. vertexShader?: string;
  60978. /**
  60979. * Attributes to use in the shader
  60980. */
  60981. attributeNames?: Array<string>;
  60982. /**
  60983. * Uniforms to use in the shader
  60984. */
  60985. uniformNames?: Array<string>;
  60986. /**
  60987. * Texture sampler names to use in the shader
  60988. */
  60989. samplerNames?: Array<string>;
  60990. /**
  60991. * The friendly name of the effect displayed in Spector.
  60992. */
  60993. name?: string;
  60994. }
  60995. /**
  60996. * Wraps an effect to be used for rendering
  60997. */
  60998. export class EffectWrapper {
  60999. /**
  61000. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61001. */
  61002. onApplyObservable: Observable<{}>;
  61003. /**
  61004. * The underlying effect
  61005. */
  61006. effect: Effect;
  61007. /**
  61008. * Creates an effect to be renderer
  61009. * @param creationOptions options to create the effect
  61010. */
  61011. constructor(creationOptions: EffectWrapperCreationOptions);
  61012. /**
  61013. * Disposes of the effect wrapper
  61014. */
  61015. dispose(): void;
  61016. }
  61017. }
  61018. declare module BABYLON {
  61019. /**
  61020. * Helper class to push actions to a pool of workers.
  61021. */
  61022. export class WorkerPool implements IDisposable {
  61023. private _workerInfos;
  61024. private _pendingActions;
  61025. /**
  61026. * Constructor
  61027. * @param workers Array of workers to use for actions
  61028. */
  61029. constructor(workers: Array<Worker>);
  61030. /**
  61031. * Terminates all workers and clears any pending actions.
  61032. */
  61033. dispose(): void;
  61034. /**
  61035. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61036. * pended until a worker has completed its action.
  61037. * @param action The action to perform. Call onComplete when the action is complete.
  61038. */
  61039. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61040. private _execute;
  61041. }
  61042. }
  61043. declare module BABYLON {
  61044. /**
  61045. * Configuration for Draco compression
  61046. */
  61047. export interface IDracoCompressionConfiguration {
  61048. /**
  61049. * Configuration for the decoder.
  61050. */
  61051. decoder: {
  61052. /**
  61053. * The url to the WebAssembly module.
  61054. */
  61055. wasmUrl?: string;
  61056. /**
  61057. * The url to the WebAssembly binary.
  61058. */
  61059. wasmBinaryUrl?: string;
  61060. /**
  61061. * The url to the fallback JavaScript module.
  61062. */
  61063. fallbackUrl?: string;
  61064. };
  61065. }
  61066. /**
  61067. * Draco compression (https://google.github.io/draco/)
  61068. *
  61069. * This class wraps the Draco module.
  61070. *
  61071. * **Encoder**
  61072. *
  61073. * The encoder is not currently implemented.
  61074. *
  61075. * **Decoder**
  61076. *
  61077. * 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.
  61078. *
  61079. * To update the configuration, use the following code:
  61080. * ```javascript
  61081. * DracoCompression.Configuration = {
  61082. * decoder: {
  61083. * wasmUrl: "<url to the WebAssembly library>",
  61084. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61085. * fallbackUrl: "<url to the fallback JavaScript library>",
  61086. * }
  61087. * };
  61088. * ```
  61089. *
  61090. * 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.
  61091. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61092. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61093. *
  61094. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61095. * ```javascript
  61096. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61097. * ```
  61098. *
  61099. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61100. */
  61101. export class DracoCompression implements IDisposable {
  61102. private _workerPoolPromise?;
  61103. private _decoderModulePromise?;
  61104. /**
  61105. * The configuration. Defaults to the following urls:
  61106. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61107. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61108. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61109. */
  61110. static Configuration: IDracoCompressionConfiguration;
  61111. /**
  61112. * Returns true if the decoder configuration is available.
  61113. */
  61114. static get DecoderAvailable(): boolean;
  61115. /**
  61116. * Default number of workers to create when creating the draco compression object.
  61117. */
  61118. static DefaultNumWorkers: number;
  61119. private static GetDefaultNumWorkers;
  61120. private static _Default;
  61121. /**
  61122. * Default instance for the draco compression object.
  61123. */
  61124. static get Default(): DracoCompression;
  61125. /**
  61126. * Constructor
  61127. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61128. */
  61129. constructor(numWorkers?: number);
  61130. /**
  61131. * Stop all async operations and release resources.
  61132. */
  61133. dispose(): void;
  61134. /**
  61135. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61136. * @returns a promise that resolves when ready
  61137. */
  61138. whenReadyAsync(): Promise<void>;
  61139. /**
  61140. * Decode Draco compressed mesh data to vertex data.
  61141. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61142. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61143. * @returns A promise that resolves with the decoded vertex data
  61144. */
  61145. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61146. [kind: string]: number;
  61147. }): Promise<VertexData>;
  61148. }
  61149. }
  61150. declare module BABYLON {
  61151. /**
  61152. * Class for building Constructive Solid Geometry
  61153. */
  61154. export class CSG {
  61155. private polygons;
  61156. /**
  61157. * The world matrix
  61158. */
  61159. matrix: Matrix;
  61160. /**
  61161. * Stores the position
  61162. */
  61163. position: Vector3;
  61164. /**
  61165. * Stores the rotation
  61166. */
  61167. rotation: Vector3;
  61168. /**
  61169. * Stores the rotation quaternion
  61170. */
  61171. rotationQuaternion: Nullable<Quaternion>;
  61172. /**
  61173. * Stores the scaling vector
  61174. */
  61175. scaling: Vector3;
  61176. /**
  61177. * Convert the Mesh to CSG
  61178. * @param mesh The Mesh to convert to CSG
  61179. * @returns A new CSG from the Mesh
  61180. */
  61181. static FromMesh(mesh: Mesh): CSG;
  61182. /**
  61183. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61184. * @param polygons Polygons used to construct a CSG solid
  61185. */
  61186. private static FromPolygons;
  61187. /**
  61188. * Clones, or makes a deep copy, of the CSG
  61189. * @returns A new CSG
  61190. */
  61191. clone(): CSG;
  61192. /**
  61193. * Unions this CSG with another CSG
  61194. * @param csg The CSG to union against this CSG
  61195. * @returns The unioned CSG
  61196. */
  61197. union(csg: CSG): CSG;
  61198. /**
  61199. * Unions this CSG with another CSG in place
  61200. * @param csg The CSG to union against this CSG
  61201. */
  61202. unionInPlace(csg: CSG): void;
  61203. /**
  61204. * Subtracts this CSG with another CSG
  61205. * @param csg The CSG to subtract against this CSG
  61206. * @returns A new CSG
  61207. */
  61208. subtract(csg: CSG): CSG;
  61209. /**
  61210. * Subtracts this CSG with another CSG in place
  61211. * @param csg The CSG to subtact against this CSG
  61212. */
  61213. subtractInPlace(csg: CSG): void;
  61214. /**
  61215. * Intersect this CSG with another CSG
  61216. * @param csg The CSG to intersect against this CSG
  61217. * @returns A new CSG
  61218. */
  61219. intersect(csg: CSG): CSG;
  61220. /**
  61221. * Intersects this CSG with another CSG in place
  61222. * @param csg The CSG to intersect against this CSG
  61223. */
  61224. intersectInPlace(csg: CSG): void;
  61225. /**
  61226. * Return a new CSG solid with solid and empty space switched. This solid is
  61227. * not modified.
  61228. * @returns A new CSG solid with solid and empty space switched
  61229. */
  61230. inverse(): CSG;
  61231. /**
  61232. * Inverses the CSG in place
  61233. */
  61234. inverseInPlace(): void;
  61235. /**
  61236. * This is used to keep meshes transformations so they can be restored
  61237. * when we build back a Babylon Mesh
  61238. * NB : All CSG operations are performed in world coordinates
  61239. * @param csg The CSG to copy the transform attributes from
  61240. * @returns This CSG
  61241. */
  61242. copyTransformAttributes(csg: CSG): CSG;
  61243. /**
  61244. * Build Raw mesh from CSG
  61245. * Coordinates here are in world space
  61246. * @param name The name of the mesh geometry
  61247. * @param scene The Scene
  61248. * @param keepSubMeshes Specifies if the submeshes should be kept
  61249. * @returns A new Mesh
  61250. */
  61251. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61252. /**
  61253. * Build Mesh from CSG taking material and transforms into account
  61254. * @param name The name of the Mesh
  61255. * @param material The material of the Mesh
  61256. * @param scene The Scene
  61257. * @param keepSubMeshes Specifies if submeshes should be kept
  61258. * @returns The new Mesh
  61259. */
  61260. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61261. }
  61262. }
  61263. declare module BABYLON {
  61264. /**
  61265. * Class used to create a trail following a mesh
  61266. */
  61267. export class TrailMesh extends Mesh {
  61268. private _generator;
  61269. private _autoStart;
  61270. private _running;
  61271. private _diameter;
  61272. private _length;
  61273. private _sectionPolygonPointsCount;
  61274. private _sectionVectors;
  61275. private _sectionNormalVectors;
  61276. private _beforeRenderObserver;
  61277. /**
  61278. * @constructor
  61279. * @param name The value used by scene.getMeshByName() to do a lookup.
  61280. * @param generator The mesh or transform node to generate a trail.
  61281. * @param scene The scene to add this mesh to.
  61282. * @param diameter Diameter of trailing mesh. Default is 1.
  61283. * @param length Length of trailing mesh. Default is 60.
  61284. * @param autoStart Automatically start trailing mesh. Default true.
  61285. */
  61286. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61287. /**
  61288. * "TrailMesh"
  61289. * @returns "TrailMesh"
  61290. */
  61291. getClassName(): string;
  61292. private _createMesh;
  61293. /**
  61294. * Start trailing mesh.
  61295. */
  61296. start(): void;
  61297. /**
  61298. * Stop trailing mesh.
  61299. */
  61300. stop(): void;
  61301. /**
  61302. * Update trailing mesh geometry.
  61303. */
  61304. update(): void;
  61305. /**
  61306. * Returns a new TrailMesh object.
  61307. * @param name is a string, the name given to the new mesh
  61308. * @param newGenerator use new generator object for cloned trail mesh
  61309. * @returns a new mesh
  61310. */
  61311. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61312. /**
  61313. * Serializes this trail mesh
  61314. * @param serializationObject object to write serialization to
  61315. */
  61316. serialize(serializationObject: any): void;
  61317. /**
  61318. * Parses a serialized trail mesh
  61319. * @param parsedMesh the serialized mesh
  61320. * @param scene the scene to create the trail mesh in
  61321. * @returns the created trail mesh
  61322. */
  61323. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61324. }
  61325. }
  61326. declare module BABYLON {
  61327. /**
  61328. * Class containing static functions to help procedurally build meshes
  61329. */
  61330. export class TiledBoxBuilder {
  61331. /**
  61332. * Creates a box mesh
  61333. * 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)
  61334. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61338. * @param name defines the name of the mesh
  61339. * @param options defines the options used to create the mesh
  61340. * @param scene defines the hosting scene
  61341. * @returns the box mesh
  61342. */
  61343. static CreateTiledBox(name: string, options: {
  61344. pattern?: number;
  61345. width?: number;
  61346. height?: number;
  61347. depth?: number;
  61348. tileSize?: number;
  61349. tileWidth?: number;
  61350. tileHeight?: number;
  61351. alignHorizontal?: number;
  61352. alignVertical?: number;
  61353. faceUV?: Vector4[];
  61354. faceColors?: Color4[];
  61355. sideOrientation?: number;
  61356. updatable?: boolean;
  61357. }, scene?: Nullable<Scene>): Mesh;
  61358. }
  61359. }
  61360. declare module BABYLON {
  61361. /**
  61362. * Class containing static functions to help procedurally build meshes
  61363. */
  61364. export class TorusKnotBuilder {
  61365. /**
  61366. * Creates a torus knot mesh
  61367. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61368. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61369. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61370. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61372. * * 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
  61373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61374. * @param name defines the name of the mesh
  61375. * @param options defines the options used to create the mesh
  61376. * @param scene defines the hosting scene
  61377. * @returns the torus knot mesh
  61378. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61379. */
  61380. static CreateTorusKnot(name: string, options: {
  61381. radius?: number;
  61382. tube?: number;
  61383. radialSegments?: number;
  61384. tubularSegments?: number;
  61385. p?: number;
  61386. q?: number;
  61387. updatable?: boolean;
  61388. sideOrientation?: number;
  61389. frontUVs?: Vector4;
  61390. backUVs?: Vector4;
  61391. }, scene: any): Mesh;
  61392. }
  61393. }
  61394. declare module BABYLON {
  61395. /**
  61396. * Polygon
  61397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61398. */
  61399. export class Polygon {
  61400. /**
  61401. * Creates a rectangle
  61402. * @param xmin bottom X coord
  61403. * @param ymin bottom Y coord
  61404. * @param xmax top X coord
  61405. * @param ymax top Y coord
  61406. * @returns points that make the resulting rectation
  61407. */
  61408. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61409. /**
  61410. * Creates a circle
  61411. * @param radius radius of circle
  61412. * @param cx scale in x
  61413. * @param cy scale in y
  61414. * @param numberOfSides number of sides that make up the circle
  61415. * @returns points that make the resulting circle
  61416. */
  61417. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61418. /**
  61419. * Creates a polygon from input string
  61420. * @param input Input polygon data
  61421. * @returns the parsed points
  61422. */
  61423. static Parse(input: string): Vector2[];
  61424. /**
  61425. * Starts building a polygon from x and y coordinates
  61426. * @param x x coordinate
  61427. * @param y y coordinate
  61428. * @returns the started path2
  61429. */
  61430. static StartingAt(x: number, y: number): Path2;
  61431. }
  61432. /**
  61433. * Builds a polygon
  61434. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61435. */
  61436. export class PolygonMeshBuilder {
  61437. private _points;
  61438. private _outlinepoints;
  61439. private _holes;
  61440. private _name;
  61441. private _scene;
  61442. private _epoints;
  61443. private _eholes;
  61444. private _addToepoint;
  61445. /**
  61446. * Babylon reference to the earcut plugin.
  61447. */
  61448. bjsEarcut: any;
  61449. /**
  61450. * Creates a PolygonMeshBuilder
  61451. * @param name name of the builder
  61452. * @param contours Path of the polygon
  61453. * @param scene scene to add to when creating the mesh
  61454. * @param earcutInjection can be used to inject your own earcut reference
  61455. */
  61456. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61457. /**
  61458. * Adds a whole within the polygon
  61459. * @param hole Array of points defining the hole
  61460. * @returns this
  61461. */
  61462. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61463. /**
  61464. * Creates the polygon
  61465. * @param updatable If the mesh should be updatable
  61466. * @param depth The depth of the mesh created
  61467. * @returns the created mesh
  61468. */
  61469. build(updatable?: boolean, depth?: number): Mesh;
  61470. /**
  61471. * Creates the polygon
  61472. * @param depth The depth of the mesh created
  61473. * @returns the created VertexData
  61474. */
  61475. buildVertexData(depth?: number): VertexData;
  61476. /**
  61477. * Adds a side to the polygon
  61478. * @param positions points that make the polygon
  61479. * @param normals normals of the polygon
  61480. * @param uvs uvs of the polygon
  61481. * @param indices indices of the polygon
  61482. * @param bounds bounds of the polygon
  61483. * @param points points of the polygon
  61484. * @param depth depth of the polygon
  61485. * @param flip flip of the polygon
  61486. */
  61487. private addSide;
  61488. }
  61489. }
  61490. declare module BABYLON {
  61491. /**
  61492. * Class containing static functions to help procedurally build meshes
  61493. */
  61494. export class PolygonBuilder {
  61495. /**
  61496. * Creates a polygon mesh
  61497. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61498. * * 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
  61499. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61501. * * 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)
  61502. * * Remember you can only change the shape positions, not their number when updating a polygon
  61503. * @param name defines the name of the mesh
  61504. * @param options defines the options used to create the mesh
  61505. * @param scene defines the hosting scene
  61506. * @param earcutInjection can be used to inject your own earcut reference
  61507. * @returns the polygon mesh
  61508. */
  61509. static CreatePolygon(name: string, options: {
  61510. shape: Vector3[];
  61511. holes?: Vector3[][];
  61512. depth?: number;
  61513. faceUV?: Vector4[];
  61514. faceColors?: Color4[];
  61515. updatable?: boolean;
  61516. sideOrientation?: number;
  61517. frontUVs?: Vector4;
  61518. backUVs?: Vector4;
  61519. wrap?: boolean;
  61520. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61521. /**
  61522. * Creates an extruded polygon mesh, with depth in the Y direction.
  61523. * * 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)
  61524. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61525. * @param name defines the name of the mesh
  61526. * @param options defines the options used to create the mesh
  61527. * @param scene defines the hosting scene
  61528. * @param earcutInjection can be used to inject your own earcut reference
  61529. * @returns the polygon mesh
  61530. */
  61531. static ExtrudePolygon(name: string, options: {
  61532. shape: Vector3[];
  61533. holes?: Vector3[][];
  61534. depth?: number;
  61535. faceUV?: Vector4[];
  61536. faceColors?: Color4[];
  61537. updatable?: boolean;
  61538. sideOrientation?: number;
  61539. frontUVs?: Vector4;
  61540. backUVs?: Vector4;
  61541. wrap?: boolean;
  61542. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61543. }
  61544. }
  61545. declare module BABYLON {
  61546. /**
  61547. * Class containing static functions to help procedurally build meshes
  61548. */
  61549. export class LatheBuilder {
  61550. /**
  61551. * Creates lathe mesh.
  61552. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61553. * * 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
  61554. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61555. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61556. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61557. * * 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
  61558. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61559. * * 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
  61560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61561. * * 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
  61562. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61564. * @param name defines the name of the mesh
  61565. * @param options defines the options used to create the mesh
  61566. * @param scene defines the hosting scene
  61567. * @returns the lathe mesh
  61568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61569. */
  61570. static CreateLathe(name: string, options: {
  61571. shape: Vector3[];
  61572. radius?: number;
  61573. tessellation?: number;
  61574. clip?: number;
  61575. arc?: number;
  61576. closed?: boolean;
  61577. updatable?: boolean;
  61578. sideOrientation?: number;
  61579. frontUVs?: Vector4;
  61580. backUVs?: Vector4;
  61581. cap?: number;
  61582. invertUV?: boolean;
  61583. }, scene?: Nullable<Scene>): Mesh;
  61584. }
  61585. }
  61586. declare module BABYLON {
  61587. /**
  61588. * Class containing static functions to help procedurally build meshes
  61589. */
  61590. export class TiledPlaneBuilder {
  61591. /**
  61592. * Creates a tiled plane mesh
  61593. * * The parameter `pattern` will, depending on value, do nothing or
  61594. * * * flip (reflect about central vertical) alternate tiles across and up
  61595. * * * flip every tile on alternate rows
  61596. * * * rotate (180 degs) alternate tiles across and up
  61597. * * * rotate every tile on alternate rows
  61598. * * * flip and rotate alternate tiles across and up
  61599. * * * flip and rotate every tile on alternate rows
  61600. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61601. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61602. * * 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
  61603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61604. * * 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)
  61605. * * 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)
  61606. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61607. * @param name defines the name of the mesh
  61608. * @param options defines the options used to create the mesh
  61609. * @param scene defines the hosting scene
  61610. * @returns the box mesh
  61611. */
  61612. static CreateTiledPlane(name: string, options: {
  61613. pattern?: number;
  61614. tileSize?: number;
  61615. tileWidth?: number;
  61616. tileHeight?: number;
  61617. size?: number;
  61618. width?: number;
  61619. height?: number;
  61620. alignHorizontal?: number;
  61621. alignVertical?: number;
  61622. sideOrientation?: number;
  61623. frontUVs?: Vector4;
  61624. backUVs?: Vector4;
  61625. updatable?: boolean;
  61626. }, scene?: Nullable<Scene>): Mesh;
  61627. }
  61628. }
  61629. declare module BABYLON {
  61630. /**
  61631. * Class containing static functions to help procedurally build meshes
  61632. */
  61633. export class TubeBuilder {
  61634. /**
  61635. * Creates a tube mesh.
  61636. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61637. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61638. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61639. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61640. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61641. * * 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)
  61642. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61643. * * 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
  61644. * * 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
  61645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61646. * * 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
  61647. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61649. * @param name defines the name of the mesh
  61650. * @param options defines the options used to create the mesh
  61651. * @param scene defines the hosting scene
  61652. * @returns the tube mesh
  61653. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61654. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61655. */
  61656. static CreateTube(name: string, options: {
  61657. path: Vector3[];
  61658. radius?: number;
  61659. tessellation?: number;
  61660. radiusFunction?: {
  61661. (i: number, distance: number): number;
  61662. };
  61663. cap?: number;
  61664. arc?: number;
  61665. updatable?: boolean;
  61666. sideOrientation?: number;
  61667. frontUVs?: Vector4;
  61668. backUVs?: Vector4;
  61669. instance?: Mesh;
  61670. invertUV?: boolean;
  61671. }, scene?: Nullable<Scene>): Mesh;
  61672. }
  61673. }
  61674. declare module BABYLON {
  61675. /**
  61676. * Class containing static functions to help procedurally build meshes
  61677. */
  61678. export class IcoSphereBuilder {
  61679. /**
  61680. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61681. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61682. * * 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`)
  61683. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61684. * * 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
  61685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61686. * * 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
  61687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61688. * @param name defines the name of the mesh
  61689. * @param options defines the options used to create the mesh
  61690. * @param scene defines the hosting scene
  61691. * @returns the icosahedron mesh
  61692. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61693. */
  61694. static CreateIcoSphere(name: string, options: {
  61695. radius?: number;
  61696. radiusX?: number;
  61697. radiusY?: number;
  61698. radiusZ?: number;
  61699. flat?: boolean;
  61700. subdivisions?: number;
  61701. sideOrientation?: number;
  61702. frontUVs?: Vector4;
  61703. backUVs?: Vector4;
  61704. updatable?: boolean;
  61705. }, scene?: Nullable<Scene>): Mesh;
  61706. }
  61707. }
  61708. declare module BABYLON {
  61709. /**
  61710. * Class containing static functions to help procedurally build meshes
  61711. */
  61712. export class DecalBuilder {
  61713. /**
  61714. * Creates a decal mesh.
  61715. * 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
  61716. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61717. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61718. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61719. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61720. * @param name defines the name of the mesh
  61721. * @param sourceMesh defines the mesh where the decal must be applied
  61722. * @param options defines the options used to create the mesh
  61723. * @param scene defines the hosting scene
  61724. * @returns the decal mesh
  61725. * @see https://doc.babylonjs.com/how_to/decals
  61726. */
  61727. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61728. position?: Vector3;
  61729. normal?: Vector3;
  61730. size?: Vector3;
  61731. angle?: number;
  61732. }): Mesh;
  61733. }
  61734. }
  61735. declare module BABYLON {
  61736. /**
  61737. * Class containing static functions to help procedurally build meshes
  61738. */
  61739. export class MeshBuilder {
  61740. /**
  61741. * Creates a box mesh
  61742. * * The parameter `size` sets the size (float) of each box side (default 1)
  61743. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61744. * * 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)
  61745. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61747. * * 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
  61748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61749. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61750. * @param name defines the name of the mesh
  61751. * @param options defines the options used to create the mesh
  61752. * @param scene defines the hosting scene
  61753. * @returns the box mesh
  61754. */
  61755. static CreateBox(name: string, options: {
  61756. size?: number;
  61757. width?: number;
  61758. height?: number;
  61759. depth?: number;
  61760. faceUV?: Vector4[];
  61761. faceColors?: Color4[];
  61762. sideOrientation?: number;
  61763. frontUVs?: Vector4;
  61764. backUVs?: Vector4;
  61765. wrap?: boolean;
  61766. topBaseAt?: number;
  61767. bottomBaseAt?: number;
  61768. updatable?: boolean;
  61769. }, scene?: Nullable<Scene>): Mesh;
  61770. /**
  61771. * Creates a tiled box mesh
  61772. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61774. * @param name defines the name of the mesh
  61775. * @param options defines the options used to create the mesh
  61776. * @param scene defines the hosting scene
  61777. * @returns the tiled box mesh
  61778. */
  61779. static CreateTiledBox(name: string, options: {
  61780. pattern?: number;
  61781. size?: number;
  61782. width?: number;
  61783. height?: number;
  61784. depth: number;
  61785. tileSize?: number;
  61786. tileWidth?: number;
  61787. tileHeight?: number;
  61788. faceUV?: Vector4[];
  61789. faceColors?: Color4[];
  61790. alignHorizontal?: number;
  61791. alignVertical?: number;
  61792. sideOrientation?: number;
  61793. updatable?: boolean;
  61794. }, scene?: Nullable<Scene>): Mesh;
  61795. /**
  61796. * Creates a sphere mesh
  61797. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61798. * * 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`)
  61799. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61800. * * 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
  61801. * * 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)
  61802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61803. * * 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
  61804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61805. * @param name defines the name of the mesh
  61806. * @param options defines the options used to create the mesh
  61807. * @param scene defines the hosting scene
  61808. * @returns the sphere mesh
  61809. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61810. */
  61811. static CreateSphere(name: string, options: {
  61812. segments?: number;
  61813. diameter?: number;
  61814. diameterX?: number;
  61815. diameterY?: number;
  61816. diameterZ?: number;
  61817. arc?: number;
  61818. slice?: number;
  61819. sideOrientation?: number;
  61820. frontUVs?: Vector4;
  61821. backUVs?: Vector4;
  61822. updatable?: boolean;
  61823. }, scene?: Nullable<Scene>): Mesh;
  61824. /**
  61825. * Creates a plane polygonal mesh. By default, this is a disc
  61826. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61827. * * 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
  61828. * * 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
  61829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61830. * * 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
  61831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61832. * @param name defines the name of the mesh
  61833. * @param options defines the options used to create the mesh
  61834. * @param scene defines the hosting scene
  61835. * @returns the plane polygonal mesh
  61836. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61837. */
  61838. static CreateDisc(name: string, options: {
  61839. radius?: number;
  61840. tessellation?: number;
  61841. arc?: number;
  61842. updatable?: boolean;
  61843. sideOrientation?: number;
  61844. frontUVs?: Vector4;
  61845. backUVs?: Vector4;
  61846. }, scene?: Nullable<Scene>): Mesh;
  61847. /**
  61848. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61849. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61850. * * 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`)
  61851. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61852. * * 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
  61853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61854. * * 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
  61855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61856. * @param name defines the name of the mesh
  61857. * @param options defines the options used to create the mesh
  61858. * @param scene defines the hosting scene
  61859. * @returns the icosahedron mesh
  61860. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61861. */
  61862. static CreateIcoSphere(name: string, options: {
  61863. radius?: number;
  61864. radiusX?: number;
  61865. radiusY?: number;
  61866. radiusZ?: number;
  61867. flat?: boolean;
  61868. subdivisions?: number;
  61869. sideOrientation?: number;
  61870. frontUVs?: Vector4;
  61871. backUVs?: Vector4;
  61872. updatable?: boolean;
  61873. }, scene?: Nullable<Scene>): Mesh;
  61874. /**
  61875. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61876. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61877. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61878. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61879. * * 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
  61880. * * 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
  61881. * * 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
  61882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61883. * * 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
  61884. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61885. * * 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
  61886. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61887. * * 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
  61888. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61890. * @param name defines the name of the mesh
  61891. * @param options defines the options used to create the mesh
  61892. * @param scene defines the hosting scene
  61893. * @returns the ribbon mesh
  61894. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61895. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61896. */
  61897. static CreateRibbon(name: string, options: {
  61898. pathArray: Vector3[][];
  61899. closeArray?: boolean;
  61900. closePath?: boolean;
  61901. offset?: number;
  61902. updatable?: boolean;
  61903. sideOrientation?: number;
  61904. frontUVs?: Vector4;
  61905. backUVs?: Vector4;
  61906. instance?: Mesh;
  61907. invertUV?: boolean;
  61908. uvs?: Vector2[];
  61909. colors?: Color4[];
  61910. }, scene?: Nullable<Scene>): Mesh;
  61911. /**
  61912. * Creates a cylinder or a cone mesh
  61913. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61914. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61915. * * 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.
  61916. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61917. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61918. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61919. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61920. * * 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).
  61921. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61922. * * 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).
  61923. * * 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
  61924. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61925. * * 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
  61926. * * 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.
  61927. * * If `enclose` is false, a ring surface is one element.
  61928. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61929. * * 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
  61930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61931. * * 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
  61932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61933. * @param name defines the name of the mesh
  61934. * @param options defines the options used to create the mesh
  61935. * @param scene defines the hosting scene
  61936. * @returns the cylinder mesh
  61937. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61938. */
  61939. static CreateCylinder(name: string, options: {
  61940. height?: number;
  61941. diameterTop?: number;
  61942. diameterBottom?: number;
  61943. diameter?: number;
  61944. tessellation?: number;
  61945. subdivisions?: number;
  61946. arc?: number;
  61947. faceColors?: Color4[];
  61948. faceUV?: Vector4[];
  61949. updatable?: boolean;
  61950. hasRings?: boolean;
  61951. enclose?: boolean;
  61952. cap?: number;
  61953. sideOrientation?: number;
  61954. frontUVs?: Vector4;
  61955. backUVs?: Vector4;
  61956. }, scene?: Nullable<Scene>): Mesh;
  61957. /**
  61958. * Creates a torus mesh
  61959. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61960. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61961. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61963. * * 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
  61964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61965. * @param name defines the name of the mesh
  61966. * @param options defines the options used to create the mesh
  61967. * @param scene defines the hosting scene
  61968. * @returns the torus mesh
  61969. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61970. */
  61971. static CreateTorus(name: string, options: {
  61972. diameter?: number;
  61973. thickness?: number;
  61974. tessellation?: number;
  61975. updatable?: boolean;
  61976. sideOrientation?: number;
  61977. frontUVs?: Vector4;
  61978. backUVs?: Vector4;
  61979. }, scene?: Nullable<Scene>): Mesh;
  61980. /**
  61981. * Creates a torus knot mesh
  61982. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61983. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61984. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61985. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61987. * * 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
  61988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61989. * @param name defines the name of the mesh
  61990. * @param options defines the options used to create the mesh
  61991. * @param scene defines the hosting scene
  61992. * @returns the torus knot mesh
  61993. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61994. */
  61995. static CreateTorusKnot(name: string, options: {
  61996. radius?: number;
  61997. tube?: number;
  61998. radialSegments?: number;
  61999. tubularSegments?: number;
  62000. p?: number;
  62001. q?: number;
  62002. updatable?: boolean;
  62003. sideOrientation?: number;
  62004. frontUVs?: Vector4;
  62005. backUVs?: Vector4;
  62006. }, scene?: Nullable<Scene>): Mesh;
  62007. /**
  62008. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62009. * * 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
  62010. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62011. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62012. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62013. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62014. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62015. * * 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
  62016. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62019. * @param name defines the name of the new line system
  62020. * @param options defines the options used to create the line system
  62021. * @param scene defines the hosting scene
  62022. * @returns a new line system mesh
  62023. */
  62024. static CreateLineSystem(name: string, options: {
  62025. lines: Vector3[][];
  62026. updatable?: boolean;
  62027. instance?: Nullable<LinesMesh>;
  62028. colors?: Nullable<Color4[][]>;
  62029. useVertexAlpha?: boolean;
  62030. }, scene: Nullable<Scene>): LinesMesh;
  62031. /**
  62032. * Creates a line mesh
  62033. * 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
  62034. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62035. * * The parameter `points` is an array successive Vector3
  62036. * * 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
  62037. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62038. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62039. * * When updating an instance, remember that only point positions can change, not the number of points
  62040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62042. * @param name defines the name of the new line system
  62043. * @param options defines the options used to create the line system
  62044. * @param scene defines the hosting scene
  62045. * @returns a new line mesh
  62046. */
  62047. static CreateLines(name: string, options: {
  62048. points: Vector3[];
  62049. updatable?: boolean;
  62050. instance?: Nullable<LinesMesh>;
  62051. colors?: Color4[];
  62052. useVertexAlpha?: boolean;
  62053. }, scene?: Nullable<Scene>): LinesMesh;
  62054. /**
  62055. * Creates a dashed line mesh
  62056. * * 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
  62057. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62058. * * The parameter `points` is an array successive Vector3
  62059. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62060. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62061. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62062. * * 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
  62063. * * When updating an instance, remember that only point positions can change, not the number of points
  62064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62065. * @param name defines the name of the mesh
  62066. * @param options defines the options used to create the mesh
  62067. * @param scene defines the hosting scene
  62068. * @returns the dashed line mesh
  62069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62070. */
  62071. static CreateDashedLines(name: string, options: {
  62072. points: Vector3[];
  62073. dashSize?: number;
  62074. gapSize?: number;
  62075. dashNb?: number;
  62076. updatable?: boolean;
  62077. instance?: LinesMesh;
  62078. }, scene?: Nullable<Scene>): LinesMesh;
  62079. /**
  62080. * 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.
  62081. * * 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.
  62082. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62083. * * 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.
  62084. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62085. * * 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
  62086. * * 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
  62087. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62089. * * 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
  62090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62092. * @param name defines the name of the mesh
  62093. * @param options defines the options used to create the mesh
  62094. * @param scene defines the hosting scene
  62095. * @returns the extruded shape mesh
  62096. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62098. */
  62099. static ExtrudeShape(name: string, options: {
  62100. shape: Vector3[];
  62101. path: Vector3[];
  62102. scale?: number;
  62103. rotation?: number;
  62104. cap?: number;
  62105. updatable?: boolean;
  62106. sideOrientation?: number;
  62107. frontUVs?: Vector4;
  62108. backUVs?: Vector4;
  62109. instance?: Mesh;
  62110. invertUV?: boolean;
  62111. }, scene?: Nullable<Scene>): Mesh;
  62112. /**
  62113. * Creates an custom extruded shape mesh.
  62114. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62115. * * 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.
  62116. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62117. * * 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
  62118. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62119. * * 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
  62120. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62121. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62122. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62123. * * 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
  62124. * * 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
  62125. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62127. * * 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
  62128. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62130. * @param name defines the name of the mesh
  62131. * @param options defines the options used to create the mesh
  62132. * @param scene defines the hosting scene
  62133. * @returns the custom extruded shape mesh
  62134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62137. */
  62138. static ExtrudeShapeCustom(name: string, options: {
  62139. shape: Vector3[];
  62140. path: Vector3[];
  62141. scaleFunction?: any;
  62142. rotationFunction?: any;
  62143. ribbonCloseArray?: boolean;
  62144. ribbonClosePath?: boolean;
  62145. cap?: number;
  62146. updatable?: boolean;
  62147. sideOrientation?: number;
  62148. frontUVs?: Vector4;
  62149. backUVs?: Vector4;
  62150. instance?: Mesh;
  62151. invertUV?: boolean;
  62152. }, scene?: Nullable<Scene>): Mesh;
  62153. /**
  62154. * Creates lathe mesh.
  62155. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62156. * * 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
  62157. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62158. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62159. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62160. * * 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
  62161. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62162. * * 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
  62163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62164. * * 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
  62165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62167. * @param name defines the name of the mesh
  62168. * @param options defines the options used to create the mesh
  62169. * @param scene defines the hosting scene
  62170. * @returns the lathe mesh
  62171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62172. */
  62173. static CreateLathe(name: string, options: {
  62174. shape: Vector3[];
  62175. radius?: number;
  62176. tessellation?: number;
  62177. clip?: number;
  62178. arc?: number;
  62179. closed?: boolean;
  62180. updatable?: boolean;
  62181. sideOrientation?: number;
  62182. frontUVs?: Vector4;
  62183. backUVs?: Vector4;
  62184. cap?: number;
  62185. invertUV?: boolean;
  62186. }, scene?: Nullable<Scene>): Mesh;
  62187. /**
  62188. * Creates a tiled plane mesh
  62189. * * You can set a limited pattern arrangement with the tiles
  62190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62191. * * 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
  62192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62193. * @param name defines the name of the mesh
  62194. * @param options defines the options used to create the mesh
  62195. * @param scene defines the hosting scene
  62196. * @returns the plane mesh
  62197. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62198. */
  62199. static CreateTiledPlane(name: string, options: {
  62200. pattern?: number;
  62201. tileSize?: number;
  62202. tileWidth?: number;
  62203. tileHeight?: number;
  62204. size?: number;
  62205. width?: number;
  62206. height?: number;
  62207. alignHorizontal?: number;
  62208. alignVertical?: number;
  62209. sideOrientation?: number;
  62210. frontUVs?: Vector4;
  62211. backUVs?: Vector4;
  62212. updatable?: boolean;
  62213. }, scene?: Nullable<Scene>): Mesh;
  62214. /**
  62215. * Creates a plane mesh
  62216. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62217. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62218. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62220. * * 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
  62221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62222. * @param name defines the name of the mesh
  62223. * @param options defines the options used to create the mesh
  62224. * @param scene defines the hosting scene
  62225. * @returns the plane mesh
  62226. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62227. */
  62228. static CreatePlane(name: string, options: {
  62229. size?: number;
  62230. width?: number;
  62231. height?: number;
  62232. sideOrientation?: number;
  62233. frontUVs?: Vector4;
  62234. backUVs?: Vector4;
  62235. updatable?: boolean;
  62236. sourcePlane?: Plane;
  62237. }, scene?: Nullable<Scene>): Mesh;
  62238. /**
  62239. * Creates a ground mesh
  62240. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62241. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62243. * @param name defines the name of the mesh
  62244. * @param options defines the options used to create the mesh
  62245. * @param scene defines the hosting scene
  62246. * @returns the ground mesh
  62247. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62248. */
  62249. static CreateGround(name: string, options: {
  62250. width?: number;
  62251. height?: number;
  62252. subdivisions?: number;
  62253. subdivisionsX?: number;
  62254. subdivisionsY?: number;
  62255. updatable?: boolean;
  62256. }, scene?: Nullable<Scene>): Mesh;
  62257. /**
  62258. * Creates a tiled ground mesh
  62259. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62260. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62261. * * 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
  62262. * * 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
  62263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62264. * @param name defines the name of the mesh
  62265. * @param options defines the options used to create the mesh
  62266. * @param scene defines the hosting scene
  62267. * @returns the tiled ground mesh
  62268. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62269. */
  62270. static CreateTiledGround(name: string, options: {
  62271. xmin: number;
  62272. zmin: number;
  62273. xmax: number;
  62274. zmax: number;
  62275. subdivisions?: {
  62276. w: number;
  62277. h: number;
  62278. };
  62279. precision?: {
  62280. w: number;
  62281. h: number;
  62282. };
  62283. updatable?: boolean;
  62284. }, scene?: Nullable<Scene>): Mesh;
  62285. /**
  62286. * Creates a ground mesh from a height map
  62287. * * The parameter `url` sets the URL of the height map image resource.
  62288. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62289. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62290. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62291. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62292. * * 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.
  62293. * * 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).
  62294. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62296. * @param name defines the name of the mesh
  62297. * @param url defines the url to the height map
  62298. * @param options defines the options used to create the mesh
  62299. * @param scene defines the hosting scene
  62300. * @returns the ground mesh
  62301. * @see https://doc.babylonjs.com/babylon101/height_map
  62302. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62303. */
  62304. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62305. width?: number;
  62306. height?: number;
  62307. subdivisions?: number;
  62308. minHeight?: number;
  62309. maxHeight?: number;
  62310. colorFilter?: Color3;
  62311. alphaFilter?: number;
  62312. updatable?: boolean;
  62313. onReady?: (mesh: GroundMesh) => void;
  62314. }, scene?: Nullable<Scene>): GroundMesh;
  62315. /**
  62316. * Creates a polygon mesh
  62317. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62318. * * 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
  62319. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62321. * * 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)
  62322. * * Remember you can only change the shape positions, not their number when updating a polygon
  62323. * @param name defines the name of the mesh
  62324. * @param options defines the options used to create the mesh
  62325. * @param scene defines the hosting scene
  62326. * @param earcutInjection can be used to inject your own earcut reference
  62327. * @returns the polygon mesh
  62328. */
  62329. static CreatePolygon(name: string, options: {
  62330. shape: Vector3[];
  62331. holes?: Vector3[][];
  62332. depth?: number;
  62333. faceUV?: Vector4[];
  62334. faceColors?: Color4[];
  62335. updatable?: boolean;
  62336. sideOrientation?: number;
  62337. frontUVs?: Vector4;
  62338. backUVs?: Vector4;
  62339. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62340. /**
  62341. * Creates an extruded polygon mesh, with depth in the Y direction.
  62342. * * 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)
  62343. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62344. * @param name defines the name of the mesh
  62345. * @param options defines the options used to create the mesh
  62346. * @param scene defines the hosting scene
  62347. * @param earcutInjection can be used to inject your own earcut reference
  62348. * @returns the polygon mesh
  62349. */
  62350. static ExtrudePolygon(name: string, options: {
  62351. shape: Vector3[];
  62352. holes?: Vector3[][];
  62353. depth?: number;
  62354. faceUV?: Vector4[];
  62355. faceColors?: Color4[];
  62356. updatable?: boolean;
  62357. sideOrientation?: number;
  62358. frontUVs?: Vector4;
  62359. backUVs?: Vector4;
  62360. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62361. /**
  62362. * Creates a tube mesh.
  62363. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62364. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62365. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62366. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62367. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62368. * * 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)
  62369. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62370. * * 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
  62371. * * 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
  62372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62373. * * 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
  62374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62376. * @param name defines the name of the mesh
  62377. * @param options defines the options used to create the mesh
  62378. * @param scene defines the hosting scene
  62379. * @returns the tube mesh
  62380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62381. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62382. */
  62383. static CreateTube(name: string, options: {
  62384. path: Vector3[];
  62385. radius?: number;
  62386. tessellation?: number;
  62387. radiusFunction?: {
  62388. (i: number, distance: number): number;
  62389. };
  62390. cap?: number;
  62391. arc?: number;
  62392. updatable?: boolean;
  62393. sideOrientation?: number;
  62394. frontUVs?: Vector4;
  62395. backUVs?: Vector4;
  62396. instance?: Mesh;
  62397. invertUV?: boolean;
  62398. }, scene?: Nullable<Scene>): Mesh;
  62399. /**
  62400. * Creates a polyhedron mesh
  62401. * * 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
  62402. * * The parameter `size` (positive float, default 1) sets the polygon size
  62403. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62404. * * 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`
  62405. * * 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
  62406. * * 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)`)
  62407. * * 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
  62408. * * 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
  62409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62410. * * 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
  62411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62412. * @param name defines the name of the mesh
  62413. * @param options defines the options used to create the mesh
  62414. * @param scene defines the hosting scene
  62415. * @returns the polyhedron mesh
  62416. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62417. */
  62418. static CreatePolyhedron(name: string, options: {
  62419. type?: number;
  62420. size?: number;
  62421. sizeX?: number;
  62422. sizeY?: number;
  62423. sizeZ?: number;
  62424. custom?: any;
  62425. faceUV?: Vector4[];
  62426. faceColors?: Color4[];
  62427. flat?: boolean;
  62428. updatable?: boolean;
  62429. sideOrientation?: number;
  62430. frontUVs?: Vector4;
  62431. backUVs?: Vector4;
  62432. }, scene?: Nullable<Scene>): Mesh;
  62433. /**
  62434. * Creates a decal mesh.
  62435. * 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
  62436. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62437. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62438. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62439. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62440. * @param name defines the name of the mesh
  62441. * @param sourceMesh defines the mesh where the decal must be applied
  62442. * @param options defines the options used to create the mesh
  62443. * @param scene defines the hosting scene
  62444. * @returns the decal mesh
  62445. * @see https://doc.babylonjs.com/how_to/decals
  62446. */
  62447. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62448. position?: Vector3;
  62449. normal?: Vector3;
  62450. size?: Vector3;
  62451. angle?: number;
  62452. }): Mesh;
  62453. }
  62454. }
  62455. declare module BABYLON {
  62456. /**
  62457. * A simplifier interface for future simplification implementations
  62458. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62459. */
  62460. export interface ISimplifier {
  62461. /**
  62462. * Simplification of a given mesh according to the given settings.
  62463. * Since this requires computation, it is assumed that the function runs async.
  62464. * @param settings The settings of the simplification, including quality and distance
  62465. * @param successCallback A callback that will be called after the mesh was simplified.
  62466. * @param errorCallback in case of an error, this callback will be called. optional.
  62467. */
  62468. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62469. }
  62470. /**
  62471. * Expected simplification settings.
  62472. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62473. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62474. */
  62475. export interface ISimplificationSettings {
  62476. /**
  62477. * Gets or sets the expected quality
  62478. */
  62479. quality: number;
  62480. /**
  62481. * Gets or sets the distance when this optimized version should be used
  62482. */
  62483. distance: number;
  62484. /**
  62485. * Gets an already optimized mesh
  62486. */
  62487. optimizeMesh?: boolean;
  62488. }
  62489. /**
  62490. * Class used to specify simplification options
  62491. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62492. */
  62493. export class SimplificationSettings implements ISimplificationSettings {
  62494. /** expected quality */
  62495. quality: number;
  62496. /** distance when this optimized version should be used */
  62497. distance: number;
  62498. /** already optimized mesh */
  62499. optimizeMesh?: boolean | undefined;
  62500. /**
  62501. * Creates a SimplificationSettings
  62502. * @param quality expected quality
  62503. * @param distance distance when this optimized version should be used
  62504. * @param optimizeMesh already optimized mesh
  62505. */
  62506. constructor(
  62507. /** expected quality */
  62508. quality: number,
  62509. /** distance when this optimized version should be used */
  62510. distance: number,
  62511. /** already optimized mesh */
  62512. optimizeMesh?: boolean | undefined);
  62513. }
  62514. /**
  62515. * Interface used to define a simplification task
  62516. */
  62517. export interface ISimplificationTask {
  62518. /**
  62519. * Array of settings
  62520. */
  62521. settings: Array<ISimplificationSettings>;
  62522. /**
  62523. * Simplification type
  62524. */
  62525. simplificationType: SimplificationType;
  62526. /**
  62527. * Mesh to simplify
  62528. */
  62529. mesh: Mesh;
  62530. /**
  62531. * Callback called on success
  62532. */
  62533. successCallback?: () => void;
  62534. /**
  62535. * Defines if parallel processing can be used
  62536. */
  62537. parallelProcessing: boolean;
  62538. }
  62539. /**
  62540. * Queue used to order the simplification tasks
  62541. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62542. */
  62543. export class SimplificationQueue {
  62544. private _simplificationArray;
  62545. /**
  62546. * Gets a boolean indicating that the process is still running
  62547. */
  62548. running: boolean;
  62549. /**
  62550. * Creates a new queue
  62551. */
  62552. constructor();
  62553. /**
  62554. * Adds a new simplification task
  62555. * @param task defines a task to add
  62556. */
  62557. addTask(task: ISimplificationTask): void;
  62558. /**
  62559. * Execute next task
  62560. */
  62561. executeNext(): void;
  62562. /**
  62563. * Execute a simplification task
  62564. * @param task defines the task to run
  62565. */
  62566. runSimplification(task: ISimplificationTask): void;
  62567. private getSimplifier;
  62568. }
  62569. /**
  62570. * The implemented types of simplification
  62571. * At the moment only Quadratic Error Decimation is implemented
  62572. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62573. */
  62574. export enum SimplificationType {
  62575. /** Quadratic error decimation */
  62576. QUADRATIC = 0
  62577. }
  62578. /**
  62579. * An implementation of the Quadratic Error simplification algorithm.
  62580. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62581. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62582. * @author RaananW
  62583. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62584. */
  62585. export class QuadraticErrorSimplification implements ISimplifier {
  62586. private _mesh;
  62587. private triangles;
  62588. private vertices;
  62589. private references;
  62590. private _reconstructedMesh;
  62591. /** Gets or sets the number pf sync interations */
  62592. syncIterations: number;
  62593. /** Gets or sets the aggressiveness of the simplifier */
  62594. aggressiveness: number;
  62595. /** Gets or sets the number of allowed iterations for decimation */
  62596. decimationIterations: number;
  62597. /** Gets or sets the espilon to use for bounding box computation */
  62598. boundingBoxEpsilon: number;
  62599. /**
  62600. * Creates a new QuadraticErrorSimplification
  62601. * @param _mesh defines the target mesh
  62602. */
  62603. constructor(_mesh: Mesh);
  62604. /**
  62605. * Simplification of a given mesh according to the given settings.
  62606. * Since this requires computation, it is assumed that the function runs async.
  62607. * @param settings The settings of the simplification, including quality and distance
  62608. * @param successCallback A callback that will be called after the mesh was simplified.
  62609. */
  62610. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62611. private runDecimation;
  62612. private initWithMesh;
  62613. private init;
  62614. private reconstructMesh;
  62615. private initDecimatedMesh;
  62616. private isFlipped;
  62617. private updateTriangles;
  62618. private identifyBorder;
  62619. private updateMesh;
  62620. private vertexError;
  62621. private calculateError;
  62622. }
  62623. }
  62624. declare module BABYLON {
  62625. interface Scene {
  62626. /** @hidden (Backing field) */
  62627. _simplificationQueue: SimplificationQueue;
  62628. /**
  62629. * Gets or sets the simplification queue attached to the scene
  62630. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62631. */
  62632. simplificationQueue: SimplificationQueue;
  62633. }
  62634. interface Mesh {
  62635. /**
  62636. * Simplify the mesh according to the given array of settings.
  62637. * Function will return immediately and will simplify async
  62638. * @param settings a collection of simplification settings
  62639. * @param parallelProcessing should all levels calculate parallel or one after the other
  62640. * @param simplificationType the type of simplification to run
  62641. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62642. * @returns the current mesh
  62643. */
  62644. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62645. }
  62646. /**
  62647. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62648. * created in a scene
  62649. */
  62650. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62651. /**
  62652. * The component name helpfull to identify the component in the list of scene components.
  62653. */
  62654. readonly name: string;
  62655. /**
  62656. * The scene the component belongs to.
  62657. */
  62658. scene: Scene;
  62659. /**
  62660. * Creates a new instance of the component for the given scene
  62661. * @param scene Defines the scene to register the component in
  62662. */
  62663. constructor(scene: Scene);
  62664. /**
  62665. * Registers the component in a given scene
  62666. */
  62667. register(): void;
  62668. /**
  62669. * Rebuilds the elements related to this component in case of
  62670. * context lost for instance.
  62671. */
  62672. rebuild(): void;
  62673. /**
  62674. * Disposes the component and the associated ressources
  62675. */
  62676. dispose(): void;
  62677. private _beforeCameraUpdate;
  62678. }
  62679. }
  62680. declare module BABYLON {
  62681. /**
  62682. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62683. */
  62684. export interface INavigationEnginePlugin {
  62685. /**
  62686. * plugin name
  62687. */
  62688. name: string;
  62689. /**
  62690. * Creates a navigation mesh
  62691. * @param meshes array of all the geometry used to compute the navigatio mesh
  62692. * @param parameters bunch of parameters used to filter geometry
  62693. */
  62694. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62695. /**
  62696. * Create a navigation mesh debug mesh
  62697. * @param scene is where the mesh will be added
  62698. * @returns debug display mesh
  62699. */
  62700. createDebugNavMesh(scene: Scene): Mesh;
  62701. /**
  62702. * Get a navigation mesh constrained position, closest to the parameter position
  62703. * @param position world position
  62704. * @returns the closest point to position constrained by the navigation mesh
  62705. */
  62706. getClosestPoint(position: Vector3): Vector3;
  62707. /**
  62708. * Get a navigation mesh constrained position, closest to the parameter position
  62709. * @param position world position
  62710. * @param result output the closest point to position constrained by the navigation mesh
  62711. */
  62712. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62713. /**
  62714. * Get a navigation mesh constrained position, within a particular radius
  62715. * @param position world position
  62716. * @param maxRadius the maximum distance to the constrained world position
  62717. * @returns the closest point to position constrained by the navigation mesh
  62718. */
  62719. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62720. /**
  62721. * Get a navigation mesh constrained position, within a particular radius
  62722. * @param position world position
  62723. * @param maxRadius the maximum distance to the constrained world position
  62724. * @param result output the closest point to position constrained by the navigation mesh
  62725. */
  62726. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62727. /**
  62728. * Compute the final position from a segment made of destination-position
  62729. * @param position world position
  62730. * @param destination world position
  62731. * @returns the resulting point along the navmesh
  62732. */
  62733. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62734. /**
  62735. * Compute the final position from a segment made of destination-position
  62736. * @param position world position
  62737. * @param destination world position
  62738. * @param result output the resulting point along the navmesh
  62739. */
  62740. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62741. /**
  62742. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62743. * @param start world position
  62744. * @param end world position
  62745. * @returns array containing world position composing the path
  62746. */
  62747. computePath(start: Vector3, end: Vector3): Vector3[];
  62748. /**
  62749. * If this plugin is supported
  62750. * @returns true if plugin is supported
  62751. */
  62752. isSupported(): boolean;
  62753. /**
  62754. * Create a new Crowd so you can add agents
  62755. * @param maxAgents the maximum agent count in the crowd
  62756. * @param maxAgentRadius the maximum radius an agent can have
  62757. * @param scene to attach the crowd to
  62758. * @returns the crowd you can add agents to
  62759. */
  62760. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62761. /**
  62762. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62763. * The queries will try to find a solution within those bounds
  62764. * default is (1,1,1)
  62765. * @param extent x,y,z value that define the extent around the queries point of reference
  62766. */
  62767. setDefaultQueryExtent(extent: Vector3): void;
  62768. /**
  62769. * Get the Bounding box extent specified by setDefaultQueryExtent
  62770. * @returns the box extent values
  62771. */
  62772. getDefaultQueryExtent(): Vector3;
  62773. /**
  62774. * build the navmesh from a previously saved state using getNavmeshData
  62775. * @param data the Uint8Array returned by getNavmeshData
  62776. */
  62777. buildFromNavmeshData(data: Uint8Array): void;
  62778. /**
  62779. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62780. * @returns data the Uint8Array that can be saved and reused
  62781. */
  62782. getNavmeshData(): Uint8Array;
  62783. /**
  62784. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62785. * @param result output the box extent values
  62786. */
  62787. getDefaultQueryExtentToRef(result: Vector3): void;
  62788. /**
  62789. * Release all resources
  62790. */
  62791. dispose(): void;
  62792. }
  62793. /**
  62794. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62795. */
  62796. export interface ICrowd {
  62797. /**
  62798. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62799. * You can attach anything to that node. The node position is updated in the scene update tick.
  62800. * @param pos world position that will be constrained by the navigation mesh
  62801. * @param parameters agent parameters
  62802. * @param transform hooked to the agent that will be update by the scene
  62803. * @returns agent index
  62804. */
  62805. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62806. /**
  62807. * Returns the agent position in world space
  62808. * @param index agent index returned by addAgent
  62809. * @returns world space position
  62810. */
  62811. getAgentPosition(index: number): Vector3;
  62812. /**
  62813. * Gets the agent position result in world space
  62814. * @param index agent index returned by addAgent
  62815. * @param result output world space position
  62816. */
  62817. getAgentPositionToRef(index: number, result: Vector3): void;
  62818. /**
  62819. * Gets the agent velocity in world space
  62820. * @param index agent index returned by addAgent
  62821. * @returns world space velocity
  62822. */
  62823. getAgentVelocity(index: number): Vector3;
  62824. /**
  62825. * Gets the agent velocity result in world space
  62826. * @param index agent index returned by addAgent
  62827. * @param result output world space velocity
  62828. */
  62829. getAgentVelocityToRef(index: number, result: Vector3): void;
  62830. /**
  62831. * remove a particular agent previously created
  62832. * @param index agent index returned by addAgent
  62833. */
  62834. removeAgent(index: number): void;
  62835. /**
  62836. * get the list of all agents attached to this crowd
  62837. * @returns list of agent indices
  62838. */
  62839. getAgents(): number[];
  62840. /**
  62841. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62842. * @param deltaTime in seconds
  62843. */
  62844. update(deltaTime: number): void;
  62845. /**
  62846. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62847. * @param index agent index returned by addAgent
  62848. * @param destination targeted world position
  62849. */
  62850. agentGoto(index: number, destination: Vector3): void;
  62851. /**
  62852. * Teleport the agent to a new position
  62853. * @param index agent index returned by addAgent
  62854. * @param destination targeted world position
  62855. */
  62856. agentTeleport(index: number, destination: Vector3): void;
  62857. /**
  62858. * Update agent parameters
  62859. * @param index agent index returned by addAgent
  62860. * @param parameters agent parameters
  62861. */
  62862. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62863. /**
  62864. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62865. * The queries will try to find a solution within those bounds
  62866. * default is (1,1,1)
  62867. * @param extent x,y,z value that define the extent around the queries point of reference
  62868. */
  62869. setDefaultQueryExtent(extent: Vector3): void;
  62870. /**
  62871. * Get the Bounding box extent specified by setDefaultQueryExtent
  62872. * @returns the box extent values
  62873. */
  62874. getDefaultQueryExtent(): Vector3;
  62875. /**
  62876. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62877. * @param result output the box extent values
  62878. */
  62879. getDefaultQueryExtentToRef(result: Vector3): void;
  62880. /**
  62881. * Release all resources
  62882. */
  62883. dispose(): void;
  62884. }
  62885. /**
  62886. * Configures an agent
  62887. */
  62888. export interface IAgentParameters {
  62889. /**
  62890. * Agent radius. [Limit: >= 0]
  62891. */
  62892. radius: number;
  62893. /**
  62894. * Agent height. [Limit: > 0]
  62895. */
  62896. height: number;
  62897. /**
  62898. * Maximum allowed acceleration. [Limit: >= 0]
  62899. */
  62900. maxAcceleration: number;
  62901. /**
  62902. * Maximum allowed speed. [Limit: >= 0]
  62903. */
  62904. maxSpeed: number;
  62905. /**
  62906. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62907. */
  62908. collisionQueryRange: number;
  62909. /**
  62910. * The path visibility optimization range. [Limit: > 0]
  62911. */
  62912. pathOptimizationRange: number;
  62913. /**
  62914. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62915. */
  62916. separationWeight: number;
  62917. }
  62918. /**
  62919. * Configures the navigation mesh creation
  62920. */
  62921. export interface INavMeshParameters {
  62922. /**
  62923. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62924. */
  62925. cs: number;
  62926. /**
  62927. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62928. */
  62929. ch: number;
  62930. /**
  62931. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62932. */
  62933. walkableSlopeAngle: number;
  62934. /**
  62935. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62936. * be considered walkable. [Limit: >= 3] [Units: vx]
  62937. */
  62938. walkableHeight: number;
  62939. /**
  62940. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62941. */
  62942. walkableClimb: number;
  62943. /**
  62944. * The distance to erode/shrink the walkable area of the heightfield away from
  62945. * obstructions. [Limit: >=0] [Units: vx]
  62946. */
  62947. walkableRadius: number;
  62948. /**
  62949. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62950. */
  62951. maxEdgeLen: number;
  62952. /**
  62953. * The maximum distance a simplfied contour's border edges should deviate
  62954. * the original raw contour. [Limit: >=0] [Units: vx]
  62955. */
  62956. maxSimplificationError: number;
  62957. /**
  62958. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62959. */
  62960. minRegionArea: number;
  62961. /**
  62962. * Any regions with a span count smaller than this value will, if possible,
  62963. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62964. */
  62965. mergeRegionArea: number;
  62966. /**
  62967. * The maximum number of vertices allowed for polygons generated during the
  62968. * contour to polygon conversion process. [Limit: >= 3]
  62969. */
  62970. maxVertsPerPoly: number;
  62971. /**
  62972. * Sets the sampling distance to use when generating the detail mesh.
  62973. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62974. */
  62975. detailSampleDist: number;
  62976. /**
  62977. * The maximum distance the detail mesh surface should deviate from heightfield
  62978. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62979. */
  62980. detailSampleMaxError: number;
  62981. }
  62982. }
  62983. declare module BABYLON {
  62984. /**
  62985. * RecastJS navigation plugin
  62986. */
  62987. export class RecastJSPlugin implements INavigationEnginePlugin {
  62988. /**
  62989. * Reference to the Recast library
  62990. */
  62991. bjsRECAST: any;
  62992. /**
  62993. * plugin name
  62994. */
  62995. name: string;
  62996. /**
  62997. * the first navmesh created. We might extend this to support multiple navmeshes
  62998. */
  62999. navMesh: any;
  63000. /**
  63001. * Initializes the recastJS plugin
  63002. * @param recastInjection can be used to inject your own recast reference
  63003. */
  63004. constructor(recastInjection?: any);
  63005. /**
  63006. * Creates a navigation mesh
  63007. * @param meshes array of all the geometry used to compute the navigatio mesh
  63008. * @param parameters bunch of parameters used to filter geometry
  63009. */
  63010. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63011. /**
  63012. * Create a navigation mesh debug mesh
  63013. * @param scene is where the mesh will be added
  63014. * @returns debug display mesh
  63015. */
  63016. createDebugNavMesh(scene: Scene): Mesh;
  63017. /**
  63018. * Get a navigation mesh constrained position, closest to the parameter position
  63019. * @param position world position
  63020. * @returns the closest point to position constrained by the navigation mesh
  63021. */
  63022. getClosestPoint(position: Vector3): Vector3;
  63023. /**
  63024. * Get a navigation mesh constrained position, closest to the parameter position
  63025. * @param position world position
  63026. * @param result output the closest point to position constrained by the navigation mesh
  63027. */
  63028. getClosestPointToRef(position: Vector3, result: Vector3): void;
  63029. /**
  63030. * Get a navigation mesh constrained position, within a particular radius
  63031. * @param position world position
  63032. * @param maxRadius the maximum distance to the constrained world position
  63033. * @returns the closest point to position constrained by the navigation mesh
  63034. */
  63035. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63036. /**
  63037. * Get a navigation mesh constrained position, within a particular radius
  63038. * @param position world position
  63039. * @param maxRadius the maximum distance to the constrained world position
  63040. * @param result output the closest point to position constrained by the navigation mesh
  63041. */
  63042. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  63043. /**
  63044. * Compute the final position from a segment made of destination-position
  63045. * @param position world position
  63046. * @param destination world position
  63047. * @returns the resulting point along the navmesh
  63048. */
  63049. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63050. /**
  63051. * Compute the final position from a segment made of destination-position
  63052. * @param position world position
  63053. * @param destination world position
  63054. * @param result output the resulting point along the navmesh
  63055. */
  63056. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  63057. /**
  63058. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63059. * @param start world position
  63060. * @param end world position
  63061. * @returns array containing world position composing the path
  63062. */
  63063. computePath(start: Vector3, end: Vector3): Vector3[];
  63064. /**
  63065. * Create a new Crowd so you can add agents
  63066. * @param maxAgents the maximum agent count in the crowd
  63067. * @param maxAgentRadius the maximum radius an agent can have
  63068. * @param scene to attach the crowd to
  63069. * @returns the crowd you can add agents to
  63070. */
  63071. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63072. /**
  63073. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63074. * The queries will try to find a solution within those bounds
  63075. * default is (1,1,1)
  63076. * @param extent x,y,z value that define the extent around the queries point of reference
  63077. */
  63078. setDefaultQueryExtent(extent: Vector3): void;
  63079. /**
  63080. * Get the Bounding box extent specified by setDefaultQueryExtent
  63081. * @returns the box extent values
  63082. */
  63083. getDefaultQueryExtent(): Vector3;
  63084. /**
  63085. * build the navmesh from a previously saved state using getNavmeshData
  63086. * @param data the Uint8Array returned by getNavmeshData
  63087. */
  63088. buildFromNavmeshData(data: Uint8Array): void;
  63089. /**
  63090. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63091. * @returns data the Uint8Array that can be saved and reused
  63092. */
  63093. getNavmeshData(): Uint8Array;
  63094. /**
  63095. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63096. * @param result output the box extent values
  63097. */
  63098. getDefaultQueryExtentToRef(result: Vector3): void;
  63099. /**
  63100. * Disposes
  63101. */
  63102. dispose(): void;
  63103. /**
  63104. * If this plugin is supported
  63105. * @returns true if plugin is supported
  63106. */
  63107. isSupported(): boolean;
  63108. }
  63109. /**
  63110. * Recast detour crowd implementation
  63111. */
  63112. export class RecastJSCrowd implements ICrowd {
  63113. /**
  63114. * Recast/detour plugin
  63115. */
  63116. bjsRECASTPlugin: RecastJSPlugin;
  63117. /**
  63118. * Link to the detour crowd
  63119. */
  63120. recastCrowd: any;
  63121. /**
  63122. * One transform per agent
  63123. */
  63124. transforms: TransformNode[];
  63125. /**
  63126. * All agents created
  63127. */
  63128. agents: number[];
  63129. /**
  63130. * Link to the scene is kept to unregister the crowd from the scene
  63131. */
  63132. private _scene;
  63133. /**
  63134. * Observer for crowd updates
  63135. */
  63136. private _onBeforeAnimationsObserver;
  63137. /**
  63138. * Constructor
  63139. * @param plugin recastJS plugin
  63140. * @param maxAgents the maximum agent count in the crowd
  63141. * @param maxAgentRadius the maximum radius an agent can have
  63142. * @param scene to attach the crowd to
  63143. * @returns the crowd you can add agents to
  63144. */
  63145. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63146. /**
  63147. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63148. * You can attach anything to that node. The node position is updated in the scene update tick.
  63149. * @param pos world position that will be constrained by the navigation mesh
  63150. * @param parameters agent parameters
  63151. * @param transform hooked to the agent that will be update by the scene
  63152. * @returns agent index
  63153. */
  63154. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63155. /**
  63156. * Returns the agent position in world space
  63157. * @param index agent index returned by addAgent
  63158. * @returns world space position
  63159. */
  63160. getAgentPosition(index: number): Vector3;
  63161. /**
  63162. * Returns the agent position result in world space
  63163. * @param index agent index returned by addAgent
  63164. * @param result output world space position
  63165. */
  63166. getAgentPositionToRef(index: number, result: Vector3): void;
  63167. /**
  63168. * Returns the agent velocity in world space
  63169. * @param index agent index returned by addAgent
  63170. * @returns world space velocity
  63171. */
  63172. getAgentVelocity(index: number): Vector3;
  63173. /**
  63174. * Returns the agent velocity result in world space
  63175. * @param index agent index returned by addAgent
  63176. * @param result output world space velocity
  63177. */
  63178. getAgentVelocityToRef(index: number, result: Vector3): void;
  63179. /**
  63180. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63181. * @param index agent index returned by addAgent
  63182. * @param destination targeted world position
  63183. */
  63184. agentGoto(index: number, destination: Vector3): void;
  63185. /**
  63186. * Teleport the agent to a new position
  63187. * @param index agent index returned by addAgent
  63188. * @param destination targeted world position
  63189. */
  63190. agentTeleport(index: number, destination: Vector3): void;
  63191. /**
  63192. * Update agent parameters
  63193. * @param index agent index returned by addAgent
  63194. * @param parameters agent parameters
  63195. */
  63196. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63197. /**
  63198. * remove a particular agent previously created
  63199. * @param index agent index returned by addAgent
  63200. */
  63201. removeAgent(index: number): void;
  63202. /**
  63203. * get the list of all agents attached to this crowd
  63204. * @returns list of agent indices
  63205. */
  63206. getAgents(): number[];
  63207. /**
  63208. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63209. * @param deltaTime in seconds
  63210. */
  63211. update(deltaTime: number): void;
  63212. /**
  63213. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63214. * The queries will try to find a solution within those bounds
  63215. * default is (1,1,1)
  63216. * @param extent x,y,z value that define the extent around the queries point of reference
  63217. */
  63218. setDefaultQueryExtent(extent: Vector3): void;
  63219. /**
  63220. * Get the Bounding box extent specified by setDefaultQueryExtent
  63221. * @returns the box extent values
  63222. */
  63223. getDefaultQueryExtent(): Vector3;
  63224. /**
  63225. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63226. * @param result output the box extent values
  63227. */
  63228. getDefaultQueryExtentToRef(result: Vector3): void;
  63229. /**
  63230. * Release all resources
  63231. */
  63232. dispose(): void;
  63233. }
  63234. }
  63235. declare module BABYLON {
  63236. /**
  63237. * Class used to enable access to IndexedDB
  63238. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63239. */
  63240. export class Database implements IOfflineProvider {
  63241. private _callbackManifestChecked;
  63242. private _currentSceneUrl;
  63243. private _db;
  63244. private _enableSceneOffline;
  63245. private _enableTexturesOffline;
  63246. private _manifestVersionFound;
  63247. private _mustUpdateRessources;
  63248. private _hasReachedQuota;
  63249. private _isSupported;
  63250. private _idbFactory;
  63251. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63252. private static IsUASupportingBlobStorage;
  63253. /**
  63254. * Gets a boolean indicating if Database storate is enabled (off by default)
  63255. */
  63256. static IDBStorageEnabled: boolean;
  63257. /**
  63258. * Gets a boolean indicating if scene must be saved in the database
  63259. */
  63260. get enableSceneOffline(): boolean;
  63261. /**
  63262. * Gets a boolean indicating if textures must be saved in the database
  63263. */
  63264. get enableTexturesOffline(): boolean;
  63265. /**
  63266. * Creates a new Database
  63267. * @param urlToScene defines the url to load the scene
  63268. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63269. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63270. */
  63271. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63272. private static _ParseURL;
  63273. private static _ReturnFullUrlLocation;
  63274. private _checkManifestFile;
  63275. /**
  63276. * Open the database and make it available
  63277. * @param successCallback defines the callback to call on success
  63278. * @param errorCallback defines the callback to call on error
  63279. */
  63280. open(successCallback: () => void, errorCallback: () => void): void;
  63281. /**
  63282. * Loads an image from the database
  63283. * @param url defines the url to load from
  63284. * @param image defines the target DOM image
  63285. */
  63286. loadImage(url: string, image: HTMLImageElement): void;
  63287. private _loadImageFromDBAsync;
  63288. private _saveImageIntoDBAsync;
  63289. private _checkVersionFromDB;
  63290. private _loadVersionFromDBAsync;
  63291. private _saveVersionIntoDBAsync;
  63292. /**
  63293. * Loads a file from database
  63294. * @param url defines the URL to load from
  63295. * @param sceneLoaded defines a callback to call on success
  63296. * @param progressCallBack defines a callback to call when progress changed
  63297. * @param errorCallback defines a callback to call on error
  63298. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63299. */
  63300. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63301. private _loadFileAsync;
  63302. private _saveFileAsync;
  63303. /**
  63304. * Validates if xhr data is correct
  63305. * @param xhr defines the request to validate
  63306. * @param dataType defines the expected data type
  63307. * @returns true if data is correct
  63308. */
  63309. private static _ValidateXHRData;
  63310. }
  63311. }
  63312. declare module BABYLON {
  63313. /** @hidden */
  63314. export var gpuUpdateParticlesPixelShader: {
  63315. name: string;
  63316. shader: string;
  63317. };
  63318. }
  63319. declare module BABYLON {
  63320. /** @hidden */
  63321. export var gpuUpdateParticlesVertexShader: {
  63322. name: string;
  63323. shader: string;
  63324. };
  63325. }
  63326. declare module BABYLON {
  63327. /** @hidden */
  63328. export var clipPlaneFragmentDeclaration2: {
  63329. name: string;
  63330. shader: string;
  63331. };
  63332. }
  63333. declare module BABYLON {
  63334. /** @hidden */
  63335. export var gpuRenderParticlesPixelShader: {
  63336. name: string;
  63337. shader: string;
  63338. };
  63339. }
  63340. declare module BABYLON {
  63341. /** @hidden */
  63342. export var clipPlaneVertexDeclaration2: {
  63343. name: string;
  63344. shader: string;
  63345. };
  63346. }
  63347. declare module BABYLON {
  63348. /** @hidden */
  63349. export var gpuRenderParticlesVertexShader: {
  63350. name: string;
  63351. shader: string;
  63352. };
  63353. }
  63354. declare module BABYLON {
  63355. /**
  63356. * This represents a GPU particle system in Babylon
  63357. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63358. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63359. */
  63360. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63361. /**
  63362. * The layer mask we are rendering the particles through.
  63363. */
  63364. layerMask: number;
  63365. private _capacity;
  63366. private _activeCount;
  63367. private _currentActiveCount;
  63368. private _accumulatedCount;
  63369. private _renderEffect;
  63370. private _updateEffect;
  63371. private _buffer0;
  63372. private _buffer1;
  63373. private _spriteBuffer;
  63374. private _updateVAO;
  63375. private _renderVAO;
  63376. private _targetIndex;
  63377. private _sourceBuffer;
  63378. private _targetBuffer;
  63379. private _engine;
  63380. private _currentRenderId;
  63381. private _started;
  63382. private _stopped;
  63383. private _timeDelta;
  63384. private _randomTexture;
  63385. private _randomTexture2;
  63386. private _attributesStrideSize;
  63387. private _updateEffectOptions;
  63388. private _randomTextureSize;
  63389. private _actualFrame;
  63390. private readonly _rawTextureWidth;
  63391. /**
  63392. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63393. */
  63394. static get IsSupported(): boolean;
  63395. /**
  63396. * An event triggered when the system is disposed.
  63397. */
  63398. onDisposeObservable: Observable<GPUParticleSystem>;
  63399. /**
  63400. * Gets the maximum number of particles active at the same time.
  63401. * @returns The max number of active particles.
  63402. */
  63403. getCapacity(): number;
  63404. /**
  63405. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63406. * to override the particles.
  63407. */
  63408. forceDepthWrite: boolean;
  63409. /**
  63410. * Gets or set the number of active particles
  63411. */
  63412. get activeParticleCount(): number;
  63413. set activeParticleCount(value: number);
  63414. private _preWarmDone;
  63415. /**
  63416. * Specifies if the particles are updated in emitter local space or world space.
  63417. */
  63418. isLocal: boolean;
  63419. /**
  63420. * Is this system ready to be used/rendered
  63421. * @return true if the system is ready
  63422. */
  63423. isReady(): boolean;
  63424. /**
  63425. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63426. * @returns True if it has been started, otherwise false.
  63427. */
  63428. isStarted(): boolean;
  63429. /**
  63430. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63431. * @returns True if it has been stopped, otherwise false.
  63432. */
  63433. isStopped(): boolean;
  63434. /**
  63435. * Gets a boolean indicating that the system is stopping
  63436. * @returns true if the system is currently stopping
  63437. */
  63438. isStopping(): boolean;
  63439. /**
  63440. * Gets the number of particles active at the same time.
  63441. * @returns The number of active particles.
  63442. */
  63443. getActiveCount(): number;
  63444. /**
  63445. * Starts the particle system and begins to emit
  63446. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63447. */
  63448. start(delay?: number): void;
  63449. /**
  63450. * Stops the particle system.
  63451. */
  63452. stop(): void;
  63453. /**
  63454. * Remove all active particles
  63455. */
  63456. reset(): void;
  63457. /**
  63458. * Returns the string "GPUParticleSystem"
  63459. * @returns a string containing the class name
  63460. */
  63461. getClassName(): string;
  63462. private _colorGradientsTexture;
  63463. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63464. /**
  63465. * Adds a new color gradient
  63466. * @param gradient defines the gradient to use (between 0 and 1)
  63467. * @param color1 defines the color to affect to the specified gradient
  63468. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63469. * @returns the current particle system
  63470. */
  63471. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63472. private _refreshColorGradient;
  63473. /** Force the system to rebuild all gradients that need to be resync */
  63474. forceRefreshGradients(): void;
  63475. /**
  63476. * Remove a specific color gradient
  63477. * @param gradient defines the gradient to remove
  63478. * @returns the current particle system
  63479. */
  63480. removeColorGradient(gradient: number): GPUParticleSystem;
  63481. private _angularSpeedGradientsTexture;
  63482. private _sizeGradientsTexture;
  63483. private _velocityGradientsTexture;
  63484. private _limitVelocityGradientsTexture;
  63485. private _dragGradientsTexture;
  63486. private _addFactorGradient;
  63487. /**
  63488. * Adds a new size gradient
  63489. * @param gradient defines the gradient to use (between 0 and 1)
  63490. * @param factor defines the size factor to affect to the specified gradient
  63491. * @returns the current particle system
  63492. */
  63493. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63494. /**
  63495. * Remove a specific size gradient
  63496. * @param gradient defines the gradient to remove
  63497. * @returns the current particle system
  63498. */
  63499. removeSizeGradient(gradient: number): GPUParticleSystem;
  63500. private _refreshFactorGradient;
  63501. /**
  63502. * Adds a new angular speed gradient
  63503. * @param gradient defines the gradient to use (between 0 and 1)
  63504. * @param factor defines the angular speed to affect to the specified gradient
  63505. * @returns the current particle system
  63506. */
  63507. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63508. /**
  63509. * Remove a specific angular speed gradient
  63510. * @param gradient defines the gradient to remove
  63511. * @returns the current particle system
  63512. */
  63513. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63514. /**
  63515. * Adds a new velocity gradient
  63516. * @param gradient defines the gradient to use (between 0 and 1)
  63517. * @param factor defines the velocity to affect to the specified gradient
  63518. * @returns the current particle system
  63519. */
  63520. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63521. /**
  63522. * Remove a specific velocity gradient
  63523. * @param gradient defines the gradient to remove
  63524. * @returns the current particle system
  63525. */
  63526. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63527. /**
  63528. * Adds a new limit velocity gradient
  63529. * @param gradient defines the gradient to use (between 0 and 1)
  63530. * @param factor defines the limit velocity value to affect to the specified gradient
  63531. * @returns the current particle system
  63532. */
  63533. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63534. /**
  63535. * Remove a specific limit velocity gradient
  63536. * @param gradient defines the gradient to remove
  63537. * @returns the current particle system
  63538. */
  63539. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63540. /**
  63541. * Adds a new drag gradient
  63542. * @param gradient defines the gradient to use (between 0 and 1)
  63543. * @param factor defines the drag value to affect to the specified gradient
  63544. * @returns the current particle system
  63545. */
  63546. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63547. /**
  63548. * Remove a specific drag gradient
  63549. * @param gradient defines the gradient to remove
  63550. * @returns the current particle system
  63551. */
  63552. removeDragGradient(gradient: number): GPUParticleSystem;
  63553. /**
  63554. * Not supported by GPUParticleSystem
  63555. * @param gradient defines the gradient to use (between 0 and 1)
  63556. * @param factor defines the emit rate value to affect to the specified gradient
  63557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63558. * @returns the current particle system
  63559. */
  63560. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63561. /**
  63562. * Not supported by GPUParticleSystem
  63563. * @param gradient defines the gradient to remove
  63564. * @returns the current particle system
  63565. */
  63566. removeEmitRateGradient(gradient: number): IParticleSystem;
  63567. /**
  63568. * Not supported by GPUParticleSystem
  63569. * @param gradient defines the gradient to use (between 0 and 1)
  63570. * @param factor defines the start size value to affect to the specified gradient
  63571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63572. * @returns the current particle system
  63573. */
  63574. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63575. /**
  63576. * Not supported by GPUParticleSystem
  63577. * @param gradient defines the gradient to remove
  63578. * @returns the current particle system
  63579. */
  63580. removeStartSizeGradient(gradient: number): IParticleSystem;
  63581. /**
  63582. * Not supported by GPUParticleSystem
  63583. * @param gradient defines the gradient to use (between 0 and 1)
  63584. * @param min defines the color remap minimal range
  63585. * @param max defines the color remap maximal range
  63586. * @returns the current particle system
  63587. */
  63588. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63589. /**
  63590. * Not supported by GPUParticleSystem
  63591. * @param gradient defines the gradient to remove
  63592. * @returns the current particle system
  63593. */
  63594. removeColorRemapGradient(): IParticleSystem;
  63595. /**
  63596. * Not supported by GPUParticleSystem
  63597. * @param gradient defines the gradient to use (between 0 and 1)
  63598. * @param min defines the alpha remap minimal range
  63599. * @param max defines the alpha remap maximal range
  63600. * @returns the current particle system
  63601. */
  63602. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63603. /**
  63604. * Not supported by GPUParticleSystem
  63605. * @param gradient defines the gradient to remove
  63606. * @returns the current particle system
  63607. */
  63608. removeAlphaRemapGradient(): IParticleSystem;
  63609. /**
  63610. * Not supported by GPUParticleSystem
  63611. * @param gradient defines the gradient to use (between 0 and 1)
  63612. * @param color defines the color to affect to the specified gradient
  63613. * @returns the current particle system
  63614. */
  63615. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63616. /**
  63617. * Not supported by GPUParticleSystem
  63618. * @param gradient defines the gradient to remove
  63619. * @returns the current particle system
  63620. */
  63621. removeRampGradient(): IParticleSystem;
  63622. /**
  63623. * Not supported by GPUParticleSystem
  63624. * @returns the list of ramp gradients
  63625. */
  63626. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63627. /**
  63628. * Not supported by GPUParticleSystem
  63629. * Gets or sets a boolean indicating that ramp gradients must be used
  63630. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63631. */
  63632. get useRampGradients(): boolean;
  63633. set useRampGradients(value: boolean);
  63634. /**
  63635. * Not supported by GPUParticleSystem
  63636. * @param gradient defines the gradient to use (between 0 and 1)
  63637. * @param factor defines the life time factor to affect to the specified gradient
  63638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63639. * @returns the current particle system
  63640. */
  63641. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63642. /**
  63643. * Not supported by GPUParticleSystem
  63644. * @param gradient defines the gradient to remove
  63645. * @returns the current particle system
  63646. */
  63647. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63648. /**
  63649. * Instantiates a GPU particle system.
  63650. * 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.
  63651. * @param name The name of the particle system
  63652. * @param options The options used to create the system
  63653. * @param scene The scene the particle system belongs to
  63654. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63655. */
  63656. constructor(name: string, options: Partial<{
  63657. capacity: number;
  63658. randomTextureSize: number;
  63659. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63660. protected _reset(): void;
  63661. private _createUpdateVAO;
  63662. private _createRenderVAO;
  63663. private _initialize;
  63664. /** @hidden */
  63665. _recreateUpdateEffect(): void;
  63666. /** @hidden */
  63667. _recreateRenderEffect(): void;
  63668. /**
  63669. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63670. * @param preWarm defines if we are in the pre-warmimg phase
  63671. */
  63672. animate(preWarm?: boolean): void;
  63673. private _createFactorGradientTexture;
  63674. private _createSizeGradientTexture;
  63675. private _createAngularSpeedGradientTexture;
  63676. private _createVelocityGradientTexture;
  63677. private _createLimitVelocityGradientTexture;
  63678. private _createDragGradientTexture;
  63679. private _createColorGradientTexture;
  63680. /**
  63681. * Renders the particle system in its current state
  63682. * @param preWarm defines if the system should only update the particles but not render them
  63683. * @returns the current number of particles
  63684. */
  63685. render(preWarm?: boolean): number;
  63686. /**
  63687. * Rebuilds the particle system
  63688. */
  63689. rebuild(): void;
  63690. private _releaseBuffers;
  63691. private _releaseVAOs;
  63692. /**
  63693. * Disposes the particle system and free the associated resources
  63694. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63695. */
  63696. dispose(disposeTexture?: boolean): void;
  63697. /**
  63698. * Clones the particle system.
  63699. * @param name The name of the cloned object
  63700. * @param newEmitter The new emitter to use
  63701. * @returns the cloned particle system
  63702. */
  63703. clone(name: string, newEmitter: any): GPUParticleSystem;
  63704. /**
  63705. * Serializes the particle system to a JSON object
  63706. * @param serializeTexture defines if the texture must be serialized as well
  63707. * @returns the JSON object
  63708. */
  63709. serialize(serializeTexture?: boolean): any;
  63710. /**
  63711. * Parses a JSON object to create a GPU particle system.
  63712. * @param parsedParticleSystem The JSON object to parse
  63713. * @param scene The scene to create the particle system in
  63714. * @param rootUrl The root url to use to load external dependencies like texture
  63715. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63716. * @returns the parsed GPU particle system
  63717. */
  63718. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63719. }
  63720. }
  63721. declare module BABYLON {
  63722. /**
  63723. * Represents a set of particle systems working together to create a specific effect
  63724. */
  63725. export class ParticleSystemSet implements IDisposable {
  63726. /**
  63727. * Gets or sets base Assets URL
  63728. */
  63729. static BaseAssetsUrl: string;
  63730. private _emitterCreationOptions;
  63731. private _emitterNode;
  63732. /**
  63733. * Gets the particle system list
  63734. */
  63735. systems: IParticleSystem[];
  63736. /**
  63737. * Gets the emitter node used with this set
  63738. */
  63739. get emitterNode(): Nullable<TransformNode>;
  63740. /**
  63741. * Creates a new emitter mesh as a sphere
  63742. * @param options defines the options used to create the sphere
  63743. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63744. * @param scene defines the hosting scene
  63745. */
  63746. setEmitterAsSphere(options: {
  63747. diameter: number;
  63748. segments: number;
  63749. color: Color3;
  63750. }, renderingGroupId: number, scene: Scene): void;
  63751. /**
  63752. * Starts all particle systems of the set
  63753. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63754. */
  63755. start(emitter?: AbstractMesh): void;
  63756. /**
  63757. * Release all associated resources
  63758. */
  63759. dispose(): void;
  63760. /**
  63761. * Serialize the set into a JSON compatible object
  63762. * @param serializeTexture defines if the texture must be serialized as well
  63763. * @returns a JSON compatible representation of the set
  63764. */
  63765. serialize(serializeTexture?: boolean): any;
  63766. /**
  63767. * Parse a new ParticleSystemSet from a serialized source
  63768. * @param data defines a JSON compatible representation of the set
  63769. * @param scene defines the hosting scene
  63770. * @param gpu defines if we want GPU particles or CPU particles
  63771. * @returns a new ParticleSystemSet
  63772. */
  63773. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63774. }
  63775. }
  63776. declare module BABYLON {
  63777. /**
  63778. * This class is made for on one-liner static method to help creating particle system set.
  63779. */
  63780. export class ParticleHelper {
  63781. /**
  63782. * Gets or sets base Assets URL
  63783. */
  63784. static BaseAssetsUrl: string;
  63785. /** Define the Url to load snippets */
  63786. static SnippetUrl: string;
  63787. /**
  63788. * Create a default particle system that you can tweak
  63789. * @param emitter defines the emitter to use
  63790. * @param capacity defines the system capacity (default is 500 particles)
  63791. * @param scene defines the hosting scene
  63792. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63793. * @returns the new Particle system
  63794. */
  63795. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63796. /**
  63797. * This is the main static method (one-liner) of this helper to create different particle systems
  63798. * @param type This string represents the type to the particle system to create
  63799. * @param scene The scene where the particle system should live
  63800. * @param gpu If the system will use gpu
  63801. * @returns the ParticleSystemSet created
  63802. */
  63803. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63804. /**
  63805. * Static function used to export a particle system to a ParticleSystemSet variable.
  63806. * Please note that the emitter shape is not exported
  63807. * @param systems defines the particle systems to export
  63808. * @returns the created particle system set
  63809. */
  63810. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63811. /**
  63812. * Creates a particle system from a snippet saved in a remote file
  63813. * @param name defines the name of the particle system to create
  63814. * @param url defines the url to load from
  63815. * @param scene defines the hosting scene
  63816. * @param gpu If the system will use gpu
  63817. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63818. * @returns a promise that will resolve to the new particle system
  63819. */
  63820. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63821. /**
  63822. * Creates a particle system from a snippet saved by the particle system editor
  63823. * @param snippetId defines the snippet to load
  63824. * @param scene defines the hosting scene
  63825. * @param gpu If the system will use gpu
  63826. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63827. * @returns a promise that will resolve to the new particle system
  63828. */
  63829. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63830. }
  63831. }
  63832. declare module BABYLON {
  63833. interface Engine {
  63834. /**
  63835. * Create an effect to use with particle systems.
  63836. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63837. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63838. * @param uniformsNames defines a list of attribute names
  63839. * @param samplers defines an array of string used to represent textures
  63840. * @param defines defines the string containing the defines to use to compile the shaders
  63841. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63842. * @param onCompiled defines a function to call when the effect creation is successful
  63843. * @param onError defines a function to call when the effect creation has failed
  63844. * @returns the new Effect
  63845. */
  63846. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63847. }
  63848. interface Mesh {
  63849. /**
  63850. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63851. * @returns an array of IParticleSystem
  63852. */
  63853. getEmittedParticleSystems(): IParticleSystem[];
  63854. /**
  63855. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63856. * @returns an array of IParticleSystem
  63857. */
  63858. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63859. }
  63860. /**
  63861. * @hidden
  63862. */
  63863. export var _IDoNeedToBeInTheBuild: number;
  63864. }
  63865. declare module BABYLON {
  63866. /** Defines the 4 color options */
  63867. export enum PointColor {
  63868. /** color value */
  63869. Color = 2,
  63870. /** uv value */
  63871. UV = 1,
  63872. /** random value */
  63873. Random = 0,
  63874. /** stated value */
  63875. Stated = 3
  63876. }
  63877. /**
  63878. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63879. * 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.
  63880. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63881. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63882. *
  63883. * Full documentation here : TO BE ENTERED
  63884. */
  63885. export class PointsCloudSystem implements IDisposable {
  63886. /**
  63887. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63888. * Example : var p = SPS.particles[i];
  63889. */
  63890. particles: CloudPoint[];
  63891. /**
  63892. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63893. */
  63894. nbParticles: number;
  63895. /**
  63896. * This a counter for your own usage. It's not set by any SPS functions.
  63897. */
  63898. counter: number;
  63899. /**
  63900. * The PCS name. This name is also given to the underlying mesh.
  63901. */
  63902. name: string;
  63903. /**
  63904. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63905. */
  63906. mesh: Mesh;
  63907. /**
  63908. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63909. * Please read :
  63910. */
  63911. vars: any;
  63912. /**
  63913. * @hidden
  63914. */
  63915. _size: number;
  63916. private _scene;
  63917. private _promises;
  63918. private _positions;
  63919. private _indices;
  63920. private _normals;
  63921. private _colors;
  63922. private _uvs;
  63923. private _indices32;
  63924. private _positions32;
  63925. private _colors32;
  63926. private _uvs32;
  63927. private _updatable;
  63928. private _isVisibilityBoxLocked;
  63929. private _alwaysVisible;
  63930. private _groups;
  63931. private _groupCounter;
  63932. private _computeParticleColor;
  63933. private _computeParticleTexture;
  63934. private _computeParticleRotation;
  63935. private _computeBoundingBox;
  63936. private _isReady;
  63937. /**
  63938. * Creates a PCS (Points Cloud System) object
  63939. * @param name (String) is the PCS name, this will be the underlying mesh name
  63940. * @param pointSize (number) is the size for each point
  63941. * @param scene (Scene) is the scene in which the PCS is added
  63942. * @param options defines the options of the PCS e.g.
  63943. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63944. */
  63945. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63946. updatable?: boolean;
  63947. });
  63948. /**
  63949. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63950. * If no points were added to the PCS, the returned mesh is just a single point.
  63951. * @returns a promise for the created mesh
  63952. */
  63953. buildMeshAsync(): Promise<Mesh>;
  63954. /**
  63955. * @hidden
  63956. */
  63957. private _buildMesh;
  63958. private _addParticle;
  63959. private _randomUnitVector;
  63960. private _getColorIndicesForCoord;
  63961. private _setPointsColorOrUV;
  63962. private _colorFromTexture;
  63963. private _calculateDensity;
  63964. /**
  63965. * Adds points to the PCS in random positions within a unit sphere
  63966. * @param nb (positive integer) the number of particles to be created from this model
  63967. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63968. * @returns the number of groups in the system
  63969. */
  63970. addPoints(nb: number, pointFunction?: any): number;
  63971. /**
  63972. * Adds points to the PCS from the surface of the model shape
  63973. * @param mesh is any Mesh object that will be used as a surface model for the points
  63974. * @param nb (positive integer) the number of particles to be created from this model
  63975. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63976. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63977. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63978. * @returns the number of groups in the system
  63979. */
  63980. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63981. /**
  63982. * Adds points to the PCS inside the model shape
  63983. * @param mesh is any Mesh object that will be used as a surface model for the points
  63984. * @param nb (positive integer) the number of particles to be created from this model
  63985. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63986. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63987. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63988. * @returns the number of groups in the system
  63989. */
  63990. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63991. /**
  63992. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63993. * This method calls `updateParticle()` for each particle of the SPS.
  63994. * For an animated SPS, it is usually called within the render loop.
  63995. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63996. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63997. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63998. * @returns the PCS.
  63999. */
  64000. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64001. /**
  64002. * Disposes the PCS.
  64003. */
  64004. dispose(): void;
  64005. /**
  64006. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64007. * doc :
  64008. * @returns the PCS.
  64009. */
  64010. refreshVisibleSize(): PointsCloudSystem;
  64011. /**
  64012. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64013. * @param size the size (float) of the visibility box
  64014. * note : this doesn't lock the PCS mesh bounding box.
  64015. * doc :
  64016. */
  64017. setVisibilityBox(size: number): void;
  64018. /**
  64019. * Gets whether the PCS is always visible or not
  64020. * doc :
  64021. */
  64022. get isAlwaysVisible(): boolean;
  64023. /**
  64024. * Sets the PCS as always visible or not
  64025. * doc :
  64026. */
  64027. set isAlwaysVisible(val: boolean);
  64028. /**
  64029. * Tells to `setParticles()` to compute the particle rotations or not
  64030. * Default value : false. The PCS is faster when it's set to false
  64031. * Note : particle rotations are only applied to parent particles
  64032. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64033. */
  64034. set computeParticleRotation(val: boolean);
  64035. /**
  64036. * Tells to `setParticles()` to compute the particle colors or not.
  64037. * Default value : true. The PCS is faster when it's set to false.
  64038. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64039. */
  64040. set computeParticleColor(val: boolean);
  64041. set computeParticleTexture(val: boolean);
  64042. /**
  64043. * Gets if `setParticles()` computes the particle colors or not.
  64044. * Default value : false. The PCS is faster when it's set to false.
  64045. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64046. */
  64047. get computeParticleColor(): boolean;
  64048. /**
  64049. * Gets if `setParticles()` computes the particle textures or not.
  64050. * Default value : false. The PCS is faster when it's set to false.
  64051. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64052. */
  64053. get computeParticleTexture(): boolean;
  64054. /**
  64055. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64056. */
  64057. set computeBoundingBox(val: boolean);
  64058. /**
  64059. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64060. */
  64061. get computeBoundingBox(): boolean;
  64062. /**
  64063. * This function does nothing. It may be overwritten to set all the particle first values.
  64064. * The PCS doesn't call this function, you may have to call it by your own.
  64065. * doc :
  64066. */
  64067. initParticles(): void;
  64068. /**
  64069. * This function does nothing. It may be overwritten to recycle a particle
  64070. * The PCS doesn't call this function, you can to call it
  64071. * doc :
  64072. * @param particle The particle to recycle
  64073. * @returns the recycled particle
  64074. */
  64075. recycleParticle(particle: CloudPoint): CloudPoint;
  64076. /**
  64077. * Updates a particle : this function should be overwritten by the user.
  64078. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64079. * doc :
  64080. * @example : just set a particle position or velocity and recycle conditions
  64081. * @param particle The particle to update
  64082. * @returns the updated particle
  64083. */
  64084. updateParticle(particle: CloudPoint): CloudPoint;
  64085. /**
  64086. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64087. * This does nothing and may be overwritten by the user.
  64088. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64089. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64090. * @param update the boolean update value actually passed to setParticles()
  64091. */
  64092. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64093. /**
  64094. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64095. * This will be passed three parameters.
  64096. * This does nothing and may be overwritten by the user.
  64097. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64098. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64099. * @param update the boolean update value actually passed to setParticles()
  64100. */
  64101. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64102. }
  64103. }
  64104. declare module BABYLON {
  64105. /**
  64106. * Represents one particle of a points cloud system.
  64107. */
  64108. export class CloudPoint {
  64109. /**
  64110. * particle global index
  64111. */
  64112. idx: number;
  64113. /**
  64114. * The color of the particle
  64115. */
  64116. color: Nullable<Color4>;
  64117. /**
  64118. * The world space position of the particle.
  64119. */
  64120. position: Vector3;
  64121. /**
  64122. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64123. */
  64124. rotation: Vector3;
  64125. /**
  64126. * The world space rotation quaternion of the particle.
  64127. */
  64128. rotationQuaternion: Nullable<Quaternion>;
  64129. /**
  64130. * The uv of the particle.
  64131. */
  64132. uv: Nullable<Vector2>;
  64133. /**
  64134. * The current speed of the particle.
  64135. */
  64136. velocity: Vector3;
  64137. /**
  64138. * The pivot point in the particle local space.
  64139. */
  64140. pivot: Vector3;
  64141. /**
  64142. * Must the particle be translated from its pivot point in its local space ?
  64143. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64144. * Default : false
  64145. */
  64146. translateFromPivot: boolean;
  64147. /**
  64148. * Index of this particle in the global "positions" array (Internal use)
  64149. * @hidden
  64150. */
  64151. _pos: number;
  64152. /**
  64153. * @hidden Index of this particle in the global "indices" array (Internal use)
  64154. */
  64155. _ind: number;
  64156. /**
  64157. * Group this particle belongs to
  64158. */
  64159. _group: PointsGroup;
  64160. /**
  64161. * Group id of this particle
  64162. */
  64163. groupId: number;
  64164. /**
  64165. * Index of the particle in its group id (Internal use)
  64166. */
  64167. idxInGroup: number;
  64168. /**
  64169. * @hidden Particle BoundingInfo object (Internal use)
  64170. */
  64171. _boundingInfo: BoundingInfo;
  64172. /**
  64173. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64174. */
  64175. _pcs: PointsCloudSystem;
  64176. /**
  64177. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64178. */
  64179. _stillInvisible: boolean;
  64180. /**
  64181. * @hidden Last computed particle rotation matrix
  64182. */
  64183. _rotationMatrix: number[];
  64184. /**
  64185. * Parent particle Id, if any.
  64186. * Default null.
  64187. */
  64188. parentId: Nullable<number>;
  64189. /**
  64190. * @hidden Internal global position in the PCS.
  64191. */
  64192. _globalPosition: Vector3;
  64193. /**
  64194. * Creates a Point Cloud object.
  64195. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64196. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64197. * @param group (PointsGroup) is the group the particle belongs to
  64198. * @param groupId (integer) is the group identifier in the PCS.
  64199. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64200. * @param pcs defines the PCS it is associated to
  64201. */
  64202. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64203. /**
  64204. * get point size
  64205. */
  64206. get size(): Vector3;
  64207. /**
  64208. * Set point size
  64209. */
  64210. set size(scale: Vector3);
  64211. /**
  64212. * Legacy support, changed quaternion to rotationQuaternion
  64213. */
  64214. get quaternion(): Nullable<Quaternion>;
  64215. /**
  64216. * Legacy support, changed quaternion to rotationQuaternion
  64217. */
  64218. set quaternion(q: Nullable<Quaternion>);
  64219. /**
  64220. * Returns a boolean. True if the particle intersects a mesh, else false
  64221. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64222. * @param target is the object (point or mesh) what the intersection is computed against
  64223. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64224. * @returns true if it intersects
  64225. */
  64226. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64227. /**
  64228. * get the rotation matrix of the particle
  64229. * @hidden
  64230. */
  64231. getRotationMatrix(m: Matrix): void;
  64232. }
  64233. /**
  64234. * Represents a group of points in a points cloud system
  64235. * * PCS internal tool, don't use it manually.
  64236. */
  64237. export class PointsGroup {
  64238. /**
  64239. * The group id
  64240. * @hidden
  64241. */
  64242. groupID: number;
  64243. /**
  64244. * image data for group (internal use)
  64245. * @hidden
  64246. */
  64247. _groupImageData: Nullable<ArrayBufferView>;
  64248. /**
  64249. * Image Width (internal use)
  64250. * @hidden
  64251. */
  64252. _groupImgWidth: number;
  64253. /**
  64254. * Image Height (internal use)
  64255. * @hidden
  64256. */
  64257. _groupImgHeight: number;
  64258. /**
  64259. * Custom position function (internal use)
  64260. * @hidden
  64261. */
  64262. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64263. /**
  64264. * density per facet for surface points
  64265. * @hidden
  64266. */
  64267. _groupDensity: number[];
  64268. /**
  64269. * Only when points are colored by texture carries pointer to texture list array
  64270. * @hidden
  64271. */
  64272. _textureNb: number;
  64273. /**
  64274. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64275. * PCS internal tool, don't use it manually.
  64276. * @hidden
  64277. */
  64278. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64279. }
  64280. }
  64281. declare module BABYLON {
  64282. interface Scene {
  64283. /** @hidden (Backing field) */
  64284. _physicsEngine: Nullable<IPhysicsEngine>;
  64285. /** @hidden */
  64286. _physicsTimeAccumulator: number;
  64287. /**
  64288. * Gets the current physics engine
  64289. * @returns a IPhysicsEngine or null if none attached
  64290. */
  64291. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64292. /**
  64293. * Enables physics to the current scene
  64294. * @param gravity defines the scene's gravity for the physics engine
  64295. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64296. * @return a boolean indicating if the physics engine was initialized
  64297. */
  64298. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64299. /**
  64300. * Disables and disposes the physics engine associated with the scene
  64301. */
  64302. disablePhysicsEngine(): void;
  64303. /**
  64304. * Gets a boolean indicating if there is an active physics engine
  64305. * @returns a boolean indicating if there is an active physics engine
  64306. */
  64307. isPhysicsEnabled(): boolean;
  64308. /**
  64309. * Deletes a physics compound impostor
  64310. * @param compound defines the compound to delete
  64311. */
  64312. deleteCompoundImpostor(compound: any): void;
  64313. /**
  64314. * An event triggered when physic simulation is about to be run
  64315. */
  64316. onBeforePhysicsObservable: Observable<Scene>;
  64317. /**
  64318. * An event triggered when physic simulation has been done
  64319. */
  64320. onAfterPhysicsObservable: Observable<Scene>;
  64321. }
  64322. interface AbstractMesh {
  64323. /** @hidden */
  64324. _physicsImpostor: Nullable<PhysicsImpostor>;
  64325. /**
  64326. * Gets or sets impostor used for physic simulation
  64327. * @see http://doc.babylonjs.com/features/physics_engine
  64328. */
  64329. physicsImpostor: Nullable<PhysicsImpostor>;
  64330. /**
  64331. * Gets the current physics impostor
  64332. * @see http://doc.babylonjs.com/features/physics_engine
  64333. * @returns a physics impostor or null
  64334. */
  64335. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64336. /** Apply a physic impulse to the mesh
  64337. * @param force defines the force to apply
  64338. * @param contactPoint defines where to apply the force
  64339. * @returns the current mesh
  64340. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64341. */
  64342. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64343. /**
  64344. * Creates a physic joint between two meshes
  64345. * @param otherMesh defines the other mesh to use
  64346. * @param pivot1 defines the pivot to use on this mesh
  64347. * @param pivot2 defines the pivot to use on the other mesh
  64348. * @param options defines additional options (can be plugin dependent)
  64349. * @returns the current mesh
  64350. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64351. */
  64352. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64353. /** @hidden */
  64354. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64355. }
  64356. /**
  64357. * Defines the physics engine scene component responsible to manage a physics engine
  64358. */
  64359. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64360. /**
  64361. * The component name helpful to identify the component in the list of scene components.
  64362. */
  64363. readonly name: string;
  64364. /**
  64365. * The scene the component belongs to.
  64366. */
  64367. scene: Scene;
  64368. /**
  64369. * Creates a new instance of the component for the given scene
  64370. * @param scene Defines the scene to register the component in
  64371. */
  64372. constructor(scene: Scene);
  64373. /**
  64374. * Registers the component in a given scene
  64375. */
  64376. register(): void;
  64377. /**
  64378. * Rebuilds the elements related to this component in case of
  64379. * context lost for instance.
  64380. */
  64381. rebuild(): void;
  64382. /**
  64383. * Disposes the component and the associated ressources
  64384. */
  64385. dispose(): void;
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /**
  64390. * A helper for physics simulations
  64391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64392. */
  64393. export class PhysicsHelper {
  64394. private _scene;
  64395. private _physicsEngine;
  64396. /**
  64397. * Initializes the Physics helper
  64398. * @param scene Babylon.js scene
  64399. */
  64400. constructor(scene: Scene);
  64401. /**
  64402. * Applies a radial explosion impulse
  64403. * @param origin the origin of the explosion
  64404. * @param radiusOrEventOptions the radius or the options of radial explosion
  64405. * @param strength the explosion strength
  64406. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64407. * @returns A physics radial explosion event, or null
  64408. */
  64409. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64410. /**
  64411. * Applies a radial explosion force
  64412. * @param origin the origin of the explosion
  64413. * @param radiusOrEventOptions the radius or the options of radial explosion
  64414. * @param strength the explosion strength
  64415. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64416. * @returns A physics radial explosion event, or null
  64417. */
  64418. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64419. /**
  64420. * Creates a gravitational field
  64421. * @param origin the origin of the explosion
  64422. * @param radiusOrEventOptions the radius or the options of radial explosion
  64423. * @param strength the explosion strength
  64424. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64425. * @returns A physics gravitational field event, or null
  64426. */
  64427. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64428. /**
  64429. * Creates a physics updraft event
  64430. * @param origin the origin of the updraft
  64431. * @param radiusOrEventOptions the radius or the options of the updraft
  64432. * @param strength the strength of the updraft
  64433. * @param height the height of the updraft
  64434. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64435. * @returns A physics updraft event, or null
  64436. */
  64437. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64438. /**
  64439. * Creates a physics vortex event
  64440. * @param origin the of the vortex
  64441. * @param radiusOrEventOptions the radius or the options of the vortex
  64442. * @param strength the strength of the vortex
  64443. * @param height the height of the vortex
  64444. * @returns a Physics vortex event, or null
  64445. * A physics vortex event or null
  64446. */
  64447. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64448. }
  64449. /**
  64450. * Represents a physics radial explosion event
  64451. */
  64452. class PhysicsRadialExplosionEvent {
  64453. private _scene;
  64454. private _options;
  64455. private _sphere;
  64456. private _dataFetched;
  64457. /**
  64458. * Initializes a radial explosioin event
  64459. * @param _scene BabylonJS scene
  64460. * @param _options The options for the vortex event
  64461. */
  64462. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64463. /**
  64464. * Returns the data related to the radial explosion event (sphere).
  64465. * @returns The radial explosion event data
  64466. */
  64467. getData(): PhysicsRadialExplosionEventData;
  64468. /**
  64469. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64470. * @param impostor A physics imposter
  64471. * @param origin the origin of the explosion
  64472. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64473. */
  64474. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64475. /**
  64476. * Triggers affecterd impostors callbacks
  64477. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64478. */
  64479. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64480. /**
  64481. * Disposes the sphere.
  64482. * @param force Specifies if the sphere should be disposed by force
  64483. */
  64484. dispose(force?: boolean): void;
  64485. /*** Helpers ***/
  64486. private _prepareSphere;
  64487. private _intersectsWithSphere;
  64488. }
  64489. /**
  64490. * Represents a gravitational field event
  64491. */
  64492. class PhysicsGravitationalFieldEvent {
  64493. private _physicsHelper;
  64494. private _scene;
  64495. private _origin;
  64496. private _options;
  64497. private _tickCallback;
  64498. private _sphere;
  64499. private _dataFetched;
  64500. /**
  64501. * Initializes the physics gravitational field event
  64502. * @param _physicsHelper A physics helper
  64503. * @param _scene BabylonJS scene
  64504. * @param _origin The origin position of the gravitational field event
  64505. * @param _options The options for the vortex event
  64506. */
  64507. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64508. /**
  64509. * Returns the data related to the gravitational field event (sphere).
  64510. * @returns A gravitational field event
  64511. */
  64512. getData(): PhysicsGravitationalFieldEventData;
  64513. /**
  64514. * Enables the gravitational field.
  64515. */
  64516. enable(): void;
  64517. /**
  64518. * Disables the gravitational field.
  64519. */
  64520. disable(): void;
  64521. /**
  64522. * Disposes the sphere.
  64523. * @param force The force to dispose from the gravitational field event
  64524. */
  64525. dispose(force?: boolean): void;
  64526. private _tick;
  64527. }
  64528. /**
  64529. * Represents a physics updraft event
  64530. */
  64531. class PhysicsUpdraftEvent {
  64532. private _scene;
  64533. private _origin;
  64534. private _options;
  64535. private _physicsEngine;
  64536. private _originTop;
  64537. private _originDirection;
  64538. private _tickCallback;
  64539. private _cylinder;
  64540. private _cylinderPosition;
  64541. private _dataFetched;
  64542. /**
  64543. * Initializes the physics updraft event
  64544. * @param _scene BabylonJS scene
  64545. * @param _origin The origin position of the updraft
  64546. * @param _options The options for the updraft event
  64547. */
  64548. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64549. /**
  64550. * Returns the data related to the updraft event (cylinder).
  64551. * @returns A physics updraft event
  64552. */
  64553. getData(): PhysicsUpdraftEventData;
  64554. /**
  64555. * Enables the updraft.
  64556. */
  64557. enable(): void;
  64558. /**
  64559. * Disables the updraft.
  64560. */
  64561. disable(): void;
  64562. /**
  64563. * Disposes the cylinder.
  64564. * @param force Specifies if the updraft should be disposed by force
  64565. */
  64566. dispose(force?: boolean): void;
  64567. private getImpostorHitData;
  64568. private _tick;
  64569. /*** Helpers ***/
  64570. private _prepareCylinder;
  64571. private _intersectsWithCylinder;
  64572. }
  64573. /**
  64574. * Represents a physics vortex event
  64575. */
  64576. class PhysicsVortexEvent {
  64577. private _scene;
  64578. private _origin;
  64579. private _options;
  64580. private _physicsEngine;
  64581. private _originTop;
  64582. private _tickCallback;
  64583. private _cylinder;
  64584. private _cylinderPosition;
  64585. private _dataFetched;
  64586. /**
  64587. * Initializes the physics vortex event
  64588. * @param _scene The BabylonJS scene
  64589. * @param _origin The origin position of the vortex
  64590. * @param _options The options for the vortex event
  64591. */
  64592. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64593. /**
  64594. * Returns the data related to the vortex event (cylinder).
  64595. * @returns The physics vortex event data
  64596. */
  64597. getData(): PhysicsVortexEventData;
  64598. /**
  64599. * Enables the vortex.
  64600. */
  64601. enable(): void;
  64602. /**
  64603. * Disables the cortex.
  64604. */
  64605. disable(): void;
  64606. /**
  64607. * Disposes the sphere.
  64608. * @param force
  64609. */
  64610. dispose(force?: boolean): void;
  64611. private getImpostorHitData;
  64612. private _tick;
  64613. /*** Helpers ***/
  64614. private _prepareCylinder;
  64615. private _intersectsWithCylinder;
  64616. }
  64617. /**
  64618. * Options fot the radial explosion event
  64619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64620. */
  64621. export class PhysicsRadialExplosionEventOptions {
  64622. /**
  64623. * The radius of the sphere for the radial explosion.
  64624. */
  64625. radius: number;
  64626. /**
  64627. * The strenth of the explosion.
  64628. */
  64629. strength: number;
  64630. /**
  64631. * The strenght of the force in correspondence to the distance of the affected object
  64632. */
  64633. falloff: PhysicsRadialImpulseFalloff;
  64634. /**
  64635. * Sphere options for the radial explosion.
  64636. */
  64637. sphere: {
  64638. segments: number;
  64639. diameter: number;
  64640. };
  64641. /**
  64642. * Sphere options for the radial explosion.
  64643. */
  64644. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64645. }
  64646. /**
  64647. * Options fot the updraft event
  64648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64649. */
  64650. export class PhysicsUpdraftEventOptions {
  64651. /**
  64652. * The radius of the cylinder for the vortex
  64653. */
  64654. radius: number;
  64655. /**
  64656. * The strenth of the updraft.
  64657. */
  64658. strength: number;
  64659. /**
  64660. * The height of the cylinder for the updraft.
  64661. */
  64662. height: number;
  64663. /**
  64664. * The mode for the the updraft.
  64665. */
  64666. updraftMode: PhysicsUpdraftMode;
  64667. }
  64668. /**
  64669. * Options fot the vortex event
  64670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64671. */
  64672. export class PhysicsVortexEventOptions {
  64673. /**
  64674. * The radius of the cylinder for the vortex
  64675. */
  64676. radius: number;
  64677. /**
  64678. * The strenth of the vortex.
  64679. */
  64680. strength: number;
  64681. /**
  64682. * The height of the cylinder for the vortex.
  64683. */
  64684. height: number;
  64685. /**
  64686. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64687. */
  64688. centripetalForceThreshold: number;
  64689. /**
  64690. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64691. */
  64692. centripetalForceMultiplier: number;
  64693. /**
  64694. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64695. */
  64696. centrifugalForceMultiplier: number;
  64697. /**
  64698. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64699. */
  64700. updraftForceMultiplier: number;
  64701. }
  64702. /**
  64703. * The strenght of the force in correspondence to the distance of the affected object
  64704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64705. */
  64706. export enum PhysicsRadialImpulseFalloff {
  64707. /** Defines that impulse is constant in strength across it's whole radius */
  64708. Constant = 0,
  64709. /** Defines that impulse gets weaker if it's further from the origin */
  64710. Linear = 1
  64711. }
  64712. /**
  64713. * The strength of the force in correspondence to the distance of the affected object
  64714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64715. */
  64716. export enum PhysicsUpdraftMode {
  64717. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64718. Center = 0,
  64719. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64720. Perpendicular = 1
  64721. }
  64722. /**
  64723. * Interface for a physics hit data
  64724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64725. */
  64726. export interface PhysicsHitData {
  64727. /**
  64728. * The force applied at the contact point
  64729. */
  64730. force: Vector3;
  64731. /**
  64732. * The contact point
  64733. */
  64734. contactPoint: Vector3;
  64735. /**
  64736. * The distance from the origin to the contact point
  64737. */
  64738. distanceFromOrigin: number;
  64739. }
  64740. /**
  64741. * Interface for radial explosion event data
  64742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64743. */
  64744. export interface PhysicsRadialExplosionEventData {
  64745. /**
  64746. * A sphere used for the radial explosion event
  64747. */
  64748. sphere: Mesh;
  64749. }
  64750. /**
  64751. * Interface for gravitational field event data
  64752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64753. */
  64754. export interface PhysicsGravitationalFieldEventData {
  64755. /**
  64756. * A sphere mesh used for the gravitational field event
  64757. */
  64758. sphere: Mesh;
  64759. }
  64760. /**
  64761. * Interface for updraft event data
  64762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64763. */
  64764. export interface PhysicsUpdraftEventData {
  64765. /**
  64766. * A cylinder used for the updraft event
  64767. */
  64768. cylinder: Mesh;
  64769. }
  64770. /**
  64771. * Interface for vortex event data
  64772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64773. */
  64774. export interface PhysicsVortexEventData {
  64775. /**
  64776. * A cylinder used for the vortex event
  64777. */
  64778. cylinder: Mesh;
  64779. }
  64780. /**
  64781. * Interface for an affected physics impostor
  64782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64783. */
  64784. export interface PhysicsAffectedImpostorWithData {
  64785. /**
  64786. * The impostor affected by the effect
  64787. */
  64788. impostor: PhysicsImpostor;
  64789. /**
  64790. * The data about the hit/horce from the explosion
  64791. */
  64792. hitData: PhysicsHitData;
  64793. }
  64794. }
  64795. declare module BABYLON {
  64796. /** @hidden */
  64797. export var blackAndWhitePixelShader: {
  64798. name: string;
  64799. shader: string;
  64800. };
  64801. }
  64802. declare module BABYLON {
  64803. /**
  64804. * Post process used to render in black and white
  64805. */
  64806. export class BlackAndWhitePostProcess extends PostProcess {
  64807. /**
  64808. * Linear about to convert he result to black and white (default: 1)
  64809. */
  64810. degree: number;
  64811. /**
  64812. * Creates a black and white post process
  64813. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64814. * @param name The name of the effect.
  64815. * @param options The required width/height ratio to downsize to before computing the render pass.
  64816. * @param camera The camera to apply the render pass to.
  64817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64818. * @param engine The engine which the post process will be applied. (default: current engine)
  64819. * @param reusable If the post process can be reused on the same frame. (default: false)
  64820. */
  64821. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64822. }
  64823. }
  64824. declare module BABYLON {
  64825. /**
  64826. * This represents a set of one or more post processes in Babylon.
  64827. * A post process can be used to apply a shader to a texture after it is rendered.
  64828. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64829. */
  64830. export class PostProcessRenderEffect {
  64831. private _postProcesses;
  64832. private _getPostProcesses;
  64833. private _singleInstance;
  64834. private _cameras;
  64835. private _indicesForCamera;
  64836. /**
  64837. * Name of the effect
  64838. * @hidden
  64839. */
  64840. _name: string;
  64841. /**
  64842. * Instantiates a post process render effect.
  64843. * A post process can be used to apply a shader to a texture after it is rendered.
  64844. * @param engine The engine the effect is tied to
  64845. * @param name The name of the effect
  64846. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64847. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64848. */
  64849. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64850. /**
  64851. * Checks if all the post processes in the effect are supported.
  64852. */
  64853. get isSupported(): boolean;
  64854. /**
  64855. * Updates the current state of the effect
  64856. * @hidden
  64857. */
  64858. _update(): void;
  64859. /**
  64860. * Attaches the effect on cameras
  64861. * @param cameras The camera to attach to.
  64862. * @hidden
  64863. */
  64864. _attachCameras(cameras: Camera): void;
  64865. /**
  64866. * Attaches the effect on cameras
  64867. * @param cameras The camera to attach to.
  64868. * @hidden
  64869. */
  64870. _attachCameras(cameras: Camera[]): void;
  64871. /**
  64872. * Detaches the effect on cameras
  64873. * @param cameras The camera to detatch from.
  64874. * @hidden
  64875. */
  64876. _detachCameras(cameras: Camera): void;
  64877. /**
  64878. * Detatches the effect on cameras
  64879. * @param cameras The camera to detatch from.
  64880. * @hidden
  64881. */
  64882. _detachCameras(cameras: Camera[]): void;
  64883. /**
  64884. * Enables the effect on given cameras
  64885. * @param cameras The camera to enable.
  64886. * @hidden
  64887. */
  64888. _enable(cameras: Camera): void;
  64889. /**
  64890. * Enables the effect on given cameras
  64891. * @param cameras The camera to enable.
  64892. * @hidden
  64893. */
  64894. _enable(cameras: Nullable<Camera[]>): void;
  64895. /**
  64896. * Disables the effect on the given cameras
  64897. * @param cameras The camera to disable.
  64898. * @hidden
  64899. */
  64900. _disable(cameras: Camera): void;
  64901. /**
  64902. * Disables the effect on the given cameras
  64903. * @param cameras The camera to disable.
  64904. * @hidden
  64905. */
  64906. _disable(cameras: Nullable<Camera[]>): void;
  64907. /**
  64908. * Gets a list of the post processes contained in the effect.
  64909. * @param camera The camera to get the post processes on.
  64910. * @returns The list of the post processes in the effect.
  64911. */
  64912. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64913. }
  64914. }
  64915. declare module BABYLON {
  64916. /** @hidden */
  64917. export var extractHighlightsPixelShader: {
  64918. name: string;
  64919. shader: string;
  64920. };
  64921. }
  64922. declare module BABYLON {
  64923. /**
  64924. * 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.
  64925. */
  64926. export class ExtractHighlightsPostProcess extends PostProcess {
  64927. /**
  64928. * The luminance threshold, pixels below this value will be set to black.
  64929. */
  64930. threshold: number;
  64931. /** @hidden */
  64932. _exposure: number;
  64933. /**
  64934. * Post process which has the input texture to be used when performing highlight extraction
  64935. * @hidden
  64936. */
  64937. _inputPostProcess: Nullable<PostProcess>;
  64938. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64939. }
  64940. }
  64941. declare module BABYLON {
  64942. /** @hidden */
  64943. export var bloomMergePixelShader: {
  64944. name: string;
  64945. shader: string;
  64946. };
  64947. }
  64948. declare module BABYLON {
  64949. /**
  64950. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64951. */
  64952. export class BloomMergePostProcess extends PostProcess {
  64953. /** Weight of the bloom to be added to the original input. */
  64954. weight: number;
  64955. /**
  64956. * Creates a new instance of @see BloomMergePostProcess
  64957. * @param name The name of the effect.
  64958. * @param originalFromInput Post process which's input will be used for the merge.
  64959. * @param blurred Blurred highlights post process which's output will be used.
  64960. * @param weight Weight of the bloom to be added to the original input.
  64961. * @param options The required width/height ratio to downsize to before computing the render pass.
  64962. * @param camera The camera to apply the render pass to.
  64963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64964. * @param engine The engine which the post process will be applied. (default: current engine)
  64965. * @param reusable If the post process can be reused on the same frame. (default: false)
  64966. * @param textureType Type of textures used when performing the post process. (default: 0)
  64967. * @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)
  64968. */
  64969. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64970. /** Weight of the bloom to be added to the original input. */
  64971. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64972. }
  64973. }
  64974. declare module BABYLON {
  64975. /**
  64976. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64977. */
  64978. export class BloomEffect extends PostProcessRenderEffect {
  64979. private bloomScale;
  64980. /**
  64981. * @hidden Internal
  64982. */
  64983. _effects: Array<PostProcess>;
  64984. /**
  64985. * @hidden Internal
  64986. */
  64987. _downscale: ExtractHighlightsPostProcess;
  64988. private _blurX;
  64989. private _blurY;
  64990. private _merge;
  64991. /**
  64992. * The luminance threshold to find bright areas of the image to bloom.
  64993. */
  64994. get threshold(): number;
  64995. set threshold(value: number);
  64996. /**
  64997. * The strength of the bloom.
  64998. */
  64999. get weight(): number;
  65000. set weight(value: number);
  65001. /**
  65002. * Specifies the size of the bloom blur kernel, relative to the final output size
  65003. */
  65004. get kernel(): number;
  65005. set kernel(value: number);
  65006. /**
  65007. * Creates a new instance of @see BloomEffect
  65008. * @param scene The scene the effect belongs to.
  65009. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65010. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65011. * @param bloomWeight The the strength of bloom.
  65012. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65013. * @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)
  65014. */
  65015. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65016. /**
  65017. * Disposes each of the internal effects for a given camera.
  65018. * @param camera The camera to dispose the effect on.
  65019. */
  65020. disposeEffects(camera: Camera): void;
  65021. /**
  65022. * @hidden Internal
  65023. */
  65024. _updateEffects(): void;
  65025. /**
  65026. * Internal
  65027. * @returns if all the contained post processes are ready.
  65028. * @hidden
  65029. */
  65030. _isReady(): boolean;
  65031. }
  65032. }
  65033. declare module BABYLON {
  65034. /** @hidden */
  65035. export var chromaticAberrationPixelShader: {
  65036. name: string;
  65037. shader: string;
  65038. };
  65039. }
  65040. declare module BABYLON {
  65041. /**
  65042. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65043. */
  65044. export class ChromaticAberrationPostProcess extends PostProcess {
  65045. /**
  65046. * The amount of seperation of rgb channels (default: 30)
  65047. */
  65048. aberrationAmount: number;
  65049. /**
  65050. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65051. */
  65052. radialIntensity: number;
  65053. /**
  65054. * 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))
  65055. */
  65056. direction: Vector2;
  65057. /**
  65058. * 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))
  65059. */
  65060. centerPosition: Vector2;
  65061. /**
  65062. * Creates a new instance ChromaticAberrationPostProcess
  65063. * @param name The name of the effect.
  65064. * @param screenWidth The width of the screen to apply the effect on.
  65065. * @param screenHeight The height of the screen to apply the effect on.
  65066. * @param options The required width/height ratio to downsize to before computing the render pass.
  65067. * @param camera The camera to apply the render pass to.
  65068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65069. * @param engine The engine which the post process will be applied. (default: current engine)
  65070. * @param reusable If the post process can be reused on the same frame. (default: false)
  65071. * @param textureType Type of textures used when performing the post process. (default: 0)
  65072. * @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)
  65073. */
  65074. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65075. }
  65076. }
  65077. declare module BABYLON {
  65078. /** @hidden */
  65079. export var circleOfConfusionPixelShader: {
  65080. name: string;
  65081. shader: string;
  65082. };
  65083. }
  65084. declare module BABYLON {
  65085. /**
  65086. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65087. */
  65088. export class CircleOfConfusionPostProcess extends PostProcess {
  65089. /**
  65090. * 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.
  65091. */
  65092. lensSize: number;
  65093. /**
  65094. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65095. */
  65096. fStop: number;
  65097. /**
  65098. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65099. */
  65100. focusDistance: number;
  65101. /**
  65102. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65103. */
  65104. focalLength: number;
  65105. private _depthTexture;
  65106. /**
  65107. * Creates a new instance CircleOfConfusionPostProcess
  65108. * @param name The name of the effect.
  65109. * @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.
  65110. * @param options The required width/height ratio to downsize to before computing the render pass.
  65111. * @param camera The camera to apply the render pass to.
  65112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65113. * @param engine The engine which the post process will be applied. (default: current engine)
  65114. * @param reusable If the post process can be reused on the same frame. (default: false)
  65115. * @param textureType Type of textures used when performing the post process. (default: 0)
  65116. * @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)
  65117. */
  65118. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65119. /**
  65120. * 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.
  65121. */
  65122. set depthTexture(value: RenderTargetTexture);
  65123. }
  65124. }
  65125. declare module BABYLON {
  65126. /** @hidden */
  65127. export var colorCorrectionPixelShader: {
  65128. name: string;
  65129. shader: string;
  65130. };
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. *
  65135. * This post-process allows the modification of rendered colors by using
  65136. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65137. *
  65138. * The object needs to be provided an url to a texture containing the color
  65139. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65140. * Use an image editing software to tweak the LUT to match your needs.
  65141. *
  65142. * For an example of a color LUT, see here:
  65143. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65144. * For explanations on color grading, see here:
  65145. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65146. *
  65147. */
  65148. export class ColorCorrectionPostProcess extends PostProcess {
  65149. private _colorTableTexture;
  65150. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65151. }
  65152. }
  65153. declare module BABYLON {
  65154. /** @hidden */
  65155. export var convolutionPixelShader: {
  65156. name: string;
  65157. shader: string;
  65158. };
  65159. }
  65160. declare module BABYLON {
  65161. /**
  65162. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65163. * input texture to perform effects such as edge detection or sharpening
  65164. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65165. */
  65166. export class ConvolutionPostProcess extends PostProcess {
  65167. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65168. kernel: number[];
  65169. /**
  65170. * Creates a new instance ConvolutionPostProcess
  65171. * @param name The name of the effect.
  65172. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65173. * @param options The required width/height ratio to downsize to before computing the render pass.
  65174. * @param camera The camera to apply the render pass to.
  65175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65176. * @param engine The engine which the post process will be applied. (default: current engine)
  65177. * @param reusable If the post process can be reused on the same frame. (default: false)
  65178. * @param textureType Type of textures used when performing the post process. (default: 0)
  65179. */
  65180. constructor(name: string,
  65181. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65182. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65183. /**
  65184. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65185. */
  65186. static EdgeDetect0Kernel: number[];
  65187. /**
  65188. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65189. */
  65190. static EdgeDetect1Kernel: number[];
  65191. /**
  65192. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65193. */
  65194. static EdgeDetect2Kernel: number[];
  65195. /**
  65196. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65197. */
  65198. static SharpenKernel: number[];
  65199. /**
  65200. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65201. */
  65202. static EmbossKernel: number[];
  65203. /**
  65204. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65205. */
  65206. static GaussianKernel: number[];
  65207. }
  65208. }
  65209. declare module BABYLON {
  65210. /**
  65211. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65212. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65213. * based on samples that have a large difference in distance than the center pixel.
  65214. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65215. */
  65216. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65217. direction: Vector2;
  65218. /**
  65219. * Creates a new instance CircleOfConfusionPostProcess
  65220. * @param name The name of the effect.
  65221. * @param scene The scene the effect belongs to.
  65222. * @param direction The direction the blur should be applied.
  65223. * @param kernel The size of the kernel used to blur.
  65224. * @param options The required width/height ratio to downsize to before computing the render pass.
  65225. * @param camera The camera to apply the render pass to.
  65226. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65227. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65229. * @param engine The engine which the post process will be applied. (default: current engine)
  65230. * @param reusable If the post process can be reused on the same frame. (default: false)
  65231. * @param textureType Type of textures used when performing the post process. (default: 0)
  65232. * @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)
  65233. */
  65234. 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);
  65235. }
  65236. }
  65237. declare module BABYLON {
  65238. /** @hidden */
  65239. export var depthOfFieldMergePixelShader: {
  65240. name: string;
  65241. shader: string;
  65242. };
  65243. }
  65244. declare module BABYLON {
  65245. /**
  65246. * Options to be set when merging outputs from the default pipeline.
  65247. */
  65248. export class DepthOfFieldMergePostProcessOptions {
  65249. /**
  65250. * The original image to merge on top of
  65251. */
  65252. originalFromInput: PostProcess;
  65253. /**
  65254. * Parameters to perform the merge of the depth of field effect
  65255. */
  65256. depthOfField?: {
  65257. circleOfConfusion: PostProcess;
  65258. blurSteps: Array<PostProcess>;
  65259. };
  65260. /**
  65261. * Parameters to perform the merge of bloom effect
  65262. */
  65263. bloom?: {
  65264. blurred: PostProcess;
  65265. weight: number;
  65266. };
  65267. }
  65268. /**
  65269. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65270. */
  65271. export class DepthOfFieldMergePostProcess extends PostProcess {
  65272. private blurSteps;
  65273. /**
  65274. * Creates a new instance of DepthOfFieldMergePostProcess
  65275. * @param name The name of the effect.
  65276. * @param originalFromInput Post process which's input will be used for the merge.
  65277. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65278. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65279. * @param options The required width/height ratio to downsize to before computing the render pass.
  65280. * @param camera The camera to apply the render pass to.
  65281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65282. * @param engine The engine which the post process will be applied. (default: current engine)
  65283. * @param reusable If the post process can be reused on the same frame. (default: false)
  65284. * @param textureType Type of textures used when performing the post process. (default: 0)
  65285. * @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)
  65286. */
  65287. 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);
  65288. /**
  65289. * Updates the effect with the current post process compile time values and recompiles the shader.
  65290. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65291. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65292. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65293. * @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
  65294. * @param onCompiled Called when the shader has been compiled.
  65295. * @param onError Called if there is an error when compiling a shader.
  65296. */
  65297. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65298. }
  65299. }
  65300. declare module BABYLON {
  65301. /**
  65302. * Specifies the level of max blur that should be applied when using the depth of field effect
  65303. */
  65304. export enum DepthOfFieldEffectBlurLevel {
  65305. /**
  65306. * Subtle blur
  65307. */
  65308. Low = 0,
  65309. /**
  65310. * Medium blur
  65311. */
  65312. Medium = 1,
  65313. /**
  65314. * Large blur
  65315. */
  65316. High = 2
  65317. }
  65318. /**
  65319. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65320. */
  65321. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65322. private _circleOfConfusion;
  65323. /**
  65324. * @hidden Internal, blurs from high to low
  65325. */
  65326. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65327. private _depthOfFieldBlurY;
  65328. private _dofMerge;
  65329. /**
  65330. * @hidden Internal post processes in depth of field effect
  65331. */
  65332. _effects: Array<PostProcess>;
  65333. /**
  65334. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65335. */
  65336. set focalLength(value: number);
  65337. get focalLength(): number;
  65338. /**
  65339. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65340. */
  65341. set fStop(value: number);
  65342. get fStop(): number;
  65343. /**
  65344. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65345. */
  65346. set focusDistance(value: number);
  65347. get focusDistance(): number;
  65348. /**
  65349. * 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.
  65350. */
  65351. set lensSize(value: number);
  65352. get lensSize(): number;
  65353. /**
  65354. * Creates a new instance DepthOfFieldEffect
  65355. * @param scene The scene the effect belongs to.
  65356. * @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.
  65357. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65358. * @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)
  65359. */
  65360. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65361. /**
  65362. * Get the current class name of the current effet
  65363. * @returns "DepthOfFieldEffect"
  65364. */
  65365. getClassName(): string;
  65366. /**
  65367. * 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.
  65368. */
  65369. set depthTexture(value: RenderTargetTexture);
  65370. /**
  65371. * Disposes each of the internal effects for a given camera.
  65372. * @param camera The camera to dispose the effect on.
  65373. */
  65374. disposeEffects(camera: Camera): void;
  65375. /**
  65376. * @hidden Internal
  65377. */
  65378. _updateEffects(): void;
  65379. /**
  65380. * Internal
  65381. * @returns if all the contained post processes are ready.
  65382. * @hidden
  65383. */
  65384. _isReady(): boolean;
  65385. }
  65386. }
  65387. declare module BABYLON {
  65388. /** @hidden */
  65389. export var displayPassPixelShader: {
  65390. name: string;
  65391. shader: string;
  65392. };
  65393. }
  65394. declare module BABYLON {
  65395. /**
  65396. * DisplayPassPostProcess which produces an output the same as it's input
  65397. */
  65398. export class DisplayPassPostProcess extends PostProcess {
  65399. /**
  65400. * Creates the DisplayPassPostProcess
  65401. * @param name The name of the effect.
  65402. * @param options The required width/height ratio to downsize to before computing the render pass.
  65403. * @param camera The camera to apply the render pass to.
  65404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65405. * @param engine The engine which the post process will be applied. (default: current engine)
  65406. * @param reusable If the post process can be reused on the same frame. (default: false)
  65407. */
  65408. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65409. }
  65410. }
  65411. declare module BABYLON {
  65412. /** @hidden */
  65413. export var filterPixelShader: {
  65414. name: string;
  65415. shader: string;
  65416. };
  65417. }
  65418. declare module BABYLON {
  65419. /**
  65420. * Applies a kernel filter to the image
  65421. */
  65422. export class FilterPostProcess extends PostProcess {
  65423. /** The matrix to be applied to the image */
  65424. kernelMatrix: Matrix;
  65425. /**
  65426. *
  65427. * @param name The name of the effect.
  65428. * @param kernelMatrix The matrix to be applied to the image
  65429. * @param options The required width/height ratio to downsize to before computing the render pass.
  65430. * @param camera The camera to apply the render pass to.
  65431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65432. * @param engine The engine which the post process will be applied. (default: current engine)
  65433. * @param reusable If the post process can be reused on the same frame. (default: false)
  65434. */
  65435. constructor(name: string,
  65436. /** The matrix to be applied to the image */
  65437. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65438. }
  65439. }
  65440. declare module BABYLON {
  65441. /** @hidden */
  65442. export var fxaaPixelShader: {
  65443. name: string;
  65444. shader: string;
  65445. };
  65446. }
  65447. declare module BABYLON {
  65448. /** @hidden */
  65449. export var fxaaVertexShader: {
  65450. name: string;
  65451. shader: string;
  65452. };
  65453. }
  65454. declare module BABYLON {
  65455. /**
  65456. * Fxaa post process
  65457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65458. */
  65459. export class FxaaPostProcess extends PostProcess {
  65460. /** @hidden */
  65461. texelWidth: number;
  65462. /** @hidden */
  65463. texelHeight: number;
  65464. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65465. private _getDefines;
  65466. }
  65467. }
  65468. declare module BABYLON {
  65469. /** @hidden */
  65470. export var grainPixelShader: {
  65471. name: string;
  65472. shader: string;
  65473. };
  65474. }
  65475. declare module BABYLON {
  65476. /**
  65477. * The GrainPostProcess adds noise to the image at mid luminance levels
  65478. */
  65479. export class GrainPostProcess extends PostProcess {
  65480. /**
  65481. * The intensity of the grain added (default: 30)
  65482. */
  65483. intensity: number;
  65484. /**
  65485. * If the grain should be randomized on every frame
  65486. */
  65487. animated: boolean;
  65488. /**
  65489. * Creates a new instance of @see GrainPostProcess
  65490. * @param name The name of the effect.
  65491. * @param options The required width/height ratio to downsize to before computing the render pass.
  65492. * @param camera The camera to apply the render pass to.
  65493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65494. * @param engine The engine which the post process will be applied. (default: current engine)
  65495. * @param reusable If the post process can be reused on the same frame. (default: false)
  65496. * @param textureType Type of textures used when performing the post process. (default: 0)
  65497. * @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)
  65498. */
  65499. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65500. }
  65501. }
  65502. declare module BABYLON {
  65503. /** @hidden */
  65504. export var highlightsPixelShader: {
  65505. name: string;
  65506. shader: string;
  65507. };
  65508. }
  65509. declare module BABYLON {
  65510. /**
  65511. * Extracts highlights from the image
  65512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65513. */
  65514. export class HighlightsPostProcess extends PostProcess {
  65515. /**
  65516. * Extracts highlights from the image
  65517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65518. * @param name The name of the effect.
  65519. * @param options The required width/height ratio to downsize to before computing the render pass.
  65520. * @param camera The camera to apply the render pass to.
  65521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65522. * @param engine The engine which the post process will be applied. (default: current engine)
  65523. * @param reusable If the post process can be reused on the same frame. (default: false)
  65524. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65525. */
  65526. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65527. }
  65528. }
  65529. declare module BABYLON {
  65530. /** @hidden */
  65531. export var mrtFragmentDeclaration: {
  65532. name: string;
  65533. shader: string;
  65534. };
  65535. }
  65536. declare module BABYLON {
  65537. /** @hidden */
  65538. export var geometryPixelShader: {
  65539. name: string;
  65540. shader: string;
  65541. };
  65542. }
  65543. declare module BABYLON {
  65544. /** @hidden */
  65545. export var geometryVertexShader: {
  65546. name: string;
  65547. shader: string;
  65548. };
  65549. }
  65550. declare module BABYLON {
  65551. /** @hidden */
  65552. interface ISavedTransformationMatrix {
  65553. world: Matrix;
  65554. viewProjection: Matrix;
  65555. }
  65556. /**
  65557. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65558. */
  65559. export class GeometryBufferRenderer {
  65560. /**
  65561. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65562. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65563. */
  65564. static readonly POSITION_TEXTURE_TYPE: number;
  65565. /**
  65566. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65567. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65568. */
  65569. static readonly VELOCITY_TEXTURE_TYPE: number;
  65570. /**
  65571. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65572. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65573. */
  65574. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65575. /**
  65576. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65577. * in order to compute objects velocities when enableVelocity is set to "true"
  65578. * @hidden
  65579. */
  65580. _previousTransformationMatrices: {
  65581. [index: number]: ISavedTransformationMatrix;
  65582. };
  65583. /**
  65584. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65585. * in order to compute objects velocities when enableVelocity is set to "true"
  65586. * @hidden
  65587. */
  65588. _previousBonesTransformationMatrices: {
  65589. [index: number]: Float32Array;
  65590. };
  65591. /**
  65592. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65593. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65594. */
  65595. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65596. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65597. renderTransparentMeshes: boolean;
  65598. private _scene;
  65599. private _multiRenderTarget;
  65600. private _ratio;
  65601. private _enablePosition;
  65602. private _enableVelocity;
  65603. private _enableReflectivity;
  65604. private _positionIndex;
  65605. private _velocityIndex;
  65606. private _reflectivityIndex;
  65607. protected _effect: Effect;
  65608. protected _cachedDefines: string;
  65609. /**
  65610. * Set the render list (meshes to be rendered) used in the G buffer.
  65611. */
  65612. set renderList(meshes: Mesh[]);
  65613. /**
  65614. * Gets wether or not G buffer are supported by the running hardware.
  65615. * This requires draw buffer supports
  65616. */
  65617. get isSupported(): boolean;
  65618. /**
  65619. * Returns the index of the given texture type in the G-Buffer textures array
  65620. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65621. * @returns the index of the given texture type in the G-Buffer textures array
  65622. */
  65623. getTextureIndex(textureType: number): number;
  65624. /**
  65625. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65626. */
  65627. get enablePosition(): boolean;
  65628. /**
  65629. * Sets whether or not objects positions are enabled for the G buffer.
  65630. */
  65631. set enablePosition(enable: boolean);
  65632. /**
  65633. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65634. */
  65635. get enableVelocity(): boolean;
  65636. /**
  65637. * Sets wether or not objects velocities are enabled for the G buffer.
  65638. */
  65639. set enableVelocity(enable: boolean);
  65640. /**
  65641. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65642. */
  65643. get enableReflectivity(): boolean;
  65644. /**
  65645. * Sets wether or not objects roughness are enabled for the G buffer.
  65646. */
  65647. set enableReflectivity(enable: boolean);
  65648. /**
  65649. * Gets the scene associated with the buffer.
  65650. */
  65651. get scene(): Scene;
  65652. /**
  65653. * Gets the ratio used by the buffer during its creation.
  65654. * How big is the buffer related to the main canvas.
  65655. */
  65656. get ratio(): number;
  65657. /** @hidden */
  65658. static _SceneComponentInitialization: (scene: Scene) => void;
  65659. /**
  65660. * Creates a new G Buffer for the scene
  65661. * @param scene The scene the buffer belongs to
  65662. * @param ratio How big is the buffer related to the main canvas.
  65663. */
  65664. constructor(scene: Scene, ratio?: number);
  65665. /**
  65666. * Checks wether everything is ready to render a submesh to the G buffer.
  65667. * @param subMesh the submesh to check readiness for
  65668. * @param useInstances is the mesh drawn using instance or not
  65669. * @returns true if ready otherwise false
  65670. */
  65671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65672. /**
  65673. * Gets the current underlying G Buffer.
  65674. * @returns the buffer
  65675. */
  65676. getGBuffer(): MultiRenderTarget;
  65677. /**
  65678. * Gets the number of samples used to render the buffer (anti aliasing).
  65679. */
  65680. get samples(): number;
  65681. /**
  65682. * Sets the number of samples used to render the buffer (anti aliasing).
  65683. */
  65684. set samples(value: number);
  65685. /**
  65686. * Disposes the renderer and frees up associated resources.
  65687. */
  65688. dispose(): void;
  65689. protected _createRenderTargets(): void;
  65690. private _copyBonesTransformationMatrices;
  65691. }
  65692. }
  65693. declare module BABYLON {
  65694. interface Scene {
  65695. /** @hidden (Backing field) */
  65696. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65697. /**
  65698. * Gets or Sets the current geometry buffer associated to the scene.
  65699. */
  65700. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65701. /**
  65702. * Enables a GeometryBufferRender and associates it with the scene
  65703. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65704. * @returns the GeometryBufferRenderer
  65705. */
  65706. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65707. /**
  65708. * Disables the GeometryBufferRender associated with the scene
  65709. */
  65710. disableGeometryBufferRenderer(): void;
  65711. }
  65712. /**
  65713. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65714. * in several rendering techniques.
  65715. */
  65716. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65717. /**
  65718. * The component name helpful to identify the component in the list of scene components.
  65719. */
  65720. readonly name: string;
  65721. /**
  65722. * The scene the component belongs to.
  65723. */
  65724. scene: Scene;
  65725. /**
  65726. * Creates a new instance of the component for the given scene
  65727. * @param scene Defines the scene to register the component in
  65728. */
  65729. constructor(scene: Scene);
  65730. /**
  65731. * Registers the component in a given scene
  65732. */
  65733. register(): void;
  65734. /**
  65735. * Rebuilds the elements related to this component in case of
  65736. * context lost for instance.
  65737. */
  65738. rebuild(): void;
  65739. /**
  65740. * Disposes the component and the associated ressources
  65741. */
  65742. dispose(): void;
  65743. private _gatherRenderTargets;
  65744. }
  65745. }
  65746. declare module BABYLON {
  65747. /** @hidden */
  65748. export var motionBlurPixelShader: {
  65749. name: string;
  65750. shader: string;
  65751. };
  65752. }
  65753. declare module BABYLON {
  65754. /**
  65755. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65756. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65757. * As an example, all you have to do is to create the post-process:
  65758. * var mb = new BABYLON.MotionBlurPostProcess(
  65759. * 'mb', // The name of the effect.
  65760. * scene, // The scene containing the objects to blur according to their velocity.
  65761. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65762. * camera // The camera to apply the render pass to.
  65763. * );
  65764. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65765. */
  65766. export class MotionBlurPostProcess extends PostProcess {
  65767. /**
  65768. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65769. */
  65770. motionStrength: number;
  65771. /**
  65772. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65773. */
  65774. get motionBlurSamples(): number;
  65775. /**
  65776. * Sets the number of iterations to be used for motion blur quality
  65777. */
  65778. set motionBlurSamples(samples: number);
  65779. private _motionBlurSamples;
  65780. private _geometryBufferRenderer;
  65781. /**
  65782. * Creates a new instance MotionBlurPostProcess
  65783. * @param name The name of the effect.
  65784. * @param scene The scene containing the objects to blur according to their velocity.
  65785. * @param options The required width/height ratio to downsize to before computing the render pass.
  65786. * @param camera The camera to apply the render pass to.
  65787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65788. * @param engine The engine which the post process will be applied. (default: current engine)
  65789. * @param reusable If the post process can be reused on the same frame. (default: false)
  65790. * @param textureType Type of textures used when performing the post process. (default: 0)
  65791. * @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)
  65792. */
  65793. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65794. /**
  65795. * Excludes the given skinned mesh from computing bones velocities.
  65796. * 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.
  65797. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65798. */
  65799. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65800. /**
  65801. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65802. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65803. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65804. */
  65805. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65806. /**
  65807. * Disposes the post process.
  65808. * @param camera The camera to dispose the post process on.
  65809. */
  65810. dispose(camera?: Camera): void;
  65811. }
  65812. }
  65813. declare module BABYLON {
  65814. /** @hidden */
  65815. export var refractionPixelShader: {
  65816. name: string;
  65817. shader: string;
  65818. };
  65819. }
  65820. declare module BABYLON {
  65821. /**
  65822. * Post process which applies a refractin texture
  65823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65824. */
  65825. export class RefractionPostProcess extends PostProcess {
  65826. /** the base color of the refraction (used to taint the rendering) */
  65827. color: Color3;
  65828. /** simulated refraction depth */
  65829. depth: number;
  65830. /** the coefficient of the base color (0 to remove base color tainting) */
  65831. colorLevel: number;
  65832. private _refTexture;
  65833. private _ownRefractionTexture;
  65834. /**
  65835. * Gets or sets the refraction texture
  65836. * Please note that you are responsible for disposing the texture if you set it manually
  65837. */
  65838. get refractionTexture(): Texture;
  65839. set refractionTexture(value: Texture);
  65840. /**
  65841. * Initializes the RefractionPostProcess
  65842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65843. * @param name The name of the effect.
  65844. * @param refractionTextureUrl Url of the refraction texture to use
  65845. * @param color the base color of the refraction (used to taint the rendering)
  65846. * @param depth simulated refraction depth
  65847. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65848. * @param camera The camera to apply the render pass to.
  65849. * @param options The required width/height ratio to downsize to before computing the render pass.
  65850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65851. * @param engine The engine which the post process will be applied. (default: current engine)
  65852. * @param reusable If the post process can be reused on the same frame. (default: false)
  65853. */
  65854. constructor(name: string, refractionTextureUrl: string,
  65855. /** the base color of the refraction (used to taint the rendering) */
  65856. color: Color3,
  65857. /** simulated refraction depth */
  65858. depth: number,
  65859. /** the coefficient of the base color (0 to remove base color tainting) */
  65860. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65861. /**
  65862. * Disposes of the post process
  65863. * @param camera Camera to dispose post process on
  65864. */
  65865. dispose(camera: Camera): void;
  65866. }
  65867. }
  65868. declare module BABYLON {
  65869. /** @hidden */
  65870. export var sharpenPixelShader: {
  65871. name: string;
  65872. shader: string;
  65873. };
  65874. }
  65875. declare module BABYLON {
  65876. /**
  65877. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65879. */
  65880. export class SharpenPostProcess extends PostProcess {
  65881. /**
  65882. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65883. */
  65884. colorAmount: number;
  65885. /**
  65886. * How much sharpness should be applied (default: 0.3)
  65887. */
  65888. edgeAmount: number;
  65889. /**
  65890. * Creates a new instance ConvolutionPostProcess
  65891. * @param name The name of the effect.
  65892. * @param options The required width/height ratio to downsize to before computing the render pass.
  65893. * @param camera The camera to apply the render pass to.
  65894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65895. * @param engine The engine which the post process will be applied. (default: current engine)
  65896. * @param reusable If the post process can be reused on the same frame. (default: false)
  65897. * @param textureType Type of textures used when performing the post process. (default: 0)
  65898. * @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)
  65899. */
  65900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65901. }
  65902. }
  65903. declare module BABYLON {
  65904. /**
  65905. * PostProcessRenderPipeline
  65906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65907. */
  65908. export class PostProcessRenderPipeline {
  65909. private engine;
  65910. private _renderEffects;
  65911. private _renderEffectsForIsolatedPass;
  65912. /**
  65913. * List of inspectable custom properties (used by the Inspector)
  65914. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65915. */
  65916. inspectableCustomProperties: IInspectable[];
  65917. /**
  65918. * @hidden
  65919. */
  65920. protected _cameras: Camera[];
  65921. /** @hidden */
  65922. _name: string;
  65923. /**
  65924. * Gets pipeline name
  65925. */
  65926. get name(): string;
  65927. /** Gets the list of attached cameras */
  65928. get cameras(): Camera[];
  65929. /**
  65930. * Initializes a PostProcessRenderPipeline
  65931. * @param engine engine to add the pipeline to
  65932. * @param name name of the pipeline
  65933. */
  65934. constructor(engine: Engine, name: string);
  65935. /**
  65936. * Gets the class name
  65937. * @returns "PostProcessRenderPipeline"
  65938. */
  65939. getClassName(): string;
  65940. /**
  65941. * If all the render effects in the pipeline are supported
  65942. */
  65943. get isSupported(): boolean;
  65944. /**
  65945. * Adds an effect to the pipeline
  65946. * @param renderEffect the effect to add
  65947. */
  65948. addEffect(renderEffect: PostProcessRenderEffect): void;
  65949. /** @hidden */
  65950. _rebuild(): void;
  65951. /** @hidden */
  65952. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65953. /** @hidden */
  65954. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65955. /** @hidden */
  65956. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65957. /** @hidden */
  65958. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65959. /** @hidden */
  65960. _attachCameras(cameras: Camera, unique: boolean): void;
  65961. /** @hidden */
  65962. _attachCameras(cameras: Camera[], unique: boolean): void;
  65963. /** @hidden */
  65964. _detachCameras(cameras: Camera): void;
  65965. /** @hidden */
  65966. _detachCameras(cameras: Nullable<Camera[]>): void;
  65967. /** @hidden */
  65968. _update(): void;
  65969. /** @hidden */
  65970. _reset(): void;
  65971. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65972. /**
  65973. * Disposes of the pipeline
  65974. */
  65975. dispose(): void;
  65976. }
  65977. }
  65978. declare module BABYLON {
  65979. /**
  65980. * PostProcessRenderPipelineManager class
  65981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65982. */
  65983. export class PostProcessRenderPipelineManager {
  65984. private _renderPipelines;
  65985. /**
  65986. * Initializes a PostProcessRenderPipelineManager
  65987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65988. */
  65989. constructor();
  65990. /**
  65991. * Gets the list of supported render pipelines
  65992. */
  65993. get supportedPipelines(): PostProcessRenderPipeline[];
  65994. /**
  65995. * Adds a pipeline to the manager
  65996. * @param renderPipeline The pipeline to add
  65997. */
  65998. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65999. /**
  66000. * Attaches a camera to the pipeline
  66001. * @param renderPipelineName The name of the pipeline to attach to
  66002. * @param cameras the camera to attach
  66003. * @param unique if the camera can be attached multiple times to the pipeline
  66004. */
  66005. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66006. /**
  66007. * Detaches a camera from the pipeline
  66008. * @param renderPipelineName The name of the pipeline to detach from
  66009. * @param cameras the camera to detach
  66010. */
  66011. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66012. /**
  66013. * Enables an effect by name on a pipeline
  66014. * @param renderPipelineName the name of the pipeline to enable the effect in
  66015. * @param renderEffectName the name of the effect to enable
  66016. * @param cameras the cameras that the effect should be enabled on
  66017. */
  66018. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66019. /**
  66020. * Disables an effect by name on a pipeline
  66021. * @param renderPipelineName the name of the pipeline to disable the effect in
  66022. * @param renderEffectName the name of the effect to disable
  66023. * @param cameras the cameras that the effect should be disabled on
  66024. */
  66025. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66026. /**
  66027. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66028. */
  66029. update(): void;
  66030. /** @hidden */
  66031. _rebuild(): void;
  66032. /**
  66033. * Disposes of the manager and pipelines
  66034. */
  66035. dispose(): void;
  66036. }
  66037. }
  66038. declare module BABYLON {
  66039. interface Scene {
  66040. /** @hidden (Backing field) */
  66041. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66042. /**
  66043. * Gets the postprocess render pipeline manager
  66044. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66045. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66046. */
  66047. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66048. }
  66049. /**
  66050. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66051. */
  66052. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66053. /**
  66054. * The component name helpfull to identify the component in the list of scene components.
  66055. */
  66056. readonly name: string;
  66057. /**
  66058. * The scene the component belongs to.
  66059. */
  66060. scene: Scene;
  66061. /**
  66062. * Creates a new instance of the component for the given scene
  66063. * @param scene Defines the scene to register the component in
  66064. */
  66065. constructor(scene: Scene);
  66066. /**
  66067. * Registers the component in a given scene
  66068. */
  66069. register(): void;
  66070. /**
  66071. * Rebuilds the elements related to this component in case of
  66072. * context lost for instance.
  66073. */
  66074. rebuild(): void;
  66075. /**
  66076. * Disposes the component and the associated ressources
  66077. */
  66078. dispose(): void;
  66079. private _gatherRenderTargets;
  66080. }
  66081. }
  66082. declare module BABYLON {
  66083. /**
  66084. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66085. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66086. */
  66087. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66088. private _scene;
  66089. private _camerasToBeAttached;
  66090. /**
  66091. * ID of the sharpen post process,
  66092. */
  66093. private readonly SharpenPostProcessId;
  66094. /**
  66095. * @ignore
  66096. * ID of the image processing post process;
  66097. */
  66098. readonly ImageProcessingPostProcessId: string;
  66099. /**
  66100. * @ignore
  66101. * ID of the Fast Approximate Anti-Aliasing post process;
  66102. */
  66103. readonly FxaaPostProcessId: string;
  66104. /**
  66105. * ID of the chromatic aberration post process,
  66106. */
  66107. private readonly ChromaticAberrationPostProcessId;
  66108. /**
  66109. * ID of the grain post process
  66110. */
  66111. private readonly GrainPostProcessId;
  66112. /**
  66113. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66114. */
  66115. sharpen: SharpenPostProcess;
  66116. private _sharpenEffect;
  66117. private bloom;
  66118. /**
  66119. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66120. */
  66121. depthOfField: DepthOfFieldEffect;
  66122. /**
  66123. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66124. */
  66125. fxaa: FxaaPostProcess;
  66126. /**
  66127. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66128. */
  66129. imageProcessing: ImageProcessingPostProcess;
  66130. /**
  66131. * Chromatic aberration post process which will shift rgb colors in the image
  66132. */
  66133. chromaticAberration: ChromaticAberrationPostProcess;
  66134. private _chromaticAberrationEffect;
  66135. /**
  66136. * Grain post process which add noise to the image
  66137. */
  66138. grain: GrainPostProcess;
  66139. private _grainEffect;
  66140. /**
  66141. * Glow post process which adds a glow to emissive areas of the image
  66142. */
  66143. private _glowLayer;
  66144. /**
  66145. * Animations which can be used to tweak settings over a period of time
  66146. */
  66147. animations: Animation[];
  66148. private _imageProcessingConfigurationObserver;
  66149. private _sharpenEnabled;
  66150. private _bloomEnabled;
  66151. private _depthOfFieldEnabled;
  66152. private _depthOfFieldBlurLevel;
  66153. private _fxaaEnabled;
  66154. private _imageProcessingEnabled;
  66155. private _defaultPipelineTextureType;
  66156. private _bloomScale;
  66157. private _chromaticAberrationEnabled;
  66158. private _grainEnabled;
  66159. private _buildAllowed;
  66160. /**
  66161. * Gets active scene
  66162. */
  66163. get scene(): Scene;
  66164. /**
  66165. * Enable or disable the sharpen process from the pipeline
  66166. */
  66167. set sharpenEnabled(enabled: boolean);
  66168. get sharpenEnabled(): boolean;
  66169. private _resizeObserver;
  66170. private _hardwareScaleLevel;
  66171. private _bloomKernel;
  66172. /**
  66173. * Specifies the size of the bloom blur kernel, relative to the final output size
  66174. */
  66175. get bloomKernel(): number;
  66176. set bloomKernel(value: number);
  66177. /**
  66178. * Specifies the weight of the bloom in the final rendering
  66179. */
  66180. private _bloomWeight;
  66181. /**
  66182. * Specifies the luma threshold for the area that will be blurred by the bloom
  66183. */
  66184. private _bloomThreshold;
  66185. private _hdr;
  66186. /**
  66187. * The strength of the bloom.
  66188. */
  66189. set bloomWeight(value: number);
  66190. get bloomWeight(): number;
  66191. /**
  66192. * The strength of the bloom.
  66193. */
  66194. set bloomThreshold(value: number);
  66195. get bloomThreshold(): number;
  66196. /**
  66197. * The scale of the bloom, lower value will provide better performance.
  66198. */
  66199. set bloomScale(value: number);
  66200. get bloomScale(): number;
  66201. /**
  66202. * Enable or disable the bloom from the pipeline
  66203. */
  66204. set bloomEnabled(enabled: boolean);
  66205. get bloomEnabled(): boolean;
  66206. private _rebuildBloom;
  66207. /**
  66208. * If the depth of field is enabled.
  66209. */
  66210. get depthOfFieldEnabled(): boolean;
  66211. set depthOfFieldEnabled(enabled: boolean);
  66212. /**
  66213. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66214. */
  66215. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66216. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66217. /**
  66218. * If the anti aliasing is enabled.
  66219. */
  66220. set fxaaEnabled(enabled: boolean);
  66221. get fxaaEnabled(): boolean;
  66222. private _samples;
  66223. /**
  66224. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66225. */
  66226. set samples(sampleCount: number);
  66227. get samples(): number;
  66228. /**
  66229. * If image processing is enabled.
  66230. */
  66231. set imageProcessingEnabled(enabled: boolean);
  66232. get imageProcessingEnabled(): boolean;
  66233. /**
  66234. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66235. */
  66236. set glowLayerEnabled(enabled: boolean);
  66237. get glowLayerEnabled(): boolean;
  66238. /**
  66239. * Gets the glow layer (or null if not defined)
  66240. */
  66241. get glowLayer(): Nullable<GlowLayer>;
  66242. /**
  66243. * Enable or disable the chromaticAberration process from the pipeline
  66244. */
  66245. set chromaticAberrationEnabled(enabled: boolean);
  66246. get chromaticAberrationEnabled(): boolean;
  66247. /**
  66248. * Enable or disable the grain process from the pipeline
  66249. */
  66250. set grainEnabled(enabled: boolean);
  66251. get grainEnabled(): boolean;
  66252. /**
  66253. * @constructor
  66254. * @param name - The rendering pipeline name (default: "")
  66255. * @param hdr - If high dynamic range textures should be used (default: true)
  66256. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66257. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66258. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66259. */
  66260. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66261. /**
  66262. * Get the class name
  66263. * @returns "DefaultRenderingPipeline"
  66264. */
  66265. getClassName(): string;
  66266. /**
  66267. * Force the compilation of the entire pipeline.
  66268. */
  66269. prepare(): void;
  66270. private _hasCleared;
  66271. private _prevPostProcess;
  66272. private _prevPrevPostProcess;
  66273. private _setAutoClearAndTextureSharing;
  66274. private _depthOfFieldSceneObserver;
  66275. private _buildPipeline;
  66276. private _disposePostProcesses;
  66277. /**
  66278. * Adds a camera to the pipeline
  66279. * @param camera the camera to be added
  66280. */
  66281. addCamera(camera: Camera): void;
  66282. /**
  66283. * Removes a camera from the pipeline
  66284. * @param camera the camera to remove
  66285. */
  66286. removeCamera(camera: Camera): void;
  66287. /**
  66288. * Dispose of the pipeline and stop all post processes
  66289. */
  66290. dispose(): void;
  66291. /**
  66292. * Serialize the rendering pipeline (Used when exporting)
  66293. * @returns the serialized object
  66294. */
  66295. serialize(): any;
  66296. /**
  66297. * Parse the serialized pipeline
  66298. * @param source Source pipeline.
  66299. * @param scene The scene to load the pipeline to.
  66300. * @param rootUrl The URL of the serialized pipeline.
  66301. * @returns An instantiated pipeline from the serialized object.
  66302. */
  66303. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66304. }
  66305. }
  66306. declare module BABYLON {
  66307. /** @hidden */
  66308. export var lensHighlightsPixelShader: {
  66309. name: string;
  66310. shader: string;
  66311. };
  66312. }
  66313. declare module BABYLON {
  66314. /** @hidden */
  66315. export var depthOfFieldPixelShader: {
  66316. name: string;
  66317. shader: string;
  66318. };
  66319. }
  66320. declare module BABYLON {
  66321. /**
  66322. * BABYLON.JS Chromatic Aberration GLSL Shader
  66323. * Author: Olivier Guyot
  66324. * Separates very slightly R, G and B colors on the edges of the screen
  66325. * Inspired by Francois Tarlier & Martins Upitis
  66326. */
  66327. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66328. /**
  66329. * @ignore
  66330. * The chromatic aberration PostProcess id in the pipeline
  66331. */
  66332. LensChromaticAberrationEffect: string;
  66333. /**
  66334. * @ignore
  66335. * The highlights enhancing PostProcess id in the pipeline
  66336. */
  66337. HighlightsEnhancingEffect: string;
  66338. /**
  66339. * @ignore
  66340. * The depth-of-field PostProcess id in the pipeline
  66341. */
  66342. LensDepthOfFieldEffect: string;
  66343. private _scene;
  66344. private _depthTexture;
  66345. private _grainTexture;
  66346. private _chromaticAberrationPostProcess;
  66347. private _highlightsPostProcess;
  66348. private _depthOfFieldPostProcess;
  66349. private _edgeBlur;
  66350. private _grainAmount;
  66351. private _chromaticAberration;
  66352. private _distortion;
  66353. private _highlightsGain;
  66354. private _highlightsThreshold;
  66355. private _dofDistance;
  66356. private _dofAperture;
  66357. private _dofDarken;
  66358. private _dofPentagon;
  66359. private _blurNoise;
  66360. /**
  66361. * @constructor
  66362. *
  66363. * Effect parameters are as follow:
  66364. * {
  66365. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66366. * edge_blur: number; // from 0 to x (1 for realism)
  66367. * distortion: number; // from 0 to x (1 for realism)
  66368. * grain_amount: number; // from 0 to 1
  66369. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66370. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66371. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66372. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66373. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66374. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66375. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66376. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66377. * }
  66378. * Note: if an effect parameter is unset, effect is disabled
  66379. *
  66380. * @param name The rendering pipeline name
  66381. * @param parameters - An object containing all parameters (see above)
  66382. * @param scene The scene linked to this pipeline
  66383. * @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)
  66384. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66385. */
  66386. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66387. /**
  66388. * Get the class name
  66389. * @returns "LensRenderingPipeline"
  66390. */
  66391. getClassName(): string;
  66392. /**
  66393. * Gets associated scene
  66394. */
  66395. get scene(): Scene;
  66396. /**
  66397. * Gets or sets the edge blur
  66398. */
  66399. get edgeBlur(): number;
  66400. set edgeBlur(value: number);
  66401. /**
  66402. * Gets or sets the grain amount
  66403. */
  66404. get grainAmount(): number;
  66405. set grainAmount(value: number);
  66406. /**
  66407. * Gets or sets the chromatic aberration amount
  66408. */
  66409. get chromaticAberration(): number;
  66410. set chromaticAberration(value: number);
  66411. /**
  66412. * Gets or sets the depth of field aperture
  66413. */
  66414. get dofAperture(): number;
  66415. set dofAperture(value: number);
  66416. /**
  66417. * Gets or sets the edge distortion
  66418. */
  66419. get edgeDistortion(): number;
  66420. set edgeDistortion(value: number);
  66421. /**
  66422. * Gets or sets the depth of field distortion
  66423. */
  66424. get dofDistortion(): number;
  66425. set dofDistortion(value: number);
  66426. /**
  66427. * Gets or sets the darken out of focus amount
  66428. */
  66429. get darkenOutOfFocus(): number;
  66430. set darkenOutOfFocus(value: number);
  66431. /**
  66432. * Gets or sets a boolean indicating if blur noise is enabled
  66433. */
  66434. get blurNoise(): boolean;
  66435. set blurNoise(value: boolean);
  66436. /**
  66437. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66438. */
  66439. get pentagonBokeh(): boolean;
  66440. set pentagonBokeh(value: boolean);
  66441. /**
  66442. * Gets or sets the highlight grain amount
  66443. */
  66444. get highlightsGain(): number;
  66445. set highlightsGain(value: number);
  66446. /**
  66447. * Gets or sets the highlight threshold
  66448. */
  66449. get highlightsThreshold(): number;
  66450. set highlightsThreshold(value: number);
  66451. /**
  66452. * Sets the amount of blur at the edges
  66453. * @param amount blur amount
  66454. */
  66455. setEdgeBlur(amount: number): void;
  66456. /**
  66457. * Sets edge blur to 0
  66458. */
  66459. disableEdgeBlur(): void;
  66460. /**
  66461. * Sets the amout of grain
  66462. * @param amount Amount of grain
  66463. */
  66464. setGrainAmount(amount: number): void;
  66465. /**
  66466. * Set grain amount to 0
  66467. */
  66468. disableGrain(): void;
  66469. /**
  66470. * Sets the chromatic aberration amount
  66471. * @param amount amount of chromatic aberration
  66472. */
  66473. setChromaticAberration(amount: number): void;
  66474. /**
  66475. * Sets chromatic aberration amount to 0
  66476. */
  66477. disableChromaticAberration(): void;
  66478. /**
  66479. * Sets the EdgeDistortion amount
  66480. * @param amount amount of EdgeDistortion
  66481. */
  66482. setEdgeDistortion(amount: number): void;
  66483. /**
  66484. * Sets edge distortion to 0
  66485. */
  66486. disableEdgeDistortion(): void;
  66487. /**
  66488. * Sets the FocusDistance amount
  66489. * @param amount amount of FocusDistance
  66490. */
  66491. setFocusDistance(amount: number): void;
  66492. /**
  66493. * Disables depth of field
  66494. */
  66495. disableDepthOfField(): void;
  66496. /**
  66497. * Sets the Aperture amount
  66498. * @param amount amount of Aperture
  66499. */
  66500. setAperture(amount: number): void;
  66501. /**
  66502. * Sets the DarkenOutOfFocus amount
  66503. * @param amount amount of DarkenOutOfFocus
  66504. */
  66505. setDarkenOutOfFocus(amount: number): void;
  66506. private _pentagonBokehIsEnabled;
  66507. /**
  66508. * Creates a pentagon bokeh effect
  66509. */
  66510. enablePentagonBokeh(): void;
  66511. /**
  66512. * Disables the pentagon bokeh effect
  66513. */
  66514. disablePentagonBokeh(): void;
  66515. /**
  66516. * Enables noise blur
  66517. */
  66518. enableNoiseBlur(): void;
  66519. /**
  66520. * Disables noise blur
  66521. */
  66522. disableNoiseBlur(): void;
  66523. /**
  66524. * Sets the HighlightsGain amount
  66525. * @param amount amount of HighlightsGain
  66526. */
  66527. setHighlightsGain(amount: number): void;
  66528. /**
  66529. * Sets the HighlightsThreshold amount
  66530. * @param amount amount of HighlightsThreshold
  66531. */
  66532. setHighlightsThreshold(amount: number): void;
  66533. /**
  66534. * Disables highlights
  66535. */
  66536. disableHighlights(): void;
  66537. /**
  66538. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66539. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66540. */
  66541. dispose(disableDepthRender?: boolean): void;
  66542. private _createChromaticAberrationPostProcess;
  66543. private _createHighlightsPostProcess;
  66544. private _createDepthOfFieldPostProcess;
  66545. private _createGrainTexture;
  66546. }
  66547. }
  66548. declare module BABYLON {
  66549. /** @hidden */
  66550. export var ssao2PixelShader: {
  66551. name: string;
  66552. shader: string;
  66553. };
  66554. }
  66555. declare module BABYLON {
  66556. /** @hidden */
  66557. export var ssaoCombinePixelShader: {
  66558. name: string;
  66559. shader: string;
  66560. };
  66561. }
  66562. declare module BABYLON {
  66563. /**
  66564. * Render pipeline to produce ssao effect
  66565. */
  66566. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66567. /**
  66568. * @ignore
  66569. * The PassPostProcess id in the pipeline that contains the original scene color
  66570. */
  66571. SSAOOriginalSceneColorEffect: string;
  66572. /**
  66573. * @ignore
  66574. * The SSAO PostProcess id in the pipeline
  66575. */
  66576. SSAORenderEffect: string;
  66577. /**
  66578. * @ignore
  66579. * The horizontal blur PostProcess id in the pipeline
  66580. */
  66581. SSAOBlurHRenderEffect: string;
  66582. /**
  66583. * @ignore
  66584. * The vertical blur PostProcess id in the pipeline
  66585. */
  66586. SSAOBlurVRenderEffect: string;
  66587. /**
  66588. * @ignore
  66589. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66590. */
  66591. SSAOCombineRenderEffect: string;
  66592. /**
  66593. * The output strength of the SSAO post-process. Default value is 1.0.
  66594. */
  66595. totalStrength: number;
  66596. /**
  66597. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66598. */
  66599. maxZ: number;
  66600. /**
  66601. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66602. */
  66603. minZAspect: number;
  66604. private _samples;
  66605. /**
  66606. * Number of samples used for the SSAO calculations. Default value is 8
  66607. */
  66608. set samples(n: number);
  66609. get samples(): number;
  66610. private _textureSamples;
  66611. /**
  66612. * Number of samples to use for antialiasing
  66613. */
  66614. set textureSamples(n: number);
  66615. get textureSamples(): number;
  66616. /**
  66617. * Ratio object used for SSAO ratio and blur ratio
  66618. */
  66619. private _ratio;
  66620. /**
  66621. * Dynamically generated sphere sampler.
  66622. */
  66623. private _sampleSphere;
  66624. /**
  66625. * Blur filter offsets
  66626. */
  66627. private _samplerOffsets;
  66628. private _expensiveBlur;
  66629. /**
  66630. * If bilateral blur should be used
  66631. */
  66632. set expensiveBlur(b: boolean);
  66633. get expensiveBlur(): boolean;
  66634. /**
  66635. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66636. */
  66637. radius: number;
  66638. /**
  66639. * The base color of the SSAO post-process
  66640. * The final result is "base + ssao" between [0, 1]
  66641. */
  66642. base: number;
  66643. /**
  66644. * Support test.
  66645. */
  66646. static get IsSupported(): boolean;
  66647. private _scene;
  66648. private _depthTexture;
  66649. private _normalTexture;
  66650. private _randomTexture;
  66651. private _originalColorPostProcess;
  66652. private _ssaoPostProcess;
  66653. private _blurHPostProcess;
  66654. private _blurVPostProcess;
  66655. private _ssaoCombinePostProcess;
  66656. /**
  66657. * Gets active scene
  66658. */
  66659. get scene(): Scene;
  66660. /**
  66661. * @constructor
  66662. * @param name The rendering pipeline name
  66663. * @param scene The scene linked to this pipeline
  66664. * @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 }
  66665. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66666. */
  66667. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66668. /**
  66669. * Get the class name
  66670. * @returns "SSAO2RenderingPipeline"
  66671. */
  66672. getClassName(): string;
  66673. /**
  66674. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66675. */
  66676. dispose(disableGeometryBufferRenderer?: boolean): void;
  66677. private _createBlurPostProcess;
  66678. /** @hidden */
  66679. _rebuild(): void;
  66680. private _bits;
  66681. private _radicalInverse_VdC;
  66682. private _hammersley;
  66683. private _hemisphereSample_uniform;
  66684. private _generateHemisphere;
  66685. private _createSSAOPostProcess;
  66686. private _createSSAOCombinePostProcess;
  66687. private _createRandomTexture;
  66688. /**
  66689. * Serialize the rendering pipeline (Used when exporting)
  66690. * @returns the serialized object
  66691. */
  66692. serialize(): any;
  66693. /**
  66694. * Parse the serialized pipeline
  66695. * @param source Source pipeline.
  66696. * @param scene The scene to load the pipeline to.
  66697. * @param rootUrl The URL of the serialized pipeline.
  66698. * @returns An instantiated pipeline from the serialized object.
  66699. */
  66700. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66701. }
  66702. }
  66703. declare module BABYLON {
  66704. /** @hidden */
  66705. export var ssaoPixelShader: {
  66706. name: string;
  66707. shader: string;
  66708. };
  66709. }
  66710. declare module BABYLON {
  66711. /**
  66712. * Render pipeline to produce ssao effect
  66713. */
  66714. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66715. /**
  66716. * @ignore
  66717. * The PassPostProcess id in the pipeline that contains the original scene color
  66718. */
  66719. SSAOOriginalSceneColorEffect: string;
  66720. /**
  66721. * @ignore
  66722. * The SSAO PostProcess id in the pipeline
  66723. */
  66724. SSAORenderEffect: string;
  66725. /**
  66726. * @ignore
  66727. * The horizontal blur PostProcess id in the pipeline
  66728. */
  66729. SSAOBlurHRenderEffect: string;
  66730. /**
  66731. * @ignore
  66732. * The vertical blur PostProcess id in the pipeline
  66733. */
  66734. SSAOBlurVRenderEffect: string;
  66735. /**
  66736. * @ignore
  66737. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66738. */
  66739. SSAOCombineRenderEffect: string;
  66740. /**
  66741. * The output strength of the SSAO post-process. Default value is 1.0.
  66742. */
  66743. totalStrength: number;
  66744. /**
  66745. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66746. */
  66747. radius: number;
  66748. /**
  66749. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66750. * Must not be equal to fallOff and superior to fallOff.
  66751. * Default value is 0.0075
  66752. */
  66753. area: number;
  66754. /**
  66755. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66756. * Must not be equal to area and inferior to area.
  66757. * Default value is 0.000001
  66758. */
  66759. fallOff: number;
  66760. /**
  66761. * The base color of the SSAO post-process
  66762. * The final result is "base + ssao" between [0, 1]
  66763. */
  66764. base: number;
  66765. private _scene;
  66766. private _depthTexture;
  66767. private _randomTexture;
  66768. private _originalColorPostProcess;
  66769. private _ssaoPostProcess;
  66770. private _blurHPostProcess;
  66771. private _blurVPostProcess;
  66772. private _ssaoCombinePostProcess;
  66773. private _firstUpdate;
  66774. /**
  66775. * Gets active scene
  66776. */
  66777. get scene(): Scene;
  66778. /**
  66779. * @constructor
  66780. * @param name - The rendering pipeline name
  66781. * @param scene - The scene linked to this pipeline
  66782. * @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 }
  66783. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66784. */
  66785. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66786. /**
  66787. * Get the class name
  66788. * @returns "SSAORenderingPipeline"
  66789. */
  66790. getClassName(): string;
  66791. /**
  66792. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66793. */
  66794. dispose(disableDepthRender?: boolean): void;
  66795. private _createBlurPostProcess;
  66796. /** @hidden */
  66797. _rebuild(): void;
  66798. private _createSSAOPostProcess;
  66799. private _createSSAOCombinePostProcess;
  66800. private _createRandomTexture;
  66801. }
  66802. }
  66803. declare module BABYLON {
  66804. /** @hidden */
  66805. export var screenSpaceReflectionPixelShader: {
  66806. name: string;
  66807. shader: string;
  66808. };
  66809. }
  66810. declare module BABYLON {
  66811. /**
  66812. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66813. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66814. */
  66815. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66816. /**
  66817. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66818. */
  66819. threshold: number;
  66820. /**
  66821. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66822. */
  66823. strength: number;
  66824. /**
  66825. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66826. */
  66827. reflectionSpecularFalloffExponent: number;
  66828. /**
  66829. * 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]
  66830. */
  66831. step: number;
  66832. /**
  66833. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66834. */
  66835. roughnessFactor: number;
  66836. private _geometryBufferRenderer;
  66837. private _enableSmoothReflections;
  66838. private _reflectionSamples;
  66839. private _smoothSteps;
  66840. /**
  66841. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66842. * @param name The name of the effect.
  66843. * @param scene The scene containing the objects to calculate reflections.
  66844. * @param options The required width/height ratio to downsize to before computing the render pass.
  66845. * @param camera The camera to apply the render pass to.
  66846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66847. * @param engine The engine which the post process will be applied. (default: current engine)
  66848. * @param reusable If the post process can be reused on the same frame. (default: false)
  66849. * @param textureType Type of textures used when performing the post process. (default: 0)
  66850. * @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)
  66851. */
  66852. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66853. /**
  66854. * Gets wether or not smoothing reflections is enabled.
  66855. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66856. */
  66857. get enableSmoothReflections(): boolean;
  66858. /**
  66859. * Sets wether or not smoothing reflections is enabled.
  66860. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66861. */
  66862. set enableSmoothReflections(enabled: boolean);
  66863. /**
  66864. * Gets the number of samples taken while computing reflections. More samples count is high,
  66865. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66866. */
  66867. get reflectionSamples(): number;
  66868. /**
  66869. * Sets the number of samples taken while computing reflections. More samples count is high,
  66870. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66871. */
  66872. set reflectionSamples(samples: number);
  66873. /**
  66874. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66875. * more the post-process will require GPU power and can generate a drop in FPS.
  66876. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66877. */
  66878. get smoothSteps(): number;
  66879. set smoothSteps(steps: number);
  66880. private _updateEffectDefines;
  66881. }
  66882. }
  66883. declare module BABYLON {
  66884. /** @hidden */
  66885. export var standardPixelShader: {
  66886. name: string;
  66887. shader: string;
  66888. };
  66889. }
  66890. declare module BABYLON {
  66891. /**
  66892. * Standard rendering pipeline
  66893. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66894. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66895. */
  66896. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66897. /**
  66898. * Public members
  66899. */
  66900. /**
  66901. * Post-process which contains the original scene color before the pipeline applies all the effects
  66902. */
  66903. originalPostProcess: Nullable<PostProcess>;
  66904. /**
  66905. * Post-process used to down scale an image x4
  66906. */
  66907. downSampleX4PostProcess: Nullable<PostProcess>;
  66908. /**
  66909. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66910. */
  66911. brightPassPostProcess: Nullable<PostProcess>;
  66912. /**
  66913. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66914. */
  66915. blurHPostProcesses: PostProcess[];
  66916. /**
  66917. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66918. */
  66919. blurVPostProcesses: PostProcess[];
  66920. /**
  66921. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66922. */
  66923. textureAdderPostProcess: Nullable<PostProcess>;
  66924. /**
  66925. * Post-process used to create volumetric lighting effect
  66926. */
  66927. volumetricLightPostProcess: Nullable<PostProcess>;
  66928. /**
  66929. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66930. */
  66931. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66932. /**
  66933. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66934. */
  66935. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66936. /**
  66937. * Post-process used to merge the volumetric light effect and the real scene color
  66938. */
  66939. volumetricLightMergePostProces: Nullable<PostProcess>;
  66940. /**
  66941. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66942. */
  66943. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66944. /**
  66945. * Base post-process used to calculate the average luminance of the final image for HDR
  66946. */
  66947. luminancePostProcess: Nullable<PostProcess>;
  66948. /**
  66949. * Post-processes used to create down sample post-processes in order to get
  66950. * the average luminance of the final image for HDR
  66951. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66952. */
  66953. luminanceDownSamplePostProcesses: PostProcess[];
  66954. /**
  66955. * Post-process used to create a HDR effect (light adaptation)
  66956. */
  66957. hdrPostProcess: Nullable<PostProcess>;
  66958. /**
  66959. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66960. */
  66961. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66962. /**
  66963. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66964. */
  66965. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66966. /**
  66967. * Post-process used to merge the final HDR post-process and the real scene color
  66968. */
  66969. hdrFinalPostProcess: Nullable<PostProcess>;
  66970. /**
  66971. * Post-process used to create a lens flare effect
  66972. */
  66973. lensFlarePostProcess: Nullable<PostProcess>;
  66974. /**
  66975. * Post-process that merges the result of the lens flare post-process and the real scene color
  66976. */
  66977. lensFlareComposePostProcess: Nullable<PostProcess>;
  66978. /**
  66979. * Post-process used to create a motion blur effect
  66980. */
  66981. motionBlurPostProcess: Nullable<PostProcess>;
  66982. /**
  66983. * Post-process used to create a depth of field effect
  66984. */
  66985. depthOfFieldPostProcess: Nullable<PostProcess>;
  66986. /**
  66987. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66988. */
  66989. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66990. /**
  66991. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66992. */
  66993. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66994. /**
  66995. * Represents the brightness threshold in order to configure the illuminated surfaces
  66996. */
  66997. brightThreshold: number;
  66998. /**
  66999. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67000. */
  67001. blurWidth: number;
  67002. /**
  67003. * Sets if the blur for highlighted surfaces must be only horizontal
  67004. */
  67005. horizontalBlur: boolean;
  67006. /**
  67007. * Gets the overall exposure used by the pipeline
  67008. */
  67009. get exposure(): number;
  67010. /**
  67011. * Sets the overall exposure used by the pipeline
  67012. */
  67013. set exposure(value: number);
  67014. /**
  67015. * Texture used typically to simulate "dirty" on camera lens
  67016. */
  67017. lensTexture: Nullable<Texture>;
  67018. /**
  67019. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67020. */
  67021. volumetricLightCoefficient: number;
  67022. /**
  67023. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67024. */
  67025. volumetricLightPower: number;
  67026. /**
  67027. * Used the set the blur intensity to smooth the volumetric lights
  67028. */
  67029. volumetricLightBlurScale: number;
  67030. /**
  67031. * Light (spot or directional) used to generate the volumetric lights rays
  67032. * The source light must have a shadow generate so the pipeline can get its
  67033. * depth map
  67034. */
  67035. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67036. /**
  67037. * For eye adaptation, represents the minimum luminance the eye can see
  67038. */
  67039. hdrMinimumLuminance: number;
  67040. /**
  67041. * For eye adaptation, represents the decrease luminance speed
  67042. */
  67043. hdrDecreaseRate: number;
  67044. /**
  67045. * For eye adaptation, represents the increase luminance speed
  67046. */
  67047. hdrIncreaseRate: number;
  67048. /**
  67049. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67050. */
  67051. get hdrAutoExposure(): boolean;
  67052. /**
  67053. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67054. */
  67055. set hdrAutoExposure(value: boolean);
  67056. /**
  67057. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67058. */
  67059. lensColorTexture: Nullable<Texture>;
  67060. /**
  67061. * The overall strengh for the lens flare effect
  67062. */
  67063. lensFlareStrength: number;
  67064. /**
  67065. * Dispersion coefficient for lens flare ghosts
  67066. */
  67067. lensFlareGhostDispersal: number;
  67068. /**
  67069. * Main lens flare halo width
  67070. */
  67071. lensFlareHaloWidth: number;
  67072. /**
  67073. * Based on the lens distortion effect, defines how much the lens flare result
  67074. * is distorted
  67075. */
  67076. lensFlareDistortionStrength: number;
  67077. /**
  67078. * Configures the blur intensity used for for lens flare (halo)
  67079. */
  67080. lensFlareBlurWidth: number;
  67081. /**
  67082. * Lens star texture must be used to simulate rays on the flares and is available
  67083. * in the documentation
  67084. */
  67085. lensStarTexture: Nullable<Texture>;
  67086. /**
  67087. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67088. * flare effect by taking account of the dirt texture
  67089. */
  67090. lensFlareDirtTexture: Nullable<Texture>;
  67091. /**
  67092. * Represents the focal length for the depth of field effect
  67093. */
  67094. depthOfFieldDistance: number;
  67095. /**
  67096. * Represents the blur intensity for the blurred part of the depth of field effect
  67097. */
  67098. depthOfFieldBlurWidth: number;
  67099. /**
  67100. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67101. */
  67102. get motionStrength(): number;
  67103. /**
  67104. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67105. */
  67106. set motionStrength(strength: number);
  67107. /**
  67108. * Gets wether or not the motion blur post-process is object based or screen based.
  67109. */
  67110. get objectBasedMotionBlur(): boolean;
  67111. /**
  67112. * Sets wether or not the motion blur post-process should be object based or screen based
  67113. */
  67114. set objectBasedMotionBlur(value: boolean);
  67115. /**
  67116. * List of animations for the pipeline (IAnimatable implementation)
  67117. */
  67118. animations: Animation[];
  67119. /**
  67120. * Private members
  67121. */
  67122. private _scene;
  67123. private _currentDepthOfFieldSource;
  67124. private _basePostProcess;
  67125. private _fixedExposure;
  67126. private _currentExposure;
  67127. private _hdrAutoExposure;
  67128. private _hdrCurrentLuminance;
  67129. private _motionStrength;
  67130. private _isObjectBasedMotionBlur;
  67131. private _floatTextureType;
  67132. private _camerasToBeAttached;
  67133. private _ratio;
  67134. private _bloomEnabled;
  67135. private _depthOfFieldEnabled;
  67136. private _vlsEnabled;
  67137. private _lensFlareEnabled;
  67138. private _hdrEnabled;
  67139. private _motionBlurEnabled;
  67140. private _fxaaEnabled;
  67141. private _screenSpaceReflectionsEnabled;
  67142. private _motionBlurSamples;
  67143. private _volumetricLightStepsCount;
  67144. private _samples;
  67145. /**
  67146. * @ignore
  67147. * Specifies if the bloom pipeline is enabled
  67148. */
  67149. get BloomEnabled(): boolean;
  67150. set BloomEnabled(enabled: boolean);
  67151. /**
  67152. * @ignore
  67153. * Specifies if the depth of field pipeline is enabed
  67154. */
  67155. get DepthOfFieldEnabled(): boolean;
  67156. set DepthOfFieldEnabled(enabled: boolean);
  67157. /**
  67158. * @ignore
  67159. * Specifies if the lens flare pipeline is enabed
  67160. */
  67161. get LensFlareEnabled(): boolean;
  67162. set LensFlareEnabled(enabled: boolean);
  67163. /**
  67164. * @ignore
  67165. * Specifies if the HDR pipeline is enabled
  67166. */
  67167. get HDREnabled(): boolean;
  67168. set HDREnabled(enabled: boolean);
  67169. /**
  67170. * @ignore
  67171. * Specifies if the volumetric lights scattering effect is enabled
  67172. */
  67173. get VLSEnabled(): boolean;
  67174. set VLSEnabled(enabled: boolean);
  67175. /**
  67176. * @ignore
  67177. * Specifies if the motion blur effect is enabled
  67178. */
  67179. get MotionBlurEnabled(): boolean;
  67180. set MotionBlurEnabled(enabled: boolean);
  67181. /**
  67182. * Specifies if anti-aliasing is enabled
  67183. */
  67184. get fxaaEnabled(): boolean;
  67185. set fxaaEnabled(enabled: boolean);
  67186. /**
  67187. * Specifies if screen space reflections are enabled.
  67188. */
  67189. get screenSpaceReflectionsEnabled(): boolean;
  67190. set screenSpaceReflectionsEnabled(enabled: boolean);
  67191. /**
  67192. * Specifies the number of steps used to calculate the volumetric lights
  67193. * Typically in interval [50, 200]
  67194. */
  67195. get volumetricLightStepsCount(): number;
  67196. set volumetricLightStepsCount(count: number);
  67197. /**
  67198. * Specifies the number of samples used for the motion blur effect
  67199. * Typically in interval [16, 64]
  67200. */
  67201. get motionBlurSamples(): number;
  67202. set motionBlurSamples(samples: number);
  67203. /**
  67204. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67205. */
  67206. get samples(): number;
  67207. set samples(sampleCount: number);
  67208. /**
  67209. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67210. * @constructor
  67211. * @param name The rendering pipeline name
  67212. * @param scene The scene linked to this pipeline
  67213. * @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)
  67214. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67215. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67216. */
  67217. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67218. private _buildPipeline;
  67219. private _createDownSampleX4PostProcess;
  67220. private _createBrightPassPostProcess;
  67221. private _createBlurPostProcesses;
  67222. private _createTextureAdderPostProcess;
  67223. private _createVolumetricLightPostProcess;
  67224. private _createLuminancePostProcesses;
  67225. private _createHdrPostProcess;
  67226. private _createLensFlarePostProcess;
  67227. private _createDepthOfFieldPostProcess;
  67228. private _createMotionBlurPostProcess;
  67229. private _getDepthTexture;
  67230. private _disposePostProcesses;
  67231. /**
  67232. * Dispose of the pipeline and stop all post processes
  67233. */
  67234. dispose(): void;
  67235. /**
  67236. * Serialize the rendering pipeline (Used when exporting)
  67237. * @returns the serialized object
  67238. */
  67239. serialize(): any;
  67240. /**
  67241. * Parse the serialized pipeline
  67242. * @param source Source pipeline.
  67243. * @param scene The scene to load the pipeline to.
  67244. * @param rootUrl The URL of the serialized pipeline.
  67245. * @returns An instantiated pipeline from the serialized object.
  67246. */
  67247. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67248. /**
  67249. * Luminance steps
  67250. */
  67251. static LuminanceSteps: number;
  67252. }
  67253. }
  67254. declare module BABYLON {
  67255. /** @hidden */
  67256. export var stereoscopicInterlacePixelShader: {
  67257. name: string;
  67258. shader: string;
  67259. };
  67260. }
  67261. declare module BABYLON {
  67262. /**
  67263. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  67264. */
  67265. export class StereoscopicInterlacePostProcessI extends PostProcess {
  67266. private _stepSize;
  67267. private _passedProcess;
  67268. /**
  67269. * Initializes a StereoscopicInterlacePostProcessI
  67270. * @param name The name of the effect.
  67271. * @param rigCameras The rig cameras to be appled to the post process
  67272. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  67273. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  67274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67275. * @param engine The engine which the post process will be applied. (default: current engine)
  67276. * @param reusable If the post process can be reused on the same frame. (default: false)
  67277. */
  67278. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67279. }
  67280. /**
  67281. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  67282. */
  67283. export class StereoscopicInterlacePostProcess extends PostProcess {
  67284. private _stepSize;
  67285. private _passedProcess;
  67286. /**
  67287. * Initializes a StereoscopicInterlacePostProcess
  67288. * @param name The name of the effect.
  67289. * @param rigCameras The rig cameras to be appled to the post process
  67290. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  67291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67292. * @param engine The engine which the post process will be applied. (default: current engine)
  67293. * @param reusable If the post process can be reused on the same frame. (default: false)
  67294. */
  67295. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67296. }
  67297. }
  67298. declare module BABYLON {
  67299. /** @hidden */
  67300. export var tonemapPixelShader: {
  67301. name: string;
  67302. shader: string;
  67303. };
  67304. }
  67305. declare module BABYLON {
  67306. /** Defines operator used for tonemapping */
  67307. export enum TonemappingOperator {
  67308. /** Hable */
  67309. Hable = 0,
  67310. /** Reinhard */
  67311. Reinhard = 1,
  67312. /** HejiDawson */
  67313. HejiDawson = 2,
  67314. /** Photographic */
  67315. Photographic = 3
  67316. }
  67317. /**
  67318. * Defines a post process to apply tone mapping
  67319. */
  67320. export class TonemapPostProcess extends PostProcess {
  67321. private _operator;
  67322. /** Defines the required exposure adjustement */
  67323. exposureAdjustment: number;
  67324. /**
  67325. * Creates a new TonemapPostProcess
  67326. * @param name defines the name of the postprocess
  67327. * @param _operator defines the operator to use
  67328. * @param exposureAdjustment defines the required exposure adjustement
  67329. * @param camera defines the camera to use (can be null)
  67330. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67331. * @param engine defines the hosting engine (can be ignore if camera is set)
  67332. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67333. */
  67334. constructor(name: string, _operator: TonemappingOperator,
  67335. /** Defines the required exposure adjustement */
  67336. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67337. }
  67338. }
  67339. declare module BABYLON {
  67340. /** @hidden */
  67341. export var volumetricLightScatteringPixelShader: {
  67342. name: string;
  67343. shader: string;
  67344. };
  67345. }
  67346. declare module BABYLON {
  67347. /** @hidden */
  67348. export var volumetricLightScatteringPassVertexShader: {
  67349. name: string;
  67350. shader: string;
  67351. };
  67352. }
  67353. declare module BABYLON {
  67354. /** @hidden */
  67355. export var volumetricLightScatteringPassPixelShader: {
  67356. name: string;
  67357. shader: string;
  67358. };
  67359. }
  67360. declare module BABYLON {
  67361. /**
  67362. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67363. */
  67364. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67365. private _volumetricLightScatteringPass;
  67366. private _volumetricLightScatteringRTT;
  67367. private _viewPort;
  67368. private _screenCoordinates;
  67369. private _cachedDefines;
  67370. /**
  67371. * If not undefined, the mesh position is computed from the attached node position
  67372. */
  67373. attachedNode: {
  67374. position: Vector3;
  67375. };
  67376. /**
  67377. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67378. */
  67379. customMeshPosition: Vector3;
  67380. /**
  67381. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67382. */
  67383. useCustomMeshPosition: boolean;
  67384. /**
  67385. * If the post-process should inverse the light scattering direction
  67386. */
  67387. invert: boolean;
  67388. /**
  67389. * The internal mesh used by the post-process
  67390. */
  67391. mesh: Mesh;
  67392. /**
  67393. * @hidden
  67394. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67395. */
  67396. get useDiffuseColor(): boolean;
  67397. set useDiffuseColor(useDiffuseColor: boolean);
  67398. /**
  67399. * Array containing the excluded meshes not rendered in the internal pass
  67400. */
  67401. excludedMeshes: AbstractMesh[];
  67402. /**
  67403. * Controls the overall intensity of the post-process
  67404. */
  67405. exposure: number;
  67406. /**
  67407. * Dissipates each sample's contribution in range [0, 1]
  67408. */
  67409. decay: number;
  67410. /**
  67411. * Controls the overall intensity of each sample
  67412. */
  67413. weight: number;
  67414. /**
  67415. * Controls the density of each sample
  67416. */
  67417. density: number;
  67418. /**
  67419. * @constructor
  67420. * @param name The post-process name
  67421. * @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)
  67422. * @param camera The camera that the post-process will be attached to
  67423. * @param mesh The mesh used to create the light scattering
  67424. * @param samples The post-process quality, default 100
  67425. * @param samplingModeThe post-process filtering mode
  67426. * @param engine The babylon engine
  67427. * @param reusable If the post-process is reusable
  67428. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67429. */
  67430. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67431. /**
  67432. * Returns the string "VolumetricLightScatteringPostProcess"
  67433. * @returns "VolumetricLightScatteringPostProcess"
  67434. */
  67435. getClassName(): string;
  67436. private _isReady;
  67437. /**
  67438. * Sets the new light position for light scattering effect
  67439. * @param position The new custom light position
  67440. */
  67441. setCustomMeshPosition(position: Vector3): void;
  67442. /**
  67443. * Returns the light position for light scattering effect
  67444. * @return Vector3 The custom light position
  67445. */
  67446. getCustomMeshPosition(): Vector3;
  67447. /**
  67448. * Disposes the internal assets and detaches the post-process from the camera
  67449. */
  67450. dispose(camera: Camera): void;
  67451. /**
  67452. * Returns the render target texture used by the post-process
  67453. * @return the render target texture used by the post-process
  67454. */
  67455. getPass(): RenderTargetTexture;
  67456. private _meshExcluded;
  67457. private _createPass;
  67458. private _updateMeshScreenCoordinates;
  67459. /**
  67460. * Creates a default mesh for the Volumeric Light Scattering post-process
  67461. * @param name The mesh name
  67462. * @param scene The scene where to create the mesh
  67463. * @return the default mesh
  67464. */
  67465. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67466. }
  67467. }
  67468. declare module BABYLON {
  67469. interface Scene {
  67470. /** @hidden (Backing field) */
  67471. _boundingBoxRenderer: BoundingBoxRenderer;
  67472. /** @hidden (Backing field) */
  67473. _forceShowBoundingBoxes: boolean;
  67474. /**
  67475. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67476. */
  67477. forceShowBoundingBoxes: boolean;
  67478. /**
  67479. * Gets the bounding box renderer associated with the scene
  67480. * @returns a BoundingBoxRenderer
  67481. */
  67482. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67483. }
  67484. interface AbstractMesh {
  67485. /** @hidden (Backing field) */
  67486. _showBoundingBox: boolean;
  67487. /**
  67488. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67489. */
  67490. showBoundingBox: boolean;
  67491. }
  67492. /**
  67493. * Component responsible of rendering the bounding box of the meshes in a scene.
  67494. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67495. */
  67496. export class BoundingBoxRenderer implements ISceneComponent {
  67497. /**
  67498. * The component name helpfull to identify the component in the list of scene components.
  67499. */
  67500. readonly name: string;
  67501. /**
  67502. * The scene the component belongs to.
  67503. */
  67504. scene: Scene;
  67505. /**
  67506. * Color of the bounding box lines placed in front of an object
  67507. */
  67508. frontColor: Color3;
  67509. /**
  67510. * Color of the bounding box lines placed behind an object
  67511. */
  67512. backColor: Color3;
  67513. /**
  67514. * Defines if the renderer should show the back lines or not
  67515. */
  67516. showBackLines: boolean;
  67517. /**
  67518. * @hidden
  67519. */
  67520. renderList: SmartArray<BoundingBox>;
  67521. private _colorShader;
  67522. private _vertexBuffers;
  67523. private _indexBuffer;
  67524. private _fillIndexBuffer;
  67525. private _fillIndexData;
  67526. /**
  67527. * Instantiates a new bounding box renderer in a scene.
  67528. * @param scene the scene the renderer renders in
  67529. */
  67530. constructor(scene: Scene);
  67531. /**
  67532. * Registers the component in a given scene
  67533. */
  67534. register(): void;
  67535. private _evaluateSubMesh;
  67536. private _activeMesh;
  67537. private _prepareRessources;
  67538. private _createIndexBuffer;
  67539. /**
  67540. * Rebuilds the elements related to this component in case of
  67541. * context lost for instance.
  67542. */
  67543. rebuild(): void;
  67544. /**
  67545. * @hidden
  67546. */
  67547. reset(): void;
  67548. /**
  67549. * Render the bounding boxes of a specific rendering group
  67550. * @param renderingGroupId defines the rendering group to render
  67551. */
  67552. render(renderingGroupId: number): void;
  67553. /**
  67554. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67555. * @param mesh Define the mesh to render the occlusion bounding box for
  67556. */
  67557. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67558. /**
  67559. * Dispose and release the resources attached to this renderer.
  67560. */
  67561. dispose(): void;
  67562. }
  67563. }
  67564. declare module BABYLON {
  67565. interface Scene {
  67566. /** @hidden (Backing field) */
  67567. _depthRenderer: {
  67568. [id: string]: DepthRenderer;
  67569. };
  67570. /**
  67571. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67572. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67573. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67574. * @returns the created depth renderer
  67575. */
  67576. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67577. /**
  67578. * Disables a depth renderer for a given camera
  67579. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67580. */
  67581. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67582. }
  67583. /**
  67584. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67585. * in several rendering techniques.
  67586. */
  67587. export class DepthRendererSceneComponent implements ISceneComponent {
  67588. /**
  67589. * The component name helpfull to identify the component in the list of scene components.
  67590. */
  67591. readonly name: string;
  67592. /**
  67593. * The scene the component belongs to.
  67594. */
  67595. scene: Scene;
  67596. /**
  67597. * Creates a new instance of the component for the given scene
  67598. * @param scene Defines the scene to register the component in
  67599. */
  67600. constructor(scene: Scene);
  67601. /**
  67602. * Registers the component in a given scene
  67603. */
  67604. register(): void;
  67605. /**
  67606. * Rebuilds the elements related to this component in case of
  67607. * context lost for instance.
  67608. */
  67609. rebuild(): void;
  67610. /**
  67611. * Disposes the component and the associated ressources
  67612. */
  67613. dispose(): void;
  67614. private _gatherRenderTargets;
  67615. private _gatherActiveCameraRenderTargets;
  67616. }
  67617. }
  67618. declare module BABYLON {
  67619. /** @hidden */
  67620. export var outlinePixelShader: {
  67621. name: string;
  67622. shader: string;
  67623. };
  67624. }
  67625. declare module BABYLON {
  67626. /** @hidden */
  67627. export var outlineVertexShader: {
  67628. name: string;
  67629. shader: string;
  67630. };
  67631. }
  67632. declare module BABYLON {
  67633. interface Scene {
  67634. /** @hidden */
  67635. _outlineRenderer: OutlineRenderer;
  67636. /**
  67637. * Gets the outline renderer associated with the scene
  67638. * @returns a OutlineRenderer
  67639. */
  67640. getOutlineRenderer(): OutlineRenderer;
  67641. }
  67642. interface AbstractMesh {
  67643. /** @hidden (Backing field) */
  67644. _renderOutline: boolean;
  67645. /**
  67646. * Gets or sets a boolean indicating if the outline must be rendered as well
  67647. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67648. */
  67649. renderOutline: boolean;
  67650. /** @hidden (Backing field) */
  67651. _renderOverlay: boolean;
  67652. /**
  67653. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67654. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67655. */
  67656. renderOverlay: boolean;
  67657. }
  67658. /**
  67659. * This class is responsible to draw bothe outline/overlay of meshes.
  67660. * It should not be used directly but through the available method on mesh.
  67661. */
  67662. export class OutlineRenderer implements ISceneComponent {
  67663. /**
  67664. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67665. */
  67666. private static _StencilReference;
  67667. /**
  67668. * The name of the component. Each component must have a unique name.
  67669. */
  67670. name: string;
  67671. /**
  67672. * The scene the component belongs to.
  67673. */
  67674. scene: Scene;
  67675. /**
  67676. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67677. */
  67678. zOffset: number;
  67679. private _engine;
  67680. private _effect;
  67681. private _cachedDefines;
  67682. private _savedDepthWrite;
  67683. /**
  67684. * Instantiates a new outline renderer. (There could be only one per scene).
  67685. * @param scene Defines the scene it belongs to
  67686. */
  67687. constructor(scene: Scene);
  67688. /**
  67689. * Register the component to one instance of a scene.
  67690. */
  67691. register(): void;
  67692. /**
  67693. * Rebuilds the elements related to this component in case of
  67694. * context lost for instance.
  67695. */
  67696. rebuild(): void;
  67697. /**
  67698. * Disposes the component and the associated ressources.
  67699. */
  67700. dispose(): void;
  67701. /**
  67702. * Renders the outline in the canvas.
  67703. * @param subMesh Defines the sumesh to render
  67704. * @param batch Defines the batch of meshes in case of instances
  67705. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67706. */
  67707. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67708. /**
  67709. * Returns whether or not the outline renderer is ready for a given submesh.
  67710. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67711. * @param subMesh Defines the submesh to check readyness for
  67712. * @param useInstances Defines wheter wee are trying to render instances or not
  67713. * @returns true if ready otherwise false
  67714. */
  67715. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67716. private _beforeRenderingMesh;
  67717. private _afterRenderingMesh;
  67718. }
  67719. }
  67720. declare module BABYLON {
  67721. /**
  67722. * Defines the basic options interface of a Sprite Frame Source Size.
  67723. */
  67724. export interface ISpriteJSONSpriteSourceSize {
  67725. /**
  67726. * number of the original width of the Frame
  67727. */
  67728. w: number;
  67729. /**
  67730. * number of the original height of the Frame
  67731. */
  67732. h: number;
  67733. }
  67734. /**
  67735. * Defines the basic options interface of a Sprite Frame Data.
  67736. */
  67737. export interface ISpriteJSONSpriteFrameData {
  67738. /**
  67739. * number of the x offset of the Frame
  67740. */
  67741. x: number;
  67742. /**
  67743. * number of the y offset of the Frame
  67744. */
  67745. y: number;
  67746. /**
  67747. * number of the width of the Frame
  67748. */
  67749. w: number;
  67750. /**
  67751. * number of the height of the Frame
  67752. */
  67753. h: number;
  67754. }
  67755. /**
  67756. * Defines the basic options interface of a JSON Sprite.
  67757. */
  67758. export interface ISpriteJSONSprite {
  67759. /**
  67760. * string name of the Frame
  67761. */
  67762. filename: string;
  67763. /**
  67764. * ISpriteJSONSpriteFrame basic object of the frame data
  67765. */
  67766. frame: ISpriteJSONSpriteFrameData;
  67767. /**
  67768. * boolean to flag is the frame was rotated.
  67769. */
  67770. rotated: boolean;
  67771. /**
  67772. * boolean to flag is the frame was trimmed.
  67773. */
  67774. trimmed: boolean;
  67775. /**
  67776. * ISpriteJSONSpriteFrame basic object of the source data
  67777. */
  67778. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67779. /**
  67780. * ISpriteJSONSpriteFrame basic object of the source data
  67781. */
  67782. sourceSize: ISpriteJSONSpriteSourceSize;
  67783. }
  67784. /**
  67785. * Defines the basic options interface of a JSON atlas.
  67786. */
  67787. export interface ISpriteJSONAtlas {
  67788. /**
  67789. * Array of objects that contain the frame data.
  67790. */
  67791. frames: Array<ISpriteJSONSprite>;
  67792. /**
  67793. * object basic object containing the sprite meta data.
  67794. */
  67795. meta?: object;
  67796. }
  67797. }
  67798. declare module BABYLON {
  67799. /** @hidden */
  67800. export var spriteMapPixelShader: {
  67801. name: string;
  67802. shader: string;
  67803. };
  67804. }
  67805. declare module BABYLON {
  67806. /** @hidden */
  67807. export var spriteMapVertexShader: {
  67808. name: string;
  67809. shader: string;
  67810. };
  67811. }
  67812. declare module BABYLON {
  67813. /**
  67814. * Defines the basic options interface of a SpriteMap
  67815. */
  67816. export interface ISpriteMapOptions {
  67817. /**
  67818. * Vector2 of the number of cells in the grid.
  67819. */
  67820. stageSize?: Vector2;
  67821. /**
  67822. * Vector2 of the size of the output plane in World Units.
  67823. */
  67824. outputSize?: Vector2;
  67825. /**
  67826. * Vector3 of the position of the output plane in World Units.
  67827. */
  67828. outputPosition?: Vector3;
  67829. /**
  67830. * Vector3 of the rotation of the output plane.
  67831. */
  67832. outputRotation?: Vector3;
  67833. /**
  67834. * number of layers that the system will reserve in resources.
  67835. */
  67836. layerCount?: number;
  67837. /**
  67838. * number of max animation frames a single cell will reserve in resources.
  67839. */
  67840. maxAnimationFrames?: number;
  67841. /**
  67842. * number cell index of the base tile when the system compiles.
  67843. */
  67844. baseTile?: number;
  67845. /**
  67846. * boolean flip the sprite after its been repositioned by the framing data.
  67847. */
  67848. flipU?: boolean;
  67849. /**
  67850. * Vector3 scalar of the global RGB values of the SpriteMap.
  67851. */
  67852. colorMultiply?: Vector3;
  67853. }
  67854. /**
  67855. * Defines the IDisposable interface in order to be cleanable from resources.
  67856. */
  67857. export interface ISpriteMap extends IDisposable {
  67858. /**
  67859. * String name of the SpriteMap.
  67860. */
  67861. name: string;
  67862. /**
  67863. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67864. */
  67865. atlasJSON: ISpriteJSONAtlas;
  67866. /**
  67867. * Texture of the SpriteMap.
  67868. */
  67869. spriteSheet: Texture;
  67870. /**
  67871. * The parameters to initialize the SpriteMap with.
  67872. */
  67873. options: ISpriteMapOptions;
  67874. }
  67875. /**
  67876. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67877. */
  67878. export class SpriteMap implements ISpriteMap {
  67879. /** The Name of the spriteMap */
  67880. name: string;
  67881. /** The JSON file with the frame and meta data */
  67882. atlasJSON: ISpriteJSONAtlas;
  67883. /** The systems Sprite Sheet Texture */
  67884. spriteSheet: Texture;
  67885. /** Arguments passed with the Constructor */
  67886. options: ISpriteMapOptions;
  67887. /** Public Sprite Storage array, parsed from atlasJSON */
  67888. sprites: Array<ISpriteJSONSprite>;
  67889. /** Returns the Number of Sprites in the System */
  67890. get spriteCount(): number;
  67891. /** Returns the Position of Output Plane*/
  67892. get position(): Vector3;
  67893. /** Returns the Position of Output Plane*/
  67894. set position(v: Vector3);
  67895. /** Returns the Rotation of Output Plane*/
  67896. get rotation(): Vector3;
  67897. /** Returns the Rotation of Output Plane*/
  67898. set rotation(v: Vector3);
  67899. /** Sets the AnimationMap*/
  67900. get animationMap(): RawTexture;
  67901. /** Sets the AnimationMap*/
  67902. set animationMap(v: RawTexture);
  67903. /** Scene that the SpriteMap was created in */
  67904. private _scene;
  67905. /** Texture Buffer of Float32 that holds tile frame data*/
  67906. private _frameMap;
  67907. /** Texture Buffers of Float32 that holds tileMap data*/
  67908. private _tileMaps;
  67909. /** Texture Buffer of Float32 that holds Animation Data*/
  67910. private _animationMap;
  67911. /** Custom ShaderMaterial Central to the System*/
  67912. private _material;
  67913. /** Custom ShaderMaterial Central to the System*/
  67914. private _output;
  67915. /** Systems Time Ticker*/
  67916. private _time;
  67917. /**
  67918. * Creates a new SpriteMap
  67919. * @param name defines the SpriteMaps Name
  67920. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67921. * @param spriteSheet is the Texture that the Sprites are on.
  67922. * @param options a basic deployment configuration
  67923. * @param scene The Scene that the map is deployed on
  67924. */
  67925. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67926. /**
  67927. * Returns tileID location
  67928. * @returns Vector2 the cell position ID
  67929. */
  67930. getTileID(): Vector2;
  67931. /**
  67932. * Gets the UV location of the mouse over the SpriteMap.
  67933. * @returns Vector2 the UV position of the mouse interaction
  67934. */
  67935. getMousePosition(): Vector2;
  67936. /**
  67937. * Creates the "frame" texture Buffer
  67938. * -------------------------------------
  67939. * Structure of frames
  67940. * "filename": "Falling-Water-2.png",
  67941. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67942. * "rotated": true,
  67943. * "trimmed": true,
  67944. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67945. * "sourceSize": {"w":32,"h":32}
  67946. * @returns RawTexture of the frameMap
  67947. */
  67948. private _createFrameBuffer;
  67949. /**
  67950. * Creates the tileMap texture Buffer
  67951. * @param buffer normally and array of numbers, or a false to generate from scratch
  67952. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67953. * @returns RawTexture of the tileMap
  67954. */
  67955. private _createTileBuffer;
  67956. /**
  67957. * Modifies the data of the tileMaps
  67958. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67959. * @param pos is the iVector2 Coordinates of the Tile
  67960. * @param tile The SpriteIndex of the new Tile
  67961. */
  67962. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67963. /**
  67964. * Creates the animationMap texture Buffer
  67965. * @param buffer normally and array of numbers, or a false to generate from scratch
  67966. * @returns RawTexture of the animationMap
  67967. */
  67968. private _createTileAnimationBuffer;
  67969. /**
  67970. * Modifies the data of the animationMap
  67971. * @param cellID is the Index of the Sprite
  67972. * @param _frame is the target Animation frame
  67973. * @param toCell is the Target Index of the next frame of the animation
  67974. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67975. * @param speed is a global scalar of the time variable on the map.
  67976. */
  67977. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67978. /**
  67979. * Exports the .tilemaps file
  67980. */
  67981. saveTileMaps(): void;
  67982. /**
  67983. * Imports the .tilemaps file
  67984. * @param url of the .tilemaps file
  67985. */
  67986. loadTileMaps(url: string): void;
  67987. /**
  67988. * Release associated resources
  67989. */
  67990. dispose(): void;
  67991. }
  67992. }
  67993. declare module BABYLON {
  67994. /**
  67995. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67996. * @see http://doc.babylonjs.com/babylon101/sprites
  67997. */
  67998. export class SpritePackedManager extends SpriteManager {
  67999. /** defines the packed manager's name */
  68000. name: string;
  68001. /**
  68002. * Creates a new sprite manager from a packed sprite sheet
  68003. * @param name defines the manager's name
  68004. * @param imgUrl defines the sprite sheet url
  68005. * @param capacity defines the maximum allowed number of sprites
  68006. * @param scene defines the hosting scene
  68007. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68008. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68009. * @param samplingMode defines the smapling mode to use with spritesheet
  68010. * @param fromPacked set to true; do not alter
  68011. */
  68012. constructor(
  68013. /** defines the packed manager's name */
  68014. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68015. }
  68016. }
  68017. declare module BABYLON {
  68018. /**
  68019. * Defines the list of states available for a task inside a AssetsManager
  68020. */
  68021. export enum AssetTaskState {
  68022. /**
  68023. * Initialization
  68024. */
  68025. INIT = 0,
  68026. /**
  68027. * Running
  68028. */
  68029. RUNNING = 1,
  68030. /**
  68031. * Done
  68032. */
  68033. DONE = 2,
  68034. /**
  68035. * Error
  68036. */
  68037. ERROR = 3
  68038. }
  68039. /**
  68040. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68041. */
  68042. export abstract class AbstractAssetTask {
  68043. /**
  68044. * Task name
  68045. */ name: string;
  68046. /**
  68047. * Callback called when the task is successful
  68048. */
  68049. onSuccess: (task: any) => void;
  68050. /**
  68051. * Callback called when the task is not successful
  68052. */
  68053. onError: (task: any, message?: string, exception?: any) => void;
  68054. /**
  68055. * Creates a new AssetsManager
  68056. * @param name defines the name of the task
  68057. */
  68058. constructor(
  68059. /**
  68060. * Task name
  68061. */ name: string);
  68062. private _isCompleted;
  68063. private _taskState;
  68064. private _errorObject;
  68065. /**
  68066. * Get if the task is completed
  68067. */
  68068. get isCompleted(): boolean;
  68069. /**
  68070. * Gets the current state of the task
  68071. */
  68072. get taskState(): AssetTaskState;
  68073. /**
  68074. * Gets the current error object (if task is in error)
  68075. */
  68076. get errorObject(): {
  68077. message?: string;
  68078. exception?: any;
  68079. };
  68080. /**
  68081. * Internal only
  68082. * @hidden
  68083. */
  68084. _setErrorObject(message?: string, exception?: any): void;
  68085. /**
  68086. * Execute the current task
  68087. * @param scene defines the scene where you want your assets to be loaded
  68088. * @param onSuccess is a callback called when the task is successfully executed
  68089. * @param onError is a callback called if an error occurs
  68090. */
  68091. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68092. /**
  68093. * Execute the current task
  68094. * @param scene defines the scene where you want your assets to be loaded
  68095. * @param onSuccess is a callback called when the task is successfully executed
  68096. * @param onError is a callback called if an error occurs
  68097. */
  68098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68099. /**
  68100. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68101. * This can be used with failed tasks that have the reason for failure fixed.
  68102. */
  68103. reset(): void;
  68104. private onErrorCallback;
  68105. private onDoneCallback;
  68106. }
  68107. /**
  68108. * Define the interface used by progress events raised during assets loading
  68109. */
  68110. export interface IAssetsProgressEvent {
  68111. /**
  68112. * Defines the number of remaining tasks to process
  68113. */
  68114. remainingCount: number;
  68115. /**
  68116. * Defines the total number of tasks
  68117. */
  68118. totalCount: number;
  68119. /**
  68120. * Defines the task that was just processed
  68121. */
  68122. task: AbstractAssetTask;
  68123. }
  68124. /**
  68125. * Class used to share progress information about assets loading
  68126. */
  68127. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68128. /**
  68129. * Defines the number of remaining tasks to process
  68130. */
  68131. remainingCount: number;
  68132. /**
  68133. * Defines the total number of tasks
  68134. */
  68135. totalCount: number;
  68136. /**
  68137. * Defines the task that was just processed
  68138. */
  68139. task: AbstractAssetTask;
  68140. /**
  68141. * Creates a AssetsProgressEvent
  68142. * @param remainingCount defines the number of remaining tasks to process
  68143. * @param totalCount defines the total number of tasks
  68144. * @param task defines the task that was just processed
  68145. */
  68146. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68147. }
  68148. /**
  68149. * Define a task used by AssetsManager to load meshes
  68150. */
  68151. export class MeshAssetTask extends AbstractAssetTask {
  68152. /**
  68153. * Defines the name of the task
  68154. */
  68155. name: string;
  68156. /**
  68157. * Defines the list of mesh's names you want to load
  68158. */
  68159. meshesNames: any;
  68160. /**
  68161. * Defines the root url to use as a base to load your meshes and associated resources
  68162. */
  68163. rootUrl: string;
  68164. /**
  68165. * Defines the filename of the scene to load from
  68166. */
  68167. sceneFilename: string;
  68168. /**
  68169. * Gets the list of loaded meshes
  68170. */
  68171. loadedMeshes: Array<AbstractMesh>;
  68172. /**
  68173. * Gets the list of loaded particle systems
  68174. */
  68175. loadedParticleSystems: Array<IParticleSystem>;
  68176. /**
  68177. * Gets the list of loaded skeletons
  68178. */
  68179. loadedSkeletons: Array<Skeleton>;
  68180. /**
  68181. * Gets the list of loaded animation groups
  68182. */
  68183. loadedAnimationGroups: Array<AnimationGroup>;
  68184. /**
  68185. * Callback called when the task is successful
  68186. */
  68187. onSuccess: (task: MeshAssetTask) => void;
  68188. /**
  68189. * Callback called when the task is successful
  68190. */
  68191. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68192. /**
  68193. * Creates a new MeshAssetTask
  68194. * @param name defines the name of the task
  68195. * @param meshesNames defines the list of mesh's names you want to load
  68196. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68197. * @param sceneFilename defines the filename of the scene to load from
  68198. */
  68199. constructor(
  68200. /**
  68201. * Defines the name of the task
  68202. */
  68203. name: string,
  68204. /**
  68205. * Defines the list of mesh's names you want to load
  68206. */
  68207. meshesNames: any,
  68208. /**
  68209. * Defines the root url to use as a base to load your meshes and associated resources
  68210. */
  68211. rootUrl: string,
  68212. /**
  68213. * Defines the filename of the scene to load from
  68214. */
  68215. sceneFilename: string);
  68216. /**
  68217. * Execute the current task
  68218. * @param scene defines the scene where you want your assets to be loaded
  68219. * @param onSuccess is a callback called when the task is successfully executed
  68220. * @param onError is a callback called if an error occurs
  68221. */
  68222. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68223. }
  68224. /**
  68225. * Define a task used by AssetsManager to load text content
  68226. */
  68227. export class TextFileAssetTask extends AbstractAssetTask {
  68228. /**
  68229. * Defines the name of the task
  68230. */
  68231. name: string;
  68232. /**
  68233. * Defines the location of the file to load
  68234. */
  68235. url: string;
  68236. /**
  68237. * Gets the loaded text string
  68238. */
  68239. text: string;
  68240. /**
  68241. * Callback called when the task is successful
  68242. */
  68243. onSuccess: (task: TextFileAssetTask) => void;
  68244. /**
  68245. * Callback called when the task is successful
  68246. */
  68247. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68248. /**
  68249. * Creates a new TextFileAssetTask object
  68250. * @param name defines the name of the task
  68251. * @param url defines the location of the file to load
  68252. */
  68253. constructor(
  68254. /**
  68255. * Defines the name of the task
  68256. */
  68257. name: string,
  68258. /**
  68259. * Defines the location of the file to load
  68260. */
  68261. url: string);
  68262. /**
  68263. * Execute the current task
  68264. * @param scene defines the scene where you want your assets to be loaded
  68265. * @param onSuccess is a callback called when the task is successfully executed
  68266. * @param onError is a callback called if an error occurs
  68267. */
  68268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68269. }
  68270. /**
  68271. * Define a task used by AssetsManager to load binary data
  68272. */
  68273. export class BinaryFileAssetTask extends AbstractAssetTask {
  68274. /**
  68275. * Defines the name of the task
  68276. */
  68277. name: string;
  68278. /**
  68279. * Defines the location of the file to load
  68280. */
  68281. url: string;
  68282. /**
  68283. * Gets the lodaded data (as an array buffer)
  68284. */
  68285. data: ArrayBuffer;
  68286. /**
  68287. * Callback called when the task is successful
  68288. */
  68289. onSuccess: (task: BinaryFileAssetTask) => void;
  68290. /**
  68291. * Callback called when the task is successful
  68292. */
  68293. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68294. /**
  68295. * Creates a new BinaryFileAssetTask object
  68296. * @param name defines the name of the new task
  68297. * @param url defines the location of the file to load
  68298. */
  68299. constructor(
  68300. /**
  68301. * Defines the name of the task
  68302. */
  68303. name: string,
  68304. /**
  68305. * Defines the location of the file to load
  68306. */
  68307. url: string);
  68308. /**
  68309. * Execute the current task
  68310. * @param scene defines the scene where you want your assets to be loaded
  68311. * @param onSuccess is a callback called when the task is successfully executed
  68312. * @param onError is a callback called if an error occurs
  68313. */
  68314. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68315. }
  68316. /**
  68317. * Define a task used by AssetsManager to load images
  68318. */
  68319. export class ImageAssetTask extends AbstractAssetTask {
  68320. /**
  68321. * Defines the name of the task
  68322. */
  68323. name: string;
  68324. /**
  68325. * Defines the location of the image to load
  68326. */
  68327. url: string;
  68328. /**
  68329. * Gets the loaded images
  68330. */
  68331. image: HTMLImageElement;
  68332. /**
  68333. * Callback called when the task is successful
  68334. */
  68335. onSuccess: (task: ImageAssetTask) => void;
  68336. /**
  68337. * Callback called when the task is successful
  68338. */
  68339. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68340. /**
  68341. * Creates a new ImageAssetTask
  68342. * @param name defines the name of the task
  68343. * @param url defines the location of the image to load
  68344. */
  68345. constructor(
  68346. /**
  68347. * Defines the name of the task
  68348. */
  68349. name: string,
  68350. /**
  68351. * Defines the location of the image to load
  68352. */
  68353. url: string);
  68354. /**
  68355. * Execute the current task
  68356. * @param scene defines the scene where you want your assets to be loaded
  68357. * @param onSuccess is a callback called when the task is successfully executed
  68358. * @param onError is a callback called if an error occurs
  68359. */
  68360. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68361. }
  68362. /**
  68363. * Defines the interface used by texture loading tasks
  68364. */
  68365. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68366. /**
  68367. * Gets the loaded texture
  68368. */
  68369. texture: TEX;
  68370. }
  68371. /**
  68372. * Define a task used by AssetsManager to load 2D textures
  68373. */
  68374. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68375. /**
  68376. * Defines the name of the task
  68377. */
  68378. name: string;
  68379. /**
  68380. * Defines the location of the file to load
  68381. */
  68382. url: string;
  68383. /**
  68384. * Defines if mipmap should not be generated (default is false)
  68385. */
  68386. noMipmap?: boolean | undefined;
  68387. /**
  68388. * Defines if texture must be inverted on Y axis (default is true)
  68389. */
  68390. invertY: boolean;
  68391. /**
  68392. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68393. */
  68394. samplingMode: number;
  68395. /**
  68396. * Gets the loaded texture
  68397. */
  68398. texture: Texture;
  68399. /**
  68400. * Callback called when the task is successful
  68401. */
  68402. onSuccess: (task: TextureAssetTask) => void;
  68403. /**
  68404. * Callback called when the task is successful
  68405. */
  68406. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68407. /**
  68408. * Creates a new TextureAssetTask object
  68409. * @param name defines the name of the task
  68410. * @param url defines the location of the file to load
  68411. * @param noMipmap defines if mipmap should not be generated (default is false)
  68412. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68413. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68414. */
  68415. constructor(
  68416. /**
  68417. * Defines the name of the task
  68418. */
  68419. name: string,
  68420. /**
  68421. * Defines the location of the file to load
  68422. */
  68423. url: string,
  68424. /**
  68425. * Defines if mipmap should not be generated (default is false)
  68426. */
  68427. noMipmap?: boolean | undefined,
  68428. /**
  68429. * Defines if texture must be inverted on Y axis (default is true)
  68430. */
  68431. invertY?: boolean,
  68432. /**
  68433. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68434. */
  68435. samplingMode?: number);
  68436. /**
  68437. * Execute the current task
  68438. * @param scene defines the scene where you want your assets to be loaded
  68439. * @param onSuccess is a callback called when the task is successfully executed
  68440. * @param onError is a callback called if an error occurs
  68441. */
  68442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68443. }
  68444. /**
  68445. * Define a task used by AssetsManager to load cube textures
  68446. */
  68447. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68448. /**
  68449. * Defines the name of the task
  68450. */
  68451. name: string;
  68452. /**
  68453. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68454. */
  68455. url: string;
  68456. /**
  68457. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68458. */
  68459. extensions?: string[] | undefined;
  68460. /**
  68461. * Defines if mipmaps should not be generated (default is false)
  68462. */
  68463. noMipmap?: boolean | undefined;
  68464. /**
  68465. * Defines the explicit list of files (undefined by default)
  68466. */
  68467. files?: string[] | undefined;
  68468. /**
  68469. * Gets the loaded texture
  68470. */
  68471. texture: CubeTexture;
  68472. /**
  68473. * Callback called when the task is successful
  68474. */
  68475. onSuccess: (task: CubeTextureAssetTask) => void;
  68476. /**
  68477. * Callback called when the task is successful
  68478. */
  68479. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68480. /**
  68481. * Creates a new CubeTextureAssetTask
  68482. * @param name defines the name of the task
  68483. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68484. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68485. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68486. * @param files defines the explicit list of files (undefined by default)
  68487. */
  68488. constructor(
  68489. /**
  68490. * Defines the name of the task
  68491. */
  68492. name: string,
  68493. /**
  68494. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68495. */
  68496. url: string,
  68497. /**
  68498. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68499. */
  68500. extensions?: string[] | undefined,
  68501. /**
  68502. * Defines if mipmaps should not be generated (default is false)
  68503. */
  68504. noMipmap?: boolean | undefined,
  68505. /**
  68506. * Defines the explicit list of files (undefined by default)
  68507. */
  68508. files?: string[] | undefined);
  68509. /**
  68510. * Execute the current task
  68511. * @param scene defines the scene where you want your assets to be loaded
  68512. * @param onSuccess is a callback called when the task is successfully executed
  68513. * @param onError is a callback called if an error occurs
  68514. */
  68515. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68516. }
  68517. /**
  68518. * Define a task used by AssetsManager to load HDR cube textures
  68519. */
  68520. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68521. /**
  68522. * Defines the name of the task
  68523. */
  68524. name: string;
  68525. /**
  68526. * Defines the location of the file to load
  68527. */
  68528. url: string;
  68529. /**
  68530. * Defines the desired size (the more it increases the longer the generation will be)
  68531. */
  68532. size: number;
  68533. /**
  68534. * Defines if mipmaps should not be generated (default is false)
  68535. */
  68536. noMipmap: boolean;
  68537. /**
  68538. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68539. */
  68540. generateHarmonics: boolean;
  68541. /**
  68542. * 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)
  68543. */
  68544. gammaSpace: boolean;
  68545. /**
  68546. * Internal Use Only
  68547. */
  68548. reserved: boolean;
  68549. /**
  68550. * Gets the loaded texture
  68551. */
  68552. texture: HDRCubeTexture;
  68553. /**
  68554. * Callback called when the task is successful
  68555. */
  68556. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68557. /**
  68558. * Callback called when the task is successful
  68559. */
  68560. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68561. /**
  68562. * Creates a new HDRCubeTextureAssetTask object
  68563. * @param name defines the name of the task
  68564. * @param url defines the location of the file to load
  68565. * @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.
  68566. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68567. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68568. * @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)
  68569. * @param reserved Internal use only
  68570. */
  68571. constructor(
  68572. /**
  68573. * Defines the name of the task
  68574. */
  68575. name: string,
  68576. /**
  68577. * Defines the location of the file to load
  68578. */
  68579. url: string,
  68580. /**
  68581. * Defines the desired size (the more it increases the longer the generation will be)
  68582. */
  68583. size: number,
  68584. /**
  68585. * Defines if mipmaps should not be generated (default is false)
  68586. */
  68587. noMipmap?: boolean,
  68588. /**
  68589. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68590. */
  68591. generateHarmonics?: boolean,
  68592. /**
  68593. * 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)
  68594. */
  68595. gammaSpace?: boolean,
  68596. /**
  68597. * Internal Use Only
  68598. */
  68599. reserved?: boolean);
  68600. /**
  68601. * Execute the current task
  68602. * @param scene defines the scene where you want your assets to be loaded
  68603. * @param onSuccess is a callback called when the task is successfully executed
  68604. * @param onError is a callback called if an error occurs
  68605. */
  68606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68607. }
  68608. /**
  68609. * Define a task used by AssetsManager to load Equirectangular cube textures
  68610. */
  68611. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68612. /**
  68613. * Defines the name of the task
  68614. */
  68615. name: string;
  68616. /**
  68617. * Defines the location of the file to load
  68618. */
  68619. url: string;
  68620. /**
  68621. * Defines the desired size (the more it increases the longer the generation will be)
  68622. */
  68623. size: number;
  68624. /**
  68625. * Defines if mipmaps should not be generated (default is false)
  68626. */
  68627. noMipmap: boolean;
  68628. /**
  68629. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68630. * but the standard material would require them in Gamma space) (default is true)
  68631. */
  68632. gammaSpace: boolean;
  68633. /**
  68634. * Gets the loaded texture
  68635. */
  68636. texture: EquiRectangularCubeTexture;
  68637. /**
  68638. * Callback called when the task is successful
  68639. */
  68640. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68641. /**
  68642. * Callback called when the task is successful
  68643. */
  68644. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68645. /**
  68646. * Creates a new EquiRectangularCubeTextureAssetTask object
  68647. * @param name defines the name of the task
  68648. * @param url defines the location of the file to load
  68649. * @param size defines the desired size (the more it increases the longer the generation will be)
  68650. * If the size is omitted this implies you are using a preprocessed cubemap.
  68651. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68652. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68653. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68654. * (default is true)
  68655. */
  68656. constructor(
  68657. /**
  68658. * Defines the name of the task
  68659. */
  68660. name: string,
  68661. /**
  68662. * Defines the location of the file to load
  68663. */
  68664. url: string,
  68665. /**
  68666. * Defines the desired size (the more it increases the longer the generation will be)
  68667. */
  68668. size: number,
  68669. /**
  68670. * Defines if mipmaps should not be generated (default is false)
  68671. */
  68672. noMipmap?: boolean,
  68673. /**
  68674. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68675. * but the standard material would require them in Gamma space) (default is true)
  68676. */
  68677. gammaSpace?: boolean);
  68678. /**
  68679. * Execute the current task
  68680. * @param scene defines the scene where you want your assets to be loaded
  68681. * @param onSuccess is a callback called when the task is successfully executed
  68682. * @param onError is a callback called if an error occurs
  68683. */
  68684. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68685. }
  68686. /**
  68687. * This class can be used to easily import assets into a scene
  68688. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68689. */
  68690. export class AssetsManager {
  68691. private _scene;
  68692. private _isLoading;
  68693. protected _tasks: AbstractAssetTask[];
  68694. protected _waitingTasksCount: number;
  68695. protected _totalTasksCount: number;
  68696. /**
  68697. * Callback called when all tasks are processed
  68698. */
  68699. onFinish: (tasks: AbstractAssetTask[]) => void;
  68700. /**
  68701. * Callback called when a task is successful
  68702. */
  68703. onTaskSuccess: (task: AbstractAssetTask) => void;
  68704. /**
  68705. * Callback called when a task had an error
  68706. */
  68707. onTaskError: (task: AbstractAssetTask) => void;
  68708. /**
  68709. * Callback called when a task is done (whatever the result is)
  68710. */
  68711. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68712. /**
  68713. * Observable called when all tasks are processed
  68714. */
  68715. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68716. /**
  68717. * Observable called when a task had an error
  68718. */
  68719. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68720. /**
  68721. * Observable called when all tasks were executed
  68722. */
  68723. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68724. /**
  68725. * Observable called when a task is done (whatever the result is)
  68726. */
  68727. onProgressObservable: Observable<IAssetsProgressEvent>;
  68728. /**
  68729. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68730. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68731. */
  68732. useDefaultLoadingScreen: boolean;
  68733. /**
  68734. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68735. * when all assets have been downloaded.
  68736. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68737. */
  68738. autoHideLoadingUI: boolean;
  68739. /**
  68740. * Creates a new AssetsManager
  68741. * @param scene defines the scene to work on
  68742. */
  68743. constructor(scene: Scene);
  68744. /**
  68745. * Add a MeshAssetTask to the list of active tasks
  68746. * @param taskName defines the name of the new task
  68747. * @param meshesNames defines the name of meshes to load
  68748. * @param rootUrl defines the root url to use to locate files
  68749. * @param sceneFilename defines the filename of the scene file
  68750. * @returns a new MeshAssetTask object
  68751. */
  68752. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68753. /**
  68754. * Add a TextFileAssetTask to the list of active tasks
  68755. * @param taskName defines the name of the new task
  68756. * @param url defines the url of the file to load
  68757. * @returns a new TextFileAssetTask object
  68758. */
  68759. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68760. /**
  68761. * Add a BinaryFileAssetTask to the list of active tasks
  68762. * @param taskName defines the name of the new task
  68763. * @param url defines the url of the file to load
  68764. * @returns a new BinaryFileAssetTask object
  68765. */
  68766. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68767. /**
  68768. * Add a ImageAssetTask to the list of active tasks
  68769. * @param taskName defines the name of the new task
  68770. * @param url defines the url of the file to load
  68771. * @returns a new ImageAssetTask object
  68772. */
  68773. addImageTask(taskName: string, url: string): ImageAssetTask;
  68774. /**
  68775. * Add a TextureAssetTask to the list of active tasks
  68776. * @param taskName defines the name of the new task
  68777. * @param url defines the url of the file to load
  68778. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68779. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68780. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68781. * @returns a new TextureAssetTask object
  68782. */
  68783. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68784. /**
  68785. * Add a CubeTextureAssetTask to the list of active tasks
  68786. * @param taskName defines the name of the new task
  68787. * @param url defines the url of the file to load
  68788. * @param extensions defines the extension to use to load the cube map (can be null)
  68789. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68790. * @param files defines the list of files to load (can be null)
  68791. * @returns a new CubeTextureAssetTask object
  68792. */
  68793. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68794. /**
  68795. *
  68796. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68797. * @param taskName defines the name of the new task
  68798. * @param url defines the url of the file to load
  68799. * @param size defines the size you want for the cubemap (can be null)
  68800. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68801. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68802. * @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)
  68803. * @param reserved Internal use only
  68804. * @returns a new HDRCubeTextureAssetTask object
  68805. */
  68806. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68807. /**
  68808. *
  68809. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68810. * @param taskName defines the name of the new task
  68811. * @param url defines the url of the file to load
  68812. * @param size defines the size you want for the cubemap (can be null)
  68813. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68814. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68815. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68816. * @returns a new EquiRectangularCubeTextureAssetTask object
  68817. */
  68818. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68819. /**
  68820. * Remove a task from the assets manager.
  68821. * @param task the task to remove
  68822. */
  68823. removeTask(task: AbstractAssetTask): void;
  68824. private _decreaseWaitingTasksCount;
  68825. private _runTask;
  68826. /**
  68827. * Reset the AssetsManager and remove all tasks
  68828. * @return the current instance of the AssetsManager
  68829. */
  68830. reset(): AssetsManager;
  68831. /**
  68832. * Start the loading process
  68833. * @return the current instance of the AssetsManager
  68834. */
  68835. load(): AssetsManager;
  68836. /**
  68837. * Start the loading process as an async operation
  68838. * @return a promise returning the list of failed tasks
  68839. */
  68840. loadAsync(): Promise<void>;
  68841. }
  68842. }
  68843. declare module BABYLON {
  68844. /**
  68845. * Wrapper class for promise with external resolve and reject.
  68846. */
  68847. export class Deferred<T> {
  68848. /**
  68849. * The promise associated with this deferred object.
  68850. */
  68851. readonly promise: Promise<T>;
  68852. private _resolve;
  68853. private _reject;
  68854. /**
  68855. * The resolve method of the promise associated with this deferred object.
  68856. */
  68857. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68858. /**
  68859. * The reject method of the promise associated with this deferred object.
  68860. */
  68861. get reject(): (reason?: any) => void;
  68862. /**
  68863. * Constructor for this deferred object.
  68864. */
  68865. constructor();
  68866. }
  68867. }
  68868. declare module BABYLON {
  68869. /**
  68870. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68871. */
  68872. export class MeshExploder {
  68873. private _centerMesh;
  68874. private _meshes;
  68875. private _meshesOrigins;
  68876. private _toCenterVectors;
  68877. private _scaledDirection;
  68878. private _newPosition;
  68879. private _centerPosition;
  68880. /**
  68881. * Explodes meshes from a center mesh.
  68882. * @param meshes The meshes to explode.
  68883. * @param centerMesh The mesh to be center of explosion.
  68884. */
  68885. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68886. private _setCenterMesh;
  68887. /**
  68888. * Get class name
  68889. * @returns "MeshExploder"
  68890. */
  68891. getClassName(): string;
  68892. /**
  68893. * "Exploded meshes"
  68894. * @returns Array of meshes with the centerMesh at index 0.
  68895. */
  68896. getMeshes(): Array<Mesh>;
  68897. /**
  68898. * Explodes meshes giving a specific direction
  68899. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68900. */
  68901. explode(direction?: number): void;
  68902. }
  68903. }
  68904. declare module BABYLON {
  68905. /**
  68906. * Class used to help managing file picking and drag'n'drop
  68907. */
  68908. export class FilesInput {
  68909. /**
  68910. * List of files ready to be loaded
  68911. */
  68912. static get FilesToLoad(): {
  68913. [key: string]: File;
  68914. };
  68915. /**
  68916. * Callback called when a file is processed
  68917. */
  68918. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68919. private _engine;
  68920. private _currentScene;
  68921. private _sceneLoadedCallback;
  68922. private _progressCallback;
  68923. private _additionalRenderLoopLogicCallback;
  68924. private _textureLoadingCallback;
  68925. private _startingProcessingFilesCallback;
  68926. private _onReloadCallback;
  68927. private _errorCallback;
  68928. private _elementToMonitor;
  68929. private _sceneFileToLoad;
  68930. private _filesToLoad;
  68931. /**
  68932. * Creates a new FilesInput
  68933. * @param engine defines the rendering engine
  68934. * @param scene defines the hosting scene
  68935. * @param sceneLoadedCallback callback called when scene is loaded
  68936. * @param progressCallback callback called to track progress
  68937. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68938. * @param textureLoadingCallback callback called when a texture is loading
  68939. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68940. * @param onReloadCallback callback called when a reload is requested
  68941. * @param errorCallback callback call if an error occurs
  68942. */
  68943. 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);
  68944. private _dragEnterHandler;
  68945. private _dragOverHandler;
  68946. private _dropHandler;
  68947. /**
  68948. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68949. * @param elementToMonitor defines the DOM element to track
  68950. */
  68951. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68952. /**
  68953. * Release all associated resources
  68954. */
  68955. dispose(): void;
  68956. private renderFunction;
  68957. private drag;
  68958. private drop;
  68959. private _traverseFolder;
  68960. private _processFiles;
  68961. /**
  68962. * Load files from a drop event
  68963. * @param event defines the drop event to use as source
  68964. */
  68965. loadFiles(event: any): void;
  68966. private _processReload;
  68967. /**
  68968. * Reload the current scene from the loaded files
  68969. */
  68970. reload(): void;
  68971. }
  68972. }
  68973. declare module BABYLON {
  68974. /**
  68975. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68977. */
  68978. export class SceneOptimization {
  68979. /**
  68980. * Defines the priority of this optimization (0 by default which means first in the list)
  68981. */
  68982. priority: number;
  68983. /**
  68984. * Gets a string describing the action executed by the current optimization
  68985. * @returns description string
  68986. */
  68987. getDescription(): string;
  68988. /**
  68989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68990. * @param scene defines the current scene where to apply this optimization
  68991. * @param optimizer defines the current optimizer
  68992. * @returns true if everything that can be done was applied
  68993. */
  68994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68995. /**
  68996. * Creates the SceneOptimization object
  68997. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68998. * @param desc defines the description associated with the optimization
  68999. */
  69000. constructor(
  69001. /**
  69002. * Defines the priority of this optimization (0 by default which means first in the list)
  69003. */
  69004. priority?: number);
  69005. }
  69006. /**
  69007. * Defines an optimization used to reduce the size of render target textures
  69008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69009. */
  69010. export class TextureOptimization extends SceneOptimization {
  69011. /**
  69012. * Defines the priority of this optimization (0 by default which means first in the list)
  69013. */
  69014. priority: number;
  69015. /**
  69016. * 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
  69017. */
  69018. maximumSize: number;
  69019. /**
  69020. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69021. */
  69022. step: number;
  69023. /**
  69024. * Gets a string describing the action executed by the current optimization
  69025. * @returns description string
  69026. */
  69027. getDescription(): string;
  69028. /**
  69029. * Creates the TextureOptimization object
  69030. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69031. * @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
  69032. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69033. */
  69034. constructor(
  69035. /**
  69036. * Defines the priority of this optimization (0 by default which means first in the list)
  69037. */
  69038. priority?: number,
  69039. /**
  69040. * 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
  69041. */
  69042. maximumSize?: number,
  69043. /**
  69044. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69045. */
  69046. step?: number);
  69047. /**
  69048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69049. * @param scene defines the current scene where to apply this optimization
  69050. * @param optimizer defines the current optimizer
  69051. * @returns true if everything that can be done was applied
  69052. */
  69053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69054. }
  69055. /**
  69056. * Defines an optimization used to increase or decrease the rendering resolution
  69057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69058. */
  69059. export class HardwareScalingOptimization extends SceneOptimization {
  69060. /**
  69061. * Defines the priority of this optimization (0 by default which means first in the list)
  69062. */
  69063. priority: number;
  69064. /**
  69065. * Defines the maximum scale to use (2 by default)
  69066. */
  69067. maximumScale: number;
  69068. /**
  69069. * Defines the step to use between two passes (0.5 by default)
  69070. */
  69071. step: number;
  69072. private _currentScale;
  69073. private _directionOffset;
  69074. /**
  69075. * Gets a string describing the action executed by the current optimization
  69076. * @return description string
  69077. */
  69078. getDescription(): string;
  69079. /**
  69080. * Creates the HardwareScalingOptimization object
  69081. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69082. * @param maximumScale defines the maximum scale to use (2 by default)
  69083. * @param step defines the step to use between two passes (0.5 by default)
  69084. */
  69085. constructor(
  69086. /**
  69087. * Defines the priority of this optimization (0 by default which means first in the list)
  69088. */
  69089. priority?: number,
  69090. /**
  69091. * Defines the maximum scale to use (2 by default)
  69092. */
  69093. maximumScale?: number,
  69094. /**
  69095. * Defines the step to use between two passes (0.5 by default)
  69096. */
  69097. step?: number);
  69098. /**
  69099. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69100. * @param scene defines the current scene where to apply this optimization
  69101. * @param optimizer defines the current optimizer
  69102. * @returns true if everything that can be done was applied
  69103. */
  69104. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69105. }
  69106. /**
  69107. * Defines an optimization used to remove shadows
  69108. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69109. */
  69110. export class ShadowsOptimization extends SceneOptimization {
  69111. /**
  69112. * Gets a string describing the action executed by the current optimization
  69113. * @return description string
  69114. */
  69115. getDescription(): string;
  69116. /**
  69117. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69118. * @param scene defines the current scene where to apply this optimization
  69119. * @param optimizer defines the current optimizer
  69120. * @returns true if everything that can be done was applied
  69121. */
  69122. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69123. }
  69124. /**
  69125. * Defines an optimization used to turn post-processes off
  69126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69127. */
  69128. export class PostProcessesOptimization extends SceneOptimization {
  69129. /**
  69130. * Gets a string describing the action executed by the current optimization
  69131. * @return description string
  69132. */
  69133. getDescription(): string;
  69134. /**
  69135. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69136. * @param scene defines the current scene where to apply this optimization
  69137. * @param optimizer defines the current optimizer
  69138. * @returns true if everything that can be done was applied
  69139. */
  69140. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69141. }
  69142. /**
  69143. * Defines an optimization used to turn lens flares off
  69144. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69145. */
  69146. export class LensFlaresOptimization extends SceneOptimization {
  69147. /**
  69148. * Gets a string describing the action executed by the current optimization
  69149. * @return description string
  69150. */
  69151. getDescription(): string;
  69152. /**
  69153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69154. * @param scene defines the current scene where to apply this optimization
  69155. * @param optimizer defines the current optimizer
  69156. * @returns true if everything that can be done was applied
  69157. */
  69158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69159. }
  69160. /**
  69161. * Defines an optimization based on user defined callback.
  69162. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69163. */
  69164. export class CustomOptimization extends SceneOptimization {
  69165. /**
  69166. * Callback called to apply the custom optimization.
  69167. */
  69168. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69169. /**
  69170. * Callback called to get custom description
  69171. */
  69172. onGetDescription: () => string;
  69173. /**
  69174. * Gets a string describing the action executed by the current optimization
  69175. * @returns description string
  69176. */
  69177. getDescription(): string;
  69178. /**
  69179. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69180. * @param scene defines the current scene where to apply this optimization
  69181. * @param optimizer defines the current optimizer
  69182. * @returns true if everything that can be done was applied
  69183. */
  69184. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69185. }
  69186. /**
  69187. * Defines an optimization used to turn particles off
  69188. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69189. */
  69190. export class ParticlesOptimization extends SceneOptimization {
  69191. /**
  69192. * Gets a string describing the action executed by the current optimization
  69193. * @return description string
  69194. */
  69195. getDescription(): string;
  69196. /**
  69197. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69198. * @param scene defines the current scene where to apply this optimization
  69199. * @param optimizer defines the current optimizer
  69200. * @returns true if everything that can be done was applied
  69201. */
  69202. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69203. }
  69204. /**
  69205. * Defines an optimization used to turn render targets off
  69206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69207. */
  69208. export class RenderTargetsOptimization extends SceneOptimization {
  69209. /**
  69210. * Gets a string describing the action executed by the current optimization
  69211. * @return description string
  69212. */
  69213. getDescription(): string;
  69214. /**
  69215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69216. * @param scene defines the current scene where to apply this optimization
  69217. * @param optimizer defines the current optimizer
  69218. * @returns true if everything that can be done was applied
  69219. */
  69220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69221. }
  69222. /**
  69223. * Defines an optimization used to merge meshes with compatible materials
  69224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69225. */
  69226. export class MergeMeshesOptimization extends SceneOptimization {
  69227. private static _UpdateSelectionTree;
  69228. /**
  69229. * Gets or sets a boolean which defines if optimization octree has to be updated
  69230. */
  69231. static get UpdateSelectionTree(): boolean;
  69232. /**
  69233. * Gets or sets a boolean which defines if optimization octree has to be updated
  69234. */
  69235. static set UpdateSelectionTree(value: boolean);
  69236. /**
  69237. * Gets a string describing the action executed by the current optimization
  69238. * @return description string
  69239. */
  69240. getDescription(): string;
  69241. private _canBeMerged;
  69242. /**
  69243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69244. * @param scene defines the current scene where to apply this optimization
  69245. * @param optimizer defines the current optimizer
  69246. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69247. * @returns true if everything that can be done was applied
  69248. */
  69249. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69250. }
  69251. /**
  69252. * Defines a list of options used by SceneOptimizer
  69253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69254. */
  69255. export class SceneOptimizerOptions {
  69256. /**
  69257. * Defines the target frame rate to reach (60 by default)
  69258. */
  69259. targetFrameRate: number;
  69260. /**
  69261. * Defines the interval between two checkes (2000ms by default)
  69262. */
  69263. trackerDuration: number;
  69264. /**
  69265. * Gets the list of optimizations to apply
  69266. */
  69267. optimizations: SceneOptimization[];
  69268. /**
  69269. * Creates a new list of options used by SceneOptimizer
  69270. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69271. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69272. */
  69273. constructor(
  69274. /**
  69275. * Defines the target frame rate to reach (60 by default)
  69276. */
  69277. targetFrameRate?: number,
  69278. /**
  69279. * Defines the interval between two checkes (2000ms by default)
  69280. */
  69281. trackerDuration?: number);
  69282. /**
  69283. * Add a new optimization
  69284. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69285. * @returns the current SceneOptimizerOptions
  69286. */
  69287. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69288. /**
  69289. * Add a new custom optimization
  69290. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69291. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69292. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69293. * @returns the current SceneOptimizerOptions
  69294. */
  69295. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69296. /**
  69297. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69298. * @param targetFrameRate defines the target frame rate (60 by default)
  69299. * @returns a SceneOptimizerOptions object
  69300. */
  69301. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69302. /**
  69303. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69304. * @param targetFrameRate defines the target frame rate (60 by default)
  69305. * @returns a SceneOptimizerOptions object
  69306. */
  69307. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69308. /**
  69309. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69310. * @param targetFrameRate defines the target frame rate (60 by default)
  69311. * @returns a SceneOptimizerOptions object
  69312. */
  69313. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69314. }
  69315. /**
  69316. * Class used to run optimizations in order to reach a target frame rate
  69317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69318. */
  69319. export class SceneOptimizer implements IDisposable {
  69320. private _isRunning;
  69321. private _options;
  69322. private _scene;
  69323. private _currentPriorityLevel;
  69324. private _targetFrameRate;
  69325. private _trackerDuration;
  69326. private _currentFrameRate;
  69327. private _sceneDisposeObserver;
  69328. private _improvementMode;
  69329. /**
  69330. * Defines an observable called when the optimizer reaches the target frame rate
  69331. */
  69332. onSuccessObservable: Observable<SceneOptimizer>;
  69333. /**
  69334. * Defines an observable called when the optimizer enables an optimization
  69335. */
  69336. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69337. /**
  69338. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69339. */
  69340. onFailureObservable: Observable<SceneOptimizer>;
  69341. /**
  69342. * Gets a boolean indicating if the optimizer is in improvement mode
  69343. */
  69344. get isInImprovementMode(): boolean;
  69345. /**
  69346. * Gets the current priority level (0 at start)
  69347. */
  69348. get currentPriorityLevel(): number;
  69349. /**
  69350. * Gets the current frame rate checked by the SceneOptimizer
  69351. */
  69352. get currentFrameRate(): number;
  69353. /**
  69354. * Gets or sets the current target frame rate (60 by default)
  69355. */
  69356. get targetFrameRate(): number;
  69357. /**
  69358. * Gets or sets the current target frame rate (60 by default)
  69359. */
  69360. set targetFrameRate(value: number);
  69361. /**
  69362. * Gets or sets the current interval between two checks (every 2000ms by default)
  69363. */
  69364. get trackerDuration(): number;
  69365. /**
  69366. * Gets or sets the current interval between two checks (every 2000ms by default)
  69367. */
  69368. set trackerDuration(value: number);
  69369. /**
  69370. * Gets the list of active optimizations
  69371. */
  69372. get optimizations(): SceneOptimization[];
  69373. /**
  69374. * Creates a new SceneOptimizer
  69375. * @param scene defines the scene to work on
  69376. * @param options defines the options to use with the SceneOptimizer
  69377. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69378. * @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)
  69379. */
  69380. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69381. /**
  69382. * Stops the current optimizer
  69383. */
  69384. stop(): void;
  69385. /**
  69386. * Reset the optimizer to initial step (current priority level = 0)
  69387. */
  69388. reset(): void;
  69389. /**
  69390. * Start the optimizer. By default it will try to reach a specific framerate
  69391. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69392. */
  69393. start(): void;
  69394. private _checkCurrentState;
  69395. /**
  69396. * Release all resources
  69397. */
  69398. dispose(): void;
  69399. /**
  69400. * Helper function to create a SceneOptimizer with one single line of code
  69401. * @param scene defines the scene to work on
  69402. * @param options defines the options to use with the SceneOptimizer
  69403. * @param onSuccess defines a callback to call on success
  69404. * @param onFailure defines a callback to call on failure
  69405. * @returns the new SceneOptimizer object
  69406. */
  69407. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69408. }
  69409. }
  69410. declare module BABYLON {
  69411. /**
  69412. * Class used to serialize a scene into a string
  69413. */
  69414. export class SceneSerializer {
  69415. /**
  69416. * Clear cache used by a previous serialization
  69417. */
  69418. static ClearCache(): void;
  69419. /**
  69420. * Serialize a scene into a JSON compatible object
  69421. * @param scene defines the scene to serialize
  69422. * @returns a JSON compatible object
  69423. */
  69424. static Serialize(scene: Scene): any;
  69425. /**
  69426. * Serialize a mesh into a JSON compatible object
  69427. * @param toSerialize defines the mesh to serialize
  69428. * @param withParents defines if parents must be serialized as well
  69429. * @param withChildren defines if children must be serialized as well
  69430. * @returns a JSON compatible object
  69431. */
  69432. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69433. }
  69434. }
  69435. declare module BABYLON {
  69436. /**
  69437. * Class used to host texture specific utilities
  69438. */
  69439. export class TextureTools {
  69440. /**
  69441. * Uses the GPU to create a copy texture rescaled at a given size
  69442. * @param texture Texture to copy from
  69443. * @param width defines the desired width
  69444. * @param height defines the desired height
  69445. * @param useBilinearMode defines if bilinear mode has to be used
  69446. * @return the generated texture
  69447. */
  69448. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69449. }
  69450. }
  69451. declare module BABYLON {
  69452. /**
  69453. * This represents the different options available for the video capture.
  69454. */
  69455. export interface VideoRecorderOptions {
  69456. /** Defines the mime type of the video. */
  69457. mimeType: string;
  69458. /** Defines the FPS the video should be recorded at. */
  69459. fps: number;
  69460. /** Defines the chunk size for the recording data. */
  69461. recordChunckSize: number;
  69462. /** The audio tracks to attach to the recording. */
  69463. audioTracks?: MediaStreamTrack[];
  69464. }
  69465. /**
  69466. * This can help with recording videos from BabylonJS.
  69467. * This is based on the available WebRTC functionalities of the browser.
  69468. *
  69469. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69470. */
  69471. export class VideoRecorder {
  69472. private static readonly _defaultOptions;
  69473. /**
  69474. * Returns whether or not the VideoRecorder is available in your browser.
  69475. * @param engine Defines the Babylon Engine.
  69476. * @returns true if supported otherwise false.
  69477. */
  69478. static IsSupported(engine: Engine): boolean;
  69479. private readonly _options;
  69480. private _canvas;
  69481. private _mediaRecorder;
  69482. private _recordedChunks;
  69483. private _fileName;
  69484. private _resolve;
  69485. private _reject;
  69486. /**
  69487. * True when a recording is already in progress.
  69488. */
  69489. get isRecording(): boolean;
  69490. /**
  69491. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69492. * @param engine Defines the BabylonJS Engine you wish to record.
  69493. * @param options Defines options that can be used to customize the capture.
  69494. */
  69495. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69496. /**
  69497. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69498. */
  69499. stopRecording(): void;
  69500. /**
  69501. * Starts recording the canvas for a max duration specified in parameters.
  69502. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69503. * If null no automatic download will start and you can rely on the promise to get the data back.
  69504. * @param maxDuration Defines the maximum recording time in seconds.
  69505. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69506. * @return A promise callback at the end of the recording with the video data in Blob.
  69507. */
  69508. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69509. /**
  69510. * Releases internal resources used during the recording.
  69511. */
  69512. dispose(): void;
  69513. private _handleDataAvailable;
  69514. private _handleError;
  69515. private _handleStop;
  69516. }
  69517. }
  69518. declare module BABYLON {
  69519. /**
  69520. * Class containing a set of static utilities functions for screenshots
  69521. */
  69522. export class ScreenshotTools {
  69523. /**
  69524. * Captures a screenshot of the current rendering
  69525. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69526. * @param engine defines the rendering engine
  69527. * @param camera defines the source camera
  69528. * @param size This parameter can be set to a single number or to an object with the
  69529. * following (optional) properties: precision, width, height. If a single number is passed,
  69530. * it will be used for both width and height. If an object is passed, the screenshot size
  69531. * will be derived from the parameters. The precision property is a multiplier allowing
  69532. * rendering at a higher or lower resolution
  69533. * @param successCallback defines the callback receives a single parameter which contains the
  69534. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69535. * src parameter of an <img> to display it
  69536. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69537. * Check your browser for supported MIME types
  69538. */
  69539. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69540. /**
  69541. * Captures a screenshot of the current rendering
  69542. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69543. * @param engine defines the rendering engine
  69544. * @param camera defines the source camera
  69545. * @param size This parameter can be set to a single number or to an object with the
  69546. * following (optional) properties: precision, width, height. If a single number is passed,
  69547. * it will be used for both width and height. If an object is passed, the screenshot size
  69548. * will be derived from the parameters. The precision property is a multiplier allowing
  69549. * rendering at a higher or lower resolution
  69550. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69551. * Check your browser for supported MIME types
  69552. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69553. * to the src parameter of an <img> to display it
  69554. */
  69555. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69556. /**
  69557. * Generates an image screenshot from the specified camera.
  69558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69559. * @param engine The engine to use for rendering
  69560. * @param camera The camera to use for rendering
  69561. * @param size This parameter can be set to a single number or to an object with the
  69562. * following (optional) properties: precision, width, height. If a single number is passed,
  69563. * it will be used for both width and height. If an object is passed, the screenshot size
  69564. * will be derived from the parameters. The precision property is a multiplier allowing
  69565. * rendering at a higher or lower resolution
  69566. * @param successCallback The callback receives a single parameter which contains the
  69567. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69568. * src parameter of an <img> to display it
  69569. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69570. * Check your browser for supported MIME types
  69571. * @param samples Texture samples (default: 1)
  69572. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69573. * @param fileName A name for for the downloaded file.
  69574. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69575. */
  69576. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69577. /**
  69578. * Generates an image screenshot from the specified camera.
  69579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69580. * @param engine The engine to use for rendering
  69581. * @param camera The camera to use for rendering
  69582. * @param size This parameter can be set to a single number or to an object with the
  69583. * following (optional) properties: precision, width, height. If a single number is passed,
  69584. * it will be used for both width and height. If an object is passed, the screenshot size
  69585. * will be derived from the parameters. The precision property is a multiplier allowing
  69586. * rendering at a higher or lower resolution
  69587. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69588. * Check your browser for supported MIME types
  69589. * @param samples Texture samples (default: 1)
  69590. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69591. * @param fileName A name for for the downloaded file.
  69592. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69593. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69594. * to the src parameter of an <img> to display it
  69595. */
  69596. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69597. /**
  69598. * Gets height and width for screenshot size
  69599. * @private
  69600. */
  69601. private static _getScreenshotSize;
  69602. }
  69603. }
  69604. declare module BABYLON {
  69605. /**
  69606. * Interface for a data buffer
  69607. */
  69608. export interface IDataBuffer {
  69609. /**
  69610. * Reads bytes from the data buffer.
  69611. * @param byteOffset The byte offset to read
  69612. * @param byteLength The byte length to read
  69613. * @returns A promise that resolves when the bytes are read
  69614. */
  69615. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69616. /**
  69617. * The byte length of the buffer.
  69618. */
  69619. readonly byteLength: number;
  69620. }
  69621. /**
  69622. * Utility class for reading from a data buffer
  69623. */
  69624. export class DataReader {
  69625. /**
  69626. * The data buffer associated with this data reader.
  69627. */
  69628. readonly buffer: IDataBuffer;
  69629. /**
  69630. * The current byte offset from the beginning of the data buffer.
  69631. */
  69632. byteOffset: number;
  69633. private _dataView;
  69634. private _dataByteOffset;
  69635. /**
  69636. * Constructor
  69637. * @param buffer The buffer to read
  69638. */
  69639. constructor(buffer: IDataBuffer);
  69640. /**
  69641. * Loads the given byte length.
  69642. * @param byteLength The byte length to load
  69643. * @returns A promise that resolves when the load is complete
  69644. */
  69645. loadAsync(byteLength: number): Promise<void>;
  69646. /**
  69647. * Read a unsigned 32-bit integer from the currently loaded data range.
  69648. * @returns The 32-bit integer read
  69649. */
  69650. readUint32(): number;
  69651. /**
  69652. * Read a byte array from the currently loaded data range.
  69653. * @param byteLength The byte length to read
  69654. * @returns The byte array read
  69655. */
  69656. readUint8Array(byteLength: number): Uint8Array;
  69657. /**
  69658. * Read a string from the currently loaded data range.
  69659. * @param byteLength The byte length to read
  69660. * @returns The string read
  69661. */
  69662. readString(byteLength: number): string;
  69663. /**
  69664. * Skips the given byte length the currently loaded data range.
  69665. * @param byteLength The byte length to skip
  69666. */
  69667. skipBytes(byteLength: number): void;
  69668. }
  69669. }
  69670. declare module BABYLON {
  69671. /**
  69672. * Class for storing data to local storage if available or in-memory storage otherwise
  69673. */
  69674. export class DataStorage {
  69675. private static _Storage;
  69676. private static _GetStorage;
  69677. /**
  69678. * Reads a string from the data storage
  69679. * @param key The key to read
  69680. * @param defaultValue The value if the key doesn't exist
  69681. * @returns The string value
  69682. */
  69683. static ReadString(key: string, defaultValue: string): string;
  69684. /**
  69685. * Writes a string to the data storage
  69686. * @param key The key to write
  69687. * @param value The value to write
  69688. */
  69689. static WriteString(key: string, value: string): void;
  69690. /**
  69691. * Reads a boolean from the data storage
  69692. * @param key The key to read
  69693. * @param defaultValue The value if the key doesn't exist
  69694. * @returns The boolean value
  69695. */
  69696. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69697. /**
  69698. * Writes a boolean to the data storage
  69699. * @param key The key to write
  69700. * @param value The value to write
  69701. */
  69702. static WriteBoolean(key: string, value: boolean): void;
  69703. /**
  69704. * Reads a number from the data storage
  69705. * @param key The key to read
  69706. * @param defaultValue The value if the key doesn't exist
  69707. * @returns The number value
  69708. */
  69709. static ReadNumber(key: string, defaultValue: number): number;
  69710. /**
  69711. * Writes a number to the data storage
  69712. * @param key The key to write
  69713. * @param value The value to write
  69714. */
  69715. static WriteNumber(key: string, value: number): void;
  69716. }
  69717. }
  69718. declare module BABYLON {
  69719. /**
  69720. * Options used for hit testing
  69721. */
  69722. export interface IWebXRLegacyHitTestOptions {
  69723. /**
  69724. * Only test when user interacted with the scene. Default - hit test every frame
  69725. */
  69726. testOnPointerDownOnly?: boolean;
  69727. /**
  69728. * The node to use to transform the local results to world coordinates
  69729. */
  69730. worldParentNode?: TransformNode;
  69731. }
  69732. /**
  69733. * Interface defining the babylon result of raycasting/hit-test
  69734. */
  69735. export interface IWebXRLegacyHitResult {
  69736. /**
  69737. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69738. */
  69739. transformationMatrix: Matrix;
  69740. /**
  69741. * The native hit test result
  69742. */
  69743. xrHitResult: XRHitResult | XRHitTestResult;
  69744. }
  69745. /**
  69746. * The currently-working hit-test module.
  69747. * Hit test (or Ray-casting) is used to interact with the real world.
  69748. * For further information read here - https://github.com/immersive-web/hit-test
  69749. */
  69750. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69751. /**
  69752. * options to use when constructing this feature
  69753. */
  69754. readonly options: IWebXRLegacyHitTestOptions;
  69755. private _direction;
  69756. private _mat;
  69757. private _onSelectEnabled;
  69758. private _origin;
  69759. /**
  69760. * The module's name
  69761. */
  69762. static readonly Name: string;
  69763. /**
  69764. * The (Babylon) version of this module.
  69765. * This is an integer representing the implementation version.
  69766. * This number does not correspond to the WebXR specs version
  69767. */
  69768. static readonly Version: number;
  69769. /**
  69770. * Populated with the last native XR Hit Results
  69771. */
  69772. lastNativeXRHitResults: XRHitResult[];
  69773. /**
  69774. * Triggered when new babylon (transformed) hit test results are available
  69775. */
  69776. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69777. /**
  69778. * Creates a new instance of the (legacy version) hit test feature
  69779. * @param _xrSessionManager an instance of WebXRSessionManager
  69780. * @param options options to use when constructing this feature
  69781. */
  69782. constructor(_xrSessionManager: WebXRSessionManager,
  69783. /**
  69784. * options to use when constructing this feature
  69785. */
  69786. options?: IWebXRLegacyHitTestOptions);
  69787. /**
  69788. * execute a hit test with an XR Ray
  69789. *
  69790. * @param xrSession a native xrSession that will execute this hit test
  69791. * @param xrRay the ray (position and direction) to use for ray-casting
  69792. * @param referenceSpace native XR reference space to use for the hit-test
  69793. * @param filter filter function that will filter the results
  69794. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69795. */
  69796. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69797. /**
  69798. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69799. * @param event the (select) event to use to select with
  69800. * @param referenceSpace the reference space to use for this hit test
  69801. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69802. */
  69803. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69804. /**
  69805. * attach this feature
  69806. * Will usually be called by the features manager
  69807. *
  69808. * @returns true if successful.
  69809. */
  69810. attach(): boolean;
  69811. /**
  69812. * detach this feature.
  69813. * Will usually be called by the features manager
  69814. *
  69815. * @returns true if successful.
  69816. */
  69817. detach(): boolean;
  69818. /**
  69819. * Dispose this feature and all of the resources attached
  69820. */
  69821. dispose(): void;
  69822. protected _onXRFrame(frame: XRFrame): void;
  69823. private _onHitTestResults;
  69824. private _onSelect;
  69825. }
  69826. }
  69827. declare module BABYLON {
  69828. /**
  69829. * Options used in the plane detector module
  69830. */
  69831. export interface IWebXRPlaneDetectorOptions {
  69832. /**
  69833. * The node to use to transform the local results to world coordinates
  69834. */
  69835. worldParentNode?: TransformNode;
  69836. }
  69837. /**
  69838. * A babylon interface for a WebXR plane.
  69839. * A Plane is actually a polygon, built from N points in space
  69840. *
  69841. * Supported in chrome 79, not supported in canary 81 ATM
  69842. */
  69843. export interface IWebXRPlane {
  69844. /**
  69845. * a babylon-assigned ID for this polygon
  69846. */
  69847. id: number;
  69848. /**
  69849. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69850. */
  69851. polygonDefinition: Array<Vector3>;
  69852. /**
  69853. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69854. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69855. */
  69856. transformationMatrix: Matrix;
  69857. /**
  69858. * the native xr-plane object
  69859. */
  69860. xrPlane: XRPlane;
  69861. }
  69862. /**
  69863. * The plane detector is used to detect planes in the real world when in AR
  69864. * For more information see https://github.com/immersive-web/real-world-geometry/
  69865. */
  69866. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69867. private _options;
  69868. private _detectedPlanes;
  69869. private _enabled;
  69870. private _lastFrameDetected;
  69871. /**
  69872. * The module's name
  69873. */
  69874. static readonly Name: string;
  69875. /**
  69876. * The (Babylon) version of this module.
  69877. * This is an integer representing the implementation version.
  69878. * This number does not correspond to the WebXR specs version
  69879. */
  69880. static readonly Version: number;
  69881. /**
  69882. * Observers registered here will be executed when a new plane was added to the session
  69883. */
  69884. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69885. /**
  69886. * Observers registered here will be executed when a plane is no longer detected in the session
  69887. */
  69888. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69889. /**
  69890. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69891. * This can execute N times every frame
  69892. */
  69893. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69894. /**
  69895. * construct a new Plane Detector
  69896. * @param _xrSessionManager an instance of xr Session manager
  69897. * @param _options configuration to use when constructing this feature
  69898. */
  69899. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69900. /**
  69901. * Dispose this feature and all of the resources attached
  69902. */
  69903. dispose(): void;
  69904. protected _onXRFrame(frame: XRFrame): void;
  69905. private _init;
  69906. private _updatePlaneWithXRPlane;
  69907. /**
  69908. * avoiding using Array.find for global support.
  69909. * @param xrPlane the plane to find in the array
  69910. */
  69911. private findIndexInPlaneArray;
  69912. }
  69913. }
  69914. declare module BABYLON {
  69915. /**
  69916. * Configuration options of the anchor system
  69917. */
  69918. export interface IWebXRAnchorSystemOptions {
  69919. /**
  69920. * Should a new anchor be added every time a select event is triggered
  69921. */
  69922. addAnchorOnSelect?: boolean;
  69923. /**
  69924. * should the anchor system use plane detection.
  69925. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69926. */
  69927. usePlaneDetection?: boolean;
  69928. /**
  69929. * a node that will be used to convert local to world coordinates
  69930. */
  69931. worldParentNode?: TransformNode;
  69932. }
  69933. /**
  69934. * A babylon container for an XR Anchor
  69935. */
  69936. export interface IWebXRAnchor {
  69937. /**
  69938. * A babylon-assigned ID for this anchor
  69939. */
  69940. id: number;
  69941. /**
  69942. * Transformation matrix to apply to an object attached to this anchor
  69943. */
  69944. transformationMatrix: Matrix;
  69945. /**
  69946. * The native anchor object
  69947. */
  69948. xrAnchor: XRAnchor;
  69949. }
  69950. /**
  69951. * An implementation of the anchor system of WebXR.
  69952. * Note that the current documented implementation is not available in any browser. Future implementations
  69953. * will use the frame to create an anchor and not the session or a detected plane
  69954. * For further information see https://github.com/immersive-web/anchors/
  69955. */
  69956. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69957. private _options;
  69958. private _enabled;
  69959. private _hitTestModule;
  69960. private _lastFrameDetected;
  69961. private _onSelect;
  69962. private _planeDetector;
  69963. private _trackedAnchors;
  69964. /**
  69965. * The module's name
  69966. */
  69967. static readonly Name: string;
  69968. /**
  69969. * The (Babylon) version of this module.
  69970. * This is an integer representing the implementation version.
  69971. * This number does not correspond to the WebXR specs version
  69972. */
  69973. static readonly Version: number;
  69974. /**
  69975. * Observers registered here will be executed when a new anchor was added to the session
  69976. */
  69977. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69978. /**
  69979. * Observers registered here will be executed when an anchor was removed from the session
  69980. */
  69981. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69982. /**
  69983. * Observers registered here will be executed when an existing anchor updates
  69984. * This can execute N times every frame
  69985. */
  69986. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69987. /**
  69988. * constructs a new anchor system
  69989. * @param _xrSessionManager an instance of WebXRSessionManager
  69990. * @param _options configuration object for this feature
  69991. */
  69992. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69993. /**
  69994. * Add anchor at a specific XR point.
  69995. *
  69996. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69997. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69998. * @returns a promise the fulfills when the anchor was created
  69999. */
  70000. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  70001. /**
  70002. * attach this feature
  70003. * Will usually be called by the features manager
  70004. *
  70005. * @returns true if successful.
  70006. */
  70007. attach(): boolean;
  70008. /**
  70009. * detach this feature.
  70010. * Will usually be called by the features manager
  70011. *
  70012. * @returns true if successful.
  70013. */
  70014. detach(): boolean;
  70015. /**
  70016. * Dispose this feature and all of the resources attached
  70017. */
  70018. dispose(): void;
  70019. /**
  70020. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  70021. * @param hitTestModule the hit-test module to use.
  70022. */
  70023. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  70024. /**
  70025. * set the plane detector to use in order to create anchors from frames
  70026. * @param planeDetector the plane-detector module to use
  70027. * @param enable enable plane-anchors. default is true
  70028. */
  70029. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  70030. protected _onXRFrame(frame: XRFrame): void;
  70031. /**
  70032. * avoiding using Array.find for global support.
  70033. * @param xrAnchor the plane to find in the array
  70034. */
  70035. private _findIndexInAnchorArray;
  70036. private _updateAnchorWithXRFrame;
  70037. }
  70038. }
  70039. declare module BABYLON {
  70040. /**
  70041. * Options interface for the background remover plugin
  70042. */
  70043. export interface IWebXRBackgroundRemoverOptions {
  70044. /**
  70045. * Further background meshes to disable when entering AR
  70046. */
  70047. backgroundMeshes?: AbstractMesh[];
  70048. /**
  70049. * flags to configure the removal of the environment helper.
  70050. * If not set, the entire background will be removed. If set, flags should be set as well.
  70051. */
  70052. environmentHelperRemovalFlags?: {
  70053. /**
  70054. * Should the skybox be removed (default false)
  70055. */
  70056. skyBox?: boolean;
  70057. /**
  70058. * Should the ground be removed (default false)
  70059. */
  70060. ground?: boolean;
  70061. };
  70062. /**
  70063. * don't disable the environment helper
  70064. */
  70065. ignoreEnvironmentHelper?: boolean;
  70066. }
  70067. /**
  70068. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  70069. */
  70070. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  70071. /**
  70072. * read-only options to be used in this module
  70073. */
  70074. readonly options: IWebXRBackgroundRemoverOptions;
  70075. /**
  70076. * The module's name
  70077. */
  70078. static readonly Name: string;
  70079. /**
  70080. * The (Babylon) version of this module.
  70081. * This is an integer representing the implementation version.
  70082. * This number does not correspond to the WebXR specs version
  70083. */
  70084. static readonly Version: number;
  70085. /**
  70086. * registered observers will be triggered when the background state changes
  70087. */
  70088. onBackgroundStateChangedObservable: Observable<boolean>;
  70089. /**
  70090. * constructs a new background remover module
  70091. * @param _xrSessionManager the session manager for this module
  70092. * @param options read-only options to be used in this module
  70093. */
  70094. constructor(_xrSessionManager: WebXRSessionManager,
  70095. /**
  70096. * read-only options to be used in this module
  70097. */
  70098. options?: IWebXRBackgroundRemoverOptions);
  70099. /**
  70100. * attach this feature
  70101. * Will usually be called by the features manager
  70102. *
  70103. * @returns true if successful.
  70104. */
  70105. attach(): boolean;
  70106. /**
  70107. * detach this feature.
  70108. * Will usually be called by the features manager
  70109. *
  70110. * @returns true if successful.
  70111. */
  70112. detach(): boolean;
  70113. /**
  70114. * Dispose this feature and all of the resources attached
  70115. */
  70116. dispose(): void;
  70117. protected _onXRFrame(_xrFrame: XRFrame): void;
  70118. private _setBackgroundState;
  70119. }
  70120. }
  70121. declare module BABYLON {
  70122. /**
  70123. * Options for the controller physics feature
  70124. */
  70125. export class IWebXRControllerPhysicsOptions {
  70126. /**
  70127. * Should the headset get its own impostor
  70128. */
  70129. enableHeadsetImpostor?: boolean;
  70130. /**
  70131. * Optional parameters for the headset impostor
  70132. */
  70133. headsetImpostorParams?: {
  70134. /**
  70135. * The type of impostor to create. Default is sphere
  70136. */
  70137. impostorType: number;
  70138. /**
  70139. * the size of the impostor. Defaults to 10cm
  70140. */
  70141. impostorSize?: number | {
  70142. width: number;
  70143. height: number;
  70144. depth: number;
  70145. };
  70146. /**
  70147. * Friction definitions
  70148. */
  70149. friction?: number;
  70150. /**
  70151. * Restitution
  70152. */
  70153. restitution?: number;
  70154. };
  70155. /**
  70156. * The physics properties of the future impostors
  70157. */
  70158. physicsProperties?: {
  70159. /**
  70160. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  70161. * Note that this requires a physics engine that supports mesh impostors!
  70162. */
  70163. useControllerMesh?: boolean;
  70164. /**
  70165. * The type of impostor to create. Default is sphere
  70166. */
  70167. impostorType?: number;
  70168. /**
  70169. * the size of the impostor. Defaults to 10cm
  70170. */
  70171. impostorSize?: number | {
  70172. width: number;
  70173. height: number;
  70174. depth: number;
  70175. };
  70176. /**
  70177. * Friction definitions
  70178. */
  70179. friction?: number;
  70180. /**
  70181. * Restitution
  70182. */
  70183. restitution?: number;
  70184. };
  70185. /**
  70186. * the xr input to use with this pointer selection
  70187. */
  70188. xrInput: WebXRInput;
  70189. }
  70190. /**
  70191. * Add physics impostor to your webxr controllers,
  70192. * including naive calculation of their linear and angular velocity
  70193. */
  70194. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  70195. private readonly _options;
  70196. private _attachController;
  70197. private _controllers;
  70198. private _debugMode;
  70199. private _delta;
  70200. private _headsetImpostor?;
  70201. private _headsetMesh?;
  70202. private _lastTimestamp;
  70203. private _tmpQuaternion;
  70204. private _tmpVector;
  70205. /**
  70206. * The module's name
  70207. */
  70208. static readonly Name: string;
  70209. /**
  70210. * The (Babylon) version of this module.
  70211. * This is an integer representing the implementation version.
  70212. * This number does not correspond to the webxr specs version
  70213. */
  70214. static readonly Version: number;
  70215. /**
  70216. * Construct a new Controller Physics Feature
  70217. * @param _xrSessionManager the corresponding xr session manager
  70218. * @param _options options to create this feature with
  70219. */
  70220. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  70221. /**
  70222. * @hidden
  70223. * enable debugging - will show console outputs and the impostor mesh
  70224. */
  70225. _enablePhysicsDebug(): void;
  70226. /**
  70227. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  70228. * @param xrController the controller to add
  70229. */
  70230. addController(xrController: WebXRInputSource): void;
  70231. /**
  70232. * attach this feature
  70233. * Will usually be called by the features manager
  70234. *
  70235. * @returns true if successful.
  70236. */
  70237. attach(): boolean;
  70238. /**
  70239. * detach this feature.
  70240. * Will usually be called by the features manager
  70241. *
  70242. * @returns true if successful.
  70243. */
  70244. detach(): boolean;
  70245. /**
  70246. * Get the headset impostor, if enabled
  70247. * @returns the impostor
  70248. */
  70249. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70250. /**
  70251. * Get the physics impostor of a specific controller.
  70252. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70253. * @param controller the controller or the controller id of which to get the impostor
  70254. * @returns the impostor or null
  70255. */
  70256. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70257. /**
  70258. * Update the physics properties provided in the constructor
  70259. * @param newProperties the new properties object
  70260. */
  70261. setPhysicsProperties(newProperties: {
  70262. impostorType?: number;
  70263. impostorSize?: number | {
  70264. width: number;
  70265. height: number;
  70266. depth: number;
  70267. };
  70268. friction?: number;
  70269. restitution?: number;
  70270. }): void;
  70271. protected _onXRFrame(_xrFrame: any): void;
  70272. private _detachController;
  70273. }
  70274. }
  70275. declare module BABYLON {
  70276. /**
  70277. * Options used for hit testing (version 2)
  70278. */
  70279. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70280. /**
  70281. * Do not create a permanent hit test. Will usually be used when only
  70282. * transient inputs are needed.
  70283. */
  70284. disablePermanentHitTest?: boolean;
  70285. /**
  70286. * Enable transient (for example touch-based) hit test inspections
  70287. */
  70288. enableTransientHitTest?: boolean;
  70289. /**
  70290. * Offset ray for the permanent hit test
  70291. */
  70292. offsetRay?: Vector3;
  70293. /**
  70294. * Offset ray for the transient hit test
  70295. */
  70296. transientOffsetRay?: Vector3;
  70297. /**
  70298. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70299. */
  70300. useReferenceSpace?: boolean;
  70301. }
  70302. /**
  70303. * Interface defining the babylon result of hit-test
  70304. */
  70305. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70306. /**
  70307. * The input source that generated this hit test (if transient)
  70308. */
  70309. inputSource?: XRInputSource;
  70310. /**
  70311. * Is this a transient hit test
  70312. */
  70313. isTransient?: boolean;
  70314. /**
  70315. * Position of the hit test result
  70316. */
  70317. position: Vector3;
  70318. /**
  70319. * Rotation of the hit test result
  70320. */
  70321. rotationQuaternion: Quaternion;
  70322. }
  70323. /**
  70324. * The currently-working hit-test module.
  70325. * Hit test (or Ray-casting) is used to interact with the real world.
  70326. * For further information read here - https://github.com/immersive-web/hit-test
  70327. *
  70328. * Tested on chrome (mobile) 80.
  70329. */
  70330. export class WebXRHitTest extends WebXRAbstractFeature {
  70331. /**
  70332. * options to use when constructing this feature
  70333. */
  70334. readonly options: IWebXRHitTestOptions;
  70335. private _tmpMat;
  70336. private _tmpPos;
  70337. private _tmpQuat;
  70338. private _transientXrHitTestSource;
  70339. private _xrHitTestSource;
  70340. private initHitTestSource;
  70341. /**
  70342. * The module's name
  70343. */
  70344. static readonly Name: string;
  70345. /**
  70346. * The (Babylon) version of this module.
  70347. * This is an integer representing the implementation version.
  70348. * This number does not correspond to the WebXR specs version
  70349. */
  70350. static readonly Version: number;
  70351. /**
  70352. * When set to true, each hit test will have its own position/rotation objects
  70353. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70354. * the developers will clone them or copy them as they see fit.
  70355. */
  70356. autoCloneTransformation: boolean;
  70357. /**
  70358. * Populated with the last native XR Hit Results
  70359. */
  70360. lastNativeXRHitResults: XRHitResult[];
  70361. /**
  70362. * Triggered when new babylon (transformed) hit test results are available
  70363. */
  70364. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70365. /**
  70366. * Use this to temporarily pause hit test checks.
  70367. */
  70368. paused: boolean;
  70369. /**
  70370. * Creates a new instance of the hit test feature
  70371. * @param _xrSessionManager an instance of WebXRSessionManager
  70372. * @param options options to use when constructing this feature
  70373. */
  70374. constructor(_xrSessionManager: WebXRSessionManager,
  70375. /**
  70376. * options to use when constructing this feature
  70377. */
  70378. options?: IWebXRHitTestOptions);
  70379. /**
  70380. * attach this feature
  70381. * Will usually be called by the features manager
  70382. *
  70383. * @returns true if successful.
  70384. */
  70385. attach(): boolean;
  70386. /**
  70387. * detach this feature.
  70388. * Will usually be called by the features manager
  70389. *
  70390. * @returns true if successful.
  70391. */
  70392. detach(): boolean;
  70393. /**
  70394. * Dispose this feature and all of the resources attached
  70395. */
  70396. dispose(): void;
  70397. protected _onXRFrame(frame: XRFrame): void;
  70398. private _processWebXRHitTestResult;
  70399. }
  70400. }
  70401. declare module BABYLON {
  70402. /**
  70403. * The motion controller class for all microsoft mixed reality controllers
  70404. */
  70405. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70406. protected readonly _mapping: {
  70407. defaultButton: {
  70408. valueNodeName: string;
  70409. unpressedNodeName: string;
  70410. pressedNodeName: string;
  70411. };
  70412. defaultAxis: {
  70413. valueNodeName: string;
  70414. minNodeName: string;
  70415. maxNodeName: string;
  70416. };
  70417. buttons: {
  70418. "xr-standard-trigger": {
  70419. rootNodeName: string;
  70420. componentProperty: string;
  70421. states: string[];
  70422. };
  70423. "xr-standard-squeeze": {
  70424. rootNodeName: string;
  70425. componentProperty: string;
  70426. states: string[];
  70427. };
  70428. "xr-standard-touchpad": {
  70429. rootNodeName: string;
  70430. labelAnchorNodeName: string;
  70431. touchPointNodeName: string;
  70432. };
  70433. "xr-standard-thumbstick": {
  70434. rootNodeName: string;
  70435. componentProperty: string;
  70436. states: string[];
  70437. };
  70438. };
  70439. axes: {
  70440. "xr-standard-touchpad": {
  70441. "x-axis": {
  70442. rootNodeName: string;
  70443. };
  70444. "y-axis": {
  70445. rootNodeName: string;
  70446. };
  70447. };
  70448. "xr-standard-thumbstick": {
  70449. "x-axis": {
  70450. rootNodeName: string;
  70451. };
  70452. "y-axis": {
  70453. rootNodeName: string;
  70454. };
  70455. };
  70456. };
  70457. };
  70458. /**
  70459. * The base url used to load the left and right controller models
  70460. */
  70461. static MODEL_BASE_URL: string;
  70462. /**
  70463. * The name of the left controller model file
  70464. */
  70465. static MODEL_LEFT_FILENAME: string;
  70466. /**
  70467. * The name of the right controller model file
  70468. */
  70469. static MODEL_RIGHT_FILENAME: string;
  70470. profileId: string;
  70471. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  70472. protected _getFilenameAndPath(): {
  70473. filename: string;
  70474. path: string;
  70475. };
  70476. protected _getModelLoadingConstraints(): boolean;
  70477. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70478. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70479. protected _updateModel(): void;
  70480. }
  70481. }
  70482. declare module BABYLON {
  70483. /**
  70484. * The motion controller class for oculus touch (quest, rift).
  70485. * This class supports legacy mapping as well the standard xr mapping
  70486. */
  70487. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70488. private _forceLegacyControllers;
  70489. private _modelRootNode;
  70490. /**
  70491. * The base url used to load the left and right controller models
  70492. */
  70493. static MODEL_BASE_URL: string;
  70494. /**
  70495. * The name of the left controller model file
  70496. */
  70497. static MODEL_LEFT_FILENAME: string;
  70498. /**
  70499. * The name of the right controller model file
  70500. */
  70501. static MODEL_RIGHT_FILENAME: string;
  70502. /**
  70503. * Base Url for the Quest controller model.
  70504. */
  70505. static QUEST_MODEL_BASE_URL: string;
  70506. profileId: string;
  70507. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70508. protected _getFilenameAndPath(): {
  70509. filename: string;
  70510. path: string;
  70511. };
  70512. protected _getModelLoadingConstraints(): boolean;
  70513. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70514. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70515. protected _updateModel(): void;
  70516. /**
  70517. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70518. * between the touch and touch 2.
  70519. */
  70520. private _isQuest;
  70521. }
  70522. }
  70523. declare module BABYLON {
  70524. /**
  70525. * The motion controller class for the standard HTC-Vive controllers
  70526. */
  70527. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70528. private _modelRootNode;
  70529. /**
  70530. * The base url used to load the left and right controller models
  70531. */
  70532. static MODEL_BASE_URL: string;
  70533. /**
  70534. * File name for the controller model.
  70535. */
  70536. static MODEL_FILENAME: string;
  70537. profileId: string;
  70538. /**
  70539. * Create a new Vive motion controller object
  70540. * @param scene the scene to use to create this controller
  70541. * @param gamepadObject the corresponding gamepad object
  70542. * @param handedness the handedness of the controller
  70543. */
  70544. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  70545. protected _getFilenameAndPath(): {
  70546. filename: string;
  70547. path: string;
  70548. };
  70549. protected _getModelLoadingConstraints(): boolean;
  70550. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70551. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70552. protected _updateModel(): void;
  70553. }
  70554. }
  70555. declare module BABYLON {
  70556. /**
  70557. * A cursor which tracks a point on a path
  70558. */
  70559. export class PathCursor {
  70560. private path;
  70561. /**
  70562. * Stores path cursor callbacks for when an onchange event is triggered
  70563. */
  70564. private _onchange;
  70565. /**
  70566. * The value of the path cursor
  70567. */
  70568. value: number;
  70569. /**
  70570. * The animation array of the path cursor
  70571. */
  70572. animations: Animation[];
  70573. /**
  70574. * Initializes the path cursor
  70575. * @param path The path to track
  70576. */
  70577. constructor(path: Path2);
  70578. /**
  70579. * Gets the cursor point on the path
  70580. * @returns A point on the path cursor at the cursor location
  70581. */
  70582. getPoint(): Vector3;
  70583. /**
  70584. * Moves the cursor ahead by the step amount
  70585. * @param step The amount to move the cursor forward
  70586. * @returns This path cursor
  70587. */
  70588. moveAhead(step?: number): PathCursor;
  70589. /**
  70590. * Moves the cursor behind by the step amount
  70591. * @param step The amount to move the cursor back
  70592. * @returns This path cursor
  70593. */
  70594. moveBack(step?: number): PathCursor;
  70595. /**
  70596. * Moves the cursor by the step amount
  70597. * If the step amount is greater than one, an exception is thrown
  70598. * @param step The amount to move the cursor
  70599. * @returns This path cursor
  70600. */
  70601. move(step: number): PathCursor;
  70602. /**
  70603. * Ensures that the value is limited between zero and one
  70604. * @returns This path cursor
  70605. */
  70606. private ensureLimits;
  70607. /**
  70608. * Runs onchange callbacks on change (used by the animation engine)
  70609. * @returns This path cursor
  70610. */
  70611. private raiseOnChange;
  70612. /**
  70613. * Executes a function on change
  70614. * @param f A path cursor onchange callback
  70615. * @returns This path cursor
  70616. */
  70617. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70618. }
  70619. }
  70620. declare module BABYLON {
  70621. /** @hidden */
  70622. export var blurPixelShader: {
  70623. name: string;
  70624. shader: string;
  70625. };
  70626. }
  70627. declare module BABYLON {
  70628. /** @hidden */
  70629. export var pointCloudVertexDeclaration: {
  70630. name: string;
  70631. shader: string;
  70632. };
  70633. }
  70634. // Mixins
  70635. interface Window {
  70636. mozIndexedDB: IDBFactory;
  70637. webkitIndexedDB: IDBFactory;
  70638. msIndexedDB: IDBFactory;
  70639. webkitURL: typeof URL;
  70640. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70641. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70642. WebGLRenderingContext: WebGLRenderingContext;
  70643. MSGesture: MSGesture;
  70644. CANNON: any;
  70645. AudioContext: AudioContext;
  70646. webkitAudioContext: AudioContext;
  70647. PointerEvent: any;
  70648. Math: Math;
  70649. Uint8Array: Uint8ArrayConstructor;
  70650. Float32Array: Float32ArrayConstructor;
  70651. mozURL: typeof URL;
  70652. msURL: typeof URL;
  70653. VRFrameData: any; // WebVR, from specs 1.1
  70654. DracoDecoderModule: any;
  70655. setImmediate(handler: (...args: any[]) => void): number;
  70656. }
  70657. interface HTMLCanvasElement {
  70658. requestPointerLock(): void;
  70659. msRequestPointerLock?(): void;
  70660. mozRequestPointerLock?(): void;
  70661. webkitRequestPointerLock?(): void;
  70662. /** Track wether a record is in progress */
  70663. isRecording: boolean;
  70664. /** Capture Stream method defined by some browsers */
  70665. captureStream(fps?: number): MediaStream;
  70666. }
  70667. interface CanvasRenderingContext2D {
  70668. msImageSmoothingEnabled: boolean;
  70669. }
  70670. interface MouseEvent {
  70671. mozMovementX: number;
  70672. mozMovementY: number;
  70673. webkitMovementX: number;
  70674. webkitMovementY: number;
  70675. msMovementX: number;
  70676. msMovementY: number;
  70677. }
  70678. interface Navigator {
  70679. mozGetVRDevices: (any: any) => any;
  70680. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70681. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70682. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70683. webkitGetGamepads(): Gamepad[];
  70684. msGetGamepads(): Gamepad[];
  70685. webkitGamepads(): Gamepad[];
  70686. }
  70687. interface HTMLVideoElement {
  70688. mozSrcObject: any;
  70689. }
  70690. interface Math {
  70691. fround(x: number): number;
  70692. imul(a: number, b: number): number;
  70693. }
  70694. interface WebGLRenderingContext {
  70695. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70696. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70697. vertexAttribDivisor(index: number, divisor: number): void;
  70698. createVertexArray(): any;
  70699. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70700. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70701. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70702. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70703. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70704. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70705. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70706. // Queries
  70707. createQuery(): WebGLQuery;
  70708. deleteQuery(query: WebGLQuery): void;
  70709. beginQuery(target: number, query: WebGLQuery): void;
  70710. endQuery(target: number): void;
  70711. getQueryParameter(query: WebGLQuery, pname: number): any;
  70712. getQuery(target: number, pname: number): any;
  70713. MAX_SAMPLES: number;
  70714. RGBA8: number;
  70715. READ_FRAMEBUFFER: number;
  70716. DRAW_FRAMEBUFFER: number;
  70717. UNIFORM_BUFFER: number;
  70718. HALF_FLOAT_OES: number;
  70719. RGBA16F: number;
  70720. RGBA32F: number;
  70721. R32F: number;
  70722. RG32F: number;
  70723. RGB32F: number;
  70724. R16F: number;
  70725. RG16F: number;
  70726. RGB16F: number;
  70727. RED: number;
  70728. RG: number;
  70729. R8: number;
  70730. RG8: number;
  70731. UNSIGNED_INT_24_8: number;
  70732. DEPTH24_STENCIL8: number;
  70733. MIN: number;
  70734. MAX: number;
  70735. /* Multiple Render Targets */
  70736. drawBuffers(buffers: number[]): void;
  70737. readBuffer(src: number): void;
  70738. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70739. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70740. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70741. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70742. // Occlusion Query
  70743. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70744. ANY_SAMPLES_PASSED: number;
  70745. QUERY_RESULT_AVAILABLE: number;
  70746. QUERY_RESULT: number;
  70747. }
  70748. interface WebGLProgram {
  70749. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70750. }
  70751. interface EXT_disjoint_timer_query {
  70752. QUERY_COUNTER_BITS_EXT: number;
  70753. TIME_ELAPSED_EXT: number;
  70754. TIMESTAMP_EXT: number;
  70755. GPU_DISJOINT_EXT: number;
  70756. QUERY_RESULT_EXT: number;
  70757. QUERY_RESULT_AVAILABLE_EXT: number;
  70758. queryCounterEXT(query: WebGLQuery, target: number): void;
  70759. createQueryEXT(): WebGLQuery;
  70760. beginQueryEXT(target: number, query: WebGLQuery): void;
  70761. endQueryEXT(target: number): void;
  70762. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70763. deleteQueryEXT(query: WebGLQuery): void;
  70764. }
  70765. interface WebGLUniformLocation {
  70766. _currentState: any;
  70767. }
  70768. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70769. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70770. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70771. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70772. interface WebGLRenderingContext {
  70773. readonly RASTERIZER_DISCARD: number;
  70774. readonly DEPTH_COMPONENT24: number;
  70775. readonly TEXTURE_3D: number;
  70776. readonly TEXTURE_2D_ARRAY: number;
  70777. readonly TEXTURE_COMPARE_FUNC: number;
  70778. readonly TEXTURE_COMPARE_MODE: number;
  70779. readonly COMPARE_REF_TO_TEXTURE: number;
  70780. readonly TEXTURE_WRAP_R: number;
  70781. readonly HALF_FLOAT: number;
  70782. readonly RGB8: number;
  70783. readonly RED_INTEGER: number;
  70784. readonly RG_INTEGER: number;
  70785. readonly RGB_INTEGER: number;
  70786. readonly RGBA_INTEGER: number;
  70787. readonly R8_SNORM: number;
  70788. readonly RG8_SNORM: number;
  70789. readonly RGB8_SNORM: number;
  70790. readonly RGBA8_SNORM: number;
  70791. readonly R8I: number;
  70792. readonly RG8I: number;
  70793. readonly RGB8I: number;
  70794. readonly RGBA8I: number;
  70795. readonly R8UI: number;
  70796. readonly RG8UI: number;
  70797. readonly RGB8UI: number;
  70798. readonly RGBA8UI: number;
  70799. readonly R16I: number;
  70800. readonly RG16I: number;
  70801. readonly RGB16I: number;
  70802. readonly RGBA16I: number;
  70803. readonly R16UI: number;
  70804. readonly RG16UI: number;
  70805. readonly RGB16UI: number;
  70806. readonly RGBA16UI: number;
  70807. readonly R32I: number;
  70808. readonly RG32I: number;
  70809. readonly RGB32I: number;
  70810. readonly RGBA32I: number;
  70811. readonly R32UI: number;
  70812. readonly RG32UI: number;
  70813. readonly RGB32UI: number;
  70814. readonly RGBA32UI: number;
  70815. readonly RGB10_A2UI: number;
  70816. readonly R11F_G11F_B10F: number;
  70817. readonly RGB9_E5: number;
  70818. readonly RGB10_A2: number;
  70819. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70820. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70821. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70822. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70823. readonly DEPTH_COMPONENT32F: number;
  70824. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70825. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70826. 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;
  70827. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70828. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70829. readonly TRANSFORM_FEEDBACK: number;
  70830. readonly INTERLEAVED_ATTRIBS: number;
  70831. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70832. createTransformFeedback(): WebGLTransformFeedback;
  70833. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70834. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70835. beginTransformFeedback(primitiveMode: number): void;
  70836. endTransformFeedback(): void;
  70837. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70838. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70839. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70840. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70841. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70842. }
  70843. interface ImageBitmap {
  70844. readonly width: number;
  70845. readonly height: number;
  70846. close(): void;
  70847. }
  70848. interface WebGLQuery extends WebGLObject {
  70849. }
  70850. declare var WebGLQuery: {
  70851. prototype: WebGLQuery;
  70852. new(): WebGLQuery;
  70853. };
  70854. interface WebGLSampler extends WebGLObject {
  70855. }
  70856. declare var WebGLSampler: {
  70857. prototype: WebGLSampler;
  70858. new(): WebGLSampler;
  70859. };
  70860. interface WebGLSync extends WebGLObject {
  70861. }
  70862. declare var WebGLSync: {
  70863. prototype: WebGLSync;
  70864. new(): WebGLSync;
  70865. };
  70866. interface WebGLTransformFeedback extends WebGLObject {
  70867. }
  70868. declare var WebGLTransformFeedback: {
  70869. prototype: WebGLTransformFeedback;
  70870. new(): WebGLTransformFeedback;
  70871. };
  70872. interface WebGLVertexArrayObject extends WebGLObject {
  70873. }
  70874. declare var WebGLVertexArrayObject: {
  70875. prototype: WebGLVertexArrayObject;
  70876. new(): WebGLVertexArrayObject;
  70877. };
  70878. // Type definitions for WebVR API
  70879. // Project: https://w3c.github.io/webvr/
  70880. // Definitions by: six a <https://github.com/lostfictions>
  70881. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70882. interface VRDisplay extends EventTarget {
  70883. /**
  70884. * Dictionary of capabilities describing the VRDisplay.
  70885. */
  70886. readonly capabilities: VRDisplayCapabilities;
  70887. /**
  70888. * z-depth defining the far plane of the eye view frustum
  70889. * enables mapping of values in the render target depth
  70890. * attachment to scene coordinates. Initially set to 10000.0.
  70891. */
  70892. depthFar: number;
  70893. /**
  70894. * z-depth defining the near plane of the eye view frustum
  70895. * enables mapping of values in the render target depth
  70896. * attachment to scene coordinates. Initially set to 0.01.
  70897. */
  70898. depthNear: number;
  70899. /**
  70900. * An identifier for this distinct VRDisplay. Used as an
  70901. * association point in the Gamepad API.
  70902. */
  70903. readonly displayId: number;
  70904. /**
  70905. * A display name, a user-readable name identifying it.
  70906. */
  70907. readonly displayName: string;
  70908. readonly isConnected: boolean;
  70909. readonly isPresenting: boolean;
  70910. /**
  70911. * If this VRDisplay supports room-scale experiences, the optional
  70912. * stage attribute contains details on the room-scale parameters.
  70913. */
  70914. readonly stageParameters: VRStageParameters | null;
  70915. /**
  70916. * Passing the value returned by `requestAnimationFrame` to
  70917. * `cancelAnimationFrame` will unregister the callback.
  70918. * @param handle Define the hanle of the request to cancel
  70919. */
  70920. cancelAnimationFrame(handle: number): void;
  70921. /**
  70922. * Stops presenting to the VRDisplay.
  70923. * @returns a promise to know when it stopped
  70924. */
  70925. exitPresent(): Promise<void>;
  70926. /**
  70927. * Return the current VREyeParameters for the given eye.
  70928. * @param whichEye Define the eye we want the parameter for
  70929. * @returns the eye parameters
  70930. */
  70931. getEyeParameters(whichEye: string): VREyeParameters;
  70932. /**
  70933. * Populates the passed VRFrameData with the information required to render
  70934. * the current frame.
  70935. * @param frameData Define the data structure to populate
  70936. * @returns true if ok otherwise false
  70937. */
  70938. getFrameData(frameData: VRFrameData): boolean;
  70939. /**
  70940. * Get the layers currently being presented.
  70941. * @returns the list of VR layers
  70942. */
  70943. getLayers(): VRLayer[];
  70944. /**
  70945. * Return a VRPose containing the future predicted pose of the VRDisplay
  70946. * when the current frame will be presented. The value returned will not
  70947. * change until JavaScript has returned control to the browser.
  70948. *
  70949. * The VRPose will contain the position, orientation, velocity,
  70950. * and acceleration of each of these properties.
  70951. * @returns the pose object
  70952. */
  70953. getPose(): VRPose;
  70954. /**
  70955. * Return the current instantaneous pose of the VRDisplay, with no
  70956. * prediction applied.
  70957. * @returns the current instantaneous pose
  70958. */
  70959. getImmediatePose(): VRPose;
  70960. /**
  70961. * The callback passed to `requestAnimationFrame` will be called
  70962. * any time a new frame should be rendered. When the VRDisplay is
  70963. * presenting the callback will be called at the native refresh
  70964. * rate of the HMD. When not presenting this function acts
  70965. * identically to how window.requestAnimationFrame acts. Content should
  70966. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70967. * asynchronously from other displays and at differing refresh rates.
  70968. * @param callback Define the eaction to run next frame
  70969. * @returns the request handle it
  70970. */
  70971. requestAnimationFrame(callback: FrameRequestCallback): number;
  70972. /**
  70973. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70974. * Repeat calls while already presenting will update the VRLayers being displayed.
  70975. * @param layers Define the list of layer to present
  70976. * @returns a promise to know when the request has been fulfilled
  70977. */
  70978. requestPresent(layers: VRLayer[]): Promise<void>;
  70979. /**
  70980. * Reset the pose for this display, treating its current position and
  70981. * orientation as the "origin/zero" values. VRPose.position,
  70982. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70983. * updated when calling resetPose(). This should be called in only
  70984. * sitting-space experiences.
  70985. */
  70986. resetPose(): void;
  70987. /**
  70988. * The VRLayer provided to the VRDisplay will be captured and presented
  70989. * in the HMD. Calling this function has the same effect on the source
  70990. * canvas as any other operation that uses its source image, and canvases
  70991. * created without preserveDrawingBuffer set to true will be cleared.
  70992. * @param pose Define the pose to submit
  70993. */
  70994. submitFrame(pose?: VRPose): void;
  70995. }
  70996. declare var VRDisplay: {
  70997. prototype: VRDisplay;
  70998. new(): VRDisplay;
  70999. };
  71000. interface VRLayer {
  71001. leftBounds?: number[] | Float32Array | null;
  71002. rightBounds?: number[] | Float32Array | null;
  71003. source?: HTMLCanvasElement | null;
  71004. }
  71005. interface VRDisplayCapabilities {
  71006. readonly canPresent: boolean;
  71007. readonly hasExternalDisplay: boolean;
  71008. readonly hasOrientation: boolean;
  71009. readonly hasPosition: boolean;
  71010. readonly maxLayers: number;
  71011. }
  71012. interface VREyeParameters {
  71013. /** @deprecated */
  71014. readonly fieldOfView: VRFieldOfView;
  71015. readonly offset: Float32Array;
  71016. readonly renderHeight: number;
  71017. readonly renderWidth: number;
  71018. }
  71019. interface VRFieldOfView {
  71020. readonly downDegrees: number;
  71021. readonly leftDegrees: number;
  71022. readonly rightDegrees: number;
  71023. readonly upDegrees: number;
  71024. }
  71025. interface VRFrameData {
  71026. readonly leftProjectionMatrix: Float32Array;
  71027. readonly leftViewMatrix: Float32Array;
  71028. readonly pose: VRPose;
  71029. readonly rightProjectionMatrix: Float32Array;
  71030. readonly rightViewMatrix: Float32Array;
  71031. readonly timestamp: number;
  71032. }
  71033. interface VRPose {
  71034. readonly angularAcceleration: Float32Array | null;
  71035. readonly angularVelocity: Float32Array | null;
  71036. readonly linearAcceleration: Float32Array | null;
  71037. readonly linearVelocity: Float32Array | null;
  71038. readonly orientation: Float32Array | null;
  71039. readonly position: Float32Array | null;
  71040. readonly timestamp: number;
  71041. }
  71042. interface VRStageParameters {
  71043. sittingToStandingTransform?: Float32Array;
  71044. sizeX?: number;
  71045. sizeY?: number;
  71046. }
  71047. interface Navigator {
  71048. getVRDisplays(): Promise<VRDisplay[]>;
  71049. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  71050. }
  71051. interface Window {
  71052. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  71053. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  71054. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  71055. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71056. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71057. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  71058. }
  71059. interface Gamepad {
  71060. readonly displayId: number;
  71061. }
  71062. type XRSessionMode =
  71063. | "inline"
  71064. | "immersive-vr"
  71065. | "immersive-ar";
  71066. type XRReferenceSpaceType =
  71067. | "viewer"
  71068. | "local"
  71069. | "local-floor"
  71070. | "bounded-floor"
  71071. | "unbounded";
  71072. type XREnvironmentBlendMode =
  71073. | "opaque"
  71074. | "additive"
  71075. | "alpha-blend";
  71076. type XRVisibilityState =
  71077. | "visible"
  71078. | "visible-blurred"
  71079. | "hidden";
  71080. type XRHandedness =
  71081. | "none"
  71082. | "left"
  71083. | "right";
  71084. type XRTargetRayMode =
  71085. | "gaze"
  71086. | "tracked-pointer"
  71087. | "screen";
  71088. type XREye =
  71089. | "none"
  71090. | "left"
  71091. | "right";
  71092. type XREventType =
  71093. | "devicechange"
  71094. | "visibilitychange"
  71095. | "end"
  71096. | "inputsourceschange"
  71097. | "select"
  71098. | "selectstart"
  71099. | "selectend"
  71100. | "squeeze"
  71101. | "squeezestart"
  71102. | "squeezeend"
  71103. | "reset";
  71104. interface XRSpace extends EventTarget {
  71105. }
  71106. interface XRRenderState {
  71107. depthNear?: number;
  71108. depthFar?: number;
  71109. inlineVerticalFieldOfView?: number;
  71110. baseLayer?: XRWebGLLayer;
  71111. }
  71112. interface XRInputSource {
  71113. handedness: XRHandedness;
  71114. targetRayMode: XRTargetRayMode;
  71115. targetRaySpace: XRSpace;
  71116. gripSpace: XRSpace | undefined;
  71117. gamepad: Gamepad | undefined;
  71118. profiles: Array<string>;
  71119. }
  71120. interface XRSessionInit {
  71121. optionalFeatures?: XRReferenceSpaceType[];
  71122. requiredFeatures?: XRReferenceSpaceType[];
  71123. }
  71124. interface XRSession extends XRAnchorCreator {
  71125. addEventListener: Function;
  71126. removeEventListener: Function;
  71127. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  71128. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  71129. requestAnimationFrame: Function;
  71130. end(): Promise<void>;
  71131. renderState: XRRenderState;
  71132. inputSources: Array<XRInputSource>;
  71133. // hit test
  71134. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  71135. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  71136. // legacy AR hit test
  71137. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71138. // legacy plane detection
  71139. updateWorldTrackingState(options: {
  71140. planeDetectionState?: { enabled: boolean; }
  71141. }): void;
  71142. }
  71143. interface XRReferenceSpace extends XRSpace {
  71144. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  71145. onreset: any;
  71146. }
  71147. type XRPlaneSet = Set<XRPlane>;
  71148. type XRAnchorSet = Set<XRAnchor>;
  71149. interface XRFrame {
  71150. session: XRSession;
  71151. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  71152. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  71153. // AR
  71154. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  71155. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  71156. // Anchors
  71157. trackedAnchors?: XRAnchorSet;
  71158. // Planes
  71159. worldInformation: {
  71160. detectedPlanes?: XRPlaneSet;
  71161. };
  71162. }
  71163. interface XRViewerPose extends XRPose {
  71164. views: Array<XRView>;
  71165. }
  71166. interface XRPose {
  71167. transform: XRRigidTransform;
  71168. emulatedPosition: boolean;
  71169. }
  71170. interface XRWebGLLayerOptions {
  71171. antialias?: boolean;
  71172. depth?: boolean;
  71173. stencil?: boolean;
  71174. alpha?: boolean;
  71175. multiview?: boolean;
  71176. framebufferScaleFactor?: number;
  71177. }
  71178. declare var XRWebGLLayer: {
  71179. prototype: XRWebGLLayer;
  71180. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  71181. };
  71182. interface XRWebGLLayer {
  71183. framebuffer: WebGLFramebuffer;
  71184. framebufferWidth: number;
  71185. framebufferHeight: number;
  71186. getViewport: Function;
  71187. }
  71188. declare class XRRigidTransform {
  71189. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  71190. position: DOMPointReadOnly;
  71191. orientation: DOMPointReadOnly;
  71192. matrix: Float32Array;
  71193. inverse: XRRigidTransform;
  71194. }
  71195. interface XRView {
  71196. eye: XREye;
  71197. projectionMatrix: Float32Array;
  71198. transform: XRRigidTransform;
  71199. }
  71200. interface XRInputSourceChangeEvent {
  71201. session: XRSession;
  71202. removed: Array<XRInputSource>;
  71203. added: Array<XRInputSource>;
  71204. }
  71205. interface XRInputSourceEvent extends Event {
  71206. readonly frame: XRFrame;
  71207. readonly inputSource: XRInputSource;
  71208. }
  71209. // Experimental(er) features
  71210. declare class XRRay {
  71211. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  71212. origin: DOMPointReadOnly;
  71213. direction: DOMPointReadOnly;
  71214. matrix: Float32Array;
  71215. }
  71216. declare enum XRHitTestTrackableType {
  71217. "point",
  71218. "plane"
  71219. }
  71220. interface XRHitResult {
  71221. hitMatrix: Float32Array;
  71222. }
  71223. interface XRTransientInputHitTestResult {
  71224. readonly inputSource: XRInputSource;
  71225. readonly results: Array<XRHitTestResult>;
  71226. }
  71227. interface XRHitTestResult {
  71228. getPose(baseSpace: XRSpace): XRPose | undefined;
  71229. }
  71230. interface XRHitTestSource {
  71231. cancel(): void;
  71232. }
  71233. interface XRTransientInputHitTestSource {
  71234. cancel(): void;
  71235. }
  71236. interface XRHitTestOptionsInit {
  71237. space: XRSpace;
  71238. entityTypes?: Array<XRHitTestTrackableType>;
  71239. offsetRay?: XRRay;
  71240. }
  71241. interface XRTransientInputHitTestOptionsInit {
  71242. profile: string;
  71243. entityTypes?: Array<XRHitTestTrackableType>;
  71244. offsetRay?: XRRay;
  71245. }
  71246. interface XRAnchor {
  71247. // remove?
  71248. id?: string;
  71249. anchorSpace: XRSpace;
  71250. lastChangedTime: number;
  71251. detach(): void;
  71252. }
  71253. interface XRPlane extends XRAnchorCreator {
  71254. orientation: "Horizontal" | "Vertical";
  71255. planeSpace: XRSpace;
  71256. polygon: Array<DOMPointReadOnly>;
  71257. lastChangedTime: number;
  71258. }
  71259. interface XRAnchorCreator {
  71260. // AR Anchors
  71261. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71262. }
  71263. /**
  71264. * @ignore
  71265. */
  71266. declare module BABYLON.GLTF2.Exporter {
  71267. }
  71268. /**
  71269. * @ignore
  71270. */
  71271. declare module BABYLON.GLTF1 {
  71272. }
  71273. declare module BABYLON.GUI {
  71274. /**
  71275. * Class used to specific a value and its associated unit
  71276. */
  71277. export class ValueAndUnit {
  71278. /** defines the unit to store */
  71279. unit: number;
  71280. /** defines a boolean indicating if the value can be negative */
  71281. negativeValueAllowed: boolean;
  71282. private _value;
  71283. private _originalUnit;
  71284. /**
  71285. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71286. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71287. */
  71288. ignoreAdaptiveScaling: boolean;
  71289. /**
  71290. * Creates a new ValueAndUnit
  71291. * @param value defines the value to store
  71292. * @param unit defines the unit to store
  71293. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71294. */
  71295. constructor(value: number,
  71296. /** defines the unit to store */
  71297. unit?: number,
  71298. /** defines a boolean indicating if the value can be negative */
  71299. negativeValueAllowed?: boolean);
  71300. /** Gets a boolean indicating if the value is a percentage */
  71301. get isPercentage(): boolean;
  71302. /** Gets a boolean indicating if the value is store as pixel */
  71303. get isPixel(): boolean;
  71304. /** Gets direct internal value */
  71305. get internalValue(): number;
  71306. /**
  71307. * Gets value as pixel
  71308. * @param host defines the root host
  71309. * @param refValue defines the reference value for percentages
  71310. * @returns the value as pixel
  71311. */
  71312. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71313. /**
  71314. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71315. * @param value defines the value to store
  71316. * @param unit defines the unit to store
  71317. * @returns the current ValueAndUnit
  71318. */
  71319. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71320. /**
  71321. * Gets the value accordingly to its unit
  71322. * @param host defines the root host
  71323. * @returns the value
  71324. */
  71325. getValue(host: AdvancedDynamicTexture): number;
  71326. /**
  71327. * Gets a string representation of the value
  71328. * @param host defines the root host
  71329. * @param decimals defines an optional number of decimals to display
  71330. * @returns a string
  71331. */
  71332. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71333. /**
  71334. * Store a value parsed from a string
  71335. * @param source defines the source string
  71336. * @returns true if the value was successfully parsed
  71337. */
  71338. fromString(source: string | number): boolean;
  71339. private static _Regex;
  71340. private static _UNITMODE_PERCENTAGE;
  71341. private static _UNITMODE_PIXEL;
  71342. /** UNITMODE_PERCENTAGE */
  71343. static get UNITMODE_PERCENTAGE(): number;
  71344. /** UNITMODE_PIXEL */
  71345. static get UNITMODE_PIXEL(): number;
  71346. }
  71347. }
  71348. declare module BABYLON.GUI {
  71349. /**
  71350. * Define a style used by control to automatically setup properties based on a template.
  71351. * Only support font related properties so far
  71352. */
  71353. export class Style implements BABYLON.IDisposable {
  71354. private _fontFamily;
  71355. private _fontStyle;
  71356. private _fontWeight;
  71357. /** @hidden */
  71358. _host: AdvancedDynamicTexture;
  71359. /** @hidden */
  71360. _fontSize: ValueAndUnit;
  71361. /**
  71362. * BABYLON.Observable raised when the style values are changed
  71363. */
  71364. onChangedObservable: BABYLON.Observable<Style>;
  71365. /**
  71366. * Creates a new style object
  71367. * @param host defines the AdvancedDynamicTexture which hosts this style
  71368. */
  71369. constructor(host: AdvancedDynamicTexture);
  71370. /**
  71371. * Gets or sets the font size
  71372. */
  71373. get fontSize(): string | number;
  71374. set fontSize(value: string | number);
  71375. /**
  71376. * Gets or sets the font family
  71377. */
  71378. get fontFamily(): string;
  71379. set fontFamily(value: string);
  71380. /**
  71381. * Gets or sets the font style
  71382. */
  71383. get fontStyle(): string;
  71384. set fontStyle(value: string);
  71385. /** Gets or sets font weight */
  71386. get fontWeight(): string;
  71387. set fontWeight(value: string);
  71388. /** Dispose all associated resources */
  71389. dispose(): void;
  71390. }
  71391. }
  71392. declare module BABYLON.GUI {
  71393. /**
  71394. * Class used to transport BABYLON.Vector2 information for pointer events
  71395. */
  71396. export class Vector2WithInfo extends BABYLON.Vector2 {
  71397. /** defines the current mouse button index */
  71398. buttonIndex: number;
  71399. /**
  71400. * Creates a new Vector2WithInfo
  71401. * @param source defines the vector2 data to transport
  71402. * @param buttonIndex defines the current mouse button index
  71403. */
  71404. constructor(source: BABYLON.Vector2,
  71405. /** defines the current mouse button index */
  71406. buttonIndex?: number);
  71407. }
  71408. /** Class used to provide 2D matrix features */
  71409. export class Matrix2D {
  71410. /** Gets the internal array of 6 floats used to store matrix data */
  71411. m: Float32Array;
  71412. /**
  71413. * Creates a new matrix
  71414. * @param m00 defines value for (0, 0)
  71415. * @param m01 defines value for (0, 1)
  71416. * @param m10 defines value for (1, 0)
  71417. * @param m11 defines value for (1, 1)
  71418. * @param m20 defines value for (2, 0)
  71419. * @param m21 defines value for (2, 1)
  71420. */
  71421. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71422. /**
  71423. * Fills the matrix from direct values
  71424. * @param m00 defines value for (0, 0)
  71425. * @param m01 defines value for (0, 1)
  71426. * @param m10 defines value for (1, 0)
  71427. * @param m11 defines value for (1, 1)
  71428. * @param m20 defines value for (2, 0)
  71429. * @param m21 defines value for (2, 1)
  71430. * @returns the current modified matrix
  71431. */
  71432. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71433. /**
  71434. * Gets matrix determinant
  71435. * @returns the determinant
  71436. */
  71437. determinant(): number;
  71438. /**
  71439. * Inverses the matrix and stores it in a target matrix
  71440. * @param result defines the target matrix
  71441. * @returns the current matrix
  71442. */
  71443. invertToRef(result: Matrix2D): Matrix2D;
  71444. /**
  71445. * Multiplies the current matrix with another one
  71446. * @param other defines the second operand
  71447. * @param result defines the target matrix
  71448. * @returns the current matrix
  71449. */
  71450. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71451. /**
  71452. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71453. * @param x defines the x coordinate to transform
  71454. * @param y defines the x coordinate to transform
  71455. * @param result defines the target vector2
  71456. * @returns the current matrix
  71457. */
  71458. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71459. /**
  71460. * Creates an identity matrix
  71461. * @returns a new matrix
  71462. */
  71463. static Identity(): Matrix2D;
  71464. /**
  71465. * Creates a translation matrix and stores it in a target matrix
  71466. * @param x defines the x coordinate of the translation
  71467. * @param y defines the y coordinate of the translation
  71468. * @param result defines the target matrix
  71469. */
  71470. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71471. /**
  71472. * Creates a scaling matrix and stores it in a target matrix
  71473. * @param x defines the x coordinate of the scaling
  71474. * @param y defines the y coordinate of the scaling
  71475. * @param result defines the target matrix
  71476. */
  71477. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71478. /**
  71479. * Creates a rotation matrix and stores it in a target matrix
  71480. * @param angle defines the rotation angle
  71481. * @param result defines the target matrix
  71482. */
  71483. static RotationToRef(angle: number, result: Matrix2D): void;
  71484. private static _TempPreTranslationMatrix;
  71485. private static _TempPostTranslationMatrix;
  71486. private static _TempRotationMatrix;
  71487. private static _TempScalingMatrix;
  71488. private static _TempCompose0;
  71489. private static _TempCompose1;
  71490. private static _TempCompose2;
  71491. /**
  71492. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71493. * @param tx defines the x coordinate of the translation
  71494. * @param ty defines the y coordinate of the translation
  71495. * @param angle defines the rotation angle
  71496. * @param scaleX defines the x coordinate of the scaling
  71497. * @param scaleY defines the y coordinate of the scaling
  71498. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71499. * @param result defines the target matrix
  71500. */
  71501. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71502. }
  71503. }
  71504. declare module BABYLON.GUI {
  71505. /**
  71506. * Class used to store 2D control sizes
  71507. */
  71508. export class Measure {
  71509. /** defines left coordinate */
  71510. left: number;
  71511. /** defines top coordinate */
  71512. top: number;
  71513. /** defines width dimension */
  71514. width: number;
  71515. /** defines height dimension */
  71516. height: number;
  71517. /**
  71518. * Creates a new measure
  71519. * @param left defines left coordinate
  71520. * @param top defines top coordinate
  71521. * @param width defines width dimension
  71522. * @param height defines height dimension
  71523. */
  71524. constructor(
  71525. /** defines left coordinate */
  71526. left: number,
  71527. /** defines top coordinate */
  71528. top: number,
  71529. /** defines width dimension */
  71530. width: number,
  71531. /** defines height dimension */
  71532. height: number);
  71533. /**
  71534. * Copy from another measure
  71535. * @param other defines the other measure to copy from
  71536. */
  71537. copyFrom(other: Measure): void;
  71538. /**
  71539. * Copy from a group of 4 floats
  71540. * @param left defines left coordinate
  71541. * @param top defines top coordinate
  71542. * @param width defines width dimension
  71543. * @param height defines height dimension
  71544. */
  71545. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71546. /**
  71547. * Computes the axis aligned bounding box measure for two given measures
  71548. * @param a Input measure
  71549. * @param b Input measure
  71550. * @param result the resulting bounding measure
  71551. */
  71552. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71553. /**
  71554. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71555. * @param transform the matrix to transform the measure before computing the AABB
  71556. * @param result the resulting AABB
  71557. */
  71558. transformToRef(transform: Matrix2D, result: Measure): void;
  71559. /**
  71560. * Check equality between this measure and another one
  71561. * @param other defines the other measures
  71562. * @returns true if both measures are equals
  71563. */
  71564. isEqualsTo(other: Measure): boolean;
  71565. /**
  71566. * Creates an empty measure
  71567. * @returns a new measure
  71568. */
  71569. static Empty(): Measure;
  71570. }
  71571. }
  71572. declare module BABYLON.GUI {
  71573. /**
  71574. * Interface used to define a control that can receive focus
  71575. */
  71576. export interface IFocusableControl {
  71577. /**
  71578. * Function called when the control receives the focus
  71579. */
  71580. onFocus(): void;
  71581. /**
  71582. * Function called when the control loses the focus
  71583. */
  71584. onBlur(): void;
  71585. /**
  71586. * Function called to let the control handle keyboard events
  71587. * @param evt defines the current keyboard event
  71588. */
  71589. processKeyboard(evt: KeyboardEvent): void;
  71590. /**
  71591. * Function called to get the list of controls that should not steal the focus from this control
  71592. * @returns an array of controls
  71593. */
  71594. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71595. }
  71596. /**
  71597. * Class used to create texture to support 2D GUI elements
  71598. * @see http://doc.babylonjs.com/how_to/gui
  71599. */
  71600. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71601. private _isDirty;
  71602. private _renderObserver;
  71603. private _resizeObserver;
  71604. private _preKeyboardObserver;
  71605. private _pointerMoveObserver;
  71606. private _pointerObserver;
  71607. private _canvasPointerOutObserver;
  71608. private _background;
  71609. /** @hidden */
  71610. _rootContainer: Container;
  71611. /** @hidden */
  71612. _lastPickedControl: Control;
  71613. /** @hidden */
  71614. _lastControlOver: {
  71615. [pointerId: number]: Control;
  71616. };
  71617. /** @hidden */
  71618. _lastControlDown: {
  71619. [pointerId: number]: Control;
  71620. };
  71621. /** @hidden */
  71622. _capturingControl: {
  71623. [pointerId: number]: Control;
  71624. };
  71625. /** @hidden */
  71626. _shouldBlockPointer: boolean;
  71627. /** @hidden */
  71628. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71629. /** @hidden */
  71630. _linkedControls: Control[];
  71631. private _isFullscreen;
  71632. private _fullscreenViewport;
  71633. private _idealWidth;
  71634. private _idealHeight;
  71635. private _useSmallestIdeal;
  71636. private _renderAtIdealSize;
  71637. private _focusedControl;
  71638. private _blockNextFocusCheck;
  71639. private _renderScale;
  71640. private _rootElement;
  71641. private _cursorChanged;
  71642. private _defaultMousePointerId;
  71643. /** @hidden */
  71644. _numLayoutCalls: number;
  71645. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71646. get numLayoutCalls(): number;
  71647. /** @hidden */
  71648. _numRenderCalls: number;
  71649. /** Gets the number of render calls made the last time the ADT has been rendered */
  71650. get numRenderCalls(): number;
  71651. /**
  71652. * Define type to string to ensure compatibility across browsers
  71653. * Safari doesn't support DataTransfer constructor
  71654. */
  71655. private _clipboardData;
  71656. /**
  71657. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71658. */
  71659. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71660. /**
  71661. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71662. */
  71663. onControlPickedObservable: BABYLON.Observable<Control>;
  71664. /**
  71665. * BABYLON.Observable event triggered before layout is evaluated
  71666. */
  71667. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71668. /**
  71669. * BABYLON.Observable event triggered after the layout was evaluated
  71670. */
  71671. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71672. /**
  71673. * BABYLON.Observable event triggered before the texture is rendered
  71674. */
  71675. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71676. /**
  71677. * BABYLON.Observable event triggered after the texture was rendered
  71678. */
  71679. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71680. /**
  71681. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71682. */
  71683. premulAlpha: boolean;
  71684. /**
  71685. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71686. * Useful when you want more antialiasing
  71687. */
  71688. get renderScale(): number;
  71689. set renderScale(value: number);
  71690. /** Gets or sets the background color */
  71691. get background(): string;
  71692. set background(value: string);
  71693. /**
  71694. * Gets or sets the ideal width used to design controls.
  71695. * The GUI will then rescale everything accordingly
  71696. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71697. */
  71698. get idealWidth(): number;
  71699. set idealWidth(value: number);
  71700. /**
  71701. * Gets or sets the ideal height used to design controls.
  71702. * The GUI will then rescale everything accordingly
  71703. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71704. */
  71705. get idealHeight(): number;
  71706. set idealHeight(value: number);
  71707. /**
  71708. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71709. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71710. */
  71711. get useSmallestIdeal(): boolean;
  71712. set useSmallestIdeal(value: boolean);
  71713. /**
  71714. * Gets or sets a boolean indicating if adaptive scaling must be used
  71715. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71716. */
  71717. get renderAtIdealSize(): boolean;
  71718. set renderAtIdealSize(value: boolean);
  71719. /**
  71720. * Gets the ratio used when in "ideal mode"
  71721. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71722. * */
  71723. get idealRatio(): number;
  71724. /**
  71725. * Gets the underlying layer used to render the texture when in fullscreen mode
  71726. */
  71727. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71728. /**
  71729. * Gets the root container control
  71730. */
  71731. get rootContainer(): Container;
  71732. /**
  71733. * Returns an array containing the root container.
  71734. * This is mostly used to let the Inspector introspects the ADT
  71735. * @returns an array containing the rootContainer
  71736. */
  71737. getChildren(): Array<Container>;
  71738. /**
  71739. * Will return all controls that are inside this texture
  71740. * @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
  71741. * @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
  71742. * @return all child controls
  71743. */
  71744. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71745. /**
  71746. * Gets or sets the current focused control
  71747. */
  71748. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71749. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71750. /**
  71751. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71752. */
  71753. get isForeground(): boolean;
  71754. set isForeground(value: boolean);
  71755. /**
  71756. * Gets or set information about clipboardData
  71757. */
  71758. get clipboardData(): string;
  71759. set clipboardData(value: string);
  71760. /**
  71761. * Creates a new AdvancedDynamicTexture
  71762. * @param name defines the name of the texture
  71763. * @param width defines the width of the texture
  71764. * @param height defines the height of the texture
  71765. * @param scene defines the hosting scene
  71766. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71767. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71768. */
  71769. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71770. /**
  71771. * Get the current class name of the texture useful for serialization or dynamic coding.
  71772. * @returns "AdvancedDynamicTexture"
  71773. */
  71774. getClassName(): string;
  71775. /**
  71776. * Function used to execute a function on all controls
  71777. * @param func defines the function to execute
  71778. * @param container defines the container where controls belong. If null the root container will be used
  71779. */
  71780. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71781. private _useInvalidateRectOptimization;
  71782. /**
  71783. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71784. */
  71785. get useInvalidateRectOptimization(): boolean;
  71786. set useInvalidateRectOptimization(value: boolean);
  71787. private _invalidatedRectangle;
  71788. /**
  71789. * Invalidates a rectangle area on the gui texture
  71790. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71791. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71792. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71793. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71794. */
  71795. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71796. /**
  71797. * Marks the texture as dirty forcing a complete update
  71798. */
  71799. markAsDirty(): void;
  71800. /**
  71801. * Helper function used to create a new style
  71802. * @returns a new style
  71803. * @see http://doc.babylonjs.com/how_to/gui#styles
  71804. */
  71805. createStyle(): Style;
  71806. /**
  71807. * Adds a new control to the root container
  71808. * @param control defines the control to add
  71809. * @returns the current texture
  71810. */
  71811. addControl(control: Control): AdvancedDynamicTexture;
  71812. /**
  71813. * Removes a control from the root container
  71814. * @param control defines the control to remove
  71815. * @returns the current texture
  71816. */
  71817. removeControl(control: Control): AdvancedDynamicTexture;
  71818. /**
  71819. * Release all resources
  71820. */
  71821. dispose(): void;
  71822. private _onResize;
  71823. /** @hidden */
  71824. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71825. /**
  71826. * Get screen coordinates for a vector3
  71827. * @param position defines the position to project
  71828. * @param worldMatrix defines the world matrix to use
  71829. * @returns the projected position
  71830. */
  71831. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71832. private _checkUpdate;
  71833. private _clearMeasure;
  71834. private _render;
  71835. /** @hidden */
  71836. _changeCursor(cursor: string): void;
  71837. /** @hidden */
  71838. _registerLastControlDown(control: Control, pointerId: number): void;
  71839. private _doPicking;
  71840. /** @hidden */
  71841. _cleanControlAfterRemovalFromList(list: {
  71842. [pointerId: number]: Control;
  71843. }, control: Control): void;
  71844. /** @hidden */
  71845. _cleanControlAfterRemoval(control: Control): void;
  71846. /** Attach to all scene events required to support pointer events */
  71847. attach(): void;
  71848. /** @hidden */
  71849. private onClipboardCopy;
  71850. /** @hidden */
  71851. private onClipboardCut;
  71852. /** @hidden */
  71853. private onClipboardPaste;
  71854. /**
  71855. * Register the clipboard Events onto the canvas
  71856. */
  71857. registerClipboardEvents(): void;
  71858. /**
  71859. * Unregister the clipboard Events from the canvas
  71860. */
  71861. unRegisterClipboardEvents(): void;
  71862. /**
  71863. * Connect the texture to a hosting mesh to enable interactions
  71864. * @param mesh defines the mesh to attach to
  71865. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71866. */
  71867. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71868. /**
  71869. * Move the focus to a specific control
  71870. * @param control defines the control which will receive the focus
  71871. */
  71872. moveFocusToControl(control: IFocusableControl): void;
  71873. private _manageFocus;
  71874. private _attachToOnPointerOut;
  71875. /**
  71876. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71877. * @param mesh defines the mesh which will receive the texture
  71878. * @param width defines the texture width (1024 by default)
  71879. * @param height defines the texture height (1024 by default)
  71880. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71881. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71882. * @returns a new AdvancedDynamicTexture
  71883. */
  71884. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71885. /**
  71886. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71887. * In this mode the texture will rely on a layer for its rendering.
  71888. * This allows it to be treated like any other layer.
  71889. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71890. * LayerMask is set through advancedTexture.layer.layerMask
  71891. * @param name defines name for the texture
  71892. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71893. * @param scene defines the hsoting scene
  71894. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71895. * @returns a new AdvancedDynamicTexture
  71896. */
  71897. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71898. }
  71899. }
  71900. declare module BABYLON.GUI {
  71901. /**
  71902. * Root class used for all 2D controls
  71903. * @see http://doc.babylonjs.com/how_to/gui#controls
  71904. */
  71905. export class Control {
  71906. /** defines the name of the control */
  71907. name?: string | undefined;
  71908. /**
  71909. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71910. */
  71911. static AllowAlphaInheritance: boolean;
  71912. private _alpha;
  71913. private _alphaSet;
  71914. private _zIndex;
  71915. /** @hidden */
  71916. _host: AdvancedDynamicTexture;
  71917. /** Gets or sets the control parent */
  71918. parent: BABYLON.Nullable<Container>;
  71919. /** @hidden */
  71920. _currentMeasure: Measure;
  71921. private _fontFamily;
  71922. private _fontStyle;
  71923. private _fontWeight;
  71924. private _fontSize;
  71925. private _font;
  71926. /** @hidden */
  71927. _width: ValueAndUnit;
  71928. /** @hidden */
  71929. _height: ValueAndUnit;
  71930. /** @hidden */
  71931. protected _fontOffset: {
  71932. ascent: number;
  71933. height: number;
  71934. descent: number;
  71935. };
  71936. private _color;
  71937. private _style;
  71938. private _styleObserver;
  71939. /** @hidden */
  71940. protected _horizontalAlignment: number;
  71941. /** @hidden */
  71942. protected _verticalAlignment: number;
  71943. /** @hidden */
  71944. protected _isDirty: boolean;
  71945. /** @hidden */
  71946. protected _wasDirty: boolean;
  71947. /** @hidden */
  71948. _tempParentMeasure: Measure;
  71949. /** @hidden */
  71950. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71951. /** @hidden */
  71952. protected _cachedParentMeasure: Measure;
  71953. private _paddingLeft;
  71954. private _paddingRight;
  71955. private _paddingTop;
  71956. private _paddingBottom;
  71957. /** @hidden */
  71958. _left: ValueAndUnit;
  71959. /** @hidden */
  71960. _top: ValueAndUnit;
  71961. private _scaleX;
  71962. private _scaleY;
  71963. private _rotation;
  71964. private _transformCenterX;
  71965. private _transformCenterY;
  71966. /** @hidden */
  71967. _transformMatrix: Matrix2D;
  71968. /** @hidden */
  71969. protected _invertTransformMatrix: Matrix2D;
  71970. /** @hidden */
  71971. protected _transformedPosition: BABYLON.Vector2;
  71972. private _isMatrixDirty;
  71973. private _cachedOffsetX;
  71974. private _cachedOffsetY;
  71975. private _isVisible;
  71976. private _isHighlighted;
  71977. /** @hidden */
  71978. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71979. private _fontSet;
  71980. private _dummyVector2;
  71981. private _downCount;
  71982. private _enterCount;
  71983. private _doNotRender;
  71984. private _downPointerIds;
  71985. protected _isEnabled: boolean;
  71986. protected _disabledColor: string;
  71987. protected _disabledColorItem: string;
  71988. /** @hidden */
  71989. protected _rebuildLayout: boolean;
  71990. /** @hidden */
  71991. _customData: any;
  71992. /** @hidden */
  71993. _isClipped: boolean;
  71994. /** @hidden */
  71995. _automaticSize: boolean;
  71996. /** @hidden */
  71997. _tag: any;
  71998. /**
  71999. * 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
  72000. */
  72001. uniqueId: number;
  72002. /**
  72003. * Gets or sets an object used to store user defined information for the node
  72004. */
  72005. metadata: any;
  72006. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  72007. isHitTestVisible: boolean;
  72008. /** Gets or sets a boolean indicating if the control can block pointer events */
  72009. isPointerBlocker: boolean;
  72010. /** Gets or sets a boolean indicating if the control can be focusable */
  72011. isFocusInvisible: boolean;
  72012. /**
  72013. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  72014. * 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
  72015. */
  72016. clipChildren: boolean;
  72017. /**
  72018. * Gets or sets a boolean indicating that control content must be clipped
  72019. * 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
  72020. */
  72021. clipContent: boolean;
  72022. /**
  72023. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  72024. */
  72025. useBitmapCache: boolean;
  72026. private _cacheData;
  72027. private _shadowOffsetX;
  72028. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  72029. get shadowOffsetX(): number;
  72030. set shadowOffsetX(value: number);
  72031. private _shadowOffsetY;
  72032. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  72033. get shadowOffsetY(): number;
  72034. set shadowOffsetY(value: number);
  72035. private _shadowBlur;
  72036. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  72037. get shadowBlur(): number;
  72038. set shadowBlur(value: number);
  72039. private _shadowColor;
  72040. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  72041. get shadowColor(): string;
  72042. set shadowColor(value: string);
  72043. /** Gets or sets the cursor to use when the control is hovered */
  72044. hoverCursor: string;
  72045. /** @hidden */
  72046. protected _linkOffsetX: ValueAndUnit;
  72047. /** @hidden */
  72048. protected _linkOffsetY: ValueAndUnit;
  72049. /** Gets the control type name */
  72050. get typeName(): string;
  72051. /**
  72052. * Get the current class name of the control.
  72053. * @returns current class name
  72054. */
  72055. getClassName(): string;
  72056. /**
  72057. * An event triggered when pointer wheel is scrolled
  72058. */
  72059. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  72060. /**
  72061. * An event triggered when the pointer move over the control.
  72062. */
  72063. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  72064. /**
  72065. * An event triggered when the pointer move out of the control.
  72066. */
  72067. onPointerOutObservable: BABYLON.Observable<Control>;
  72068. /**
  72069. * An event triggered when the pointer taps the control
  72070. */
  72071. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  72072. /**
  72073. * An event triggered when pointer up
  72074. */
  72075. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  72076. /**
  72077. * An event triggered when a control is clicked on
  72078. */
  72079. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  72080. /**
  72081. * An event triggered when pointer enters the control
  72082. */
  72083. onPointerEnterObservable: BABYLON.Observable<Control>;
  72084. /**
  72085. * An event triggered when the control is marked as dirty
  72086. */
  72087. onDirtyObservable: BABYLON.Observable<Control>;
  72088. /**
  72089. * An event triggered before drawing the control
  72090. */
  72091. onBeforeDrawObservable: BABYLON.Observable<Control>;
  72092. /**
  72093. * An event triggered after the control was drawn
  72094. */
  72095. onAfterDrawObservable: BABYLON.Observable<Control>;
  72096. /**
  72097. * An event triggered when the control has been disposed
  72098. */
  72099. onDisposeObservable: BABYLON.Observable<Control>;
  72100. /**
  72101. * Get the hosting AdvancedDynamicTexture
  72102. */
  72103. get host(): AdvancedDynamicTexture;
  72104. /** Gets or set information about font offsets (used to render and align text) */
  72105. get fontOffset(): {
  72106. ascent: number;
  72107. height: number;
  72108. descent: number;
  72109. };
  72110. set fontOffset(offset: {
  72111. ascent: number;
  72112. height: number;
  72113. descent: number;
  72114. });
  72115. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  72116. get alpha(): number;
  72117. set alpha(value: number);
  72118. /**
  72119. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  72120. */
  72121. get isHighlighted(): boolean;
  72122. set isHighlighted(value: boolean);
  72123. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  72124. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72125. */
  72126. get scaleX(): number;
  72127. set scaleX(value: number);
  72128. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  72129. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72130. */
  72131. get scaleY(): number;
  72132. set scaleY(value: number);
  72133. /** Gets or sets the rotation angle (0 by default)
  72134. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72135. */
  72136. get rotation(): number;
  72137. set rotation(value: number);
  72138. /** Gets or sets the transformation center on Y axis (0 by default)
  72139. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72140. */
  72141. get transformCenterY(): number;
  72142. set transformCenterY(value: number);
  72143. /** Gets or sets the transformation center on X axis (0 by default)
  72144. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72145. */
  72146. get transformCenterX(): number;
  72147. set transformCenterX(value: number);
  72148. /**
  72149. * Gets or sets the horizontal alignment
  72150. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72151. */
  72152. get horizontalAlignment(): number;
  72153. set horizontalAlignment(value: number);
  72154. /**
  72155. * Gets or sets the vertical alignment
  72156. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72157. */
  72158. get verticalAlignment(): number;
  72159. set verticalAlignment(value: number);
  72160. /**
  72161. * Gets or sets control width
  72162. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72163. */
  72164. get width(): string | number;
  72165. set width(value: string | number);
  72166. /**
  72167. * Gets or sets the control width in pixel
  72168. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72169. */
  72170. get widthInPixels(): number;
  72171. set widthInPixels(value: number);
  72172. /**
  72173. * Gets or sets control height
  72174. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72175. */
  72176. get height(): string | number;
  72177. set height(value: string | number);
  72178. /**
  72179. * Gets or sets control height in pixel
  72180. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72181. */
  72182. get heightInPixels(): number;
  72183. set heightInPixels(value: number);
  72184. /** Gets or set font family */
  72185. get fontFamily(): string;
  72186. set fontFamily(value: string);
  72187. /** Gets or sets font style */
  72188. get fontStyle(): string;
  72189. set fontStyle(value: string);
  72190. /** Gets or sets font weight */
  72191. get fontWeight(): string;
  72192. set fontWeight(value: string);
  72193. /**
  72194. * Gets or sets style
  72195. * @see http://doc.babylonjs.com/how_to/gui#styles
  72196. */
  72197. get style(): BABYLON.Nullable<Style>;
  72198. set style(value: BABYLON.Nullable<Style>);
  72199. /** @hidden */
  72200. get _isFontSizeInPercentage(): boolean;
  72201. /** Gets or sets font size in pixels */
  72202. get fontSizeInPixels(): number;
  72203. set fontSizeInPixels(value: number);
  72204. /** Gets or sets font size */
  72205. get fontSize(): string | number;
  72206. set fontSize(value: string | number);
  72207. /** Gets or sets foreground color */
  72208. get color(): string;
  72209. set color(value: string);
  72210. /** Gets or sets z index which is used to reorder controls on the z axis */
  72211. get zIndex(): number;
  72212. set zIndex(value: number);
  72213. /** Gets or sets a boolean indicating if the control can be rendered */
  72214. get notRenderable(): boolean;
  72215. set notRenderable(value: boolean);
  72216. /** Gets or sets a boolean indicating if the control is visible */
  72217. get isVisible(): boolean;
  72218. set isVisible(value: boolean);
  72219. /** Gets a boolean indicating that the control needs to update its rendering */
  72220. get isDirty(): boolean;
  72221. /**
  72222. * Gets the current linked mesh (or null if none)
  72223. */
  72224. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72225. /**
  72226. * Gets or sets a value indicating the padding to use on the left of the control
  72227. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72228. */
  72229. get paddingLeft(): string | number;
  72230. set paddingLeft(value: string | number);
  72231. /**
  72232. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  72233. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72234. */
  72235. get paddingLeftInPixels(): number;
  72236. set paddingLeftInPixels(value: number);
  72237. /**
  72238. * Gets or sets a value indicating the padding to use on the right of the control
  72239. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72240. */
  72241. get paddingRight(): string | number;
  72242. set paddingRight(value: string | number);
  72243. /**
  72244. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72245. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72246. */
  72247. get paddingRightInPixels(): number;
  72248. set paddingRightInPixels(value: number);
  72249. /**
  72250. * Gets or sets a value indicating the padding to use on the top of the control
  72251. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72252. */
  72253. get paddingTop(): string | number;
  72254. set paddingTop(value: string | number);
  72255. /**
  72256. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72257. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72258. */
  72259. get paddingTopInPixels(): number;
  72260. set paddingTopInPixels(value: number);
  72261. /**
  72262. * Gets or sets a value indicating the padding to use on the bottom of the control
  72263. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72264. */
  72265. get paddingBottom(): string | number;
  72266. set paddingBottom(value: string | number);
  72267. /**
  72268. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72269. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72270. */
  72271. get paddingBottomInPixels(): number;
  72272. set paddingBottomInPixels(value: number);
  72273. /**
  72274. * Gets or sets a value indicating the left coordinate of the control
  72275. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72276. */
  72277. get left(): string | number;
  72278. set left(value: string | number);
  72279. /**
  72280. * Gets or sets a value indicating the left coordinate in pixels of the control
  72281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72282. */
  72283. get leftInPixels(): number;
  72284. set leftInPixels(value: number);
  72285. /**
  72286. * Gets or sets a value indicating the top coordinate of the control
  72287. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72288. */
  72289. get top(): string | number;
  72290. set top(value: string | number);
  72291. /**
  72292. * Gets or sets a value indicating the top coordinate in pixels of the control
  72293. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72294. */
  72295. get topInPixels(): number;
  72296. set topInPixels(value: number);
  72297. /**
  72298. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72299. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72300. */
  72301. get linkOffsetX(): string | number;
  72302. set linkOffsetX(value: string | number);
  72303. /**
  72304. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72305. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72306. */
  72307. get linkOffsetXInPixels(): number;
  72308. set linkOffsetXInPixels(value: number);
  72309. /**
  72310. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72311. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72312. */
  72313. get linkOffsetY(): string | number;
  72314. set linkOffsetY(value: string | number);
  72315. /**
  72316. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72317. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72318. */
  72319. get linkOffsetYInPixels(): number;
  72320. set linkOffsetYInPixels(value: number);
  72321. /** Gets the center coordinate on X axis */
  72322. get centerX(): number;
  72323. /** Gets the center coordinate on Y axis */
  72324. get centerY(): number;
  72325. /** Gets or sets if control is Enabled*/
  72326. get isEnabled(): boolean;
  72327. set isEnabled(value: boolean);
  72328. /** Gets or sets background color of control if it's disabled*/
  72329. get disabledColor(): string;
  72330. set disabledColor(value: string);
  72331. /** Gets or sets front color of control if it's disabled*/
  72332. get disabledColorItem(): string;
  72333. set disabledColorItem(value: string);
  72334. /**
  72335. * Creates a new control
  72336. * @param name defines the name of the control
  72337. */
  72338. constructor(
  72339. /** defines the name of the control */
  72340. name?: string | undefined);
  72341. /** @hidden */
  72342. protected _getTypeName(): string;
  72343. /**
  72344. * Gets the first ascendant in the hierarchy of the given type
  72345. * @param className defines the required type
  72346. * @returns the ascendant or null if not found
  72347. */
  72348. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72349. /** @hidden */
  72350. _resetFontCache(): void;
  72351. /**
  72352. * Determines if a container is an ascendant of the current control
  72353. * @param container defines the container to look for
  72354. * @returns true if the container is one of the ascendant of the control
  72355. */
  72356. isAscendant(container: Control): boolean;
  72357. /**
  72358. * Gets coordinates in local control space
  72359. * @param globalCoordinates defines the coordinates to transform
  72360. * @returns the new coordinates in local space
  72361. */
  72362. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72363. /**
  72364. * Gets coordinates in local control space
  72365. * @param globalCoordinates defines the coordinates to transform
  72366. * @param result defines the target vector2 where to store the result
  72367. * @returns the current control
  72368. */
  72369. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72370. /**
  72371. * Gets coordinates in parent local control space
  72372. * @param globalCoordinates defines the coordinates to transform
  72373. * @returns the new coordinates in parent local space
  72374. */
  72375. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72376. /**
  72377. * Move the current control to a vector3 position projected onto the screen.
  72378. * @param position defines the target position
  72379. * @param scene defines the hosting scene
  72380. */
  72381. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72382. /**
  72383. * Will store all controls that have this control as ascendant in a given array
  72384. * @param results defines the array where to store the descendants
  72385. * @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
  72386. * @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
  72387. */
  72388. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72389. /**
  72390. * Will return all controls that have this control as ascendant
  72391. * @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
  72392. * @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
  72393. * @return all child controls
  72394. */
  72395. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72396. /**
  72397. * Link current control with a target mesh
  72398. * @param mesh defines the mesh to link with
  72399. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72400. */
  72401. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72402. /** @hidden */
  72403. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72404. /** @hidden */
  72405. _offsetLeft(offset: number): void;
  72406. /** @hidden */
  72407. _offsetTop(offset: number): void;
  72408. /** @hidden */
  72409. _markMatrixAsDirty(): void;
  72410. /** @hidden */
  72411. _flagDescendantsAsMatrixDirty(): void;
  72412. /** @hidden */
  72413. _intersectsRect(rect: Measure): boolean;
  72414. /** @hidden */
  72415. protected invalidateRect(): void;
  72416. /** @hidden */
  72417. _markAsDirty(force?: boolean): void;
  72418. /** @hidden */
  72419. _markAllAsDirty(): void;
  72420. /** @hidden */
  72421. _link(host: AdvancedDynamicTexture): void;
  72422. /** @hidden */
  72423. protected _transform(context?: CanvasRenderingContext2D): void;
  72424. /** @hidden */
  72425. _renderHighlight(context: CanvasRenderingContext2D): void;
  72426. /** @hidden */
  72427. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72428. /** @hidden */
  72429. protected _applyStates(context: CanvasRenderingContext2D): void;
  72430. /** @hidden */
  72431. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72432. /** @hidden */
  72433. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72434. protected _evaluateClippingState(parentMeasure: Measure): void;
  72435. /** @hidden */
  72436. _measure(): void;
  72437. /** @hidden */
  72438. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72439. /** @hidden */
  72440. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72441. /** @hidden */
  72442. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72443. /** @hidden */
  72444. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72445. private static _ClipMeasure;
  72446. private _tmpMeasureA;
  72447. private _clip;
  72448. /** @hidden */
  72449. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72450. /** @hidden */
  72451. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72452. /**
  72453. * Tests if a given coordinates belong to the current control
  72454. * @param x defines x coordinate to test
  72455. * @param y defines y coordinate to test
  72456. * @returns true if the coordinates are inside the control
  72457. */
  72458. contains(x: number, y: number): boolean;
  72459. /** @hidden */
  72460. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72461. /** @hidden */
  72462. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72463. /** @hidden */
  72464. _onPointerEnter(target: Control): boolean;
  72465. /** @hidden */
  72466. _onPointerOut(target: Control, force?: boolean): void;
  72467. /** @hidden */
  72468. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72469. /** @hidden */
  72470. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72471. /** @hidden */
  72472. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72473. /** @hidden */
  72474. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72475. /** @hidden */
  72476. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72477. private _prepareFont;
  72478. /** Releases associated resources */
  72479. dispose(): void;
  72480. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72481. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72482. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72483. private static _VERTICAL_ALIGNMENT_TOP;
  72484. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72485. private static _VERTICAL_ALIGNMENT_CENTER;
  72486. /** HORIZONTAL_ALIGNMENT_LEFT */
  72487. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72488. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72489. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72490. /** HORIZONTAL_ALIGNMENT_CENTER */
  72491. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72492. /** VERTICAL_ALIGNMENT_TOP */
  72493. static get VERTICAL_ALIGNMENT_TOP(): number;
  72494. /** VERTICAL_ALIGNMENT_BOTTOM */
  72495. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72496. /** VERTICAL_ALIGNMENT_CENTER */
  72497. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72498. private static _FontHeightSizes;
  72499. /** @hidden */
  72500. static _GetFontOffset(font: string): {
  72501. ascent: number;
  72502. height: number;
  72503. descent: number;
  72504. };
  72505. /**
  72506. * Creates a stack panel that can be used to render headers
  72507. * @param control defines the control to associate with the header
  72508. * @param text defines the text of the header
  72509. * @param size defines the size of the header
  72510. * @param options defines options used to configure the header
  72511. * @returns a new StackPanel
  72512. * @ignore
  72513. * @hidden
  72514. */
  72515. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72516. isHorizontal: boolean;
  72517. controlFirst: boolean;
  72518. }) => any;
  72519. /** @hidden */
  72520. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72521. }
  72522. }
  72523. declare module BABYLON.GUI {
  72524. /**
  72525. * Root class for 2D containers
  72526. * @see http://doc.babylonjs.com/how_to/gui#containers
  72527. */
  72528. export class Container extends Control {
  72529. name?: string | undefined;
  72530. /** @hidden */
  72531. _children: Control[];
  72532. /** @hidden */
  72533. protected _measureForChildren: Measure;
  72534. /** @hidden */
  72535. protected _background: string;
  72536. /** @hidden */
  72537. protected _adaptWidthToChildren: boolean;
  72538. /** @hidden */
  72539. protected _adaptHeightToChildren: boolean;
  72540. /**
  72541. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72542. */
  72543. logLayoutCycleErrors: boolean;
  72544. /**
  72545. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72546. */
  72547. maxLayoutCycle: number;
  72548. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72549. get adaptHeightToChildren(): boolean;
  72550. set adaptHeightToChildren(value: boolean);
  72551. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72552. get adaptWidthToChildren(): boolean;
  72553. set adaptWidthToChildren(value: boolean);
  72554. /** Gets or sets background color */
  72555. get background(): string;
  72556. set background(value: string);
  72557. /** Gets the list of children */
  72558. get children(): Control[];
  72559. /**
  72560. * Creates a new Container
  72561. * @param name defines the name of the container
  72562. */
  72563. constructor(name?: string | undefined);
  72564. protected _getTypeName(): string;
  72565. _flagDescendantsAsMatrixDirty(): void;
  72566. /**
  72567. * Gets a child using its name
  72568. * @param name defines the child name to look for
  72569. * @returns the child control if found
  72570. */
  72571. getChildByName(name: string): BABYLON.Nullable<Control>;
  72572. /**
  72573. * Gets a child using its type and its name
  72574. * @param name defines the child name to look for
  72575. * @param type defines the child type to look for
  72576. * @returns the child control if found
  72577. */
  72578. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72579. /**
  72580. * Search for a specific control in children
  72581. * @param control defines the control to look for
  72582. * @returns true if the control is in child list
  72583. */
  72584. containsControl(control: Control): boolean;
  72585. /**
  72586. * Adds a new control to the current container
  72587. * @param control defines the control to add
  72588. * @returns the current container
  72589. */
  72590. addControl(control: BABYLON.Nullable<Control>): Container;
  72591. /**
  72592. * Removes all controls from the current container
  72593. * @returns the current container
  72594. */
  72595. clearControls(): Container;
  72596. /**
  72597. * Removes a control from the current container
  72598. * @param control defines the control to remove
  72599. * @returns the current container
  72600. */
  72601. removeControl(control: Control): Container;
  72602. /** @hidden */
  72603. _reOrderControl(control: Control): void;
  72604. /** @hidden */
  72605. _offsetLeft(offset: number): void;
  72606. /** @hidden */
  72607. _offsetTop(offset: number): void;
  72608. /** @hidden */
  72609. _markAllAsDirty(): void;
  72610. /** @hidden */
  72611. protected _localDraw(context: CanvasRenderingContext2D): void;
  72612. /** @hidden */
  72613. _link(host: AdvancedDynamicTexture): void;
  72614. /** @hidden */
  72615. protected _beforeLayout(): void;
  72616. /** @hidden */
  72617. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72618. /** @hidden */
  72619. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72620. protected _postMeasure(): void;
  72621. /** @hidden */
  72622. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72623. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72624. /** @hidden */
  72625. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72626. /** @hidden */
  72627. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72628. /** Releases associated resources */
  72629. dispose(): void;
  72630. }
  72631. }
  72632. declare module BABYLON.GUI {
  72633. /** Class used to create rectangle container */
  72634. export class Rectangle extends Container {
  72635. name?: string | undefined;
  72636. private _thickness;
  72637. private _cornerRadius;
  72638. /** Gets or sets border thickness */
  72639. get thickness(): number;
  72640. set thickness(value: number);
  72641. /** Gets or sets the corner radius angle */
  72642. get cornerRadius(): number;
  72643. set cornerRadius(value: number);
  72644. /**
  72645. * Creates a new Rectangle
  72646. * @param name defines the control name
  72647. */
  72648. constructor(name?: string | undefined);
  72649. protected _getTypeName(): string;
  72650. protected _localDraw(context: CanvasRenderingContext2D): void;
  72651. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72652. private _drawRoundedRect;
  72653. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72654. }
  72655. }
  72656. declare module BABYLON.GUI {
  72657. /**
  72658. * Enum that determines the text-wrapping mode to use.
  72659. */
  72660. export enum TextWrapping {
  72661. /**
  72662. * Clip the text when it's larger than Control.width; this is the default mode.
  72663. */
  72664. Clip = 0,
  72665. /**
  72666. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72667. */
  72668. WordWrap = 1,
  72669. /**
  72670. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72671. */
  72672. Ellipsis = 2
  72673. }
  72674. /**
  72675. * Class used to create text block control
  72676. */
  72677. export class TextBlock extends Control {
  72678. /**
  72679. * Defines the name of the control
  72680. */
  72681. name?: string | undefined;
  72682. private _text;
  72683. private _textWrapping;
  72684. private _textHorizontalAlignment;
  72685. private _textVerticalAlignment;
  72686. private _lines;
  72687. private _resizeToFit;
  72688. private _lineSpacing;
  72689. private _outlineWidth;
  72690. private _outlineColor;
  72691. /**
  72692. * An event triggered after the text is changed
  72693. */
  72694. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72695. /**
  72696. * An event triggered after the text was broken up into lines
  72697. */
  72698. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72699. /**
  72700. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72701. */
  72702. get lines(): any[];
  72703. /**
  72704. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72705. */
  72706. get resizeToFit(): boolean;
  72707. /**
  72708. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72709. */
  72710. set resizeToFit(value: boolean);
  72711. /**
  72712. * Gets or sets a boolean indicating if text must be wrapped
  72713. */
  72714. get textWrapping(): TextWrapping | boolean;
  72715. /**
  72716. * Gets or sets a boolean indicating if text must be wrapped
  72717. */
  72718. set textWrapping(value: TextWrapping | boolean);
  72719. /**
  72720. * Gets or sets text to display
  72721. */
  72722. get text(): string;
  72723. /**
  72724. * Gets or sets text to display
  72725. */
  72726. set text(value: string);
  72727. /**
  72728. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72729. */
  72730. get textHorizontalAlignment(): number;
  72731. /**
  72732. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72733. */
  72734. set textHorizontalAlignment(value: number);
  72735. /**
  72736. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72737. */
  72738. get textVerticalAlignment(): number;
  72739. /**
  72740. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72741. */
  72742. set textVerticalAlignment(value: number);
  72743. /**
  72744. * Gets or sets line spacing value
  72745. */
  72746. set lineSpacing(value: string | number);
  72747. /**
  72748. * Gets or sets line spacing value
  72749. */
  72750. get lineSpacing(): string | number;
  72751. /**
  72752. * Gets or sets outlineWidth of the text to display
  72753. */
  72754. get outlineWidth(): number;
  72755. /**
  72756. * Gets or sets outlineWidth of the text to display
  72757. */
  72758. set outlineWidth(value: number);
  72759. /**
  72760. * Gets or sets outlineColor of the text to display
  72761. */
  72762. get outlineColor(): string;
  72763. /**
  72764. * Gets or sets outlineColor of the text to display
  72765. */
  72766. set outlineColor(value: string);
  72767. /**
  72768. * Creates a new TextBlock object
  72769. * @param name defines the name of the control
  72770. * @param text defines the text to display (emptry string by default)
  72771. */
  72772. constructor(
  72773. /**
  72774. * Defines the name of the control
  72775. */
  72776. name?: string | undefined, text?: string);
  72777. protected _getTypeName(): string;
  72778. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72779. private _drawText;
  72780. /** @hidden */
  72781. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72782. protected _applyStates(context: CanvasRenderingContext2D): void;
  72783. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72784. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72785. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72786. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72787. protected _renderLines(context: CanvasRenderingContext2D): void;
  72788. /**
  72789. * Given a width constraint applied on the text block, find the expected height
  72790. * @returns expected height
  72791. */
  72792. computeExpectedHeight(): number;
  72793. dispose(): void;
  72794. }
  72795. }
  72796. declare module BABYLON.GUI {
  72797. /**
  72798. * Class used to create 2D images
  72799. */
  72800. export class Image extends Control {
  72801. name?: string | undefined;
  72802. private _workingCanvas;
  72803. private _domImage;
  72804. private _imageWidth;
  72805. private _imageHeight;
  72806. private _loaded;
  72807. private _stretch;
  72808. private _source;
  72809. private _autoScale;
  72810. private _sourceLeft;
  72811. private _sourceTop;
  72812. private _sourceWidth;
  72813. private _sourceHeight;
  72814. private _svgAttributesComputationCompleted;
  72815. private _isSVG;
  72816. private _cellWidth;
  72817. private _cellHeight;
  72818. private _cellId;
  72819. private _populateNinePatchSlicesFromImage;
  72820. private _sliceLeft;
  72821. private _sliceRight;
  72822. private _sliceTop;
  72823. private _sliceBottom;
  72824. private _detectPointerOnOpaqueOnly;
  72825. /**
  72826. * BABYLON.Observable notified when the content is loaded
  72827. */
  72828. onImageLoadedObservable: BABYLON.Observable<Image>;
  72829. /**
  72830. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72831. */
  72832. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72833. /**
  72834. * Gets a boolean indicating that the content is loaded
  72835. */
  72836. get isLoaded(): boolean;
  72837. /**
  72838. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72839. */
  72840. get populateNinePatchSlicesFromImage(): boolean;
  72841. set populateNinePatchSlicesFromImage(value: boolean);
  72842. /**
  72843. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72844. * Beware using this as this will comsume more memory as the image has to be stored twice
  72845. */
  72846. get detectPointerOnOpaqueOnly(): boolean;
  72847. set detectPointerOnOpaqueOnly(value: boolean);
  72848. /**
  72849. * Gets or sets the left value for slicing (9-patch)
  72850. */
  72851. get sliceLeft(): number;
  72852. set sliceLeft(value: number);
  72853. /**
  72854. * Gets or sets the right value for slicing (9-patch)
  72855. */
  72856. get sliceRight(): number;
  72857. set sliceRight(value: number);
  72858. /**
  72859. * Gets or sets the top value for slicing (9-patch)
  72860. */
  72861. get sliceTop(): number;
  72862. set sliceTop(value: number);
  72863. /**
  72864. * Gets or sets the bottom value for slicing (9-patch)
  72865. */
  72866. get sliceBottom(): number;
  72867. set sliceBottom(value: number);
  72868. /**
  72869. * Gets or sets the left coordinate in the source image
  72870. */
  72871. get sourceLeft(): number;
  72872. set sourceLeft(value: number);
  72873. /**
  72874. * Gets or sets the top coordinate in the source image
  72875. */
  72876. get sourceTop(): number;
  72877. set sourceTop(value: number);
  72878. /**
  72879. * Gets or sets the width to capture in the source image
  72880. */
  72881. get sourceWidth(): number;
  72882. set sourceWidth(value: number);
  72883. /**
  72884. * Gets or sets the height to capture in the source image
  72885. */
  72886. get sourceHeight(): number;
  72887. set sourceHeight(value: number);
  72888. /** Indicates if the format of the image is SVG */
  72889. get isSVG(): boolean;
  72890. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72891. get svgAttributesComputationCompleted(): boolean;
  72892. /**
  72893. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72894. * @see http://doc.babylonjs.com/how_to/gui#image
  72895. */
  72896. get autoScale(): boolean;
  72897. set autoScale(value: boolean);
  72898. /** Gets or sets the streching mode used by the image */
  72899. get stretch(): number;
  72900. set stretch(value: number);
  72901. /** @hidden */
  72902. _rotate90(n: number, preserveProperties?: boolean): Image;
  72903. private _handleRotationForSVGImage;
  72904. private _rotate90SourceProperties;
  72905. /**
  72906. * Gets or sets the internal DOM image used to render the control
  72907. */
  72908. set domImage(value: HTMLImageElement);
  72909. get domImage(): HTMLImageElement;
  72910. private _onImageLoaded;
  72911. private _extractNinePatchSliceDataFromImage;
  72912. /**
  72913. * Gets or sets image source url
  72914. */
  72915. set source(value: BABYLON.Nullable<string>);
  72916. /**
  72917. * Checks for svg document with icon id present
  72918. */
  72919. private _svgCheck;
  72920. /**
  72921. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72922. * given external svg file and icon id
  72923. */
  72924. private _getSVGAttribs;
  72925. /**
  72926. * Gets or sets the cell width to use when animation sheet is enabled
  72927. * @see http://doc.babylonjs.com/how_to/gui#image
  72928. */
  72929. get cellWidth(): number;
  72930. set cellWidth(value: number);
  72931. /**
  72932. * Gets or sets the cell height to use when animation sheet is enabled
  72933. * @see http://doc.babylonjs.com/how_to/gui#image
  72934. */
  72935. get cellHeight(): number;
  72936. set cellHeight(value: number);
  72937. /**
  72938. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72939. * @see http://doc.babylonjs.com/how_to/gui#image
  72940. */
  72941. get cellId(): number;
  72942. set cellId(value: number);
  72943. /**
  72944. * Creates a new Image
  72945. * @param name defines the control name
  72946. * @param url defines the image url
  72947. */
  72948. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72949. /**
  72950. * Tests if a given coordinates belong to the current control
  72951. * @param x defines x coordinate to test
  72952. * @param y defines y coordinate to test
  72953. * @returns true if the coordinates are inside the control
  72954. */
  72955. contains(x: number, y: number): boolean;
  72956. protected _getTypeName(): string;
  72957. /** Force the control to synchronize with its content */
  72958. synchronizeSizeWithContent(): void;
  72959. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72960. private _prepareWorkingCanvasForOpaqueDetection;
  72961. private _drawImage;
  72962. _draw(context: CanvasRenderingContext2D): void;
  72963. private _renderCornerPatch;
  72964. private _renderNinePatch;
  72965. dispose(): void;
  72966. /** STRETCH_NONE */
  72967. static readonly STRETCH_NONE: number;
  72968. /** STRETCH_FILL */
  72969. static readonly STRETCH_FILL: number;
  72970. /** STRETCH_UNIFORM */
  72971. static readonly STRETCH_UNIFORM: number;
  72972. /** STRETCH_EXTEND */
  72973. static readonly STRETCH_EXTEND: number;
  72974. /** NINE_PATCH */
  72975. static readonly STRETCH_NINE_PATCH: number;
  72976. }
  72977. }
  72978. declare module BABYLON.GUI {
  72979. /**
  72980. * Class used to create 2D buttons
  72981. */
  72982. export class Button extends Rectangle {
  72983. name?: string | undefined;
  72984. /**
  72985. * Function called to generate a pointer enter animation
  72986. */
  72987. pointerEnterAnimation: () => void;
  72988. /**
  72989. * Function called to generate a pointer out animation
  72990. */
  72991. pointerOutAnimation: () => void;
  72992. /**
  72993. * Function called to generate a pointer down animation
  72994. */
  72995. pointerDownAnimation: () => void;
  72996. /**
  72997. * Function called to generate a pointer up animation
  72998. */
  72999. pointerUpAnimation: () => void;
  73000. /**
  73001. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  73002. */
  73003. delegatePickingToChildren: boolean;
  73004. private _image;
  73005. /**
  73006. * Returns the image part of the button (if any)
  73007. */
  73008. get image(): BABYLON.Nullable<Image>;
  73009. private _textBlock;
  73010. /**
  73011. * Returns the image part of the button (if any)
  73012. */
  73013. get textBlock(): BABYLON.Nullable<TextBlock>;
  73014. /**
  73015. * Creates a new Button
  73016. * @param name defines the name of the button
  73017. */
  73018. constructor(name?: string | undefined);
  73019. protected _getTypeName(): string;
  73020. /** @hidden */
  73021. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73022. /** @hidden */
  73023. _onPointerEnter(target: Control): boolean;
  73024. /** @hidden */
  73025. _onPointerOut(target: Control, force?: boolean): void;
  73026. /** @hidden */
  73027. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73028. /** @hidden */
  73029. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73030. /**
  73031. * Creates a new button made with an image and a text
  73032. * @param name defines the name of the button
  73033. * @param text defines the text of the button
  73034. * @param imageUrl defines the url of the image
  73035. * @returns a new Button
  73036. */
  73037. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  73038. /**
  73039. * Creates a new button made with an image
  73040. * @param name defines the name of the button
  73041. * @param imageUrl defines the url of the image
  73042. * @returns a new Button
  73043. */
  73044. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  73045. /**
  73046. * Creates a new button made with a text
  73047. * @param name defines the name of the button
  73048. * @param text defines the text of the button
  73049. * @returns a new Button
  73050. */
  73051. static CreateSimpleButton(name: string, text: string): Button;
  73052. /**
  73053. * Creates a new button made with an image and a centered text
  73054. * @param name defines the name of the button
  73055. * @param text defines the text of the button
  73056. * @param imageUrl defines the url of the image
  73057. * @returns a new Button
  73058. */
  73059. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  73060. }
  73061. }
  73062. declare module BABYLON.GUI {
  73063. /**
  73064. * Class used to create a 2D stack panel container
  73065. */
  73066. export class StackPanel extends Container {
  73067. name?: string | undefined;
  73068. private _isVertical;
  73069. private _manualWidth;
  73070. private _manualHeight;
  73071. private _doNotTrackManualChanges;
  73072. /**
  73073. * Gets or sets a boolean indicating that layou warnings should be ignored
  73074. */
  73075. ignoreLayoutWarnings: boolean;
  73076. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  73077. get isVertical(): boolean;
  73078. set isVertical(value: boolean);
  73079. /**
  73080. * Gets or sets panel width.
  73081. * This value should not be set when in horizontal mode as it will be computed automatically
  73082. */
  73083. set width(value: string | number);
  73084. get width(): string | number;
  73085. /**
  73086. * Gets or sets panel height.
  73087. * This value should not be set when in vertical mode as it will be computed automatically
  73088. */
  73089. set height(value: string | number);
  73090. get height(): string | number;
  73091. /**
  73092. * Creates a new StackPanel
  73093. * @param name defines control name
  73094. */
  73095. constructor(name?: string | undefined);
  73096. protected _getTypeName(): string;
  73097. /** @hidden */
  73098. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73099. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73100. protected _postMeasure(): void;
  73101. }
  73102. }
  73103. declare module BABYLON.GUI {
  73104. /**
  73105. * Class used to represent a 2D checkbox
  73106. */
  73107. export class Checkbox extends Control {
  73108. name?: string | undefined;
  73109. private _isChecked;
  73110. private _background;
  73111. private _checkSizeRatio;
  73112. private _thickness;
  73113. /** Gets or sets border thickness */
  73114. get thickness(): number;
  73115. set thickness(value: number);
  73116. /**
  73117. * BABYLON.Observable raised when isChecked property changes
  73118. */
  73119. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73120. /** Gets or sets a value indicating the ratio between overall size and check size */
  73121. get checkSizeRatio(): number;
  73122. set checkSizeRatio(value: number);
  73123. /** Gets or sets background color */
  73124. get background(): string;
  73125. set background(value: string);
  73126. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73127. get isChecked(): boolean;
  73128. set isChecked(value: boolean);
  73129. /**
  73130. * Creates a new CheckBox
  73131. * @param name defines the control name
  73132. */
  73133. constructor(name?: string | undefined);
  73134. protected _getTypeName(): string;
  73135. /** @hidden */
  73136. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73137. /** @hidden */
  73138. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73139. /**
  73140. * Utility function to easily create a checkbox with a header
  73141. * @param title defines the label to use for the header
  73142. * @param onValueChanged defines the callback to call when value changes
  73143. * @returns a StackPanel containing the checkbox and a textBlock
  73144. */
  73145. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  73146. }
  73147. }
  73148. declare module BABYLON.GUI {
  73149. /**
  73150. * Class used to store key control properties
  73151. */
  73152. export class KeyPropertySet {
  73153. /** Width */
  73154. width?: string;
  73155. /** Height */
  73156. height?: string;
  73157. /** Left padding */
  73158. paddingLeft?: string;
  73159. /** Right padding */
  73160. paddingRight?: string;
  73161. /** Top padding */
  73162. paddingTop?: string;
  73163. /** Bottom padding */
  73164. paddingBottom?: string;
  73165. /** Foreground color */
  73166. color?: string;
  73167. /** Background color */
  73168. background?: string;
  73169. }
  73170. /**
  73171. * Class used to create virtual keyboard
  73172. */
  73173. export class VirtualKeyboard extends StackPanel {
  73174. /** BABYLON.Observable raised when a key is pressed */
  73175. onKeyPressObservable: BABYLON.Observable<string>;
  73176. /** Gets or sets default key button width */
  73177. defaultButtonWidth: string;
  73178. /** Gets or sets default key button height */
  73179. defaultButtonHeight: string;
  73180. /** Gets or sets default key button left padding */
  73181. defaultButtonPaddingLeft: string;
  73182. /** Gets or sets default key button right padding */
  73183. defaultButtonPaddingRight: string;
  73184. /** Gets or sets default key button top padding */
  73185. defaultButtonPaddingTop: string;
  73186. /** Gets or sets default key button bottom padding */
  73187. defaultButtonPaddingBottom: string;
  73188. /** Gets or sets default key button foreground color */
  73189. defaultButtonColor: string;
  73190. /** Gets or sets default key button background color */
  73191. defaultButtonBackground: string;
  73192. /** Gets or sets shift button foreground color */
  73193. shiftButtonColor: string;
  73194. /** Gets or sets shift button thickness*/
  73195. selectedShiftThickness: number;
  73196. /** Gets shift key state */
  73197. shiftState: number;
  73198. protected _getTypeName(): string;
  73199. private _createKey;
  73200. /**
  73201. * Adds a new row of keys
  73202. * @param keys defines the list of keys to add
  73203. * @param propertySets defines the associated property sets
  73204. */
  73205. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  73206. /**
  73207. * Set the shift key to a specific state
  73208. * @param shiftState defines the new shift state
  73209. */
  73210. applyShiftState(shiftState: number): void;
  73211. private _currentlyConnectedInputText;
  73212. private _connectedInputTexts;
  73213. private _onKeyPressObserver;
  73214. /** Gets the input text control currently attached to the keyboard */
  73215. get connectedInputText(): BABYLON.Nullable<InputText>;
  73216. /**
  73217. * Connects the keyboard with an input text control
  73218. *
  73219. * @param input defines the target control
  73220. */
  73221. connect(input: InputText): void;
  73222. /**
  73223. * Disconnects the keyboard from connected InputText controls
  73224. *
  73225. * @param input optionally defines a target control, otherwise all are disconnected
  73226. */
  73227. disconnect(input?: InputText): void;
  73228. private _removeConnectedInputObservables;
  73229. /**
  73230. * Release all resources
  73231. */
  73232. dispose(): void;
  73233. /**
  73234. * Creates a new keyboard using a default layout
  73235. *
  73236. * @param name defines control name
  73237. * @returns a new VirtualKeyboard
  73238. */
  73239. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  73240. }
  73241. }
  73242. declare module BABYLON.GUI {
  73243. /**
  73244. * Class used to create input text control
  73245. */
  73246. export class InputText extends Control implements IFocusableControl {
  73247. name?: string | undefined;
  73248. private _text;
  73249. private _placeholderText;
  73250. private _background;
  73251. private _focusedBackground;
  73252. private _focusedColor;
  73253. private _placeholderColor;
  73254. private _thickness;
  73255. private _margin;
  73256. private _autoStretchWidth;
  73257. private _maxWidth;
  73258. private _isFocused;
  73259. private _blinkTimeout;
  73260. private _blinkIsEven;
  73261. private _cursorOffset;
  73262. private _scrollLeft;
  73263. private _textWidth;
  73264. private _clickedCoordinate;
  73265. private _deadKey;
  73266. private _addKey;
  73267. private _currentKey;
  73268. private _isTextHighlightOn;
  73269. private _textHighlightColor;
  73270. private _highligherOpacity;
  73271. private _highlightedText;
  73272. private _startHighlightIndex;
  73273. private _endHighlightIndex;
  73274. private _cursorIndex;
  73275. private _onFocusSelectAll;
  73276. private _isPointerDown;
  73277. private _onClipboardObserver;
  73278. private _onPointerDblTapObserver;
  73279. /** @hidden */
  73280. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73281. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73282. promptMessage: string;
  73283. /** Force disable prompt on mobile device */
  73284. disableMobilePrompt: boolean;
  73285. /** BABYLON.Observable raised when the text changes */
  73286. onTextChangedObservable: BABYLON.Observable<InputText>;
  73287. /** BABYLON.Observable raised just before an entered character is to be added */
  73288. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73289. /** BABYLON.Observable raised when the control gets the focus */
  73290. onFocusObservable: BABYLON.Observable<InputText>;
  73291. /** BABYLON.Observable raised when the control loses the focus */
  73292. onBlurObservable: BABYLON.Observable<InputText>;
  73293. /**Observable raised when the text is highlighted */
  73294. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73295. /**Observable raised when copy event is triggered */
  73296. onTextCopyObservable: BABYLON.Observable<InputText>;
  73297. /** BABYLON.Observable raised when cut event is triggered */
  73298. onTextCutObservable: BABYLON.Observable<InputText>;
  73299. /** BABYLON.Observable raised when paste event is triggered */
  73300. onTextPasteObservable: BABYLON.Observable<InputText>;
  73301. /** BABYLON.Observable raised when a key event was processed */
  73302. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73303. /** Gets or sets the maximum width allowed by the control */
  73304. get maxWidth(): string | number;
  73305. /** Gets the maximum width allowed by the control in pixels */
  73306. get maxWidthInPixels(): number;
  73307. set maxWidth(value: string | number);
  73308. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73309. get highligherOpacity(): number;
  73310. set highligherOpacity(value: number);
  73311. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73312. get onFocusSelectAll(): boolean;
  73313. set onFocusSelectAll(value: boolean);
  73314. /** Gets or sets the text hightlight color */
  73315. get textHighlightColor(): string;
  73316. set textHighlightColor(value: string);
  73317. /** Gets or sets control margin */
  73318. get margin(): string;
  73319. /** Gets control margin in pixels */
  73320. get marginInPixels(): number;
  73321. set margin(value: string);
  73322. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73323. get autoStretchWidth(): boolean;
  73324. set autoStretchWidth(value: boolean);
  73325. /** Gets or sets border thickness */
  73326. get thickness(): number;
  73327. set thickness(value: number);
  73328. /** Gets or sets the background color when focused */
  73329. get focusedBackground(): string;
  73330. set focusedBackground(value: string);
  73331. /** Gets or sets the background color when focused */
  73332. get focusedColor(): string;
  73333. set focusedColor(value: string);
  73334. /** Gets or sets the background color */
  73335. get background(): string;
  73336. set background(value: string);
  73337. /** Gets or sets the placeholder color */
  73338. get placeholderColor(): string;
  73339. set placeholderColor(value: string);
  73340. /** Gets or sets the text displayed when the control is empty */
  73341. get placeholderText(): string;
  73342. set placeholderText(value: string);
  73343. /** Gets or sets the dead key flag */
  73344. get deadKey(): boolean;
  73345. set deadKey(flag: boolean);
  73346. /** Gets or sets the highlight text */
  73347. get highlightedText(): string;
  73348. set highlightedText(text: string);
  73349. /** Gets or sets if the current key should be added */
  73350. get addKey(): boolean;
  73351. set addKey(flag: boolean);
  73352. /** Gets or sets the value of the current key being entered */
  73353. get currentKey(): string;
  73354. set currentKey(key: string);
  73355. /** Gets or sets the text displayed in the control */
  73356. get text(): string;
  73357. set text(value: string);
  73358. /** Gets or sets control width */
  73359. get width(): string | number;
  73360. set width(value: string | number);
  73361. /**
  73362. * Creates a new InputText
  73363. * @param name defines the control name
  73364. * @param text defines the text of the control
  73365. */
  73366. constructor(name?: string | undefined, text?: string);
  73367. /** @hidden */
  73368. onBlur(): void;
  73369. /** @hidden */
  73370. onFocus(): void;
  73371. protected _getTypeName(): string;
  73372. /**
  73373. * Function called to get the list of controls that should not steal the focus from this control
  73374. * @returns an array of controls
  73375. */
  73376. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73377. /** @hidden */
  73378. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73379. /** @hidden */
  73380. private _updateValueFromCursorIndex;
  73381. /** @hidden */
  73382. private _processDblClick;
  73383. /** @hidden */
  73384. private _selectAllText;
  73385. /**
  73386. * Handles the keyboard event
  73387. * @param evt Defines the KeyboardEvent
  73388. */
  73389. processKeyboard(evt: KeyboardEvent): void;
  73390. /** @hidden */
  73391. private _onCopyText;
  73392. /** @hidden */
  73393. private _onCutText;
  73394. /** @hidden */
  73395. private _onPasteText;
  73396. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73397. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73398. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73399. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73400. protected _beforeRenderText(text: string): string;
  73401. dispose(): void;
  73402. }
  73403. }
  73404. declare module BABYLON.GUI {
  73405. /**
  73406. * Class used to create a 2D grid container
  73407. */
  73408. export class Grid extends Container {
  73409. name?: string | undefined;
  73410. private _rowDefinitions;
  73411. private _columnDefinitions;
  73412. private _cells;
  73413. private _childControls;
  73414. /**
  73415. * Gets the number of columns
  73416. */
  73417. get columnCount(): number;
  73418. /**
  73419. * Gets the number of rows
  73420. */
  73421. get rowCount(): number;
  73422. /** Gets the list of children */
  73423. get children(): Control[];
  73424. /** Gets the list of cells (e.g. the containers) */
  73425. get cells(): {
  73426. [key: string]: Container;
  73427. };
  73428. /**
  73429. * Gets the definition of a specific row
  73430. * @param index defines the index of the row
  73431. * @returns the row definition
  73432. */
  73433. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73434. /**
  73435. * Gets the definition of a specific column
  73436. * @param index defines the index of the column
  73437. * @returns the column definition
  73438. */
  73439. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73440. /**
  73441. * Adds a new row to the grid
  73442. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73443. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73444. * @returns the current grid
  73445. */
  73446. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73447. /**
  73448. * Adds a new column to the grid
  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. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73454. /**
  73455. * Update a row definition
  73456. * @param index defines the index of the row to update
  73457. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73458. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73459. * @returns the current grid
  73460. */
  73461. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73462. /**
  73463. * Update a column definition
  73464. * @param index defines the index of the column to update
  73465. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73466. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73467. * @returns the current grid
  73468. */
  73469. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73470. /**
  73471. * Gets the list of children stored in a specific cell
  73472. * @param row defines the row to check
  73473. * @param column defines the column to check
  73474. * @returns the list of controls
  73475. */
  73476. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73477. /**
  73478. * Gets a string representing the child cell info (row x column)
  73479. * @param child defines the control to get info from
  73480. * @returns a string containing the child cell info (row x column)
  73481. */
  73482. getChildCellInfo(child: Control): string;
  73483. private _removeCell;
  73484. private _offsetCell;
  73485. /**
  73486. * Remove a column definition at specified index
  73487. * @param index defines the index of the column to remove
  73488. * @returns the current grid
  73489. */
  73490. removeColumnDefinition(index: number): Grid;
  73491. /**
  73492. * Remove a row definition at specified index
  73493. * @param index defines the index of the row to remove
  73494. * @returns the current grid
  73495. */
  73496. removeRowDefinition(index: number): Grid;
  73497. /**
  73498. * Adds a new control to the current grid
  73499. * @param control defines the control to add
  73500. * @param row defines the row where to add the control (0 by default)
  73501. * @param column defines the column where to add the control (0 by default)
  73502. * @returns the current grid
  73503. */
  73504. addControl(control: Control, row?: number, column?: number): Grid;
  73505. /**
  73506. * Removes a control from the current container
  73507. * @param control defines the control to remove
  73508. * @returns the current container
  73509. */
  73510. removeControl(control: Control): Container;
  73511. /**
  73512. * Creates a new Grid
  73513. * @param name defines control name
  73514. */
  73515. constructor(name?: string | undefined);
  73516. protected _getTypeName(): string;
  73517. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73518. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73519. _flagDescendantsAsMatrixDirty(): void;
  73520. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73521. /** Releases associated resources */
  73522. dispose(): void;
  73523. }
  73524. }
  73525. declare module BABYLON.GUI {
  73526. /** Class used to create color pickers */
  73527. export class ColorPicker extends Control {
  73528. name?: string | undefined;
  73529. private static _Epsilon;
  73530. private _colorWheelCanvas;
  73531. private _value;
  73532. private _tmpColor;
  73533. private _pointerStartedOnSquare;
  73534. private _pointerStartedOnWheel;
  73535. private _squareLeft;
  73536. private _squareTop;
  73537. private _squareSize;
  73538. private _h;
  73539. private _s;
  73540. private _v;
  73541. private _lastPointerDownID;
  73542. /**
  73543. * BABYLON.Observable raised when the value changes
  73544. */
  73545. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73546. /** Gets or sets the color of the color picker */
  73547. get value(): BABYLON.Color3;
  73548. set value(value: BABYLON.Color3);
  73549. /**
  73550. * Gets or sets control width
  73551. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73552. */
  73553. get width(): string | number;
  73554. set width(value: string | number);
  73555. /**
  73556. * Gets or sets control height
  73557. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73558. */
  73559. get height(): string | number;
  73560. /** Gets or sets control height */
  73561. set height(value: string | number);
  73562. /** Gets or sets control size */
  73563. get size(): string | number;
  73564. set size(value: string | number);
  73565. /**
  73566. * Creates a new ColorPicker
  73567. * @param name defines the control name
  73568. */
  73569. constructor(name?: string | undefined);
  73570. protected _getTypeName(): string;
  73571. /** @hidden */
  73572. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73573. private _updateSquareProps;
  73574. private _drawGradientSquare;
  73575. private _drawCircle;
  73576. private _createColorWheelCanvas;
  73577. /** @hidden */
  73578. _draw(context: CanvasRenderingContext2D): void;
  73579. private _pointerIsDown;
  73580. private _updateValueFromPointer;
  73581. private _isPointOnSquare;
  73582. private _isPointOnWheel;
  73583. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73584. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73585. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73586. /**
  73587. * This function expands the color picker by creating a color picker dialog with manual
  73588. * color value input and the ability to save colors into an array to be used later in
  73589. * subsequent launches of the dialogue.
  73590. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73591. * @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.
  73592. * @returns picked color as a hex string and the saved colors array as hex strings.
  73593. */
  73594. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73595. pickerWidth?: string;
  73596. pickerHeight?: string;
  73597. headerHeight?: string;
  73598. lastColor?: string;
  73599. swatchLimit?: number;
  73600. numSwatchesPerLine?: number;
  73601. savedColors?: Array<string>;
  73602. }): Promise<{
  73603. savedColors?: string[];
  73604. pickedColor: string;
  73605. }>;
  73606. }
  73607. }
  73608. declare module BABYLON.GUI {
  73609. /** Class used to create 2D ellipse containers */
  73610. export class Ellipse extends Container {
  73611. name?: string | undefined;
  73612. private _thickness;
  73613. /** Gets or sets border thickness */
  73614. get thickness(): number;
  73615. set thickness(value: number);
  73616. /**
  73617. * Creates a new Ellipse
  73618. * @param name defines the control name
  73619. */
  73620. constructor(name?: string | undefined);
  73621. protected _getTypeName(): string;
  73622. protected _localDraw(context: CanvasRenderingContext2D): void;
  73623. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73624. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73625. }
  73626. }
  73627. declare module BABYLON.GUI {
  73628. /**
  73629. * Class used to create a password control
  73630. */
  73631. export class InputPassword extends InputText {
  73632. protected _beforeRenderText(text: string): string;
  73633. }
  73634. }
  73635. declare module BABYLON.GUI {
  73636. /** Class used to render 2D lines */
  73637. export class Line extends Control {
  73638. name?: string | undefined;
  73639. private _lineWidth;
  73640. private _x1;
  73641. private _y1;
  73642. private _x2;
  73643. private _y2;
  73644. private _dash;
  73645. private _connectedControl;
  73646. private _connectedControlDirtyObserver;
  73647. /** Gets or sets the dash pattern */
  73648. get dash(): Array<number>;
  73649. set dash(value: Array<number>);
  73650. /** Gets or sets the control connected with the line end */
  73651. get connectedControl(): Control;
  73652. set connectedControl(value: Control);
  73653. /** Gets or sets start coordinates on X axis */
  73654. get x1(): string | number;
  73655. set x1(value: string | number);
  73656. /** Gets or sets start coordinates on Y axis */
  73657. get y1(): string | number;
  73658. set y1(value: string | number);
  73659. /** Gets or sets end coordinates on X axis */
  73660. get x2(): string | number;
  73661. set x2(value: string | number);
  73662. /** Gets or sets end coordinates on Y axis */
  73663. get y2(): string | number;
  73664. set y2(value: string | number);
  73665. /** Gets or sets line width */
  73666. get lineWidth(): number;
  73667. set lineWidth(value: number);
  73668. /** Gets or sets horizontal alignment */
  73669. set horizontalAlignment(value: number);
  73670. /** Gets or sets vertical alignment */
  73671. set verticalAlignment(value: number);
  73672. private get _effectiveX2();
  73673. private get _effectiveY2();
  73674. /**
  73675. * Creates a new Line
  73676. * @param name defines the control name
  73677. */
  73678. constructor(name?: string | undefined);
  73679. protected _getTypeName(): string;
  73680. _draw(context: CanvasRenderingContext2D): void;
  73681. _measure(): void;
  73682. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73683. /**
  73684. * Move one end of the line given 3D cartesian coordinates.
  73685. * @param position Targeted world position
  73686. * @param scene BABYLON.Scene
  73687. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73688. */
  73689. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73690. /**
  73691. * Move one end of the line to a position in screen absolute space.
  73692. * @param projectedPosition Position in screen absolute space (X, Y)
  73693. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73694. */
  73695. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73696. }
  73697. }
  73698. declare module BABYLON.GUI {
  73699. /**
  73700. * Class used to store a point for a MultiLine object.
  73701. * The point can be pure 2D coordinates, a mesh or a control
  73702. */
  73703. export class MultiLinePoint {
  73704. private _multiLine;
  73705. private _x;
  73706. private _y;
  73707. private _control;
  73708. private _mesh;
  73709. private _controlObserver;
  73710. private _meshObserver;
  73711. /** @hidden */
  73712. _point: BABYLON.Vector2;
  73713. /**
  73714. * Creates a new MultiLinePoint
  73715. * @param multiLine defines the source MultiLine object
  73716. */
  73717. constructor(multiLine: MultiLine);
  73718. /** Gets or sets x coordinate */
  73719. get x(): string | number;
  73720. set x(value: string | number);
  73721. /** Gets or sets y coordinate */
  73722. get y(): string | number;
  73723. set y(value: string | number);
  73724. /** Gets or sets the control associated with this point */
  73725. get control(): BABYLON.Nullable<Control>;
  73726. set control(value: BABYLON.Nullable<Control>);
  73727. /** Gets or sets the mesh associated with this point */
  73728. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73729. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73730. /** Resets links */
  73731. resetLinks(): void;
  73732. /**
  73733. * Gets a translation vector
  73734. * @returns the translation vector
  73735. */
  73736. translate(): BABYLON.Vector2;
  73737. private _translatePoint;
  73738. /** Release associated resources */
  73739. dispose(): void;
  73740. }
  73741. }
  73742. declare module BABYLON.GUI {
  73743. /**
  73744. * Class used to create multi line control
  73745. */
  73746. export class MultiLine extends Control {
  73747. name?: string | undefined;
  73748. private _lineWidth;
  73749. private _dash;
  73750. private _points;
  73751. private _minX;
  73752. private _minY;
  73753. private _maxX;
  73754. private _maxY;
  73755. /**
  73756. * Creates a new MultiLine
  73757. * @param name defines the control name
  73758. */
  73759. constructor(name?: string | undefined);
  73760. /** Gets or sets dash pattern */
  73761. get dash(): Array<number>;
  73762. set dash(value: Array<number>);
  73763. /**
  73764. * Gets point stored at specified index
  73765. * @param index defines the index to look for
  73766. * @returns the requested point if found
  73767. */
  73768. getAt(index: number): MultiLinePoint;
  73769. /** Function called when a point is updated */
  73770. onPointUpdate: () => void;
  73771. /**
  73772. * Adds new points to the point collection
  73773. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73774. * @returns the list of created MultiLinePoint
  73775. */
  73776. add(...items: (AbstractMesh | Control | {
  73777. x: string | number;
  73778. y: string | number;
  73779. })[]): MultiLinePoint[];
  73780. /**
  73781. * Adds a new point to the point collection
  73782. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73783. * @returns the created MultiLinePoint
  73784. */
  73785. push(item?: (AbstractMesh | Control | {
  73786. x: string | number;
  73787. y: string | number;
  73788. })): MultiLinePoint;
  73789. /**
  73790. * Remove a specific value or point from the active point collection
  73791. * @param value defines the value or point to remove
  73792. */
  73793. remove(value: number | MultiLinePoint): void;
  73794. /**
  73795. * Resets this object to initial state (no point)
  73796. */
  73797. reset(): void;
  73798. /**
  73799. * Resets all links
  73800. */
  73801. resetLinks(): void;
  73802. /** Gets or sets line width */
  73803. get lineWidth(): number;
  73804. set lineWidth(value: number);
  73805. set horizontalAlignment(value: number);
  73806. set verticalAlignment(value: number);
  73807. protected _getTypeName(): string;
  73808. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73809. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73810. _measure(): void;
  73811. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73812. dispose(): void;
  73813. }
  73814. }
  73815. declare module BABYLON.GUI {
  73816. /**
  73817. * Class used to create radio button controls
  73818. */
  73819. export class RadioButton extends Control {
  73820. name?: string | undefined;
  73821. private _isChecked;
  73822. private _background;
  73823. private _checkSizeRatio;
  73824. private _thickness;
  73825. /** Gets or sets border thickness */
  73826. get thickness(): number;
  73827. set thickness(value: number);
  73828. /** Gets or sets group name */
  73829. group: string;
  73830. /** BABYLON.Observable raised when isChecked is changed */
  73831. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73832. /** Gets or sets a value indicating the ratio between overall size and check size */
  73833. get checkSizeRatio(): number;
  73834. set checkSizeRatio(value: number);
  73835. /** Gets or sets background color */
  73836. get background(): string;
  73837. set background(value: string);
  73838. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73839. get isChecked(): boolean;
  73840. set isChecked(value: boolean);
  73841. /**
  73842. * Creates a new RadioButton
  73843. * @param name defines the control name
  73844. */
  73845. constructor(name?: string | undefined);
  73846. protected _getTypeName(): string;
  73847. _draw(context: CanvasRenderingContext2D): void;
  73848. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73849. /**
  73850. * Utility function to easily create a radio button with a header
  73851. * @param title defines the label to use for the header
  73852. * @param group defines the group to use for the radio button
  73853. * @param isChecked defines the initial state of the radio button
  73854. * @param onValueChanged defines the callback to call when value changes
  73855. * @returns a StackPanel containing the radio button and a textBlock
  73856. */
  73857. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73858. }
  73859. }
  73860. declare module BABYLON.GUI {
  73861. /**
  73862. * Class used to create slider controls
  73863. */
  73864. export class BaseSlider extends Control {
  73865. name?: string | undefined;
  73866. protected _thumbWidth: ValueAndUnit;
  73867. private _minimum;
  73868. private _maximum;
  73869. private _value;
  73870. private _isVertical;
  73871. protected _barOffset: ValueAndUnit;
  73872. private _isThumbClamped;
  73873. protected _displayThumb: boolean;
  73874. private _step;
  73875. private _lastPointerDownID;
  73876. protected _effectiveBarOffset: number;
  73877. protected _renderLeft: number;
  73878. protected _renderTop: number;
  73879. protected _renderWidth: number;
  73880. protected _renderHeight: number;
  73881. protected _backgroundBoxLength: number;
  73882. protected _backgroundBoxThickness: number;
  73883. protected _effectiveThumbThickness: number;
  73884. /** BABYLON.Observable raised when the sldier value changes */
  73885. onValueChangedObservable: BABYLON.Observable<number>;
  73886. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73887. get displayThumb(): boolean;
  73888. set displayThumb(value: boolean);
  73889. /** Gets or sets a step to apply to values (0 by default) */
  73890. get step(): number;
  73891. set step(value: number);
  73892. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73893. get barOffset(): string | number;
  73894. /** Gets main bar offset in pixels*/
  73895. get barOffsetInPixels(): number;
  73896. set barOffset(value: string | number);
  73897. /** Gets or sets thumb width */
  73898. get thumbWidth(): string | number;
  73899. /** Gets thumb width in pixels */
  73900. get thumbWidthInPixels(): number;
  73901. set thumbWidth(value: string | number);
  73902. /** Gets or sets minimum value */
  73903. get minimum(): number;
  73904. set minimum(value: number);
  73905. /** Gets or sets maximum value */
  73906. get maximum(): number;
  73907. set maximum(value: number);
  73908. /** Gets or sets current value */
  73909. get value(): number;
  73910. set value(value: number);
  73911. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73912. get isVertical(): boolean;
  73913. set isVertical(value: boolean);
  73914. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73915. get isThumbClamped(): boolean;
  73916. set isThumbClamped(value: boolean);
  73917. /**
  73918. * Creates a new BaseSlider
  73919. * @param name defines the control name
  73920. */
  73921. constructor(name?: string | undefined);
  73922. protected _getTypeName(): string;
  73923. protected _getThumbPosition(): number;
  73924. protected _getThumbThickness(type: string): number;
  73925. protected _prepareRenderingData(type: string): void;
  73926. private _pointerIsDown;
  73927. /** @hidden */
  73928. protected _updateValueFromPointer(x: number, y: number): void;
  73929. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73930. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73931. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73932. }
  73933. }
  73934. declare module BABYLON.GUI {
  73935. /**
  73936. * Class used to create slider controls
  73937. */
  73938. export class Slider extends BaseSlider {
  73939. name?: string | undefined;
  73940. private _background;
  73941. private _borderColor;
  73942. private _isThumbCircle;
  73943. protected _displayValueBar: boolean;
  73944. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73945. get displayValueBar(): boolean;
  73946. set displayValueBar(value: boolean);
  73947. /** Gets or sets border color */
  73948. get borderColor(): string;
  73949. set borderColor(value: string);
  73950. /** Gets or sets background color */
  73951. get background(): string;
  73952. set background(value: string);
  73953. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73954. get isThumbCircle(): boolean;
  73955. set isThumbCircle(value: boolean);
  73956. /**
  73957. * Creates a new Slider
  73958. * @param name defines the control name
  73959. */
  73960. constructor(name?: string | undefined);
  73961. protected _getTypeName(): string;
  73962. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73963. }
  73964. }
  73965. declare module BABYLON.GUI {
  73966. /** Class used to create a RadioGroup
  73967. * which contains groups of radio buttons
  73968. */
  73969. export class SelectorGroup {
  73970. /** name of SelectorGroup */
  73971. name: string;
  73972. private _groupPanel;
  73973. private _selectors;
  73974. private _groupHeader;
  73975. /**
  73976. * Creates a new SelectorGroup
  73977. * @param name of group, used as a group heading
  73978. */
  73979. constructor(
  73980. /** name of SelectorGroup */
  73981. name: string);
  73982. /** Gets the groupPanel of the SelectorGroup */
  73983. get groupPanel(): StackPanel;
  73984. /** Gets the selectors array */
  73985. get selectors(): StackPanel[];
  73986. /** Gets and sets the group header */
  73987. get header(): string;
  73988. set header(label: string);
  73989. /** @hidden */
  73990. private _addGroupHeader;
  73991. /** @hidden*/
  73992. _getSelector(selectorNb: number): StackPanel | undefined;
  73993. /** Removes the selector at the given position
  73994. * @param selectorNb the position of the selector within the group
  73995. */
  73996. removeSelector(selectorNb: number): void;
  73997. }
  73998. /** Class used to create a CheckboxGroup
  73999. * which contains groups of checkbox buttons
  74000. */
  74001. export class CheckboxGroup extends SelectorGroup {
  74002. /** Adds a checkbox as a control
  74003. * @param text is the label for the selector
  74004. * @param func is the function called when the Selector is checked
  74005. * @param checked is true when Selector is checked
  74006. */
  74007. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  74008. /** @hidden */
  74009. _setSelectorLabel(selectorNb: number, label: string): void;
  74010. /** @hidden */
  74011. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74012. /** @hidden */
  74013. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74014. /** @hidden */
  74015. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74016. }
  74017. /** Class used to create a RadioGroup
  74018. * which contains groups of radio buttons
  74019. */
  74020. export class RadioGroup extends SelectorGroup {
  74021. private _selectNb;
  74022. /** Adds a radio button as a control
  74023. * @param label is the label for the selector
  74024. * @param func is the function called when the Selector is checked
  74025. * @param checked is true when Selector is checked
  74026. */
  74027. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  74028. /** @hidden */
  74029. _setSelectorLabel(selectorNb: number, label: string): void;
  74030. /** @hidden */
  74031. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74032. /** @hidden */
  74033. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74034. /** @hidden */
  74035. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74036. }
  74037. /** Class used to create a SliderGroup
  74038. * which contains groups of slider buttons
  74039. */
  74040. export class SliderGroup extends SelectorGroup {
  74041. /**
  74042. * Adds a slider to the SelectorGroup
  74043. * @param label is the label for the SliderBar
  74044. * @param func is the function called when the Slider moves
  74045. * @param unit is a string describing the units used, eg degrees or metres
  74046. * @param min is the minimum value for the Slider
  74047. * @param max is the maximum value for the Slider
  74048. * @param value is the start value for the Slider between min and max
  74049. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  74050. */
  74051. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  74052. /** @hidden */
  74053. _setSelectorLabel(selectorNb: number, label: string): void;
  74054. /** @hidden */
  74055. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74056. /** @hidden */
  74057. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74058. /** @hidden */
  74059. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74060. }
  74061. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  74062. * @see http://doc.babylonjs.com/how_to/selector
  74063. */
  74064. export class SelectionPanel extends Rectangle {
  74065. /** name of SelectionPanel */
  74066. name: string;
  74067. /** an array of SelectionGroups */
  74068. groups: SelectorGroup[];
  74069. private _panel;
  74070. private _buttonColor;
  74071. private _buttonBackground;
  74072. private _headerColor;
  74073. private _barColor;
  74074. private _barHeight;
  74075. private _spacerHeight;
  74076. private _labelColor;
  74077. private _groups;
  74078. private _bars;
  74079. /**
  74080. * Creates a new SelectionPanel
  74081. * @param name of SelectionPanel
  74082. * @param groups is an array of SelectionGroups
  74083. */
  74084. constructor(
  74085. /** name of SelectionPanel */
  74086. name: string,
  74087. /** an array of SelectionGroups */
  74088. groups?: SelectorGroup[]);
  74089. protected _getTypeName(): string;
  74090. /** Gets or sets the headerColor */
  74091. get headerColor(): string;
  74092. set headerColor(color: string);
  74093. private _setHeaderColor;
  74094. /** Gets or sets the button color */
  74095. get buttonColor(): string;
  74096. set buttonColor(color: string);
  74097. private _setbuttonColor;
  74098. /** Gets or sets the label color */
  74099. get labelColor(): string;
  74100. set labelColor(color: string);
  74101. private _setLabelColor;
  74102. /** Gets or sets the button background */
  74103. get buttonBackground(): string;
  74104. set buttonBackground(color: string);
  74105. private _setButtonBackground;
  74106. /** Gets or sets the color of separator bar */
  74107. get barColor(): string;
  74108. set barColor(color: string);
  74109. private _setBarColor;
  74110. /** Gets or sets the height of separator bar */
  74111. get barHeight(): string;
  74112. set barHeight(value: string);
  74113. private _setBarHeight;
  74114. /** Gets or sets the height of spacers*/
  74115. get spacerHeight(): string;
  74116. set spacerHeight(value: string);
  74117. private _setSpacerHeight;
  74118. /** Adds a bar between groups */
  74119. private _addSpacer;
  74120. /** Add a group to the selection panel
  74121. * @param group is the selector group to add
  74122. */
  74123. addGroup(group: SelectorGroup): void;
  74124. /** Remove the group from the given position
  74125. * @param groupNb is the position of the group in the list
  74126. */
  74127. removeGroup(groupNb: number): void;
  74128. /** Change a group header label
  74129. * @param label is the new group header label
  74130. * @param groupNb is the number of the group to relabel
  74131. * */
  74132. setHeaderName(label: string, groupNb: number): void;
  74133. /** Change selector label to the one given
  74134. * @param label is the new selector label
  74135. * @param groupNb is the number of the groupcontaining the selector
  74136. * @param selectorNb is the number of the selector within a group to relabel
  74137. * */
  74138. relabel(label: string, groupNb: number, selectorNb: number): void;
  74139. /** For a given group position remove the selector at the given position
  74140. * @param groupNb is the number of the group to remove the selector from
  74141. * @param selectorNb is the number of the selector within the group
  74142. */
  74143. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  74144. /** For a given group position of correct type add a checkbox button
  74145. * @param groupNb is the number of the group to remove the selector from
  74146. * @param label is the label for the selector
  74147. * @param func is the function called when the Selector is checked
  74148. * @param checked is true when Selector is checked
  74149. */
  74150. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74151. /** For a given group position of correct type add a radio button
  74152. * @param groupNb is the number of the group to remove the selector from
  74153. * @param label is the label for the selector
  74154. * @param func is the function called when the Selector is checked
  74155. * @param checked is true when Selector is checked
  74156. */
  74157. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74158. /**
  74159. * For a given slider group add a slider
  74160. * @param groupNb is the number of the group to add the slider to
  74161. * @param label is the label for the Slider
  74162. * @param func is the function called when the Slider moves
  74163. * @param unit is a string describing the units used, eg degrees or metres
  74164. * @param min is the minimum value for the Slider
  74165. * @param max is the maximum value for the Slider
  74166. * @param value is the start value for the Slider between min and max
  74167. * @param onVal is the function used to format the value displayed, eg radians to degrees
  74168. */
  74169. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  74170. }
  74171. }
  74172. declare module BABYLON.GUI {
  74173. /**
  74174. * Class used to hold a the container for ScrollViewer
  74175. * @hidden
  74176. */
  74177. export class _ScrollViewerWindow extends Container {
  74178. parentClientWidth: number;
  74179. parentClientHeight: number;
  74180. private _freezeControls;
  74181. private _parentMeasure;
  74182. private _oldLeft;
  74183. private _oldTop;
  74184. get freezeControls(): boolean;
  74185. set freezeControls(value: boolean);
  74186. private _bucketWidth;
  74187. private _bucketHeight;
  74188. private _buckets;
  74189. private _bucketLen;
  74190. get bucketWidth(): number;
  74191. get bucketHeight(): number;
  74192. setBucketSizes(width: number, height: number): void;
  74193. private _useBuckets;
  74194. private _makeBuckets;
  74195. private _dispatchInBuckets;
  74196. private _updateMeasures;
  74197. private _updateChildrenMeasures;
  74198. private _restoreMeasures;
  74199. /**
  74200. * Creates a new ScrollViewerWindow
  74201. * @param name of ScrollViewerWindow
  74202. */
  74203. constructor(name?: string);
  74204. protected _getTypeName(): string;
  74205. /** @hidden */
  74206. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74207. /** @hidden */
  74208. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74209. private _scrollChildren;
  74210. private _scrollChildrenWithBuckets;
  74211. /** @hidden */
  74212. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74213. protected _postMeasure(): void;
  74214. }
  74215. }
  74216. declare module BABYLON.GUI {
  74217. /**
  74218. * Class used to create slider controls
  74219. */
  74220. export class ScrollBar extends BaseSlider {
  74221. name?: string | undefined;
  74222. private _background;
  74223. private _borderColor;
  74224. private _tempMeasure;
  74225. /** Gets or sets border color */
  74226. get borderColor(): string;
  74227. set borderColor(value: string);
  74228. /** Gets or sets background color */
  74229. get background(): string;
  74230. set background(value: string);
  74231. /**
  74232. * Creates a new Slider
  74233. * @param name defines the control name
  74234. */
  74235. constructor(name?: string | undefined);
  74236. protected _getTypeName(): string;
  74237. protected _getThumbThickness(): number;
  74238. _draw(context: CanvasRenderingContext2D): void;
  74239. private _first;
  74240. private _originX;
  74241. private _originY;
  74242. /** @hidden */
  74243. protected _updateValueFromPointer(x: number, y: number): void;
  74244. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74245. }
  74246. }
  74247. declare module BABYLON.GUI {
  74248. /**
  74249. * Class used to create slider controls
  74250. */
  74251. export class ImageScrollBar extends BaseSlider {
  74252. name?: string | undefined;
  74253. private _backgroundBaseImage;
  74254. private _backgroundImage;
  74255. private _thumbImage;
  74256. private _thumbBaseImage;
  74257. private _thumbLength;
  74258. private _thumbHeight;
  74259. private _barImageHeight;
  74260. private _tempMeasure;
  74261. /** Number of 90° rotation to apply on the images when in vertical mode */
  74262. num90RotationInVerticalMode: number;
  74263. /**
  74264. * Gets or sets the image used to render the background for horizontal bar
  74265. */
  74266. get backgroundImage(): Image;
  74267. set backgroundImage(value: Image);
  74268. /**
  74269. * Gets or sets the image used to render the thumb
  74270. */
  74271. get thumbImage(): Image;
  74272. set thumbImage(value: Image);
  74273. /**
  74274. * Gets or sets the length of the thumb
  74275. */
  74276. get thumbLength(): number;
  74277. set thumbLength(value: number);
  74278. /**
  74279. * Gets or sets the height of the thumb
  74280. */
  74281. get thumbHeight(): number;
  74282. set thumbHeight(value: number);
  74283. /**
  74284. * Gets or sets the height of the bar image
  74285. */
  74286. get barImageHeight(): number;
  74287. set barImageHeight(value: number);
  74288. /**
  74289. * Creates a new ImageScrollBar
  74290. * @param name defines the control name
  74291. */
  74292. constructor(name?: string | undefined);
  74293. protected _getTypeName(): string;
  74294. protected _getThumbThickness(): number;
  74295. _draw(context: CanvasRenderingContext2D): void;
  74296. private _first;
  74297. private _originX;
  74298. private _originY;
  74299. /** @hidden */
  74300. protected _updateValueFromPointer(x: number, y: number): void;
  74301. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74302. }
  74303. }
  74304. declare module BABYLON.GUI {
  74305. /**
  74306. * Class used to hold a viewer window and sliders in a grid
  74307. */
  74308. export class ScrollViewer extends Rectangle {
  74309. private _grid;
  74310. private _horizontalBarSpace;
  74311. private _verticalBarSpace;
  74312. private _dragSpace;
  74313. private _horizontalBar;
  74314. private _verticalBar;
  74315. private _barColor;
  74316. private _barBackground;
  74317. private _barImage;
  74318. private _horizontalBarImage;
  74319. private _verticalBarImage;
  74320. private _barBackgroundImage;
  74321. private _horizontalBarBackgroundImage;
  74322. private _verticalBarBackgroundImage;
  74323. private _barSize;
  74324. private _window;
  74325. private _pointerIsOver;
  74326. private _wheelPrecision;
  74327. private _onWheelObserver;
  74328. private _clientWidth;
  74329. private _clientHeight;
  74330. private _useImageBar;
  74331. private _thumbLength;
  74332. private _thumbHeight;
  74333. private _barImageHeight;
  74334. private _horizontalBarImageHeight;
  74335. private _verticalBarImageHeight;
  74336. private _oldWindowContentsWidth;
  74337. private _oldWindowContentsHeight;
  74338. /**
  74339. * Gets the horizontal scrollbar
  74340. */
  74341. get horizontalBar(): ScrollBar | ImageScrollBar;
  74342. /**
  74343. * Gets the vertical scrollbar
  74344. */
  74345. get verticalBar(): ScrollBar | ImageScrollBar;
  74346. /**
  74347. * Adds a new control to the current container
  74348. * @param control defines the control to add
  74349. * @returns the current container
  74350. */
  74351. addControl(control: BABYLON.Nullable<Control>): Container;
  74352. /**
  74353. * Removes a control from the current container
  74354. * @param control defines the control to remove
  74355. * @returns the current container
  74356. */
  74357. removeControl(control: Control): Container;
  74358. /** Gets the list of children */
  74359. get children(): Control[];
  74360. _flagDescendantsAsMatrixDirty(): void;
  74361. /**
  74362. * Freezes or unfreezes the controls in the window.
  74363. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74364. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74365. */
  74366. get freezeControls(): boolean;
  74367. set freezeControls(value: boolean);
  74368. /** Gets the bucket width */
  74369. get bucketWidth(): number;
  74370. /** Gets the bucket height */
  74371. get bucketHeight(): number;
  74372. /**
  74373. * Sets the bucket sizes.
  74374. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74375. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74376. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74377. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74378. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74379. * used), that's why it is not enabled by default.
  74380. * @param width width of the bucket
  74381. * @param height height of the bucket
  74382. */
  74383. setBucketSizes(width: number, height: number): void;
  74384. private _forceHorizontalBar;
  74385. private _forceVerticalBar;
  74386. /**
  74387. * Forces the horizontal scroll bar to be displayed
  74388. */
  74389. get forceHorizontalBar(): boolean;
  74390. set forceHorizontalBar(value: boolean);
  74391. /**
  74392. * Forces the vertical scroll bar to be displayed
  74393. */
  74394. get forceVerticalBar(): boolean;
  74395. set forceVerticalBar(value: boolean);
  74396. /**
  74397. * Creates a new ScrollViewer
  74398. * @param name of ScrollViewer
  74399. */
  74400. constructor(name?: string, isImageBased?: boolean);
  74401. /** Reset the scroll viewer window to initial size */
  74402. resetWindow(): void;
  74403. protected _getTypeName(): string;
  74404. private _buildClientSizes;
  74405. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74406. protected _postMeasure(): void;
  74407. /**
  74408. * Gets or sets the mouse wheel precision
  74409. * from 0 to 1 with a default value of 0.05
  74410. * */
  74411. get wheelPrecision(): number;
  74412. set wheelPrecision(value: number);
  74413. /** Gets or sets the scroll bar container background color */
  74414. get scrollBackground(): string;
  74415. set scrollBackground(color: string);
  74416. /** Gets or sets the bar color */
  74417. get barColor(): string;
  74418. set barColor(color: string);
  74419. /** Gets or sets the bar image */
  74420. get thumbImage(): Image;
  74421. set thumbImage(value: Image);
  74422. /** Gets or sets the horizontal bar image */
  74423. get horizontalThumbImage(): Image;
  74424. set horizontalThumbImage(value: Image);
  74425. /** Gets or sets the vertical bar image */
  74426. get verticalThumbImage(): Image;
  74427. set verticalThumbImage(value: Image);
  74428. /** Gets or sets the size of the bar */
  74429. get barSize(): number;
  74430. set barSize(value: number);
  74431. /** Gets or sets the length of the thumb */
  74432. get thumbLength(): number;
  74433. set thumbLength(value: number);
  74434. /** Gets or sets the height of the thumb */
  74435. get thumbHeight(): number;
  74436. set thumbHeight(value: number);
  74437. /** Gets or sets the height of the bar image */
  74438. get barImageHeight(): number;
  74439. set barImageHeight(value: number);
  74440. /** Gets or sets the height of the horizontal bar image */
  74441. get horizontalBarImageHeight(): number;
  74442. set horizontalBarImageHeight(value: number);
  74443. /** Gets or sets the height of the vertical bar image */
  74444. get verticalBarImageHeight(): number;
  74445. set verticalBarImageHeight(value: number);
  74446. /** Gets or sets the bar background */
  74447. get barBackground(): string;
  74448. set barBackground(color: string);
  74449. /** Gets or sets the bar background image */
  74450. get barImage(): Image;
  74451. set barImage(value: Image);
  74452. /** Gets or sets the horizontal bar background image */
  74453. get horizontalBarImage(): Image;
  74454. set horizontalBarImage(value: Image);
  74455. /** Gets or sets the vertical bar background image */
  74456. get verticalBarImage(): Image;
  74457. set verticalBarImage(value: Image);
  74458. private _setWindowPosition;
  74459. /** @hidden */
  74460. private _updateScroller;
  74461. _link(host: AdvancedDynamicTexture): void;
  74462. /** @hidden */
  74463. private _addBar;
  74464. /** @hidden */
  74465. private _attachWheel;
  74466. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74467. /** Releases associated resources */
  74468. dispose(): void;
  74469. }
  74470. }
  74471. declare module BABYLON.GUI {
  74472. /** Class used to render a grid */
  74473. export class DisplayGrid extends Control {
  74474. name?: string | undefined;
  74475. private _cellWidth;
  74476. private _cellHeight;
  74477. private _minorLineTickness;
  74478. private _minorLineColor;
  74479. private _majorLineTickness;
  74480. private _majorLineColor;
  74481. private _majorLineFrequency;
  74482. private _background;
  74483. private _displayMajorLines;
  74484. private _displayMinorLines;
  74485. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74486. get displayMinorLines(): boolean;
  74487. set displayMinorLines(value: boolean);
  74488. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74489. get displayMajorLines(): boolean;
  74490. set displayMajorLines(value: boolean);
  74491. /** Gets or sets background color (Black by default) */
  74492. get background(): string;
  74493. set background(value: string);
  74494. /** Gets or sets the width of each cell (20 by default) */
  74495. get cellWidth(): number;
  74496. set cellWidth(value: number);
  74497. /** Gets or sets the height of each cell (20 by default) */
  74498. get cellHeight(): number;
  74499. set cellHeight(value: number);
  74500. /** Gets or sets the tickness of minor lines (1 by default) */
  74501. get minorLineTickness(): number;
  74502. set minorLineTickness(value: number);
  74503. /** Gets or sets the color of minor lines (DarkGray by default) */
  74504. get minorLineColor(): string;
  74505. set minorLineColor(value: string);
  74506. /** Gets or sets the tickness of major lines (2 by default) */
  74507. get majorLineTickness(): number;
  74508. set majorLineTickness(value: number);
  74509. /** Gets or sets the color of major lines (White by default) */
  74510. get majorLineColor(): string;
  74511. set majorLineColor(value: string);
  74512. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74513. get majorLineFrequency(): number;
  74514. set majorLineFrequency(value: number);
  74515. /**
  74516. * Creates a new GridDisplayRectangle
  74517. * @param name defines the control name
  74518. */
  74519. constructor(name?: string | undefined);
  74520. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74521. protected _getTypeName(): string;
  74522. }
  74523. }
  74524. declare module BABYLON.GUI {
  74525. /**
  74526. * Class used to create slider controls based on images
  74527. */
  74528. export class ImageBasedSlider extends BaseSlider {
  74529. name?: string | undefined;
  74530. private _backgroundImage;
  74531. private _thumbImage;
  74532. private _valueBarImage;
  74533. private _tempMeasure;
  74534. get displayThumb(): boolean;
  74535. set displayThumb(value: boolean);
  74536. /**
  74537. * Gets or sets the image used to render the background
  74538. */
  74539. get backgroundImage(): Image;
  74540. set backgroundImage(value: Image);
  74541. /**
  74542. * Gets or sets the image used to render the value bar
  74543. */
  74544. get valueBarImage(): Image;
  74545. set valueBarImage(value: Image);
  74546. /**
  74547. * Gets or sets the image used to render the thumb
  74548. */
  74549. get thumbImage(): Image;
  74550. set thumbImage(value: Image);
  74551. /**
  74552. * Creates a new ImageBasedSlider
  74553. * @param name defines the control name
  74554. */
  74555. constructor(name?: string | undefined);
  74556. protected _getTypeName(): string;
  74557. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74558. }
  74559. }
  74560. declare module BABYLON.GUI {
  74561. /**
  74562. * Forcing an export so that this code will execute
  74563. * @hidden
  74564. */
  74565. const name = "Statics";
  74566. }
  74567. declare module BABYLON.GUI {
  74568. /**
  74569. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74570. */
  74571. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74572. /**
  74573. * Define the instrumented AdvancedDynamicTexture.
  74574. */
  74575. texture: AdvancedDynamicTexture;
  74576. private _captureRenderTime;
  74577. private _renderTime;
  74578. private _captureLayoutTime;
  74579. private _layoutTime;
  74580. private _onBeginRenderObserver;
  74581. private _onEndRenderObserver;
  74582. private _onBeginLayoutObserver;
  74583. private _onEndLayoutObserver;
  74584. /**
  74585. * Gets the perf counter used to capture render time
  74586. */
  74587. get renderTimeCounter(): BABYLON.PerfCounter;
  74588. /**
  74589. * Gets the perf counter used to capture layout time
  74590. */
  74591. get layoutTimeCounter(): BABYLON.PerfCounter;
  74592. /**
  74593. * Enable or disable the render time capture
  74594. */
  74595. get captureRenderTime(): boolean;
  74596. set captureRenderTime(value: boolean);
  74597. /**
  74598. * Enable or disable the layout time capture
  74599. */
  74600. get captureLayoutTime(): boolean;
  74601. set captureLayoutTime(value: boolean);
  74602. /**
  74603. * Instantiates a new advanced dynamic texture instrumentation.
  74604. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74605. * @param texture Defines the AdvancedDynamicTexture to instrument
  74606. */
  74607. constructor(
  74608. /**
  74609. * Define the instrumented AdvancedDynamicTexture.
  74610. */
  74611. texture: AdvancedDynamicTexture);
  74612. /**
  74613. * Dispose and release associated resources.
  74614. */
  74615. dispose(): void;
  74616. }
  74617. }
  74618. declare module BABYLON.GUI {
  74619. /**
  74620. * Class used to load GUI via XML.
  74621. */
  74622. export class XmlLoader {
  74623. private _nodes;
  74624. private _nodeTypes;
  74625. private _isLoaded;
  74626. private _objectAttributes;
  74627. private _parentClass;
  74628. /**
  74629. * Create a new xml loader
  74630. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74631. */
  74632. constructor(parentClass?: null);
  74633. private _getChainElement;
  74634. private _getClassAttribute;
  74635. private _createGuiElement;
  74636. private _parseGrid;
  74637. private _parseElement;
  74638. private _prepareSourceElement;
  74639. private _parseElementsFromSource;
  74640. private _parseXml;
  74641. /**
  74642. * Gets if the loading has finished.
  74643. * @returns whether the loading has finished or not
  74644. */
  74645. isLoaded(): boolean;
  74646. /**
  74647. * Gets a loaded node / control by id.
  74648. * @param id the Controls id set in the xml
  74649. * @returns element of type Control
  74650. */
  74651. getNodeById(id: string): any;
  74652. /**
  74653. * Gets all loaded nodes / controls
  74654. * @returns Array of controls
  74655. */
  74656. getNodes(): any;
  74657. /**
  74658. * Initiates the xml layout loading
  74659. * @param xmlFile defines the xml layout to load
  74660. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74661. * @param callback defines the callback called on layout load.
  74662. */
  74663. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74664. }
  74665. }
  74666. declare module BABYLON.GUI {
  74667. /**
  74668. * Class used to create containers for controls
  74669. */
  74670. export class Container3D extends Control3D {
  74671. private _blockLayout;
  74672. /**
  74673. * Gets the list of child controls
  74674. */
  74675. protected _children: Control3D[];
  74676. /**
  74677. * Gets the list of child controls
  74678. */
  74679. get children(): Array<Control3D>;
  74680. /**
  74681. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74682. * This is helpful to optimize layout operation when adding multiple children in a row
  74683. */
  74684. get blockLayout(): boolean;
  74685. set blockLayout(value: boolean);
  74686. /**
  74687. * Creates a new container
  74688. * @param name defines the container name
  74689. */
  74690. constructor(name?: string);
  74691. /**
  74692. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74693. * @returns the current container
  74694. */
  74695. updateLayout(): Container3D;
  74696. /**
  74697. * Gets a boolean indicating if the given control is in the children of this control
  74698. * @param control defines the control to check
  74699. * @returns true if the control is in the child list
  74700. */
  74701. containsControl(control: Control3D): boolean;
  74702. /**
  74703. * Adds a control to the children of this control
  74704. * @param control defines the control to add
  74705. * @returns the current container
  74706. */
  74707. addControl(control: Control3D): Container3D;
  74708. /**
  74709. * This function will be called everytime a new control is added
  74710. */
  74711. protected _arrangeChildren(): void;
  74712. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74713. /**
  74714. * Removes a control from the children of this control
  74715. * @param control defines the control to remove
  74716. * @returns the current container
  74717. */
  74718. removeControl(control: Control3D): Container3D;
  74719. protected _getTypeName(): string;
  74720. /**
  74721. * Releases all associated resources
  74722. */
  74723. dispose(): void;
  74724. /** Control rotation will remain unchanged */
  74725. static readonly UNSET_ORIENTATION: number;
  74726. /** Control will rotate to make it look at sphere central axis */
  74727. static readonly FACEORIGIN_ORIENTATION: number;
  74728. /** Control will rotate to make it look back at sphere central axis */
  74729. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74730. /** Control will rotate to look at z axis (0, 0, 1) */
  74731. static readonly FACEFORWARD_ORIENTATION: number;
  74732. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74733. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74734. }
  74735. }
  74736. declare module BABYLON.GUI {
  74737. /**
  74738. * Class used to manage 3D user interface
  74739. * @see http://doc.babylonjs.com/how_to/gui3d
  74740. */
  74741. export class GUI3DManager implements BABYLON.IDisposable {
  74742. private _scene;
  74743. private _sceneDisposeObserver;
  74744. private _utilityLayer;
  74745. private _rootContainer;
  74746. private _pointerObserver;
  74747. private _pointerOutObserver;
  74748. /** @hidden */
  74749. _lastPickedControl: Control3D;
  74750. /** @hidden */
  74751. _lastControlOver: {
  74752. [pointerId: number]: Control3D;
  74753. };
  74754. /** @hidden */
  74755. _lastControlDown: {
  74756. [pointerId: number]: Control3D;
  74757. };
  74758. /**
  74759. * BABYLON.Observable raised when the point picked by the pointer events changed
  74760. */
  74761. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74762. /** @hidden */
  74763. _sharedMaterials: {
  74764. [key: string]: BABYLON.Material;
  74765. };
  74766. /** Gets the hosting scene */
  74767. get scene(): BABYLON.Scene;
  74768. /** Gets associated utility layer */
  74769. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74770. /**
  74771. * Creates a new GUI3DManager
  74772. * @param scene
  74773. */
  74774. constructor(scene?: BABYLON.Scene);
  74775. private _handlePointerOut;
  74776. private _doPicking;
  74777. /**
  74778. * Gets the root container
  74779. */
  74780. get rootContainer(): Container3D;
  74781. /**
  74782. * Gets a boolean indicating if the given control is in the root child list
  74783. * @param control defines the control to check
  74784. * @returns true if the control is in the root child list
  74785. */
  74786. containsControl(control: Control3D): boolean;
  74787. /**
  74788. * Adds a control to the root child list
  74789. * @param control defines the control to add
  74790. * @returns the current manager
  74791. */
  74792. addControl(control: Control3D): GUI3DManager;
  74793. /**
  74794. * Removes a control from the root child list
  74795. * @param control defines the control to remove
  74796. * @returns the current container
  74797. */
  74798. removeControl(control: Control3D): GUI3DManager;
  74799. /**
  74800. * Releases all associated resources
  74801. */
  74802. dispose(): void;
  74803. }
  74804. }
  74805. declare module BABYLON.GUI {
  74806. /**
  74807. * Class used to transport BABYLON.Vector3 information for pointer events
  74808. */
  74809. export class Vector3WithInfo extends BABYLON.Vector3 {
  74810. /** defines the current mouse button index */
  74811. buttonIndex: number;
  74812. /**
  74813. * Creates a new Vector3WithInfo
  74814. * @param source defines the vector3 data to transport
  74815. * @param buttonIndex defines the current mouse button index
  74816. */
  74817. constructor(source: BABYLON.Vector3,
  74818. /** defines the current mouse button index */
  74819. buttonIndex?: number);
  74820. }
  74821. }
  74822. declare module BABYLON.GUI {
  74823. /**
  74824. * Class used as base class for controls
  74825. */
  74826. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74827. /** Defines the control name */
  74828. name?: string | undefined;
  74829. /** @hidden */
  74830. _host: GUI3DManager;
  74831. private _node;
  74832. private _downCount;
  74833. private _enterCount;
  74834. private _downPointerIds;
  74835. private _isVisible;
  74836. /** Gets or sets the control position in world space */
  74837. get position(): BABYLON.Vector3;
  74838. set position(value: BABYLON.Vector3);
  74839. /** Gets or sets the control scaling in world space */
  74840. get scaling(): BABYLON.Vector3;
  74841. set scaling(value: BABYLON.Vector3);
  74842. /** Callback used to start pointer enter animation */
  74843. pointerEnterAnimation: () => void;
  74844. /** Callback used to start pointer out animation */
  74845. pointerOutAnimation: () => void;
  74846. /** Callback used to start pointer down animation */
  74847. pointerDownAnimation: () => void;
  74848. /** Callback used to start pointer up animation */
  74849. pointerUpAnimation: () => void;
  74850. /**
  74851. * An event triggered when the pointer move over the control
  74852. */
  74853. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74854. /**
  74855. * An event triggered when the pointer move out of the control
  74856. */
  74857. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74858. /**
  74859. * An event triggered when the pointer taps the control
  74860. */
  74861. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74862. /**
  74863. * An event triggered when pointer is up
  74864. */
  74865. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74866. /**
  74867. * An event triggered when a control is clicked on (with a mouse)
  74868. */
  74869. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74870. /**
  74871. * An event triggered when pointer enters the control
  74872. */
  74873. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74874. /**
  74875. * Gets or sets the parent container
  74876. */
  74877. parent: BABYLON.Nullable<Container3D>;
  74878. private _behaviors;
  74879. /**
  74880. * Gets the list of attached behaviors
  74881. * @see http://doc.babylonjs.com/features/behaviour
  74882. */
  74883. get behaviors(): BABYLON.Behavior<Control3D>[];
  74884. /**
  74885. * Attach a behavior to the control
  74886. * @see http://doc.babylonjs.com/features/behaviour
  74887. * @param behavior defines the behavior to attach
  74888. * @returns the current control
  74889. */
  74890. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74891. /**
  74892. * Remove an attached behavior
  74893. * @see http://doc.babylonjs.com/features/behaviour
  74894. * @param behavior defines the behavior to attach
  74895. * @returns the current control
  74896. */
  74897. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74898. /**
  74899. * Gets an attached behavior by name
  74900. * @param name defines the name of the behavior to look for
  74901. * @see http://doc.babylonjs.com/features/behaviour
  74902. * @returns null if behavior was not found else the requested behavior
  74903. */
  74904. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74905. /** Gets or sets a boolean indicating if the control is visible */
  74906. get isVisible(): boolean;
  74907. set isVisible(value: boolean);
  74908. /**
  74909. * Creates a new control
  74910. * @param name defines the control name
  74911. */
  74912. constructor(
  74913. /** Defines the control name */
  74914. name?: string | undefined);
  74915. /**
  74916. * Gets a string representing the class name
  74917. */
  74918. get typeName(): string;
  74919. /**
  74920. * Get the current class name of the control.
  74921. * @returns current class name
  74922. */
  74923. getClassName(): string;
  74924. protected _getTypeName(): string;
  74925. /**
  74926. * Gets the transform node used by this control
  74927. */
  74928. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74929. /**
  74930. * Gets the mesh used to render this control
  74931. */
  74932. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74933. /**
  74934. * Link the control as child of the given node
  74935. * @param node defines the node to link to. Use null to unlink the control
  74936. * @returns the current control
  74937. */
  74938. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74939. /** @hidden **/
  74940. _prepareNode(scene: BABYLON.Scene): void;
  74941. /**
  74942. * Node creation.
  74943. * Can be overriden by children
  74944. * @param scene defines the scene where the node must be attached
  74945. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74946. */
  74947. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74948. /**
  74949. * Affect a material to the given mesh
  74950. * @param mesh defines the mesh which will represent the control
  74951. */
  74952. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74953. /** @hidden */
  74954. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74955. /** @hidden */
  74956. _onPointerEnter(target: Control3D): boolean;
  74957. /** @hidden */
  74958. _onPointerOut(target: Control3D): void;
  74959. /** @hidden */
  74960. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74961. /** @hidden */
  74962. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74963. /** @hidden */
  74964. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74965. /** @hidden */
  74966. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74967. /** @hidden */
  74968. _disposeNode(): void;
  74969. /**
  74970. * Releases all associated resources
  74971. */
  74972. dispose(): void;
  74973. }
  74974. }
  74975. declare module BABYLON.GUI {
  74976. /**
  74977. * Class used as a root to all buttons
  74978. */
  74979. export class AbstractButton3D extends Control3D {
  74980. /**
  74981. * Creates a new button
  74982. * @param name defines the control name
  74983. */
  74984. constructor(name?: string);
  74985. protected _getTypeName(): string;
  74986. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74987. }
  74988. }
  74989. declare module BABYLON.GUI {
  74990. /**
  74991. * Class used to create a button in 3D
  74992. */
  74993. export class Button3D extends AbstractButton3D {
  74994. /** @hidden */
  74995. protected _currentMaterial: BABYLON.Material;
  74996. private _facadeTexture;
  74997. private _content;
  74998. private _contentResolution;
  74999. private _contentScaleRatio;
  75000. /**
  75001. * Gets or sets the texture resolution used to render content (512 by default)
  75002. */
  75003. get contentResolution(): BABYLON.int;
  75004. set contentResolution(value: BABYLON.int);
  75005. /**
  75006. * Gets or sets the texture scale ratio used to render content (2 by default)
  75007. */
  75008. get contentScaleRatio(): number;
  75009. set contentScaleRatio(value: number);
  75010. protected _disposeFacadeTexture(): void;
  75011. protected _resetContent(): void;
  75012. /**
  75013. * Creates a new button
  75014. * @param name defines the control name
  75015. */
  75016. constructor(name?: string);
  75017. /**
  75018. * Gets or sets the GUI 2D content used to display the button's facade
  75019. */
  75020. get content(): Control;
  75021. set content(value: Control);
  75022. /**
  75023. * Apply the facade texture (created from the content property).
  75024. * This function can be overloaded by child classes
  75025. * @param facadeTexture defines the AdvancedDynamicTexture to use
  75026. */
  75027. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75028. protected _getTypeName(): string;
  75029. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75030. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75031. /**
  75032. * Releases all associated resources
  75033. */
  75034. dispose(): void;
  75035. }
  75036. }
  75037. declare module BABYLON.GUI {
  75038. /**
  75039. * Abstract class used to create a container panel deployed on the surface of a volume
  75040. */
  75041. export abstract class VolumeBasedPanel extends Container3D {
  75042. private _columns;
  75043. private _rows;
  75044. private _rowThenColum;
  75045. private _orientation;
  75046. protected _cellWidth: number;
  75047. protected _cellHeight: number;
  75048. /**
  75049. * Gets or sets the distance between elements
  75050. */
  75051. margin: number;
  75052. /**
  75053. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  75054. * | Value | Type | Description |
  75055. * | ----- | ----------------------------------- | ----------- |
  75056. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  75057. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  75058. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  75059. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  75060. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  75061. */
  75062. get orientation(): number;
  75063. set orientation(value: number);
  75064. /**
  75065. * Gets or sets the number of columns requested (10 by default).
  75066. * The panel will automatically compute the number of rows based on number of child controls.
  75067. */
  75068. get columns(): BABYLON.int;
  75069. set columns(value: BABYLON.int);
  75070. /**
  75071. * Gets or sets a the number of rows requested.
  75072. * The panel will automatically compute the number of columns based on number of child controls.
  75073. */
  75074. get rows(): BABYLON.int;
  75075. set rows(value: BABYLON.int);
  75076. /**
  75077. * Creates new VolumeBasedPanel
  75078. */
  75079. constructor();
  75080. protected _arrangeChildren(): void;
  75081. /** Child classes must implement this function to provide correct control positioning */
  75082. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75083. /** Child classes can implement this function to provide additional processing */
  75084. protected _finalProcessing(): void;
  75085. }
  75086. }
  75087. declare module BABYLON.GUI {
  75088. /**
  75089. * Class used to create a container panel deployed on the surface of a cylinder
  75090. */
  75091. export class CylinderPanel extends VolumeBasedPanel {
  75092. private _radius;
  75093. /**
  75094. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  75095. */
  75096. get radius(): BABYLON.float;
  75097. set radius(value: BABYLON.float);
  75098. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75099. private _cylindricalMapping;
  75100. }
  75101. }
  75102. declare module BABYLON.GUI {
  75103. /** @hidden */
  75104. export var fluentVertexShader: {
  75105. name: string;
  75106. shader: string;
  75107. };
  75108. }
  75109. declare module BABYLON.GUI {
  75110. /** @hidden */
  75111. export var fluentPixelShader: {
  75112. name: string;
  75113. shader: string;
  75114. };
  75115. }
  75116. declare module BABYLON.GUI {
  75117. /** @hidden */
  75118. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  75119. INNERGLOW: boolean;
  75120. BORDER: boolean;
  75121. HOVERLIGHT: boolean;
  75122. TEXTURE: boolean;
  75123. constructor();
  75124. }
  75125. /**
  75126. * Class used to render controls with fluent desgin
  75127. */
  75128. export class FluentMaterial extends BABYLON.PushMaterial {
  75129. /**
  75130. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  75131. */
  75132. innerGlowColorIntensity: number;
  75133. /**
  75134. * Gets or sets the inner glow color (white by default)
  75135. */
  75136. innerGlowColor: BABYLON.Color3;
  75137. /**
  75138. * Gets or sets alpha value (default is 1.0)
  75139. */
  75140. alpha: number;
  75141. /**
  75142. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  75143. */
  75144. albedoColor: BABYLON.Color3;
  75145. /**
  75146. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  75147. */
  75148. renderBorders: boolean;
  75149. /**
  75150. * Gets or sets border width (default is 0.5)
  75151. */
  75152. borderWidth: number;
  75153. /**
  75154. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  75155. */
  75156. edgeSmoothingValue: number;
  75157. /**
  75158. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  75159. */
  75160. borderMinValue: number;
  75161. /**
  75162. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  75163. */
  75164. renderHoverLight: boolean;
  75165. /**
  75166. * Gets or sets the radius used to render the hover light (default is 1.0)
  75167. */
  75168. hoverRadius: number;
  75169. /**
  75170. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  75171. */
  75172. hoverColor: BABYLON.Color4;
  75173. /**
  75174. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  75175. */
  75176. hoverPosition: BABYLON.Vector3;
  75177. private _albedoTexture;
  75178. /** Gets or sets the texture to use for albedo color */
  75179. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75180. /**
  75181. * Creates a new Fluent material
  75182. * @param name defines the name of the material
  75183. * @param scene defines the hosting scene
  75184. */
  75185. constructor(name: string, scene: BABYLON.Scene);
  75186. needAlphaBlending(): boolean;
  75187. needAlphaTesting(): boolean;
  75188. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75190. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75191. getActiveTextures(): BABYLON.BaseTexture[];
  75192. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75193. dispose(forceDisposeEffect?: boolean): void;
  75194. clone(name: string): FluentMaterial;
  75195. serialize(): any;
  75196. getClassName(): string;
  75197. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  75198. }
  75199. }
  75200. declare module BABYLON.GUI {
  75201. /**
  75202. * Class used to create a holographic button in 3D
  75203. */
  75204. export class HolographicButton extends Button3D {
  75205. private _backPlate;
  75206. private _textPlate;
  75207. private _frontPlate;
  75208. private _text;
  75209. private _imageUrl;
  75210. private _shareMaterials;
  75211. private _frontMaterial;
  75212. private _backMaterial;
  75213. private _plateMaterial;
  75214. private _pickedPointObserver;
  75215. private _tooltipFade;
  75216. private _tooltipTextBlock;
  75217. private _tooltipTexture;
  75218. private _tooltipMesh;
  75219. private _tooltipHoverObserver;
  75220. private _tooltipOutObserver;
  75221. private _disposeTooltip;
  75222. /**
  75223. * Rendering ground id of all the mesh in the button
  75224. */
  75225. set renderingGroupId(id: number);
  75226. get renderingGroupId(): number;
  75227. /**
  75228. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  75229. */
  75230. set tooltipText(text: BABYLON.Nullable<string>);
  75231. get tooltipText(): BABYLON.Nullable<string>;
  75232. /**
  75233. * Gets or sets text for the button
  75234. */
  75235. get text(): string;
  75236. set text(value: string);
  75237. /**
  75238. * Gets or sets the image url for the button
  75239. */
  75240. get imageUrl(): string;
  75241. set imageUrl(value: string);
  75242. /**
  75243. * Gets the back material used by this button
  75244. */
  75245. get backMaterial(): FluentMaterial;
  75246. /**
  75247. * Gets the front material used by this button
  75248. */
  75249. get frontMaterial(): FluentMaterial;
  75250. /**
  75251. * Gets the plate material used by this button
  75252. */
  75253. get plateMaterial(): BABYLON.StandardMaterial;
  75254. /**
  75255. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75256. */
  75257. get shareMaterials(): boolean;
  75258. /**
  75259. * Creates a new button
  75260. * @param name defines the control name
  75261. */
  75262. constructor(name?: string, shareMaterials?: boolean);
  75263. protected _getTypeName(): string;
  75264. private _rebuildContent;
  75265. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75266. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75267. private _createBackMaterial;
  75268. private _createFrontMaterial;
  75269. private _createPlateMaterial;
  75270. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75271. /**
  75272. * Releases all associated resources
  75273. */
  75274. dispose(): void;
  75275. }
  75276. }
  75277. declare module BABYLON.GUI {
  75278. /**
  75279. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75280. */
  75281. export class MeshButton3D extends Button3D {
  75282. /** @hidden */
  75283. protected _currentMesh: BABYLON.Mesh;
  75284. /**
  75285. * Creates a new 3D button based on a mesh
  75286. * @param mesh mesh to become a 3D button
  75287. * @param name defines the control name
  75288. */
  75289. constructor(mesh: BABYLON.Mesh, name?: string);
  75290. protected _getTypeName(): string;
  75291. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75292. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75293. }
  75294. }
  75295. declare module BABYLON.GUI {
  75296. /**
  75297. * Class used to create a container panel deployed on the surface of a plane
  75298. */
  75299. export class PlanePanel extends VolumeBasedPanel {
  75300. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75301. }
  75302. }
  75303. declare module BABYLON.GUI {
  75304. /**
  75305. * Class used to create a container panel where items get randomized planar mapping
  75306. */
  75307. export class ScatterPanel extends VolumeBasedPanel {
  75308. private _iteration;
  75309. /**
  75310. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75311. */
  75312. get iteration(): BABYLON.float;
  75313. set iteration(value: BABYLON.float);
  75314. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75315. private _scatterMapping;
  75316. protected _finalProcessing(): void;
  75317. }
  75318. }
  75319. declare module BABYLON.GUI {
  75320. /**
  75321. * Class used to create a container panel deployed on the surface of a sphere
  75322. */
  75323. export class SpherePanel extends VolumeBasedPanel {
  75324. private _radius;
  75325. /**
  75326. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75327. */
  75328. get radius(): BABYLON.float;
  75329. set radius(value: BABYLON.float);
  75330. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75331. private _sphericalMapping;
  75332. }
  75333. }
  75334. declare module BABYLON.GUI {
  75335. /**
  75336. * Class used to create a stack panel in 3D on XY plane
  75337. */
  75338. export class StackPanel3D extends Container3D {
  75339. private _isVertical;
  75340. /**
  75341. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75342. */
  75343. get isVertical(): boolean;
  75344. set isVertical(value: boolean);
  75345. /**
  75346. * Gets or sets the distance between elements
  75347. */
  75348. margin: number;
  75349. /**
  75350. * Creates new StackPanel
  75351. * @param isVertical
  75352. */
  75353. constructor(isVertical?: boolean);
  75354. protected _arrangeChildren(): void;
  75355. }
  75356. }
  75357. declare module BABYLON {
  75358. /**
  75359. * Configuration for glTF validation
  75360. */
  75361. export interface IGLTFValidationConfiguration {
  75362. /**
  75363. * The url of the glTF validator.
  75364. */
  75365. url: string;
  75366. }
  75367. /**
  75368. * glTF validation
  75369. */
  75370. export class GLTFValidation {
  75371. /**
  75372. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75373. */
  75374. static Configuration: IGLTFValidationConfiguration;
  75375. private static _LoadScriptPromise;
  75376. /**
  75377. * Validate a glTF asset using the glTF-Validator.
  75378. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75379. * @param rootUrl The root url for the glTF
  75380. * @param fileName The file name for the glTF
  75381. * @param getExternalResource The callback to get external resources for the glTF validator
  75382. * @returns A promise that resolves with the glTF validation results once complete
  75383. */
  75384. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75385. }
  75386. }
  75387. declare module BABYLON {
  75388. /**
  75389. * Mode that determines the coordinate system to use.
  75390. */
  75391. export enum GLTFLoaderCoordinateSystemMode {
  75392. /**
  75393. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75394. */
  75395. AUTO = 0,
  75396. /**
  75397. * Sets the useRightHandedSystem flag on the scene.
  75398. */
  75399. FORCE_RIGHT_HANDED = 1
  75400. }
  75401. /**
  75402. * Mode that determines what animations will start.
  75403. */
  75404. export enum GLTFLoaderAnimationStartMode {
  75405. /**
  75406. * No animation will start.
  75407. */
  75408. NONE = 0,
  75409. /**
  75410. * The first animation will start.
  75411. */
  75412. FIRST = 1,
  75413. /**
  75414. * All animations will start.
  75415. */
  75416. ALL = 2
  75417. }
  75418. /**
  75419. * Interface that contains the data for the glTF asset.
  75420. */
  75421. export interface IGLTFLoaderData {
  75422. /**
  75423. * The object that represents the glTF JSON.
  75424. */
  75425. json: Object;
  75426. /**
  75427. * The BIN chunk of a binary glTF.
  75428. */
  75429. bin: Nullable<IDataBuffer>;
  75430. }
  75431. /**
  75432. * Interface for extending the loader.
  75433. */
  75434. export interface IGLTFLoaderExtension {
  75435. /**
  75436. * The name of this extension.
  75437. */
  75438. readonly name: string;
  75439. /**
  75440. * Defines whether this extension is enabled.
  75441. */
  75442. enabled: boolean;
  75443. /**
  75444. * Defines the order of this extension.
  75445. * The loader sorts the extensions using these values when loading.
  75446. */
  75447. order?: number;
  75448. }
  75449. /**
  75450. * Loader state.
  75451. */
  75452. export enum GLTFLoaderState {
  75453. /**
  75454. * The asset is loading.
  75455. */
  75456. LOADING = 0,
  75457. /**
  75458. * The asset is ready for rendering.
  75459. */
  75460. READY = 1,
  75461. /**
  75462. * The asset is completely loaded.
  75463. */
  75464. COMPLETE = 2
  75465. }
  75466. /** @hidden */
  75467. export interface IImportMeshAsyncOutput {
  75468. meshes: AbstractMesh[];
  75469. particleSystems: IParticleSystem[];
  75470. skeletons: Skeleton[];
  75471. animationGroups: AnimationGroup[];
  75472. lights: Light[];
  75473. transformNodes: TransformNode[];
  75474. }
  75475. /** @hidden */
  75476. export interface IGLTFLoader extends IDisposable {
  75477. readonly state: Nullable<GLTFLoaderState>;
  75478. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75479. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75480. }
  75481. /**
  75482. * File loader for loading glTF files into a scene.
  75483. */
  75484. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75485. /** @hidden */
  75486. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75487. /** @hidden */
  75488. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75489. /**
  75490. * Raised when the asset has been parsed
  75491. */
  75492. onParsedObservable: Observable<IGLTFLoaderData>;
  75493. private _onParsedObserver;
  75494. /**
  75495. * Raised when the asset has been parsed
  75496. */
  75497. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75498. /**
  75499. * 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.
  75500. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75501. * Defaults to true.
  75502. * @hidden
  75503. */
  75504. static IncrementalLoading: boolean;
  75505. /**
  75506. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75507. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75508. * @hidden
  75509. */
  75510. static HomogeneousCoordinates: boolean;
  75511. /**
  75512. * The coordinate system mode. Defaults to AUTO.
  75513. */
  75514. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75515. /**
  75516. * The animation start mode. Defaults to FIRST.
  75517. */
  75518. animationStartMode: GLTFLoaderAnimationStartMode;
  75519. /**
  75520. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75521. */
  75522. compileMaterials: boolean;
  75523. /**
  75524. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75525. */
  75526. useClipPlane: boolean;
  75527. /**
  75528. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75529. */
  75530. compileShadowGenerators: boolean;
  75531. /**
  75532. * Defines if the Alpha blended materials are only applied as coverage.
  75533. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75534. * If true, no extra effects are applied to transparent pixels.
  75535. */
  75536. transparencyAsCoverage: boolean;
  75537. /**
  75538. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75539. * Enabling will disable offline support and glTF validator.
  75540. * Defaults to false.
  75541. */
  75542. useRangeRequests: boolean;
  75543. /**
  75544. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75545. */
  75546. createInstances: boolean;
  75547. /**
  75548. * Function called before loading a url referenced by the asset.
  75549. */
  75550. preprocessUrlAsync: (url: string) => Promise<string>;
  75551. /**
  75552. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75553. */
  75554. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75555. private _onMeshLoadedObserver;
  75556. /**
  75557. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75558. */
  75559. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75560. /**
  75561. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75562. */
  75563. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75564. private _onTextureLoadedObserver;
  75565. /**
  75566. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75567. */
  75568. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75569. /**
  75570. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75571. */
  75572. readonly onMaterialLoadedObservable: Observable<Material>;
  75573. private _onMaterialLoadedObserver;
  75574. /**
  75575. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75576. */
  75577. set onMaterialLoaded(callback: (material: Material) => void);
  75578. /**
  75579. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75580. */
  75581. readonly onCameraLoadedObservable: Observable<Camera>;
  75582. private _onCameraLoadedObserver;
  75583. /**
  75584. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75585. */
  75586. set onCameraLoaded(callback: (camera: Camera) => void);
  75587. /**
  75588. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75589. * For assets with LODs, raised when all of the LODs are complete.
  75590. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75591. */
  75592. readonly onCompleteObservable: Observable<void>;
  75593. private _onCompleteObserver;
  75594. /**
  75595. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75596. * For assets with LODs, raised when all of the LODs are complete.
  75597. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75598. */
  75599. set onComplete(callback: () => void);
  75600. /**
  75601. * Observable raised when an error occurs.
  75602. */
  75603. readonly onErrorObservable: Observable<any>;
  75604. private _onErrorObserver;
  75605. /**
  75606. * Callback raised when an error occurs.
  75607. */
  75608. set onError(callback: (reason: any) => void);
  75609. /**
  75610. * Observable raised after the loader is disposed.
  75611. */
  75612. readonly onDisposeObservable: Observable<void>;
  75613. private _onDisposeObserver;
  75614. /**
  75615. * Callback raised after the loader is disposed.
  75616. */
  75617. set onDispose(callback: () => void);
  75618. /**
  75619. * Observable raised after a loader extension is created.
  75620. * Set additional options for a loader extension in this event.
  75621. */
  75622. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75623. private _onExtensionLoadedObserver;
  75624. /**
  75625. * Callback raised after a loader extension is created.
  75626. */
  75627. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75628. /**
  75629. * Defines if the loader logging is enabled.
  75630. */
  75631. get loggingEnabled(): boolean;
  75632. set loggingEnabled(value: boolean);
  75633. /**
  75634. * Defines if the loader should capture performance counters.
  75635. */
  75636. get capturePerformanceCounters(): boolean;
  75637. set capturePerformanceCounters(value: boolean);
  75638. /**
  75639. * Defines if the loader should validate the asset.
  75640. */
  75641. validate: boolean;
  75642. /**
  75643. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75644. */
  75645. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75646. private _onValidatedObserver;
  75647. /**
  75648. * Callback raised after a loader extension is created.
  75649. */
  75650. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75651. private _loader;
  75652. /**
  75653. * Name of the loader ("gltf")
  75654. */
  75655. name: string;
  75656. /** @hidden */
  75657. extensions: ISceneLoaderPluginExtensions;
  75658. /**
  75659. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75660. */
  75661. dispose(): void;
  75662. /** @hidden */
  75663. _clear(): void;
  75664. /** @hidden */
  75665. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75666. /** @hidden */
  75667. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75668. /** @hidden */
  75669. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75670. meshes: AbstractMesh[];
  75671. particleSystems: IParticleSystem[];
  75672. skeletons: Skeleton[];
  75673. animationGroups: AnimationGroup[];
  75674. }>;
  75675. /** @hidden */
  75676. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75677. /** @hidden */
  75678. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75679. /** @hidden */
  75680. canDirectLoad(data: string): boolean;
  75681. /** @hidden */
  75682. directLoad(scene: Scene, data: string): any;
  75683. /**
  75684. * The callback that allows custom handling of the root url based on the response url.
  75685. * @param rootUrl the original root url
  75686. * @param responseURL the response url if available
  75687. * @returns the new root url
  75688. */
  75689. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75690. /** @hidden */
  75691. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75692. /**
  75693. * The loader state or null if the loader is not active.
  75694. */
  75695. get loaderState(): Nullable<GLTFLoaderState>;
  75696. /**
  75697. * Returns a promise that resolves when the asset is completely loaded.
  75698. * @returns a promise that resolves when the asset is completely loaded.
  75699. */
  75700. whenCompleteAsync(): Promise<void>;
  75701. private _validate;
  75702. private _getLoader;
  75703. private _parseJson;
  75704. private _unpackBinaryAsync;
  75705. private _unpackBinaryV1Async;
  75706. private _unpackBinaryV2Async;
  75707. private static _parseVersion;
  75708. private static _compareVersion;
  75709. private static readonly _logSpaces;
  75710. private _logIndentLevel;
  75711. private _loggingEnabled;
  75712. /** @hidden */
  75713. _log: (message: string) => void;
  75714. /** @hidden */
  75715. _logOpen(message: string): void;
  75716. /** @hidden */
  75717. _logClose(): void;
  75718. private _logEnabled;
  75719. private _logDisabled;
  75720. private _capturePerformanceCounters;
  75721. /** @hidden */
  75722. _startPerformanceCounter: (counterName: string) => void;
  75723. /** @hidden */
  75724. _endPerformanceCounter: (counterName: string) => void;
  75725. private _startPerformanceCounterEnabled;
  75726. private _startPerformanceCounterDisabled;
  75727. private _endPerformanceCounterEnabled;
  75728. private _endPerformanceCounterDisabled;
  75729. }
  75730. }
  75731. declare module BABYLON.GLTF1 {
  75732. /**
  75733. * Enums
  75734. * @hidden
  75735. */
  75736. export enum EComponentType {
  75737. BYTE = 5120,
  75738. UNSIGNED_BYTE = 5121,
  75739. SHORT = 5122,
  75740. UNSIGNED_SHORT = 5123,
  75741. FLOAT = 5126
  75742. }
  75743. /** @hidden */
  75744. export enum EShaderType {
  75745. FRAGMENT = 35632,
  75746. VERTEX = 35633
  75747. }
  75748. /** @hidden */
  75749. export enum EParameterType {
  75750. BYTE = 5120,
  75751. UNSIGNED_BYTE = 5121,
  75752. SHORT = 5122,
  75753. UNSIGNED_SHORT = 5123,
  75754. INT = 5124,
  75755. UNSIGNED_INT = 5125,
  75756. FLOAT = 5126,
  75757. FLOAT_VEC2 = 35664,
  75758. FLOAT_VEC3 = 35665,
  75759. FLOAT_VEC4 = 35666,
  75760. INT_VEC2 = 35667,
  75761. INT_VEC3 = 35668,
  75762. INT_VEC4 = 35669,
  75763. BOOL = 35670,
  75764. BOOL_VEC2 = 35671,
  75765. BOOL_VEC3 = 35672,
  75766. BOOL_VEC4 = 35673,
  75767. FLOAT_MAT2 = 35674,
  75768. FLOAT_MAT3 = 35675,
  75769. FLOAT_MAT4 = 35676,
  75770. SAMPLER_2D = 35678
  75771. }
  75772. /** @hidden */
  75773. export enum ETextureWrapMode {
  75774. CLAMP_TO_EDGE = 33071,
  75775. MIRRORED_REPEAT = 33648,
  75776. REPEAT = 10497
  75777. }
  75778. /** @hidden */
  75779. export enum ETextureFilterType {
  75780. NEAREST = 9728,
  75781. LINEAR = 9728,
  75782. NEAREST_MIPMAP_NEAREST = 9984,
  75783. LINEAR_MIPMAP_NEAREST = 9985,
  75784. NEAREST_MIPMAP_LINEAR = 9986,
  75785. LINEAR_MIPMAP_LINEAR = 9987
  75786. }
  75787. /** @hidden */
  75788. export enum ETextureFormat {
  75789. ALPHA = 6406,
  75790. RGB = 6407,
  75791. RGBA = 6408,
  75792. LUMINANCE = 6409,
  75793. LUMINANCE_ALPHA = 6410
  75794. }
  75795. /** @hidden */
  75796. export enum ECullingType {
  75797. FRONT = 1028,
  75798. BACK = 1029,
  75799. FRONT_AND_BACK = 1032
  75800. }
  75801. /** @hidden */
  75802. export enum EBlendingFunction {
  75803. ZERO = 0,
  75804. ONE = 1,
  75805. SRC_COLOR = 768,
  75806. ONE_MINUS_SRC_COLOR = 769,
  75807. DST_COLOR = 774,
  75808. ONE_MINUS_DST_COLOR = 775,
  75809. SRC_ALPHA = 770,
  75810. ONE_MINUS_SRC_ALPHA = 771,
  75811. DST_ALPHA = 772,
  75812. ONE_MINUS_DST_ALPHA = 773,
  75813. CONSTANT_COLOR = 32769,
  75814. ONE_MINUS_CONSTANT_COLOR = 32770,
  75815. CONSTANT_ALPHA = 32771,
  75816. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75817. SRC_ALPHA_SATURATE = 776
  75818. }
  75819. /** @hidden */
  75820. export interface IGLTFProperty {
  75821. extensions?: {
  75822. [key: string]: any;
  75823. };
  75824. extras?: Object;
  75825. }
  75826. /** @hidden */
  75827. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75828. name?: string;
  75829. }
  75830. /** @hidden */
  75831. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75832. bufferView: string;
  75833. byteOffset: number;
  75834. byteStride: number;
  75835. count: number;
  75836. type: string;
  75837. componentType: EComponentType;
  75838. max?: number[];
  75839. min?: number[];
  75840. name?: string;
  75841. }
  75842. /** @hidden */
  75843. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75844. buffer: string;
  75845. byteOffset: number;
  75846. byteLength: number;
  75847. byteStride: number;
  75848. target?: number;
  75849. }
  75850. /** @hidden */
  75851. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75852. uri: string;
  75853. byteLength?: number;
  75854. type?: string;
  75855. }
  75856. /** @hidden */
  75857. export interface IGLTFShader extends IGLTFChildRootProperty {
  75858. uri: string;
  75859. type: EShaderType;
  75860. }
  75861. /** @hidden */
  75862. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75863. attributes: string[];
  75864. fragmentShader: string;
  75865. vertexShader: string;
  75866. }
  75867. /** @hidden */
  75868. export interface IGLTFTechniqueParameter {
  75869. type: number;
  75870. count?: number;
  75871. semantic?: string;
  75872. node?: string;
  75873. value?: number | boolean | string | Array<any>;
  75874. source?: string;
  75875. babylonValue?: any;
  75876. }
  75877. /** @hidden */
  75878. export interface IGLTFTechniqueCommonProfile {
  75879. lightingModel: string;
  75880. texcoordBindings: Object;
  75881. parameters?: Array<any>;
  75882. }
  75883. /** @hidden */
  75884. export interface IGLTFTechniqueStatesFunctions {
  75885. blendColor?: number[];
  75886. blendEquationSeparate?: number[];
  75887. blendFuncSeparate?: number[];
  75888. colorMask: boolean[];
  75889. cullFace: number[];
  75890. }
  75891. /** @hidden */
  75892. export interface IGLTFTechniqueStates {
  75893. enable: number[];
  75894. functions: IGLTFTechniqueStatesFunctions;
  75895. }
  75896. /** @hidden */
  75897. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75898. parameters: {
  75899. [key: string]: IGLTFTechniqueParameter;
  75900. };
  75901. program: string;
  75902. attributes: {
  75903. [key: string]: string;
  75904. };
  75905. uniforms: {
  75906. [key: string]: string;
  75907. };
  75908. states: IGLTFTechniqueStates;
  75909. }
  75910. /** @hidden */
  75911. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75912. technique?: string;
  75913. values: string[];
  75914. }
  75915. /** @hidden */
  75916. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75917. attributes: {
  75918. [key: string]: string;
  75919. };
  75920. indices: string;
  75921. material: string;
  75922. mode?: number;
  75923. }
  75924. /** @hidden */
  75925. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75926. primitives: IGLTFMeshPrimitive[];
  75927. }
  75928. /** @hidden */
  75929. export interface IGLTFImage extends IGLTFChildRootProperty {
  75930. uri: string;
  75931. }
  75932. /** @hidden */
  75933. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75934. magFilter?: number;
  75935. minFilter?: number;
  75936. wrapS?: number;
  75937. wrapT?: number;
  75938. }
  75939. /** @hidden */
  75940. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75941. sampler: string;
  75942. source: string;
  75943. format?: ETextureFormat;
  75944. internalFormat?: ETextureFormat;
  75945. target?: number;
  75946. type?: number;
  75947. babylonTexture?: Texture;
  75948. }
  75949. /** @hidden */
  75950. export interface IGLTFAmbienLight {
  75951. color?: number[];
  75952. }
  75953. /** @hidden */
  75954. export interface IGLTFDirectionalLight {
  75955. color?: number[];
  75956. }
  75957. /** @hidden */
  75958. export interface IGLTFPointLight {
  75959. color?: number[];
  75960. constantAttenuation?: number;
  75961. linearAttenuation?: number;
  75962. quadraticAttenuation?: number;
  75963. }
  75964. /** @hidden */
  75965. export interface IGLTFSpotLight {
  75966. color?: number[];
  75967. constantAttenuation?: number;
  75968. fallOfAngle?: number;
  75969. fallOffExponent?: number;
  75970. linearAttenuation?: number;
  75971. quadraticAttenuation?: number;
  75972. }
  75973. /** @hidden */
  75974. export interface IGLTFLight extends IGLTFChildRootProperty {
  75975. type: string;
  75976. }
  75977. /** @hidden */
  75978. export interface IGLTFCameraOrthographic {
  75979. xmag: number;
  75980. ymag: number;
  75981. zfar: number;
  75982. znear: number;
  75983. }
  75984. /** @hidden */
  75985. export interface IGLTFCameraPerspective {
  75986. aspectRatio: number;
  75987. yfov: number;
  75988. zfar: number;
  75989. znear: number;
  75990. }
  75991. /** @hidden */
  75992. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75993. type: string;
  75994. }
  75995. /** @hidden */
  75996. export interface IGLTFAnimationChannelTarget {
  75997. id: string;
  75998. path: string;
  75999. }
  76000. /** @hidden */
  76001. export interface IGLTFAnimationChannel {
  76002. sampler: string;
  76003. target: IGLTFAnimationChannelTarget;
  76004. }
  76005. /** @hidden */
  76006. export interface IGLTFAnimationSampler {
  76007. input: string;
  76008. output: string;
  76009. interpolation?: string;
  76010. }
  76011. /** @hidden */
  76012. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  76013. channels?: IGLTFAnimationChannel[];
  76014. parameters?: {
  76015. [key: string]: string;
  76016. };
  76017. samplers?: {
  76018. [key: string]: IGLTFAnimationSampler;
  76019. };
  76020. }
  76021. /** @hidden */
  76022. export interface IGLTFNodeInstanceSkin {
  76023. skeletons: string[];
  76024. skin: string;
  76025. meshes: string[];
  76026. }
  76027. /** @hidden */
  76028. export interface IGLTFSkins extends IGLTFChildRootProperty {
  76029. bindShapeMatrix: number[];
  76030. inverseBindMatrices: string;
  76031. jointNames: string[];
  76032. babylonSkeleton?: Skeleton;
  76033. }
  76034. /** @hidden */
  76035. export interface IGLTFNode extends IGLTFChildRootProperty {
  76036. camera?: string;
  76037. children: string[];
  76038. skin?: string;
  76039. jointName?: string;
  76040. light?: string;
  76041. matrix: number[];
  76042. mesh?: string;
  76043. meshes?: string[];
  76044. rotation?: number[];
  76045. scale?: number[];
  76046. translation?: number[];
  76047. babylonNode?: Node;
  76048. }
  76049. /** @hidden */
  76050. export interface IGLTFScene extends IGLTFChildRootProperty {
  76051. nodes: string[];
  76052. }
  76053. /** @hidden */
  76054. export interface IGLTFRuntime {
  76055. extensions: {
  76056. [key: string]: any;
  76057. };
  76058. accessors: {
  76059. [key: string]: IGLTFAccessor;
  76060. };
  76061. buffers: {
  76062. [key: string]: IGLTFBuffer;
  76063. };
  76064. bufferViews: {
  76065. [key: string]: IGLTFBufferView;
  76066. };
  76067. meshes: {
  76068. [key: string]: IGLTFMesh;
  76069. };
  76070. lights: {
  76071. [key: string]: IGLTFLight;
  76072. };
  76073. cameras: {
  76074. [key: string]: IGLTFCamera;
  76075. };
  76076. nodes: {
  76077. [key: string]: IGLTFNode;
  76078. };
  76079. images: {
  76080. [key: string]: IGLTFImage;
  76081. };
  76082. textures: {
  76083. [key: string]: IGLTFTexture;
  76084. };
  76085. shaders: {
  76086. [key: string]: IGLTFShader;
  76087. };
  76088. programs: {
  76089. [key: string]: IGLTFProgram;
  76090. };
  76091. samplers: {
  76092. [key: string]: IGLTFSampler;
  76093. };
  76094. techniques: {
  76095. [key: string]: IGLTFTechnique;
  76096. };
  76097. materials: {
  76098. [key: string]: IGLTFMaterial;
  76099. };
  76100. animations: {
  76101. [key: string]: IGLTFAnimation;
  76102. };
  76103. skins: {
  76104. [key: string]: IGLTFSkins;
  76105. };
  76106. currentScene?: Object;
  76107. scenes: {
  76108. [key: string]: IGLTFScene;
  76109. };
  76110. extensionsUsed: string[];
  76111. extensionsRequired?: string[];
  76112. buffersCount: number;
  76113. shaderscount: number;
  76114. scene: Scene;
  76115. rootUrl: string;
  76116. loadedBufferCount: number;
  76117. loadedBufferViews: {
  76118. [name: string]: ArrayBufferView;
  76119. };
  76120. loadedShaderCount: number;
  76121. importOnlyMeshes: boolean;
  76122. importMeshesNames?: string[];
  76123. dummyNodes: Node[];
  76124. forAssetContainer: boolean;
  76125. }
  76126. /** @hidden */
  76127. export interface INodeToRoot {
  76128. bone: Bone;
  76129. node: IGLTFNode;
  76130. id: string;
  76131. }
  76132. /** @hidden */
  76133. export interface IJointNode {
  76134. node: IGLTFNode;
  76135. id: string;
  76136. }
  76137. }
  76138. declare module BABYLON.GLTF1 {
  76139. /**
  76140. * Utils functions for GLTF
  76141. * @hidden
  76142. */
  76143. export class GLTFUtils {
  76144. /**
  76145. * Sets the given "parameter" matrix
  76146. * @param scene: the Scene object
  76147. * @param source: the source node where to pick the matrix
  76148. * @param parameter: the GLTF technique parameter
  76149. * @param uniformName: the name of the shader's uniform
  76150. * @param shaderMaterial: the shader material
  76151. */
  76152. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  76153. /**
  76154. * Sets the given "parameter" matrix
  76155. * @param shaderMaterial: the shader material
  76156. * @param uniform: the name of the shader's uniform
  76157. * @param value: the value of the uniform
  76158. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  76159. */
  76160. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  76161. /**
  76162. * Returns the wrap mode of the texture
  76163. * @param mode: the mode value
  76164. */
  76165. static GetWrapMode(mode: number): number;
  76166. /**
  76167. * Returns the byte stride giving an accessor
  76168. * @param accessor: the GLTF accessor objet
  76169. */
  76170. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  76171. /**
  76172. * Returns the texture filter mode giving a mode value
  76173. * @param mode: the filter mode value
  76174. */
  76175. static GetTextureFilterMode(mode: number): ETextureFilterType;
  76176. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  76177. /**
  76178. * Returns a buffer from its accessor
  76179. * @param gltfRuntime: the GLTF runtime
  76180. * @param accessor: the GLTF accessor
  76181. */
  76182. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  76183. /**
  76184. * Decodes a buffer view into a string
  76185. * @param view: the buffer view
  76186. */
  76187. static DecodeBufferToText(view: ArrayBufferView): string;
  76188. /**
  76189. * Returns the default material of gltf. Related to
  76190. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  76191. * @param scene: the Babylon.js scene
  76192. */
  76193. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  76194. private static _DefaultMaterial;
  76195. }
  76196. }
  76197. declare module BABYLON.GLTF1 {
  76198. /**
  76199. * Implementation of the base glTF spec
  76200. * @hidden
  76201. */
  76202. export class GLTFLoaderBase {
  76203. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  76204. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76205. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  76206. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76207. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  76208. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76209. }
  76210. /**
  76211. * glTF V1 Loader
  76212. * @hidden
  76213. */
  76214. export class GLTFLoader implements IGLTFLoader {
  76215. static Extensions: {
  76216. [name: string]: GLTFLoaderExtension;
  76217. };
  76218. static RegisterExtension(extension: GLTFLoaderExtension): void;
  76219. state: Nullable<GLTFLoaderState>;
  76220. dispose(): void;
  76221. private _importMeshAsync;
  76222. /**
  76223. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  76224. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76225. * @param scene the scene the meshes should be added to
  76226. * @param forAssetContainer defines if the entities must be stored in the scene
  76227. * @param data gltf data containing information of the meshes in a loaded file
  76228. * @param rootUrl root url to load from
  76229. * @param onProgress event that fires when loading progress has occured
  76230. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76231. */
  76232. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  76233. private _loadAsync;
  76234. /**
  76235. * Imports all objects from a loaded gltf file and adds them to the scene
  76236. * @param scene the scene the objects should be added to
  76237. * @param data gltf data containing information of the meshes in a loaded file
  76238. * @param rootUrl root url to load from
  76239. * @param onProgress event that fires when loading progress has occured
  76240. * @returns a promise which completes when objects have been loaded to the scene
  76241. */
  76242. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  76243. private _loadShadersAsync;
  76244. private _loadBuffersAsync;
  76245. private _createNodes;
  76246. }
  76247. /** @hidden */
  76248. export abstract class GLTFLoaderExtension {
  76249. private _name;
  76250. constructor(name: string);
  76251. get name(): string;
  76252. /**
  76253. * Defines an override for loading the runtime
  76254. * Return true to stop further extensions from loading the runtime
  76255. */
  76256. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76257. /**
  76258. * Defines an onverride for creating gltf runtime
  76259. * Return true to stop further extensions from creating the runtime
  76260. */
  76261. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76262. /**
  76263. * Defines an override for loading buffers
  76264. * Return true to stop further extensions from loading this buffer
  76265. */
  76266. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76267. /**
  76268. * Defines an override for loading texture buffers
  76269. * Return true to stop further extensions from loading this texture data
  76270. */
  76271. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76272. /**
  76273. * Defines an override for creating textures
  76274. * Return true to stop further extensions from loading this texture
  76275. */
  76276. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76277. /**
  76278. * Defines an override for loading shader strings
  76279. * Return true to stop further extensions from loading this shader data
  76280. */
  76281. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76282. /**
  76283. * Defines an override for loading materials
  76284. * Return true to stop further extensions from loading this material
  76285. */
  76286. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76287. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76288. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76289. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76290. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76291. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76292. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76293. private static LoadTextureBufferAsync;
  76294. private static CreateTextureAsync;
  76295. private static ApplyExtensions;
  76296. }
  76297. }
  76298. declare module BABYLON.GLTF1 {
  76299. /** @hidden */
  76300. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76301. private _bin;
  76302. constructor();
  76303. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76304. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76305. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76306. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76307. }
  76308. }
  76309. declare module BABYLON.GLTF1 {
  76310. /** @hidden */
  76311. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76312. constructor();
  76313. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76314. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76315. private _loadTexture;
  76316. }
  76317. }
  76318. declare module BABYLON.GLTF2.Loader {
  76319. /**
  76320. * Loader interface with an index field.
  76321. */
  76322. export interface IArrayItem {
  76323. /**
  76324. * The index of this item in the array.
  76325. */
  76326. index: number;
  76327. }
  76328. /**
  76329. * Loader interface with additional members.
  76330. */
  76331. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76332. /** @hidden */
  76333. _data?: Promise<ArrayBufferView>;
  76334. /** @hidden */
  76335. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76336. }
  76337. /**
  76338. * Loader interface with additional members.
  76339. */
  76340. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76341. }
  76342. /** @hidden */
  76343. export interface _IAnimationSamplerData {
  76344. input: Float32Array;
  76345. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76346. output: Float32Array;
  76347. }
  76348. /**
  76349. * Loader interface with additional members.
  76350. */
  76351. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76352. /** @hidden */
  76353. _data?: Promise<_IAnimationSamplerData>;
  76354. }
  76355. /**
  76356. * Loader interface with additional members.
  76357. */
  76358. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76359. channels: IAnimationChannel[];
  76360. samplers: IAnimationSampler[];
  76361. /** @hidden */
  76362. _babylonAnimationGroup?: AnimationGroup;
  76363. }
  76364. /**
  76365. * Loader interface with additional members.
  76366. */
  76367. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76368. /** @hidden */
  76369. _data?: Promise<ArrayBufferView>;
  76370. }
  76371. /**
  76372. * Loader interface with additional members.
  76373. */
  76374. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76375. /** @hidden */
  76376. _data?: Promise<ArrayBufferView>;
  76377. /** @hidden */
  76378. _babylonBuffer?: Promise<Buffer>;
  76379. }
  76380. /**
  76381. * Loader interface with additional members.
  76382. */
  76383. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76384. }
  76385. /**
  76386. * Loader interface with additional members.
  76387. */
  76388. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76389. /** @hidden */
  76390. _data?: Promise<ArrayBufferView>;
  76391. }
  76392. /**
  76393. * Loader interface with additional members.
  76394. */
  76395. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76396. }
  76397. /**
  76398. * Loader interface with additional members.
  76399. */
  76400. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76401. }
  76402. /**
  76403. * Loader interface with additional members.
  76404. */
  76405. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76406. baseColorTexture?: ITextureInfo;
  76407. metallicRoughnessTexture?: ITextureInfo;
  76408. }
  76409. /**
  76410. * Loader interface with additional members.
  76411. */
  76412. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76413. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76414. normalTexture?: IMaterialNormalTextureInfo;
  76415. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76416. emissiveTexture?: ITextureInfo;
  76417. /** @hidden */
  76418. _data?: {
  76419. [babylonDrawMode: number]: {
  76420. babylonMaterial: Material;
  76421. babylonMeshes: AbstractMesh[];
  76422. promise: Promise<void>;
  76423. };
  76424. };
  76425. }
  76426. /**
  76427. * Loader interface with additional members.
  76428. */
  76429. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76430. primitives: IMeshPrimitive[];
  76431. }
  76432. /**
  76433. * Loader interface with additional members.
  76434. */
  76435. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76436. /** @hidden */
  76437. _instanceData?: {
  76438. babylonSourceMesh: Mesh;
  76439. promise: Promise<any>;
  76440. };
  76441. }
  76442. /**
  76443. * Loader interface with additional members.
  76444. */
  76445. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76446. /**
  76447. * The parent glTF node.
  76448. */
  76449. parent?: INode;
  76450. /** @hidden */
  76451. _babylonTransformNode?: TransformNode;
  76452. /** @hidden */
  76453. _primitiveBabylonMeshes?: AbstractMesh[];
  76454. /** @hidden */
  76455. _babylonBones?: Bone[];
  76456. /** @hidden */
  76457. _numMorphTargets?: number;
  76458. }
  76459. /** @hidden */
  76460. export interface _ISamplerData {
  76461. noMipMaps: boolean;
  76462. samplingMode: number;
  76463. wrapU: number;
  76464. wrapV: number;
  76465. }
  76466. /**
  76467. * Loader interface with additional members.
  76468. */
  76469. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76470. /** @hidden */
  76471. _data?: _ISamplerData;
  76472. }
  76473. /**
  76474. * Loader interface with additional members.
  76475. */
  76476. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76477. }
  76478. /**
  76479. * Loader interface with additional members.
  76480. */
  76481. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76482. /** @hidden */
  76483. _data?: {
  76484. babylonSkeleton: Skeleton;
  76485. promise: Promise<void>;
  76486. };
  76487. }
  76488. /**
  76489. * Loader interface with additional members.
  76490. */
  76491. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76492. }
  76493. /**
  76494. * Loader interface with additional members.
  76495. */
  76496. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76497. }
  76498. /**
  76499. * Loader interface with additional members.
  76500. */
  76501. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76502. accessors?: IAccessor[];
  76503. animations?: IAnimation[];
  76504. buffers?: IBuffer[];
  76505. bufferViews?: IBufferView[];
  76506. cameras?: ICamera[];
  76507. images?: IImage[];
  76508. materials?: IMaterial[];
  76509. meshes?: IMesh[];
  76510. nodes?: INode[];
  76511. samplers?: ISampler[];
  76512. scenes?: IScene[];
  76513. skins?: ISkin[];
  76514. textures?: ITexture[];
  76515. }
  76516. }
  76517. declare module BABYLON.GLTF2 {
  76518. /**
  76519. * Interface for a glTF loader extension.
  76520. */
  76521. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76522. /**
  76523. * Called after the loader state changes to LOADING.
  76524. */
  76525. onLoading?(): void;
  76526. /**
  76527. * Called after the loader state changes to READY.
  76528. */
  76529. onReady?(): void;
  76530. /**
  76531. * Define this method to modify the default behavior when loading scenes.
  76532. * @param context The context when loading the asset
  76533. * @param scene The glTF scene property
  76534. * @returns A promise that resolves when the load is complete or null if not handled
  76535. */
  76536. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76537. /**
  76538. * Define this method to modify the default behavior when loading nodes.
  76539. * @param context The context when loading the asset
  76540. * @param node The glTF node property
  76541. * @param assign A function called synchronously after parsing the glTF properties
  76542. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76543. */
  76544. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76545. /**
  76546. * Define this method to modify the default behavior when loading cameras.
  76547. * @param context The context when loading the asset
  76548. * @param camera The glTF camera property
  76549. * @param assign A function called synchronously after parsing the glTF properties
  76550. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76551. */
  76552. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76553. /**
  76554. * @hidden
  76555. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76556. * @param context The context when loading the asset
  76557. * @param primitive The glTF mesh primitive property
  76558. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76559. */
  76560. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76561. /**
  76562. * @hidden
  76563. * Define this method to modify the default behavior when loading data for mesh primitives.
  76564. * @param context The context when loading the asset
  76565. * @param name The mesh name when loading the asset
  76566. * @param node The glTF node when loading the asset
  76567. * @param mesh The glTF mesh when loading the asset
  76568. * @param primitive The glTF mesh primitive property
  76569. * @param assign A function called synchronously after parsing the glTF properties
  76570. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76571. */
  76572. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76573. /**
  76574. * @hidden
  76575. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76576. * @param context The context when loading the asset
  76577. * @param material The glTF material property
  76578. * @param assign A function called synchronously after parsing the glTF properties
  76579. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76580. */
  76581. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76582. /**
  76583. * Define this method to modify the default behavior when creating materials.
  76584. * @param context The context when loading the asset
  76585. * @param material The glTF material property
  76586. * @param babylonDrawMode The draw mode for the Babylon material
  76587. * @returns The Babylon material or null if not handled
  76588. */
  76589. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76590. /**
  76591. * Define this method to modify the default behavior when loading material properties.
  76592. * @param context The context when loading the asset
  76593. * @param material The glTF material property
  76594. * @param babylonMaterial The Babylon material
  76595. * @returns A promise that resolves when the load is complete or null if not handled
  76596. */
  76597. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76598. /**
  76599. * Define this method to modify the default behavior when loading texture infos.
  76600. * @param context The context when loading the asset
  76601. * @param textureInfo The glTF texture info property
  76602. * @param assign A function called synchronously after parsing the glTF properties
  76603. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76604. */
  76605. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76606. /**
  76607. * @hidden
  76608. * Define this method to modify the default behavior when loading textures.
  76609. * @param context The context when loading the asset
  76610. * @param texture The glTF texture property
  76611. * @param assign A function called synchronously after parsing the glTF properties
  76612. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76613. */
  76614. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76615. /**
  76616. * Define this method to modify the default behavior when loading animations.
  76617. * @param context The context when loading the asset
  76618. * @param animation The glTF animation property
  76619. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76620. */
  76621. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76622. /**
  76623. * @hidden
  76624. * Define this method to modify the default behavior when loading skins.
  76625. * @param context The context when loading the asset
  76626. * @param node The glTF node property
  76627. * @param skin The glTF skin property
  76628. * @returns A promise that resolves when the load is complete or null if not handled
  76629. */
  76630. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76631. /**
  76632. * @hidden
  76633. * Define this method to modify the default behavior when loading uris.
  76634. * @param context The context when loading the asset
  76635. * @param property The glTF property associated with the uri
  76636. * @param uri The uri to load
  76637. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76638. */
  76639. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76640. /**
  76641. * Define this method to modify the default behavior when loading buffer views.
  76642. * @param context The context when loading the asset
  76643. * @param bufferView The glTF buffer view property
  76644. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76645. */
  76646. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76647. /**
  76648. * Define this method to modify the default behavior when loading buffers.
  76649. * @param context The context when loading the asset
  76650. * @param buffer The glTF buffer property
  76651. * @param byteOffset The byte offset to load
  76652. * @param byteLength The byte length to load
  76653. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76654. */
  76655. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76656. }
  76657. }
  76658. declare module BABYLON.GLTF2 {
  76659. /**
  76660. * Helper class for working with arrays when loading the glTF asset
  76661. */
  76662. export class ArrayItem {
  76663. /**
  76664. * Gets an item from the given array.
  76665. * @param context The context when loading the asset
  76666. * @param array The array to get the item from
  76667. * @param index The index to the array
  76668. * @returns The array item
  76669. */
  76670. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76671. /**
  76672. * Assign an `index` field to each item of the given array.
  76673. * @param array The array of items
  76674. */
  76675. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76676. }
  76677. /**
  76678. * The glTF 2.0 loader
  76679. */
  76680. export class GLTFLoader implements IGLTFLoader {
  76681. /** @hidden */
  76682. _completePromises: Promise<any>[];
  76683. /** @hidden */
  76684. _forAssetContainer: boolean;
  76685. /** Storage */
  76686. _babylonLights: Light[];
  76687. private _disposed;
  76688. private _parent;
  76689. private _state;
  76690. private _extensions;
  76691. private _rootUrl;
  76692. private _fileName;
  76693. private _uniqueRootUrl;
  76694. private _gltf;
  76695. private _bin;
  76696. private _babylonScene;
  76697. private _rootBabylonMesh;
  76698. private _defaultBabylonMaterialData;
  76699. private _progressCallback?;
  76700. private _requests;
  76701. private static _RegisteredExtensions;
  76702. /**
  76703. * The default glTF sampler.
  76704. */
  76705. static readonly DefaultSampler: ISampler;
  76706. /**
  76707. * Registers a loader extension.
  76708. * @param name The name of the loader extension.
  76709. * @param factory The factory function that creates the loader extension.
  76710. */
  76711. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76712. /**
  76713. * Unregisters a loader extension.
  76714. * @param name The name of the loader extension.
  76715. * @returns A boolean indicating whether the extension has been unregistered
  76716. */
  76717. static UnregisterExtension(name: string): boolean;
  76718. /**
  76719. * The loader state.
  76720. */
  76721. get state(): Nullable<GLTFLoaderState>;
  76722. /**
  76723. * The object that represents the glTF JSON.
  76724. */
  76725. get gltf(): IGLTF;
  76726. /**
  76727. * The BIN chunk of a binary glTF.
  76728. */
  76729. get bin(): Nullable<IDataBuffer>;
  76730. /**
  76731. * The parent file loader.
  76732. */
  76733. get parent(): GLTFFileLoader;
  76734. /**
  76735. * The Babylon scene when loading the asset.
  76736. */
  76737. get babylonScene(): Scene;
  76738. /**
  76739. * The root Babylon mesh when loading the asset.
  76740. */
  76741. get rootBabylonMesh(): Mesh;
  76742. /** @hidden */
  76743. constructor(parent: GLTFFileLoader);
  76744. /** @hidden */
  76745. dispose(): void;
  76746. /** @hidden */
  76747. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76748. /** @hidden */
  76749. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76750. private _loadAsync;
  76751. private _loadData;
  76752. private _setupData;
  76753. private _loadExtensions;
  76754. private _checkExtensions;
  76755. private _setState;
  76756. private _createRootNode;
  76757. /**
  76758. * Loads a glTF scene.
  76759. * @param context The context when loading the asset
  76760. * @param scene The glTF scene property
  76761. * @returns A promise that resolves when the load is complete
  76762. */
  76763. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76764. private _forEachPrimitive;
  76765. private _getMeshes;
  76766. private _getTransformNodes;
  76767. private _getSkeletons;
  76768. private _getAnimationGroups;
  76769. private _startAnimations;
  76770. /**
  76771. * Loads a glTF node.
  76772. * @param context The context when loading the asset
  76773. * @param node The glTF node property
  76774. * @param assign A function called synchronously after parsing the glTF properties
  76775. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76776. */
  76777. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76778. private _loadMeshAsync;
  76779. /**
  76780. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76781. * @param context The context when loading the asset
  76782. * @param name The mesh name when loading the asset
  76783. * @param node The glTF node when loading the asset
  76784. * @param mesh The glTF mesh when loading the asset
  76785. * @param primitive The glTF mesh primitive property
  76786. * @param assign A function called synchronously after parsing the glTF properties
  76787. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76788. */
  76789. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76790. private _loadVertexDataAsync;
  76791. private _createMorphTargets;
  76792. private _loadMorphTargetsAsync;
  76793. private _loadMorphTargetVertexDataAsync;
  76794. private static _LoadTransform;
  76795. private _loadSkinAsync;
  76796. private _loadBones;
  76797. private _loadBone;
  76798. private _loadSkinInverseBindMatricesDataAsync;
  76799. private _updateBoneMatrices;
  76800. private _getNodeMatrix;
  76801. /**
  76802. * Loads a glTF camera.
  76803. * @param context The context when loading the asset
  76804. * @param camera The glTF camera property
  76805. * @param assign A function called synchronously after parsing the glTF properties
  76806. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76807. */
  76808. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76809. private _loadAnimationsAsync;
  76810. /**
  76811. * Loads a glTF animation.
  76812. * @param context The context when loading the asset
  76813. * @param animation The glTF animation property
  76814. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76815. */
  76816. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76817. /**
  76818. * @hidden Loads a glTF animation channel.
  76819. * @param context The context when loading the asset
  76820. * @param animationContext The context of the animation when loading the asset
  76821. * @param animation The glTF animation property
  76822. * @param channel The glTF animation channel property
  76823. * @param babylonAnimationGroup The babylon animation group property
  76824. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76825. * @returns A void promise when the channel load is complete
  76826. */
  76827. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76828. private _loadAnimationSamplerAsync;
  76829. private _loadBufferAsync;
  76830. /**
  76831. * Loads a glTF buffer view.
  76832. * @param context The context when loading the asset
  76833. * @param bufferView The glTF buffer view property
  76834. * @returns A promise that resolves with the loaded data when the load is complete
  76835. */
  76836. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76837. private _loadAccessorAsync;
  76838. /** @hidden */
  76839. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76840. private _loadIndicesAccessorAsync;
  76841. private _loadVertexBufferViewAsync;
  76842. private _loadVertexAccessorAsync;
  76843. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76844. /** @hidden */
  76845. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76846. private _createDefaultMaterial;
  76847. /**
  76848. * Creates a Babylon material from a glTF material.
  76849. * @param context The context when loading the asset
  76850. * @param material The glTF material property
  76851. * @param babylonDrawMode The draw mode for the Babylon material
  76852. * @returns The Babylon material
  76853. */
  76854. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76855. /**
  76856. * Loads properties from a glTF material into a Babylon material.
  76857. * @param context The context when loading the asset
  76858. * @param material The glTF material property
  76859. * @param babylonMaterial The Babylon material
  76860. * @returns A promise that resolves when the load is complete
  76861. */
  76862. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76863. /**
  76864. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76865. * @param context The context when loading the asset
  76866. * @param material The glTF material property
  76867. * @param babylonMaterial The Babylon material
  76868. * @returns A promise that resolves when the load is complete
  76869. */
  76870. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76871. /**
  76872. * Loads the alpha properties from a glTF material into a Babylon material.
  76873. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76874. * @param context The context when loading the asset
  76875. * @param material The glTF material property
  76876. * @param babylonMaterial The Babylon material
  76877. */
  76878. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76879. /**
  76880. * Loads a glTF texture info.
  76881. * @param context The context when loading the asset
  76882. * @param textureInfo The glTF texture info property
  76883. * @param assign A function called synchronously after parsing the glTF properties
  76884. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76885. */
  76886. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76887. /** @hidden */
  76888. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76889. /** @hidden */
  76890. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76891. private _loadSampler;
  76892. /**
  76893. * Loads a glTF image.
  76894. * @param context The context when loading the asset
  76895. * @param image The glTF image property
  76896. * @returns A promise that resolves with the loaded data when the load is complete
  76897. */
  76898. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76899. /**
  76900. * Loads a glTF uri.
  76901. * @param context The context when loading the asset
  76902. * @param property The glTF property associated with the uri
  76903. * @param uri The base64 or relative uri
  76904. * @returns A promise that resolves with the loaded data when the load is complete
  76905. */
  76906. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76907. private _onProgress;
  76908. /**
  76909. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76910. * @param babylonObject the Babylon object with metadata
  76911. * @param pointer the JSON pointer
  76912. */
  76913. static AddPointerMetadata(babylonObject: {
  76914. metadata: any;
  76915. }, pointer: string): void;
  76916. private static _GetTextureWrapMode;
  76917. private static _GetTextureSamplingMode;
  76918. private static _GetTypedArrayConstructor;
  76919. private static _GetTypedArray;
  76920. private static _GetNumComponents;
  76921. private static _ValidateUri;
  76922. private static _GetDrawMode;
  76923. private _compileMaterialsAsync;
  76924. private _compileShadowGeneratorsAsync;
  76925. private _forEachExtensions;
  76926. private _applyExtensions;
  76927. private _extensionsOnLoading;
  76928. private _extensionsOnReady;
  76929. private _extensionsLoadSceneAsync;
  76930. private _extensionsLoadNodeAsync;
  76931. private _extensionsLoadCameraAsync;
  76932. private _extensionsLoadVertexDataAsync;
  76933. private _extensionsLoadMeshPrimitiveAsync;
  76934. private _extensionsLoadMaterialAsync;
  76935. private _extensionsCreateMaterial;
  76936. private _extensionsLoadMaterialPropertiesAsync;
  76937. private _extensionsLoadTextureInfoAsync;
  76938. private _extensionsLoadTextureAsync;
  76939. private _extensionsLoadAnimationAsync;
  76940. private _extensionsLoadSkinAsync;
  76941. private _extensionsLoadUriAsync;
  76942. private _extensionsLoadBufferViewAsync;
  76943. private _extensionsLoadBufferAsync;
  76944. /**
  76945. * Helper method called by a loader extension to load an glTF extension.
  76946. * @param context The context when loading the asset
  76947. * @param property The glTF property to load the extension from
  76948. * @param extensionName The name of the extension to load
  76949. * @param actionAsync The action to run
  76950. * @returns The promise returned by actionAsync or null if the extension does not exist
  76951. */
  76952. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76953. /**
  76954. * Helper method called by a loader extension to load a glTF extra.
  76955. * @param context The context when loading the asset
  76956. * @param property The glTF property to load the extra from
  76957. * @param extensionName The name of the extension to load
  76958. * @param actionAsync The action to run
  76959. * @returns The promise returned by actionAsync or null if the extra does not exist
  76960. */
  76961. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76962. /**
  76963. * Checks for presence of an extension.
  76964. * @param name The name of the extension to check
  76965. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76966. */
  76967. isExtensionUsed(name: string): boolean;
  76968. /**
  76969. * Increments the indentation level and logs a message.
  76970. * @param message The message to log
  76971. */
  76972. logOpen(message: string): void;
  76973. /**
  76974. * Decrements the indentation level.
  76975. */
  76976. logClose(): void;
  76977. /**
  76978. * Logs a message
  76979. * @param message The message to log
  76980. */
  76981. log(message: string): void;
  76982. /**
  76983. * Starts a performance counter.
  76984. * @param counterName The name of the performance counter
  76985. */
  76986. startPerformanceCounter(counterName: string): void;
  76987. /**
  76988. * Ends a performance counter.
  76989. * @param counterName The name of the performance counter
  76990. */
  76991. endPerformanceCounter(counterName: string): void;
  76992. }
  76993. }
  76994. declare module BABYLON.GLTF2.Loader.Extensions {
  76995. /**
  76996. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76997. */
  76998. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76999. /**
  77000. * The name of this extension.
  77001. */
  77002. readonly name: string;
  77003. /**
  77004. * Defines whether this extension is enabled.
  77005. */
  77006. enabled: boolean;
  77007. private _loader;
  77008. private _lights?;
  77009. /** @hidden */
  77010. constructor(loader: GLTFLoader);
  77011. /** @hidden */
  77012. dispose(): void;
  77013. /** @hidden */
  77014. onLoading(): void;
  77015. /** @hidden */
  77016. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77017. private _loadLightAsync;
  77018. }
  77019. }
  77020. declare module BABYLON.GLTF2.Loader.Extensions {
  77021. /**
  77022. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  77023. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  77024. * !!! Experimental Extension Subject to Changes !!!
  77025. */
  77026. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  77027. /**
  77028. * The name of this extension.
  77029. */
  77030. readonly name: string;
  77031. /**
  77032. * Defines whether this extension is enabled.
  77033. */
  77034. enabled: boolean;
  77035. private _loader;
  77036. /** @hidden */
  77037. constructor(loader: GLTFLoader);
  77038. /** @hidden */
  77039. dispose(): void;
  77040. /** @hidden */
  77041. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77042. }
  77043. }
  77044. declare module BABYLON.GLTF2.Loader.Extensions {
  77045. /**
  77046. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  77047. */
  77048. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  77049. /**
  77050. * The name of this extension.
  77051. */
  77052. readonly name: string;
  77053. /**
  77054. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  77055. */
  77056. dracoCompression?: DracoCompression;
  77057. /**
  77058. * Defines whether this extension is enabled.
  77059. */
  77060. enabled: boolean;
  77061. private _loader;
  77062. /** @hidden */
  77063. constructor(loader: GLTFLoader);
  77064. /** @hidden */
  77065. dispose(): void;
  77066. /** @hidden */
  77067. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77068. }
  77069. }
  77070. declare module BABYLON.GLTF2.Loader.Extensions {
  77071. /**
  77072. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  77073. */
  77074. export class KHR_lights implements IGLTFLoaderExtension {
  77075. /**
  77076. * The name of this extension.
  77077. */
  77078. readonly name: string;
  77079. /**
  77080. * Defines whether this extension is enabled.
  77081. */
  77082. enabled: boolean;
  77083. private _loader;
  77084. private _lights?;
  77085. /** @hidden */
  77086. constructor(loader: GLTFLoader);
  77087. /** @hidden */
  77088. dispose(): void;
  77089. /** @hidden */
  77090. onLoading(): void;
  77091. /** @hidden */
  77092. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77093. }
  77094. }
  77095. declare module BABYLON.GLTF2.Loader.Extensions {
  77096. /**
  77097. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  77098. */
  77099. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  77100. /**
  77101. * The name of this extension.
  77102. */
  77103. readonly name: string;
  77104. /**
  77105. * Defines whether this extension is enabled.
  77106. */
  77107. enabled: boolean;
  77108. /**
  77109. * Defines a number that determines the order the extensions are applied.
  77110. */
  77111. order: number;
  77112. private _loader;
  77113. /** @hidden */
  77114. constructor(loader: GLTFLoader);
  77115. /** @hidden */
  77116. dispose(): void;
  77117. /** @hidden */
  77118. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77119. private _loadSpecularGlossinessPropertiesAsync;
  77120. }
  77121. }
  77122. declare module BABYLON.GLTF2.Loader.Extensions {
  77123. /**
  77124. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  77125. */
  77126. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  77127. /**
  77128. * The name of this extension.
  77129. */
  77130. readonly name: string;
  77131. /**
  77132. * Defines whether this extension is enabled.
  77133. */
  77134. enabled: boolean;
  77135. /**
  77136. * Defines a number that determines the order the extensions are applied.
  77137. */
  77138. order: number;
  77139. private _loader;
  77140. /** @hidden */
  77141. constructor(loader: GLTFLoader);
  77142. /** @hidden */
  77143. dispose(): void;
  77144. /** @hidden */
  77145. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77146. private _loadUnlitPropertiesAsync;
  77147. }
  77148. }
  77149. declare module BABYLON.GLTF2.Loader.Extensions {
  77150. /**
  77151. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77152. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  77153. * !!! Experimental Extension Subject to Changes !!!
  77154. */
  77155. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  77156. /**
  77157. * The name of this extension.
  77158. */
  77159. readonly name: string;
  77160. /**
  77161. * Defines whether this extension is enabled.
  77162. */
  77163. enabled: boolean;
  77164. /**
  77165. * Defines a number that determines the order the extensions are applied.
  77166. */
  77167. order: number;
  77168. private _loader;
  77169. /** @hidden */
  77170. constructor(loader: GLTFLoader);
  77171. /** @hidden */
  77172. dispose(): void;
  77173. /** @hidden */
  77174. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77175. private _loadClearCoatPropertiesAsync;
  77176. }
  77177. }
  77178. declare module BABYLON.GLTF2.Loader.Extensions {
  77179. /**
  77180. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  77181. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77182. * !!! Experimental Extension Subject to Changes !!!
  77183. */
  77184. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  77185. /**
  77186. * The name of this extension.
  77187. */
  77188. readonly name: string;
  77189. /**
  77190. * Defines whether this extension is enabled.
  77191. */
  77192. enabled: boolean;
  77193. /**
  77194. * Defines a number that determines the order the extensions are applied.
  77195. */
  77196. order: number;
  77197. private _loader;
  77198. /** @hidden */
  77199. constructor(loader: GLTFLoader);
  77200. /** @hidden */
  77201. dispose(): void;
  77202. /** @hidden */
  77203. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77204. private _loadSheenPropertiesAsync;
  77205. }
  77206. }
  77207. declare module BABYLON.GLTF2.Loader.Extensions {
  77208. /**
  77209. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77210. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77211. * !!! Experimental Extension Subject to Changes !!!
  77212. */
  77213. export class KHR_materials_specular implements IGLTFLoaderExtension {
  77214. /**
  77215. * The name of this extension.
  77216. */
  77217. readonly name: string;
  77218. /**
  77219. * Defines whether this extension is enabled.
  77220. */
  77221. enabled: boolean;
  77222. /**
  77223. * Defines a number that determines the order the extensions are applied.
  77224. */
  77225. order: number;
  77226. private _loader;
  77227. /** @hidden */
  77228. constructor(loader: GLTFLoader);
  77229. /** @hidden */
  77230. dispose(): void;
  77231. /** @hidden */
  77232. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77233. private _loadSpecularPropertiesAsync;
  77234. }
  77235. }
  77236. declare module BABYLON.GLTF2.Loader.Extensions {
  77237. /**
  77238. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  77239. */
  77240. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  77241. /**
  77242. * The name of this extension.
  77243. */
  77244. readonly name: string;
  77245. /**
  77246. * Defines whether this extension is enabled.
  77247. */
  77248. enabled: boolean;
  77249. /** @hidden */
  77250. constructor(loader: GLTFLoader);
  77251. /** @hidden */
  77252. dispose(): void;
  77253. }
  77254. }
  77255. declare module BABYLON.GLTF2.Loader.Extensions {
  77256. /**
  77257. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77258. * !!! Experimental Extension Subject to Changes !!!
  77259. */
  77260. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77261. /** The name of this extension. */
  77262. readonly name: string;
  77263. /** Defines whether this extension is enabled. */
  77264. enabled: boolean;
  77265. private _loader;
  77266. /** @hidden */
  77267. constructor(loader: GLTFLoader);
  77268. /** @hidden */
  77269. dispose(): void;
  77270. /** @hidden */
  77271. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77272. }
  77273. }
  77274. declare module BABYLON.GLTF2.Loader.Extensions {
  77275. /**
  77276. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77277. */
  77278. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77279. /**
  77280. * The name of this extension.
  77281. */
  77282. readonly name: string;
  77283. /**
  77284. * Defines whether this extension is enabled.
  77285. */
  77286. enabled: boolean;
  77287. private _loader;
  77288. /** @hidden */
  77289. constructor(loader: GLTFLoader);
  77290. /** @hidden */
  77291. dispose(): void;
  77292. /** @hidden */
  77293. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77294. }
  77295. }
  77296. declare module BABYLON.GLTF2.Loader.Extensions {
  77297. /**
  77298. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77299. */
  77300. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77301. /**
  77302. * The name of this extension.
  77303. */
  77304. readonly name: string;
  77305. /**
  77306. * Defines whether this extension is enabled.
  77307. */
  77308. enabled: boolean;
  77309. private _loader;
  77310. private _clips;
  77311. private _emitters;
  77312. /** @hidden */
  77313. constructor(loader: GLTFLoader);
  77314. /** @hidden */
  77315. dispose(): void;
  77316. /** @hidden */
  77317. onLoading(): void;
  77318. /** @hidden */
  77319. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77320. /** @hidden */
  77321. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77322. /** @hidden */
  77323. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77324. private _loadClipAsync;
  77325. private _loadEmitterAsync;
  77326. private _getEventAction;
  77327. private _loadAnimationEventAsync;
  77328. }
  77329. }
  77330. declare module BABYLON.GLTF2.Loader.Extensions {
  77331. /**
  77332. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77333. */
  77334. export class MSFT_lod implements IGLTFLoaderExtension {
  77335. /**
  77336. * The name of this extension.
  77337. */
  77338. readonly name: string;
  77339. /**
  77340. * Defines whether this extension is enabled.
  77341. */
  77342. enabled: boolean;
  77343. /**
  77344. * Defines a number that determines the order the extensions are applied.
  77345. */
  77346. order: number;
  77347. /**
  77348. * Maximum number of LODs to load, starting from the lowest LOD.
  77349. */
  77350. maxLODsToLoad: number;
  77351. /**
  77352. * Observable raised when all node LODs of one level are loaded.
  77353. * The event data is the index of the loaded LOD starting from zero.
  77354. * Dispose the loader to cancel the loading of the next level of LODs.
  77355. */
  77356. onNodeLODsLoadedObservable: Observable<number>;
  77357. /**
  77358. * Observable raised when all material LODs of one level are loaded.
  77359. * The event data is the index of the loaded LOD starting from zero.
  77360. * Dispose the loader to cancel the loading of the next level of LODs.
  77361. */
  77362. onMaterialLODsLoadedObservable: Observable<number>;
  77363. private _loader;
  77364. private _nodeIndexLOD;
  77365. private _nodeSignalLODs;
  77366. private _nodePromiseLODs;
  77367. private _materialIndexLOD;
  77368. private _materialSignalLODs;
  77369. private _materialPromiseLODs;
  77370. private _indexLOD;
  77371. private _bufferLODs;
  77372. /** @hidden */
  77373. constructor(loader: GLTFLoader);
  77374. /** @hidden */
  77375. dispose(): void;
  77376. /** @hidden */
  77377. onReady(): void;
  77378. /** @hidden */
  77379. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77380. /** @hidden */
  77381. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77382. /** @hidden */
  77383. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77384. /** @hidden */
  77385. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77386. /** @hidden */
  77387. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77388. private _loadBufferLOD;
  77389. /**
  77390. * Gets an array of LOD properties from lowest to highest.
  77391. */
  77392. private _getLODs;
  77393. private _disposeTransformNode;
  77394. private _disposeMaterials;
  77395. }
  77396. }
  77397. declare module BABYLON.GLTF2.Loader.Extensions {
  77398. /** @hidden */
  77399. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77400. readonly name: string;
  77401. enabled: boolean;
  77402. private _loader;
  77403. constructor(loader: GLTFLoader);
  77404. dispose(): void;
  77405. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77406. }
  77407. }
  77408. declare module BABYLON.GLTF2.Loader.Extensions {
  77409. /** @hidden */
  77410. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77411. readonly name: string;
  77412. enabled: boolean;
  77413. private _loader;
  77414. constructor(loader: GLTFLoader);
  77415. dispose(): void;
  77416. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77417. }
  77418. }
  77419. declare module BABYLON.GLTF2.Loader.Extensions {
  77420. /**
  77421. * Store glTF extras (if present) in BJS objects' metadata
  77422. */
  77423. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77424. /**
  77425. * The name of this extension.
  77426. */
  77427. readonly name: string;
  77428. /**
  77429. * Defines whether this extension is enabled.
  77430. */
  77431. enabled: boolean;
  77432. private _loader;
  77433. private _assignExtras;
  77434. /** @hidden */
  77435. constructor(loader: GLTFLoader);
  77436. /** @hidden */
  77437. dispose(): void;
  77438. /** @hidden */
  77439. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77440. /** @hidden */
  77441. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77442. /** @hidden */
  77443. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77444. }
  77445. }
  77446. declare module BABYLON {
  77447. /**
  77448. * Class reading and parsing the MTL file bundled with the obj file.
  77449. */
  77450. export class MTLFileLoader {
  77451. /**
  77452. * Invert Y-Axis of referenced textures on load
  77453. */
  77454. static INVERT_TEXTURE_Y: boolean;
  77455. /**
  77456. * All material loaded from the mtl will be set here
  77457. */
  77458. materials: StandardMaterial[];
  77459. /**
  77460. * This function will read the mtl file and create each material described inside
  77461. * This function could be improve by adding :
  77462. * -some component missing (Ni, Tf...)
  77463. * -including the specific options available
  77464. *
  77465. * @param scene defines the scene the material will be created in
  77466. * @param data defines the mtl data to parse
  77467. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77468. * @param forAssetContainer defines if the material should be registered in the scene
  77469. */
  77470. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77471. /**
  77472. * Gets the texture for the material.
  77473. *
  77474. * If the material is imported from input file,
  77475. * We sanitize the url to ensure it takes the textre from aside the material.
  77476. *
  77477. * @param rootUrl The root url to load from
  77478. * @param value The value stored in the mtl
  77479. * @return The Texture
  77480. */
  77481. private static _getTexture;
  77482. }
  77483. }
  77484. declare module BABYLON {
  77485. /**
  77486. * Options for loading OBJ/MTL files
  77487. */
  77488. type MeshLoadOptions = {
  77489. /**
  77490. * Defines if UVs are optimized by default during load.
  77491. */
  77492. OptimizeWithUV: boolean;
  77493. /**
  77494. * Defines custom scaling of UV coordinates of loaded meshes.
  77495. */
  77496. UVScaling: Vector2;
  77497. /**
  77498. * Invert model on y-axis (does a model scaling inversion)
  77499. */
  77500. InvertY: boolean;
  77501. /**
  77502. * Invert Y-Axis of referenced textures on load
  77503. */
  77504. InvertTextureY: boolean;
  77505. /**
  77506. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77507. */
  77508. ImportVertexColors: boolean;
  77509. /**
  77510. * Compute the normals for the model, even if normals are present in the file.
  77511. */
  77512. ComputeNormals: boolean;
  77513. /**
  77514. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77515. */
  77516. SkipMaterials: boolean;
  77517. /**
  77518. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77519. */
  77520. MaterialLoadingFailsSilently: boolean;
  77521. };
  77522. /**
  77523. * OBJ file type loader.
  77524. * This is a babylon scene loader plugin.
  77525. */
  77526. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77527. /**
  77528. * Defines if UVs are optimized by default during load.
  77529. */
  77530. static OPTIMIZE_WITH_UV: boolean;
  77531. /**
  77532. * Invert model on y-axis (does a model scaling inversion)
  77533. */
  77534. static INVERT_Y: boolean;
  77535. /**
  77536. * Invert Y-Axis of referenced textures on load
  77537. */
  77538. static get INVERT_TEXTURE_Y(): boolean;
  77539. static set INVERT_TEXTURE_Y(value: boolean);
  77540. /**
  77541. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77542. */
  77543. static IMPORT_VERTEX_COLORS: boolean;
  77544. /**
  77545. * Compute the normals for the model, even if normals are present in the file.
  77546. */
  77547. static COMPUTE_NORMALS: boolean;
  77548. /**
  77549. * Defines custom scaling of UV coordinates of loaded meshes.
  77550. */
  77551. static UV_SCALING: Vector2;
  77552. /**
  77553. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77554. */
  77555. static SKIP_MATERIALS: boolean;
  77556. /**
  77557. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77558. *
  77559. * Defaults to true for backwards compatibility.
  77560. */
  77561. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77562. /**
  77563. * Defines the name of the plugin.
  77564. */
  77565. name: string;
  77566. /**
  77567. * Defines the extension the plugin is able to load.
  77568. */
  77569. extensions: string;
  77570. /** @hidden */
  77571. obj: RegExp;
  77572. /** @hidden */
  77573. group: RegExp;
  77574. /** @hidden */
  77575. mtllib: RegExp;
  77576. /** @hidden */
  77577. usemtl: RegExp;
  77578. /** @hidden */
  77579. smooth: RegExp;
  77580. /** @hidden */
  77581. vertexPattern: RegExp;
  77582. /** @hidden */
  77583. normalPattern: RegExp;
  77584. /** @hidden */
  77585. uvPattern: RegExp;
  77586. /** @hidden */
  77587. facePattern1: RegExp;
  77588. /** @hidden */
  77589. facePattern2: RegExp;
  77590. /** @hidden */
  77591. facePattern3: RegExp;
  77592. /** @hidden */
  77593. facePattern4: RegExp;
  77594. /** @hidden */
  77595. facePattern5: RegExp;
  77596. private _forAssetContainer;
  77597. private _meshLoadOptions;
  77598. /**
  77599. * Creates loader for .OBJ files
  77600. *
  77601. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77602. */
  77603. constructor(meshLoadOptions?: MeshLoadOptions);
  77604. private static get currentMeshLoadOptions();
  77605. /**
  77606. * Calls synchronously the MTL file attached to this obj.
  77607. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77608. * Without this function materials are not displayed in the first frame (but displayed after).
  77609. * In consequence it is impossible to get material information in your HTML file
  77610. *
  77611. * @param url The URL of the MTL file
  77612. * @param rootUrl
  77613. * @param onSuccess Callback function to be called when the MTL file is loaded
  77614. * @private
  77615. */
  77616. private _loadMTL;
  77617. /**
  77618. * Instantiates a OBJ file loader plugin.
  77619. * @returns the created plugin
  77620. */
  77621. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77622. /**
  77623. * If the data string can be loaded directly.
  77624. *
  77625. * @param data string containing the file data
  77626. * @returns if the data can be loaded directly
  77627. */
  77628. canDirectLoad(data: string): boolean;
  77629. /**
  77630. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77631. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77632. * @param scene the scene the meshes should be added to
  77633. * @param data the OBJ data to load
  77634. * @param rootUrl root url to load from
  77635. * @param onProgress event that fires when loading progress has occured
  77636. * @param fileName Defines the name of the file to load
  77637. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77638. */
  77639. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77640. meshes: AbstractMesh[];
  77641. particleSystems: IParticleSystem[];
  77642. skeletons: Skeleton[];
  77643. animationGroups: AnimationGroup[];
  77644. }>;
  77645. /**
  77646. * Imports all objects from the loaded OBJ data and adds them to the scene
  77647. * @param scene the scene the objects should be added to
  77648. * @param data the OBJ data to load
  77649. * @param rootUrl root url to load from
  77650. * @param onProgress event that fires when loading progress has occured
  77651. * @param fileName Defines the name of the file to load
  77652. * @returns a promise which completes when objects have been loaded to the scene
  77653. */
  77654. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77655. /**
  77656. * Load into an asset container.
  77657. * @param scene The scene to load into
  77658. * @param data The data to import
  77659. * @param rootUrl The root url for scene and resources
  77660. * @param onProgress The callback when the load progresses
  77661. * @param fileName Defines the name of the file to load
  77662. * @returns The loaded asset container
  77663. */
  77664. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77665. /**
  77666. * Read the OBJ file and create an Array of meshes.
  77667. * Each mesh contains all information given by the OBJ and the MTL file.
  77668. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77669. *
  77670. * @param meshesNames
  77671. * @param scene Scene The scene where are displayed the data
  77672. * @param data String The content of the obj file
  77673. * @param rootUrl String The path to the folder
  77674. * @returns Array<AbstractMesh>
  77675. * @private
  77676. */
  77677. private _parseSolid;
  77678. }
  77679. }
  77680. declare module BABYLON {
  77681. /**
  77682. * STL file type loader.
  77683. * This is a babylon scene loader plugin.
  77684. */
  77685. export class STLFileLoader implements ISceneLoaderPlugin {
  77686. /** @hidden */
  77687. solidPattern: RegExp;
  77688. /** @hidden */
  77689. facetsPattern: RegExp;
  77690. /** @hidden */
  77691. normalPattern: RegExp;
  77692. /** @hidden */
  77693. vertexPattern: RegExp;
  77694. /**
  77695. * Defines the name of the plugin.
  77696. */
  77697. name: string;
  77698. /**
  77699. * Defines the extensions the stl loader is able to load.
  77700. * force data to come in as an ArrayBuffer
  77701. * we'll convert to string if it looks like it's an ASCII .stl
  77702. */
  77703. extensions: ISceneLoaderPluginExtensions;
  77704. /**
  77705. * Import meshes into a scene.
  77706. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77707. * @param scene The scene to import into
  77708. * @param data The data to import
  77709. * @param rootUrl The root url for scene and resources
  77710. * @param meshes The meshes array to import into
  77711. * @param particleSystems The particle systems array to import into
  77712. * @param skeletons The skeletons array to import into
  77713. * @param onError The callback when import fails
  77714. * @returns True if successful or false otherwise
  77715. */
  77716. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77717. /**
  77718. * Load into a scene.
  77719. * @param scene The scene to load into
  77720. * @param data The data to import
  77721. * @param rootUrl The root url for scene and resources
  77722. * @param onError The callback when import fails
  77723. * @returns true if successful or false otherwise
  77724. */
  77725. load(scene: Scene, data: any, rootUrl: string): boolean;
  77726. /**
  77727. * Load into an asset container.
  77728. * @param scene The scene to load into
  77729. * @param data The data to import
  77730. * @param rootUrl The root url for scene and resources
  77731. * @param onError The callback when import fails
  77732. * @returns The loaded asset container
  77733. */
  77734. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77735. private _isBinary;
  77736. private _parseBinary;
  77737. private _parseASCII;
  77738. }
  77739. }
  77740. declare module BABYLON {
  77741. /**
  77742. * Class for generating OBJ data from a Babylon scene.
  77743. */
  77744. export class OBJExport {
  77745. /**
  77746. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77747. * @param mesh defines the list of meshes to serialize
  77748. * @param materials defines if materials should be exported
  77749. * @param matlibname defines the name of the associated mtl file
  77750. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77751. * @returns the OBJ content
  77752. */
  77753. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77754. /**
  77755. * Exports the material(s) of a mesh in .MTL file format (text)
  77756. * @param mesh defines the mesh to extract the material from
  77757. * @returns the mtl content
  77758. */
  77759. static MTL(mesh: Mesh): string;
  77760. }
  77761. }
  77762. declare module BABYLON {
  77763. /** @hidden */
  77764. export var __IGLTFExporterExtension: number;
  77765. /**
  77766. * Interface for extending the exporter
  77767. * @hidden
  77768. */
  77769. export interface IGLTFExporterExtension {
  77770. /**
  77771. * The name of this extension
  77772. */
  77773. readonly name: string;
  77774. /**
  77775. * Defines whether this extension is enabled
  77776. */
  77777. enabled: boolean;
  77778. /**
  77779. * Defines whether this extension is required
  77780. */
  77781. required: boolean;
  77782. }
  77783. }
  77784. declare module BABYLON.GLTF2.Exporter {
  77785. /** @hidden */
  77786. export var __IGLTFExporterExtensionV2: number;
  77787. /**
  77788. * Interface for a glTF exporter extension
  77789. * @hidden
  77790. */
  77791. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77792. /**
  77793. * Define this method to modify the default behavior before exporting a texture
  77794. * @param context The context when loading the asset
  77795. * @param babylonTexture The Babylon.js texture
  77796. * @param mimeType The mime-type of the generated image
  77797. * @returns A promise that resolves with the exported texture
  77798. */
  77799. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77800. /**
  77801. * Define this method to get notified when a texture info is created
  77802. * @param context The context when loading the asset
  77803. * @param textureInfo The glTF texture info
  77804. * @param babylonTexture The Babylon.js texture
  77805. */
  77806. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77807. /**
  77808. * Define this method to modify the default behavior when exporting texture info
  77809. * @param context The context when loading the asset
  77810. * @param meshPrimitive glTF mesh primitive
  77811. * @param babylonSubMesh Babylon submesh
  77812. * @param binaryWriter glTF serializer binary writer instance
  77813. * @returns nullable IMeshPrimitive promise
  77814. */
  77815. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77816. /**
  77817. * Define this method to modify the default behavior when exporting a node
  77818. * @param context The context when exporting the node
  77819. * @param node glTF node
  77820. * @param babylonNode BabylonJS node
  77821. * @returns nullable INode promise
  77822. */
  77823. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77824. [key: number]: number;
  77825. }): Promise<Nullable<INode>>;
  77826. /**
  77827. * Define this method to modify the default behavior when exporting a material
  77828. * @param material glTF material
  77829. * @param babylonMaterial BabylonJS material
  77830. * @returns nullable IMaterial promise
  77831. */
  77832. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77833. /**
  77834. * Define this method to return additional textures to export from a material
  77835. * @param material glTF material
  77836. * @param babylonMaterial BabylonJS material
  77837. * @returns List of textures
  77838. */
  77839. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77840. /** Gets a boolean indicating that this extension was used */
  77841. wasUsed: boolean;
  77842. /** Gets a boolean indicating that this extension is required for the file to work */
  77843. required: boolean;
  77844. /**
  77845. * Called after the exporter state changes to EXPORTING
  77846. */
  77847. onExporting?(): void;
  77848. }
  77849. }
  77850. declare module BABYLON.GLTF2.Exporter {
  77851. /**
  77852. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77853. * @hidden
  77854. */
  77855. export class _GLTFMaterialExporter {
  77856. /**
  77857. * Represents the dielectric specular values for R, G and B
  77858. */
  77859. private static readonly _DielectricSpecular;
  77860. /**
  77861. * Allows the maximum specular power to be defined for material calculations
  77862. */
  77863. private static readonly _MaxSpecularPower;
  77864. /**
  77865. * Mapping to store textures
  77866. */
  77867. private _textureMap;
  77868. /**
  77869. * Numeric tolerance value
  77870. */
  77871. private static readonly _Epsilon;
  77872. /**
  77873. * Reference to the glTF Exporter
  77874. */
  77875. private _exporter;
  77876. constructor(exporter: _Exporter);
  77877. /**
  77878. * Specifies if two colors are approximately equal in value
  77879. * @param color1 first color to compare to
  77880. * @param color2 second color to compare to
  77881. * @param epsilon threshold value
  77882. */
  77883. private static FuzzyEquals;
  77884. /**
  77885. * Gets the materials from a Babylon scene and converts them to glTF materials
  77886. * @param scene babylonjs scene
  77887. * @param mimeType texture mime type
  77888. * @param images array of images
  77889. * @param textures array of textures
  77890. * @param materials array of materials
  77891. * @param imageData mapping of texture names to base64 textures
  77892. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77893. */
  77894. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77895. /**
  77896. * Makes a copy of the glTF material without the texture parameters
  77897. * @param originalMaterial original glTF material
  77898. * @returns glTF material without texture parameters
  77899. */
  77900. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77901. /**
  77902. * Specifies if the material has any texture parameters present
  77903. * @param material glTF Material
  77904. * @returns boolean specifying if texture parameters are present
  77905. */
  77906. _hasTexturesPresent(material: IMaterial): boolean;
  77907. /**
  77908. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77909. * @param babylonStandardMaterial
  77910. * @returns glTF Metallic Roughness Material representation
  77911. */
  77912. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77913. /**
  77914. * Computes the metallic factor
  77915. * @param diffuse diffused value
  77916. * @param specular specular value
  77917. * @param oneMinusSpecularStrength one minus the specular strength
  77918. * @returns metallic value
  77919. */
  77920. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77921. /**
  77922. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77923. * @param glTFMaterial glTF material
  77924. * @param babylonMaterial Babylon material
  77925. */
  77926. private static _SetAlphaMode;
  77927. /**
  77928. * Converts a Babylon Standard Material to a glTF Material
  77929. * @param babylonStandardMaterial BJS Standard Material
  77930. * @param mimeType mime type to use for the textures
  77931. * @param images array of glTF image interfaces
  77932. * @param textures array of glTF texture interfaces
  77933. * @param materials array of glTF material interfaces
  77934. * @param imageData map of image file name to data
  77935. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77936. */
  77937. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77938. private _finishMaterial;
  77939. /**
  77940. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77941. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77942. * @param mimeType mime type to use for the textures
  77943. * @param images array of glTF image interfaces
  77944. * @param textures array of glTF texture interfaces
  77945. * @param materials array of glTF material interfaces
  77946. * @param imageData map of image file name to data
  77947. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77948. */
  77949. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77950. /**
  77951. * Converts an image typed array buffer to a base64 image
  77952. * @param buffer typed array buffer
  77953. * @param width width of the image
  77954. * @param height height of the image
  77955. * @param mimeType mimetype of the image
  77956. * @returns base64 image string
  77957. */
  77958. private _createBase64FromCanvasAsync;
  77959. /**
  77960. * Generates a white texture based on the specified width and height
  77961. * @param width width of the texture in pixels
  77962. * @param height height of the texture in pixels
  77963. * @param scene babylonjs scene
  77964. * @returns white texture
  77965. */
  77966. private _createWhiteTexture;
  77967. /**
  77968. * 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
  77969. * @param texture1 first texture to resize
  77970. * @param texture2 second texture to resize
  77971. * @param scene babylonjs scene
  77972. * @returns resized textures or null
  77973. */
  77974. private _resizeTexturesToSameDimensions;
  77975. /**
  77976. * Converts an array of pixels to a Float32Array
  77977. * Throws an error if the pixel format is not supported
  77978. * @param pixels - array buffer containing pixel values
  77979. * @returns Float32 of pixels
  77980. */
  77981. private _convertPixelArrayToFloat32;
  77982. /**
  77983. * Convert Specular Glossiness Textures to Metallic Roughness
  77984. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77985. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77986. * @param diffuseTexture texture used to store diffuse information
  77987. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77988. * @param factors specular glossiness material factors
  77989. * @param mimeType the mime type to use for the texture
  77990. * @returns pbr metallic roughness interface or null
  77991. */
  77992. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77993. /**
  77994. * Converts specular glossiness material properties to metallic roughness
  77995. * @param specularGlossiness interface with specular glossiness material properties
  77996. * @returns interface with metallic roughness material properties
  77997. */
  77998. private _convertSpecularGlossinessToMetallicRoughness;
  77999. /**
  78000. * Calculates the surface reflectance, independent of lighting conditions
  78001. * @param color Color source to calculate brightness from
  78002. * @returns number representing the perceived brightness, or zero if color is undefined
  78003. */
  78004. private _getPerceivedBrightness;
  78005. /**
  78006. * Returns the maximum color component value
  78007. * @param color
  78008. * @returns maximum color component value, or zero if color is null or undefined
  78009. */
  78010. private _getMaxComponent;
  78011. /**
  78012. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  78013. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78014. * @param mimeType mime type to use for the textures
  78015. * @param images array of glTF image interfaces
  78016. * @param textures array of glTF texture interfaces
  78017. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78018. * @param imageData map of image file name to data
  78019. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78020. * @returns glTF PBR Metallic Roughness factors
  78021. */
  78022. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  78023. private _getGLTFTextureSampler;
  78024. private _getGLTFTextureWrapMode;
  78025. private _getGLTFTextureWrapModesSampler;
  78026. /**
  78027. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  78028. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78029. * @param mimeType mime type to use for the textures
  78030. * @param images array of glTF image interfaces
  78031. * @param textures array of glTF texture interfaces
  78032. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78033. * @param imageData map of image file name to data
  78034. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78035. * @returns glTF PBR Metallic Roughness factors
  78036. */
  78037. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  78038. /**
  78039. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  78040. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78041. * @param mimeType mime type to use for the textures
  78042. * @param images array of glTF image interfaces
  78043. * @param textures array of glTF texture interfaces
  78044. * @param materials array of glTF material interfaces
  78045. * @param imageData map of image file name to data
  78046. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78047. */
  78048. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  78049. private setMetallicRoughnessPbrMaterial;
  78050. private getPixelsFromTexture;
  78051. /**
  78052. * Extracts a texture from a Babylon texture into file data and glTF data
  78053. * @param babylonTexture Babylon texture to extract
  78054. * @param mimeType Mime Type of the babylonTexture
  78055. * @return glTF texture info, or null if the texture format is not supported
  78056. */
  78057. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78058. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78059. /**
  78060. * Builds a texture from base64 string
  78061. * @param base64Texture base64 texture string
  78062. * @param baseTextureName Name to use for the texture
  78063. * @param mimeType image mime type for the texture
  78064. * @param images array of images
  78065. * @param textures array of textures
  78066. * @param imageData map of image data
  78067. * @returns glTF texture info, or null if the texture format is not supported
  78068. */
  78069. private _getTextureInfoFromBase64;
  78070. }
  78071. }
  78072. declare module BABYLON {
  78073. /**
  78074. * Class for holding and downloading glTF file data
  78075. */
  78076. export class GLTFData {
  78077. /**
  78078. * Object which contains the file name as the key and its data as the value
  78079. */
  78080. glTFFiles: {
  78081. [fileName: string]: string | Blob;
  78082. };
  78083. /**
  78084. * Initializes the glTF file object
  78085. */
  78086. constructor();
  78087. /**
  78088. * Downloads the glTF data as files based on their names and data
  78089. */
  78090. downloadFiles(): void;
  78091. }
  78092. }
  78093. declare module BABYLON {
  78094. /**
  78095. * Holds a collection of exporter options and parameters
  78096. */
  78097. export interface IExportOptions {
  78098. /**
  78099. * Function which indicates whether a babylon node should be exported or not
  78100. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  78101. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  78102. */
  78103. shouldExportNode?(node: Node): boolean;
  78104. /**
  78105. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  78106. * @param metadata source metadata to read from
  78107. * @returns the data to store to glTF node extras
  78108. */
  78109. metadataSelector?(metadata: any): any;
  78110. /**
  78111. * The sample rate to bake animation curves
  78112. */
  78113. animationSampleRate?: number;
  78114. /**
  78115. * Begin serialization without waiting for the scene to be ready
  78116. */
  78117. exportWithoutWaitingForScene?: boolean;
  78118. /**
  78119. * Indicates if coordinate system swapping root nodes should be included in export
  78120. */
  78121. includeCoordinateSystemConversionNodes?: boolean;
  78122. }
  78123. /**
  78124. * Class for generating glTF data from a Babylon scene.
  78125. */
  78126. export class GLTF2Export {
  78127. /**
  78128. * Exports the geometry of the scene to .gltf file format asynchronously
  78129. * @param scene Babylon scene with scene hierarchy information
  78130. * @param filePrefix File prefix to use when generating the glTF file
  78131. * @param options Exporter options
  78132. * @returns Returns an object with a .gltf file and associates texture names
  78133. * as keys and their data and paths as values
  78134. */
  78135. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78136. private static _PreExportAsync;
  78137. private static _PostExportAsync;
  78138. /**
  78139. * Exports the geometry of the scene to .glb file format asychronously
  78140. * @param scene Babylon scene with scene hierarchy information
  78141. * @param filePrefix File prefix to use when generating glb file
  78142. * @param options Exporter options
  78143. * @returns Returns an object with a .glb filename as key and data as value
  78144. */
  78145. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78146. }
  78147. }
  78148. declare module BABYLON.GLTF2.Exporter {
  78149. /**
  78150. * @hidden
  78151. */
  78152. export class _GLTFUtilities {
  78153. /**
  78154. * Creates a buffer view based on the supplied arguments
  78155. * @param bufferIndex index value of the specified buffer
  78156. * @param byteOffset byte offset value
  78157. * @param byteLength byte length of the bufferView
  78158. * @param byteStride byte distance between conequential elements
  78159. * @param name name of the buffer view
  78160. * @returns bufferView for glTF
  78161. */
  78162. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  78163. /**
  78164. * Creates an accessor based on the supplied arguments
  78165. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  78166. * @param name The name of the accessor
  78167. * @param type The type of the accessor
  78168. * @param componentType The datatype of components in the attribute
  78169. * @param count The number of attributes referenced by this accessor
  78170. * @param byteOffset The offset relative to the start of the bufferView in bytes
  78171. * @param min Minimum value of each component in this attribute
  78172. * @param max Maximum value of each component in this attribute
  78173. * @returns accessor for glTF
  78174. */
  78175. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  78176. /**
  78177. * Calculates the minimum and maximum values of an array of position floats
  78178. * @param positions Positions array of a mesh
  78179. * @param vertexStart Starting vertex offset to calculate min and max values
  78180. * @param vertexCount Number of vertices to check for min and max values
  78181. * @returns min number array and max number array
  78182. */
  78183. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  78184. min: number[];
  78185. max: number[];
  78186. };
  78187. /**
  78188. * Converts a new right-handed Vector3
  78189. * @param vector vector3 array
  78190. * @returns right-handed Vector3
  78191. */
  78192. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  78193. /**
  78194. * Converts a Vector3 to right-handed
  78195. * @param vector Vector3 to convert to right-handed
  78196. */
  78197. static _GetRightHandedPositionVector3FromRef(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 _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  78203. /**
  78204. * Converts a new right-handed Vector3
  78205. * @param vector vector3 array
  78206. * @returns right-handed Vector3
  78207. */
  78208. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  78209. /**
  78210. * Converts a Vector3 to right-handed
  78211. * @param vector Vector3 to convert to right-handed
  78212. */
  78213. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  78214. /**
  78215. * Converts a three element number array to right-handed
  78216. * @param vector number array to convert to right-handed
  78217. */
  78218. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  78219. /**
  78220. * Converts a Vector4 to right-handed
  78221. * @param vector Vector4 to convert to right-handed
  78222. */
  78223. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  78224. /**
  78225. * Converts a Vector4 to right-handed
  78226. * @param vector Vector4 to convert to right-handed
  78227. */
  78228. static _GetRightHandedArray4FromRef(vector: number[]): void;
  78229. /**
  78230. * Converts a Quaternion to right-handed
  78231. * @param quaternion Source quaternion to convert to right-handed
  78232. */
  78233. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  78234. /**
  78235. * Converts a Quaternion to right-handed
  78236. * @param quaternion Source quaternion to convert to right-handed
  78237. */
  78238. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  78239. static _NormalizeTangentFromRef(tangent: Vector4): void;
  78240. }
  78241. }
  78242. declare module BABYLON.GLTF2.Exporter {
  78243. /**
  78244. * Converts Babylon Scene into glTF 2.0.
  78245. * @hidden
  78246. */
  78247. export class _Exporter {
  78248. /**
  78249. * Stores the glTF to export
  78250. */
  78251. _glTF: IGLTF;
  78252. /**
  78253. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78254. */
  78255. _bufferViews: IBufferView[];
  78256. /**
  78257. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78258. */
  78259. _accessors: IAccessor[];
  78260. /**
  78261. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78262. */
  78263. _nodes: INode[];
  78264. /**
  78265. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78266. */
  78267. private _scenes;
  78268. /**
  78269. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78270. */
  78271. private _meshes;
  78272. /**
  78273. * Stores all the generated material information, which represents the appearance of each primitive
  78274. */
  78275. _materials: IMaterial[];
  78276. _materialMap: {
  78277. [materialID: number]: number;
  78278. };
  78279. /**
  78280. * Stores all the generated texture information, which is referenced by glTF materials
  78281. */
  78282. _textures: ITexture[];
  78283. /**
  78284. * Stores all the generated image information, which is referenced by glTF textures
  78285. */
  78286. _images: IImage[];
  78287. /**
  78288. * Stores all the texture samplers
  78289. */
  78290. _samplers: ISampler[];
  78291. /**
  78292. * Stores all the generated animation samplers, which is referenced by glTF animations
  78293. */
  78294. /**
  78295. * Stores the animations for glTF models
  78296. */
  78297. private _animations;
  78298. /**
  78299. * Stores the total amount of bytes stored in the glTF buffer
  78300. */
  78301. private _totalByteLength;
  78302. /**
  78303. * Stores a reference to the Babylon scene containing the source geometry and material information
  78304. */
  78305. _babylonScene: Scene;
  78306. /**
  78307. * Stores a map of the image data, where the key is the file name and the value
  78308. * is the image data
  78309. */
  78310. _imageData: {
  78311. [fileName: string]: {
  78312. data: Uint8Array;
  78313. mimeType: ImageMimeType;
  78314. };
  78315. };
  78316. /**
  78317. * Stores a map of the unique id of a node to its index in the node array
  78318. */
  78319. _nodeMap: {
  78320. [key: number]: number;
  78321. };
  78322. /**
  78323. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78324. */
  78325. _convertToRightHandedSystem: boolean;
  78326. /**
  78327. * Specifies if a Babylon node should be converted to right-handed on export
  78328. */
  78329. _convertToRightHandedSystemMap: {
  78330. [nodeId: number]: boolean;
  78331. };
  78332. _includeCoordinateSystemConversionNodes: boolean;
  78333. /**
  78334. * Baked animation sample rate
  78335. */
  78336. private _animationSampleRate;
  78337. private _options;
  78338. private _localEngine;
  78339. _glTFMaterialExporter: _GLTFMaterialExporter;
  78340. private _extensions;
  78341. private static _ExtensionNames;
  78342. private static _ExtensionFactories;
  78343. private _applyExtension;
  78344. private _applyExtensions;
  78345. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78346. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78347. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78348. [key: number]: number;
  78349. }): Promise<Nullable<INode>>;
  78350. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78351. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78352. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78353. private _forEachExtensions;
  78354. private _extensionsOnExporting;
  78355. /**
  78356. * Load glTF serializer extensions
  78357. */
  78358. private _loadExtensions;
  78359. /**
  78360. * Creates a glTF Exporter instance, which can accept optional exporter options
  78361. * @param babylonScene Babylon scene object
  78362. * @param options Options to modify the behavior of the exporter
  78363. */
  78364. constructor(babylonScene: Scene, options?: IExportOptions);
  78365. dispose(): void;
  78366. /**
  78367. * Registers a glTF exporter extension
  78368. * @param name Name of the extension to export
  78369. * @param factory The factory function that creates the exporter extension
  78370. */
  78371. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78372. /**
  78373. * Un-registers an exporter extension
  78374. * @param name The name fo the exporter extension
  78375. * @returns A boolean indicating whether the extension has been un-registered
  78376. */
  78377. static UnregisterExtension(name: string): boolean;
  78378. /**
  78379. * Lazy load a local engine
  78380. */
  78381. _getLocalEngine(): Engine;
  78382. private reorderIndicesBasedOnPrimitiveMode;
  78383. /**
  78384. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78385. * clock-wise during export to glTF
  78386. * @param submesh BabylonJS submesh
  78387. * @param primitiveMode Primitive mode of the mesh
  78388. * @param sideOrientation the winding order of the submesh
  78389. * @param vertexBufferKind The type of vertex attribute
  78390. * @param meshAttributeArray The vertex attribute data
  78391. * @param byteOffset The offset to the binary data
  78392. * @param binaryWriter The binary data for the glTF file
  78393. * @param convertToRightHandedSystem Converts the values to right-handed
  78394. */
  78395. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78396. /**
  78397. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78398. * clock-wise during export to glTF
  78399. * @param submesh BabylonJS submesh
  78400. * @param primitiveMode Primitive mode of the mesh
  78401. * @param sideOrientation the winding order of the submesh
  78402. * @param vertexBufferKind The type of vertex attribute
  78403. * @param meshAttributeArray The vertex attribute data
  78404. * @param byteOffset The offset to the binary data
  78405. * @param binaryWriter The binary data for the glTF file
  78406. * @param convertToRightHandedSystem Converts the values to right-handed
  78407. */
  78408. private reorderTriangleFillMode;
  78409. /**
  78410. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78411. * clock-wise during export to glTF
  78412. * @param submesh BabylonJS submesh
  78413. * @param primitiveMode Primitive mode of the mesh
  78414. * @param sideOrientation the winding order of the submesh
  78415. * @param vertexBufferKind The type of vertex attribute
  78416. * @param meshAttributeArray The vertex attribute data
  78417. * @param byteOffset The offset to the binary data
  78418. * @param binaryWriter The binary data for the glTF file
  78419. * @param convertToRightHandedSystem Converts the values to right-handed
  78420. */
  78421. private reorderTriangleStripDrawMode;
  78422. /**
  78423. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78424. * clock-wise during export to glTF
  78425. * @param submesh BabylonJS submesh
  78426. * @param primitiveMode Primitive mode of the mesh
  78427. * @param sideOrientation the winding order of the submesh
  78428. * @param vertexBufferKind The type of vertex attribute
  78429. * @param meshAttributeArray The vertex attribute data
  78430. * @param byteOffset The offset to the binary data
  78431. * @param binaryWriter The binary data for the glTF file
  78432. * @param convertToRightHandedSystem Converts the values to right-handed
  78433. */
  78434. private reorderTriangleFanMode;
  78435. /**
  78436. * Writes the vertex attribute data to binary
  78437. * @param vertices The vertices to write to the binary writer
  78438. * @param byteOffset The offset into the binary writer to overwrite binary data
  78439. * @param vertexAttributeKind The vertex attribute type
  78440. * @param meshAttributeArray The vertex attribute data
  78441. * @param binaryWriter The writer containing the binary data
  78442. * @param convertToRightHandedSystem Converts the values to right-handed
  78443. */
  78444. private writeVertexAttributeData;
  78445. /**
  78446. * Writes mesh attribute data to a data buffer
  78447. * Returns the bytelength of the data
  78448. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78449. * @param meshAttributeArray Array containing the attribute data
  78450. * @param binaryWriter The buffer to write the binary data to
  78451. * @param indices Used to specify the order of the vertex data
  78452. * @param convertToRightHandedSystem Converts the values to right-handed
  78453. */
  78454. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78455. /**
  78456. * Generates glTF json data
  78457. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78458. * @param glTFPrefix Text to use when prefixing a glTF file
  78459. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78460. * @returns json data as string
  78461. */
  78462. private generateJSON;
  78463. /**
  78464. * Generates data for .gltf and .bin files based on the glTF prefix string
  78465. * @param glTFPrefix Text to use when prefixing a glTF file
  78466. * @param dispose Dispose the exporter
  78467. * @returns GLTFData with glTF file data
  78468. */
  78469. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78470. /**
  78471. * Creates a binary buffer for glTF
  78472. * @returns array buffer for binary data
  78473. */
  78474. private _generateBinaryAsync;
  78475. /**
  78476. * Pads the number to a multiple of 4
  78477. * @param num number to pad
  78478. * @returns padded number
  78479. */
  78480. private _getPadding;
  78481. /**
  78482. * @hidden
  78483. */
  78484. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78485. /**
  78486. * Sets the TRS for each node
  78487. * @param node glTF Node for storing the transformation data
  78488. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78489. * @param convertToRightHandedSystem Converts the values to right-handed
  78490. */
  78491. private setNodeTransformation;
  78492. private getVertexBufferFromMesh;
  78493. /**
  78494. * Creates a bufferview based on the vertices type for the Babylon mesh
  78495. * @param kind Indicates the type of vertices data
  78496. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78497. * @param binaryWriter The buffer to write the bufferview data to
  78498. * @param convertToRightHandedSystem Converts the values to right-handed
  78499. */
  78500. private createBufferViewKind;
  78501. /**
  78502. * The primitive mode of the Babylon mesh
  78503. * @param babylonMesh The BabylonJS mesh
  78504. */
  78505. private getMeshPrimitiveMode;
  78506. /**
  78507. * Sets the primitive mode of the glTF mesh primitive
  78508. * @param meshPrimitive glTF mesh primitive
  78509. * @param primitiveMode The primitive mode
  78510. */
  78511. private setPrimitiveMode;
  78512. /**
  78513. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78514. * @param meshPrimitive glTF mesh primitive
  78515. * @param attributeKind vertex attribute
  78516. * @returns boolean specifying if uv coordinates are present
  78517. */
  78518. private setAttributeKind;
  78519. /**
  78520. * Sets data for the primitive attributes of each submesh
  78521. * @param mesh glTF Mesh object to store the primitive attribute information
  78522. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78523. * @param binaryWriter Buffer to write the attribute data to
  78524. * @param convertToRightHandedSystem Converts the values to right-handed
  78525. */
  78526. private setPrimitiveAttributesAsync;
  78527. /**
  78528. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78529. * @param node The node to check
  78530. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78531. */
  78532. private isBabylonCoordinateSystemConvertingNode;
  78533. /**
  78534. * Creates a glTF scene based on the array of meshes
  78535. * Returns the the total byte offset
  78536. * @param babylonScene Babylon scene to get the mesh data from
  78537. * @param binaryWriter Buffer to write binary data to
  78538. */
  78539. private createSceneAsync;
  78540. /**
  78541. * Creates a mapping of Node unique id to node index and handles animations
  78542. * @param babylonScene Babylon Scene
  78543. * @param nodes Babylon transform nodes
  78544. * @param binaryWriter Buffer to write binary data to
  78545. * @returns Node mapping of unique id to index
  78546. */
  78547. private createNodeMapAndAnimationsAsync;
  78548. /**
  78549. * Creates a glTF node from a Babylon mesh
  78550. * @param babylonMesh Source Babylon mesh
  78551. * @param binaryWriter Buffer for storing geometry data
  78552. * @param convertToRightHandedSystem Converts the values to right-handed
  78553. * @param nodeMap Node mapping of unique id to glTF node index
  78554. * @returns glTF node
  78555. */
  78556. private createNodeAsync;
  78557. }
  78558. /**
  78559. * @hidden
  78560. *
  78561. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78562. */
  78563. export class _BinaryWriter {
  78564. /**
  78565. * Array buffer which stores all binary data
  78566. */
  78567. private _arrayBuffer;
  78568. /**
  78569. * View of the array buffer
  78570. */
  78571. private _dataView;
  78572. /**
  78573. * byte offset of data in array buffer
  78574. */
  78575. private _byteOffset;
  78576. /**
  78577. * Initialize binary writer with an initial byte length
  78578. * @param byteLength Initial byte length of the array buffer
  78579. */
  78580. constructor(byteLength: number);
  78581. /**
  78582. * Resize the array buffer to the specified byte length
  78583. * @param byteLength
  78584. */
  78585. private resizeBuffer;
  78586. /**
  78587. * Get an array buffer with the length of the byte offset
  78588. * @returns ArrayBuffer resized to the byte offset
  78589. */
  78590. getArrayBuffer(): ArrayBuffer;
  78591. /**
  78592. * Get the byte offset of the array buffer
  78593. * @returns byte offset
  78594. */
  78595. getByteOffset(): number;
  78596. /**
  78597. * Stores an UInt8 in the array buffer
  78598. * @param entry
  78599. * @param byteOffset If defined, specifies where to set the value as an offset.
  78600. */
  78601. setUInt8(entry: number, byteOffset?: number): void;
  78602. /**
  78603. * Gets an UInt32 in the array buffer
  78604. * @param entry
  78605. * @param byteOffset If defined, specifies where to set the value as an offset.
  78606. */
  78607. getUInt32(byteOffset: number): number;
  78608. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78609. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78610. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78611. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78612. /**
  78613. * Stores a Float32 in the array buffer
  78614. * @param entry
  78615. */
  78616. setFloat32(entry: number, byteOffset?: number): void;
  78617. /**
  78618. * Stores an UInt32 in the array buffer
  78619. * @param entry
  78620. * @param byteOffset If defined, specifies where to set the value as an offset.
  78621. */
  78622. setUInt32(entry: number, byteOffset?: number): void;
  78623. }
  78624. }
  78625. declare module BABYLON.GLTF2.Exporter {
  78626. /**
  78627. * @hidden
  78628. * Interface to store animation data.
  78629. */
  78630. export interface _IAnimationData {
  78631. /**
  78632. * Keyframe data.
  78633. */
  78634. inputs: number[];
  78635. /**
  78636. * Value data.
  78637. */
  78638. outputs: number[][];
  78639. /**
  78640. * Animation interpolation data.
  78641. */
  78642. samplerInterpolation: AnimationSamplerInterpolation;
  78643. /**
  78644. * Minimum keyframe value.
  78645. */
  78646. inputsMin: number;
  78647. /**
  78648. * Maximum keyframe value.
  78649. */
  78650. inputsMax: number;
  78651. }
  78652. /**
  78653. * @hidden
  78654. */
  78655. export interface _IAnimationInfo {
  78656. /**
  78657. * The target channel for the animation
  78658. */
  78659. animationChannelTargetPath: AnimationChannelTargetPath;
  78660. /**
  78661. * The glTF accessor type for the data.
  78662. */
  78663. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78664. /**
  78665. * Specifies if quaternions should be used.
  78666. */
  78667. useQuaternion: boolean;
  78668. }
  78669. /**
  78670. * @hidden
  78671. * Utility class for generating glTF animation data from BabylonJS.
  78672. */
  78673. export class _GLTFAnimation {
  78674. /**
  78675. * @ignore
  78676. *
  78677. * Creates glTF channel animation from BabylonJS animation.
  78678. * @param babylonTransformNode - BabylonJS mesh.
  78679. * @param animation - animation.
  78680. * @param animationChannelTargetPath - The target animation channel.
  78681. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78682. * @param useQuaternion - Specifies if quaternions are used.
  78683. * @returns nullable IAnimationData
  78684. */
  78685. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78686. private static _DeduceAnimationInfo;
  78687. /**
  78688. * @ignore
  78689. * Create node animations from the transform node animations
  78690. * @param babylonNode
  78691. * @param runtimeGLTFAnimation
  78692. * @param idleGLTFAnimations
  78693. * @param nodeMap
  78694. * @param nodes
  78695. * @param binaryWriter
  78696. * @param bufferViews
  78697. * @param accessors
  78698. * @param convertToRightHandedSystem
  78699. * @param animationSampleRate
  78700. */
  78701. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78702. [key: number]: number;
  78703. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78704. /**
  78705. * @ignore
  78706. * Create node animations from the animation groups
  78707. * @param babylonScene
  78708. * @param glTFAnimations
  78709. * @param nodeMap
  78710. * @param nodes
  78711. * @param binaryWriter
  78712. * @param bufferViews
  78713. * @param accessors
  78714. * @param convertToRightHandedSystemMap
  78715. * @param animationSampleRate
  78716. */
  78717. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78718. [key: number]: number;
  78719. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78720. [nodeId: number]: boolean;
  78721. }, animationSampleRate: number): void;
  78722. private static AddAnimation;
  78723. /**
  78724. * Create a baked animation
  78725. * @param babylonTransformNode BabylonJS mesh
  78726. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78727. * @param animationChannelTargetPath animation target channel
  78728. * @param minFrame minimum animation frame
  78729. * @param maxFrame maximum animation frame
  78730. * @param fps frames per second of the animation
  78731. * @param inputs input key frames of the animation
  78732. * @param outputs output key frame data of the animation
  78733. * @param convertToRightHandedSystem converts the values to right-handed
  78734. * @param useQuaternion specifies if quaternions should be used
  78735. */
  78736. private static _CreateBakedAnimation;
  78737. private static _ConvertFactorToVector3OrQuaternion;
  78738. private static _SetInterpolatedValue;
  78739. /**
  78740. * Creates linear animation from the animation key frames
  78741. * @param babylonTransformNode BabylonJS mesh
  78742. * @param animation BabylonJS animation
  78743. * @param animationChannelTargetPath The target animation channel
  78744. * @param frameDelta The difference between the last and first frame of the animation
  78745. * @param inputs Array to store the key frame times
  78746. * @param outputs Array to store the key frame data
  78747. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78748. * @param useQuaternion Specifies if quaternions are used in the animation
  78749. */
  78750. private static _CreateLinearOrStepAnimation;
  78751. /**
  78752. * Creates cubic spline animation from the animation key frames
  78753. * @param babylonTransformNode BabylonJS mesh
  78754. * @param animation BabylonJS animation
  78755. * @param animationChannelTargetPath The target animation channel
  78756. * @param frameDelta The difference between the last and first frame of the animation
  78757. * @param inputs Array to store the key frame times
  78758. * @param outputs Array to store the key frame data
  78759. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78760. * @param useQuaternion Specifies if quaternions are used in the animation
  78761. */
  78762. private static _CreateCubicSplineAnimation;
  78763. private static _GetBasePositionRotationOrScale;
  78764. /**
  78765. * Adds a key frame value
  78766. * @param keyFrame
  78767. * @param animation
  78768. * @param outputs
  78769. * @param animationChannelTargetPath
  78770. * @param basePositionRotationOrScale
  78771. * @param convertToRightHandedSystem
  78772. * @param useQuaternion
  78773. */
  78774. private static _AddKeyframeValue;
  78775. /**
  78776. * Determine the interpolation based on the key frames
  78777. * @param keyFrames
  78778. * @param animationChannelTargetPath
  78779. * @param useQuaternion
  78780. */
  78781. private static _DeduceInterpolation;
  78782. /**
  78783. * Adds an input tangent or output tangent to the output data
  78784. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78785. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78786. * @param outputs The animation data by keyframe
  78787. * @param animationChannelTargetPath The target animation channel
  78788. * @param interpolation The interpolation type
  78789. * @param keyFrame The key frame with the animation data
  78790. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78791. * @param useQuaternion Specifies if quaternions are used
  78792. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78793. */
  78794. private static AddSplineTangent;
  78795. /**
  78796. * Get the minimum and maximum key frames' frame values
  78797. * @param keyFrames animation key frames
  78798. * @returns the minimum and maximum key frame value
  78799. */
  78800. private static calculateMinMaxKeyFrames;
  78801. }
  78802. }
  78803. declare module BABYLON.GLTF2.Exporter {
  78804. /** @hidden */
  78805. export var textureTransformPixelShader: {
  78806. name: string;
  78807. shader: string;
  78808. };
  78809. }
  78810. declare module BABYLON.GLTF2.Exporter.Extensions {
  78811. /**
  78812. * @hidden
  78813. */
  78814. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78815. private _recordedTextures;
  78816. /** Name of this extension */
  78817. readonly name: string;
  78818. /** Defines whether this extension is enabled */
  78819. enabled: boolean;
  78820. /** Defines whether this extension is required */
  78821. required: boolean;
  78822. /** Reference to the glTF exporter */
  78823. private _wasUsed;
  78824. constructor(exporter: _Exporter);
  78825. dispose(): void;
  78826. /** @hidden */
  78827. get wasUsed(): boolean;
  78828. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78829. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78830. /**
  78831. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78832. * @param babylonTexture
  78833. * @param offset
  78834. * @param rotation
  78835. * @param scale
  78836. * @param scene
  78837. */
  78838. private _textureTransformTextureAsync;
  78839. }
  78840. }
  78841. declare module BABYLON.GLTF2.Exporter.Extensions {
  78842. /**
  78843. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78844. */
  78845. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78846. /** The name of this extension. */
  78847. readonly name: string;
  78848. /** Defines whether this extension is enabled. */
  78849. enabled: boolean;
  78850. /** Defines whether this extension is required */
  78851. required: boolean;
  78852. /** Reference to the glTF exporter */
  78853. private _exporter;
  78854. private _lights;
  78855. /** @hidden */
  78856. constructor(exporter: _Exporter);
  78857. /** @hidden */
  78858. dispose(): void;
  78859. /** @hidden */
  78860. get wasUsed(): boolean;
  78861. /** @hidden */
  78862. onExporting(): void;
  78863. /**
  78864. * Define this method to modify the default behavior when exporting a node
  78865. * @param context The context when exporting the node
  78866. * @param node glTF node
  78867. * @param babylonNode BabylonJS node
  78868. * @param nodeMap Node mapping of unique id to glTF node index
  78869. * @returns nullable INode promise
  78870. */
  78871. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78872. [key: number]: number;
  78873. }): Promise<Nullable<INode>>;
  78874. }
  78875. }
  78876. declare module BABYLON.GLTF2.Exporter.Extensions {
  78877. /**
  78878. * @hidden
  78879. */
  78880. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78881. /** Name of this extension */
  78882. readonly name: string;
  78883. /** Defines whether this extension is enabled */
  78884. enabled: boolean;
  78885. /** Defines whether this extension is required */
  78886. required: boolean;
  78887. /** Reference to the glTF exporter */
  78888. private _textureInfos;
  78889. private _exportedTextures;
  78890. private _wasUsed;
  78891. constructor(exporter: _Exporter);
  78892. dispose(): void;
  78893. /** @hidden */
  78894. get wasUsed(): boolean;
  78895. private _getTextureIndex;
  78896. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78897. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78898. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78899. }
  78900. }
  78901. declare module BABYLON {
  78902. /**
  78903. * Class for generating STL data from a Babylon scene.
  78904. */
  78905. export class STLExport {
  78906. /**
  78907. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78908. * @param meshes list defines the mesh to serialize
  78909. * @param download triggers the automatic download of the file.
  78910. * @param fileName changes the downloads fileName.
  78911. * @param binary changes the STL to a binary type.
  78912. * @param isLittleEndian toggle for binary type exporter.
  78913. * @returns the STL as UTF8 string
  78914. */
  78915. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78916. }
  78917. }
  78918. declare module "babylonjs-gltf2interface" {
  78919. export = BABYLON.GLTF2;
  78920. }
  78921. /**
  78922. * Module for glTF 2.0 Interface
  78923. */
  78924. declare module BABYLON.GLTF2 {
  78925. /**
  78926. * The datatype of the components in the attribute
  78927. */
  78928. const enum AccessorComponentType {
  78929. /**
  78930. * Byte
  78931. */
  78932. BYTE = 5120,
  78933. /**
  78934. * Unsigned Byte
  78935. */
  78936. UNSIGNED_BYTE = 5121,
  78937. /**
  78938. * Short
  78939. */
  78940. SHORT = 5122,
  78941. /**
  78942. * Unsigned Short
  78943. */
  78944. UNSIGNED_SHORT = 5123,
  78945. /**
  78946. * Unsigned Int
  78947. */
  78948. UNSIGNED_INT = 5125,
  78949. /**
  78950. * Float
  78951. */
  78952. FLOAT = 5126,
  78953. }
  78954. /**
  78955. * Specifies if the attirbute is a scalar, vector, or matrix
  78956. */
  78957. const enum AccessorType {
  78958. /**
  78959. * Scalar
  78960. */
  78961. SCALAR = "SCALAR",
  78962. /**
  78963. * Vector2
  78964. */
  78965. VEC2 = "VEC2",
  78966. /**
  78967. * Vector3
  78968. */
  78969. VEC3 = "VEC3",
  78970. /**
  78971. * Vector4
  78972. */
  78973. VEC4 = "VEC4",
  78974. /**
  78975. * Matrix2x2
  78976. */
  78977. MAT2 = "MAT2",
  78978. /**
  78979. * Matrix3x3
  78980. */
  78981. MAT3 = "MAT3",
  78982. /**
  78983. * Matrix4x4
  78984. */
  78985. MAT4 = "MAT4",
  78986. }
  78987. /**
  78988. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78989. */
  78990. const enum AnimationChannelTargetPath {
  78991. /**
  78992. * Translation
  78993. */
  78994. TRANSLATION = "translation",
  78995. /**
  78996. * Rotation
  78997. */
  78998. ROTATION = "rotation",
  78999. /**
  79000. * Scale
  79001. */
  79002. SCALE = "scale",
  79003. /**
  79004. * Weights
  79005. */
  79006. WEIGHTS = "weights",
  79007. }
  79008. /**
  79009. * Interpolation algorithm
  79010. */
  79011. const enum AnimationSamplerInterpolation {
  79012. /**
  79013. * The animated values are linearly interpolated between keyframes
  79014. */
  79015. LINEAR = "LINEAR",
  79016. /**
  79017. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  79018. */
  79019. STEP = "STEP",
  79020. /**
  79021. * The animation's interpolation is computed using a cubic spline with specified tangents
  79022. */
  79023. CUBICSPLINE = "CUBICSPLINE",
  79024. }
  79025. /**
  79026. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79027. */
  79028. const enum CameraType {
  79029. /**
  79030. * A perspective camera containing properties to create a perspective projection matrix
  79031. */
  79032. PERSPECTIVE = "perspective",
  79033. /**
  79034. * An orthographic camera containing properties to create an orthographic projection matrix
  79035. */
  79036. ORTHOGRAPHIC = "orthographic",
  79037. }
  79038. /**
  79039. * The mime-type of the image
  79040. */
  79041. const enum ImageMimeType {
  79042. /**
  79043. * JPEG Mime-type
  79044. */
  79045. JPEG = "image/jpeg",
  79046. /**
  79047. * PNG Mime-type
  79048. */
  79049. PNG = "image/png",
  79050. }
  79051. /**
  79052. * The alpha rendering mode of the material
  79053. */
  79054. const enum MaterialAlphaMode {
  79055. /**
  79056. * The alpha value is ignored and the rendered output is fully opaque
  79057. */
  79058. OPAQUE = "OPAQUE",
  79059. /**
  79060. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  79061. */
  79062. MASK = "MASK",
  79063. /**
  79064. * 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)
  79065. */
  79066. BLEND = "BLEND",
  79067. }
  79068. /**
  79069. * The type of the primitives to render
  79070. */
  79071. const enum MeshPrimitiveMode {
  79072. /**
  79073. * Points
  79074. */
  79075. POINTS = 0,
  79076. /**
  79077. * Lines
  79078. */
  79079. LINES = 1,
  79080. /**
  79081. * Line Loop
  79082. */
  79083. LINE_LOOP = 2,
  79084. /**
  79085. * Line Strip
  79086. */
  79087. LINE_STRIP = 3,
  79088. /**
  79089. * Triangles
  79090. */
  79091. TRIANGLES = 4,
  79092. /**
  79093. * Triangle Strip
  79094. */
  79095. TRIANGLE_STRIP = 5,
  79096. /**
  79097. * Triangle Fan
  79098. */
  79099. TRIANGLE_FAN = 6,
  79100. }
  79101. /**
  79102. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79103. */
  79104. const enum TextureMagFilter {
  79105. /**
  79106. * Nearest
  79107. */
  79108. NEAREST = 9728,
  79109. /**
  79110. * Linear
  79111. */
  79112. LINEAR = 9729,
  79113. }
  79114. /**
  79115. * Minification filter. All valid values correspond to WebGL enums
  79116. */
  79117. const enum TextureMinFilter {
  79118. /**
  79119. * Nearest
  79120. */
  79121. NEAREST = 9728,
  79122. /**
  79123. * Linear
  79124. */
  79125. LINEAR = 9729,
  79126. /**
  79127. * Nearest Mip-Map Nearest
  79128. */
  79129. NEAREST_MIPMAP_NEAREST = 9984,
  79130. /**
  79131. * Linear Mipmap Nearest
  79132. */
  79133. LINEAR_MIPMAP_NEAREST = 9985,
  79134. /**
  79135. * Nearest Mipmap Linear
  79136. */
  79137. NEAREST_MIPMAP_LINEAR = 9986,
  79138. /**
  79139. * Linear Mipmap Linear
  79140. */
  79141. LINEAR_MIPMAP_LINEAR = 9987,
  79142. }
  79143. /**
  79144. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79145. */
  79146. const enum TextureWrapMode {
  79147. /**
  79148. * Clamp to Edge
  79149. */
  79150. CLAMP_TO_EDGE = 33071,
  79151. /**
  79152. * Mirrored Repeat
  79153. */
  79154. MIRRORED_REPEAT = 33648,
  79155. /**
  79156. * Repeat
  79157. */
  79158. REPEAT = 10497,
  79159. }
  79160. /**
  79161. * glTF Property
  79162. */
  79163. interface IProperty {
  79164. /**
  79165. * Dictionary object with extension-specific objects
  79166. */
  79167. extensions?: {
  79168. [key: string]: any;
  79169. };
  79170. /**
  79171. * Application-Specific data
  79172. */
  79173. extras?: any;
  79174. }
  79175. /**
  79176. * glTF Child of Root Property
  79177. */
  79178. interface IChildRootProperty extends IProperty {
  79179. /**
  79180. * The user-defined name of this object
  79181. */
  79182. name?: string;
  79183. }
  79184. /**
  79185. * Indices of those attributes that deviate from their initialization value
  79186. */
  79187. interface IAccessorSparseIndices extends IProperty {
  79188. /**
  79189. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79190. */
  79191. bufferView: number;
  79192. /**
  79193. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79194. */
  79195. byteOffset?: number;
  79196. /**
  79197. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  79198. */
  79199. componentType: AccessorComponentType;
  79200. }
  79201. /**
  79202. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  79203. */
  79204. interface IAccessorSparseValues extends IProperty {
  79205. /**
  79206. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79207. */
  79208. bufferView: number;
  79209. /**
  79210. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79211. */
  79212. byteOffset?: number;
  79213. }
  79214. /**
  79215. * Sparse storage of attributes that deviate from their initialization value
  79216. */
  79217. interface IAccessorSparse extends IProperty {
  79218. /**
  79219. * The number of attributes encoded in this sparse accessor
  79220. */
  79221. count: number;
  79222. /**
  79223. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  79224. */
  79225. indices: IAccessorSparseIndices;
  79226. /**
  79227. * 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
  79228. */
  79229. values: IAccessorSparseValues;
  79230. }
  79231. /**
  79232. * 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
  79233. */
  79234. interface IAccessor extends IChildRootProperty {
  79235. /**
  79236. * The index of the bufferview
  79237. */
  79238. bufferView?: number;
  79239. /**
  79240. * The offset relative to the start of the bufferView in bytes
  79241. */
  79242. byteOffset?: number;
  79243. /**
  79244. * The datatype of components in the attribute
  79245. */
  79246. componentType: AccessorComponentType;
  79247. /**
  79248. * Specifies whether integer data values should be normalized
  79249. */
  79250. normalized?: boolean;
  79251. /**
  79252. * The number of attributes referenced by this accessor
  79253. */
  79254. count: number;
  79255. /**
  79256. * Specifies if the attribute is a scalar, vector, or matrix
  79257. */
  79258. type: AccessorType;
  79259. /**
  79260. * Maximum value of each component in this attribute
  79261. */
  79262. max?: number[];
  79263. /**
  79264. * Minimum value of each component in this attribute
  79265. */
  79266. min?: number[];
  79267. /**
  79268. * Sparse storage of attributes that deviate from their initialization value
  79269. */
  79270. sparse?: IAccessorSparse;
  79271. }
  79272. /**
  79273. * Targets an animation's sampler at a node's property
  79274. */
  79275. interface IAnimationChannel extends IProperty {
  79276. /**
  79277. * The index of a sampler in this animation used to compute the value for the target
  79278. */
  79279. sampler: number;
  79280. /**
  79281. * The index of the node and TRS property to target
  79282. */
  79283. target: IAnimationChannelTarget;
  79284. }
  79285. /**
  79286. * The index of the node and TRS property that an animation channel targets
  79287. */
  79288. interface IAnimationChannelTarget extends IProperty {
  79289. /**
  79290. * The index of the node to target
  79291. */
  79292. node: number;
  79293. /**
  79294. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79295. */
  79296. path: AnimationChannelTargetPath;
  79297. }
  79298. /**
  79299. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79300. */
  79301. interface IAnimationSampler extends IProperty {
  79302. /**
  79303. * The index of an accessor containing keyframe input values, e.g., time
  79304. */
  79305. input: number;
  79306. /**
  79307. * Interpolation algorithm
  79308. */
  79309. interpolation?: AnimationSamplerInterpolation;
  79310. /**
  79311. * The index of an accessor, containing keyframe output values
  79312. */
  79313. output: number;
  79314. }
  79315. /**
  79316. * A keyframe animation
  79317. */
  79318. interface IAnimation extends IChildRootProperty {
  79319. /**
  79320. * An array of channels, each of which targets an animation's sampler at a node's property
  79321. */
  79322. channels: IAnimationChannel[];
  79323. /**
  79324. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79325. */
  79326. samplers: IAnimationSampler[];
  79327. }
  79328. /**
  79329. * Metadata about the glTF asset
  79330. */
  79331. interface IAsset extends IChildRootProperty {
  79332. /**
  79333. * A copyright message suitable for display to credit the content creator
  79334. */
  79335. copyright?: string;
  79336. /**
  79337. * Tool that generated this glTF model. Useful for debugging
  79338. */
  79339. generator?: string;
  79340. /**
  79341. * The glTF version that this asset targets
  79342. */
  79343. version: string;
  79344. /**
  79345. * The minimum glTF version that this asset targets
  79346. */
  79347. minVersion?: string;
  79348. }
  79349. /**
  79350. * A buffer points to binary geometry, animation, or skins
  79351. */
  79352. interface IBuffer extends IChildRootProperty {
  79353. /**
  79354. * 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
  79355. */
  79356. uri?: string;
  79357. /**
  79358. * The length of the buffer in bytes
  79359. */
  79360. byteLength: number;
  79361. }
  79362. /**
  79363. * A view into a buffer generally representing a subset of the buffer
  79364. */
  79365. interface IBufferView extends IChildRootProperty {
  79366. /**
  79367. * The index of the buffer
  79368. */
  79369. buffer: number;
  79370. /**
  79371. * The offset into the buffer in bytes
  79372. */
  79373. byteOffset?: number;
  79374. /**
  79375. * The lenth of the bufferView in bytes
  79376. */
  79377. byteLength: number;
  79378. /**
  79379. * The stride, in bytes
  79380. */
  79381. byteStride?: number;
  79382. }
  79383. /**
  79384. * An orthographic camera containing properties to create an orthographic projection matrix
  79385. */
  79386. interface ICameraOrthographic extends IProperty {
  79387. /**
  79388. * The floating-point horizontal magnification of the view. Must not be zero
  79389. */
  79390. xmag: number;
  79391. /**
  79392. * The floating-point vertical magnification of the view. Must not be zero
  79393. */
  79394. ymag: number;
  79395. /**
  79396. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79397. */
  79398. zfar: number;
  79399. /**
  79400. * The floating-point distance to the near clipping plane
  79401. */
  79402. znear: number;
  79403. }
  79404. /**
  79405. * A perspective camera containing properties to create a perspective projection matrix
  79406. */
  79407. interface ICameraPerspective extends IProperty {
  79408. /**
  79409. * The floating-point aspect ratio of the field of view
  79410. */
  79411. aspectRatio?: number;
  79412. /**
  79413. * The floating-point vertical field of view in radians
  79414. */
  79415. yfov: number;
  79416. /**
  79417. * The floating-point distance to the far clipping plane
  79418. */
  79419. zfar?: number;
  79420. /**
  79421. * The floating-point distance to the near clipping plane
  79422. */
  79423. znear: number;
  79424. }
  79425. /**
  79426. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79427. */
  79428. interface ICamera extends IChildRootProperty {
  79429. /**
  79430. * An orthographic camera containing properties to create an orthographic projection matrix
  79431. */
  79432. orthographic?: ICameraOrthographic;
  79433. /**
  79434. * A perspective camera containing properties to create a perspective projection matrix
  79435. */
  79436. perspective?: ICameraPerspective;
  79437. /**
  79438. * Specifies if the camera uses a perspective or orthographic projection
  79439. */
  79440. type: CameraType;
  79441. }
  79442. /**
  79443. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79444. */
  79445. interface IImage extends IChildRootProperty {
  79446. /**
  79447. * 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
  79448. */
  79449. uri?: string;
  79450. /**
  79451. * The image's MIME type
  79452. */
  79453. mimeType?: ImageMimeType;
  79454. /**
  79455. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79456. */
  79457. bufferView?: number;
  79458. }
  79459. /**
  79460. * Material Normal Texture Info
  79461. */
  79462. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79463. /**
  79464. * The scalar multiplier applied to each normal vector of the normal texture
  79465. */
  79466. scale?: number;
  79467. }
  79468. /**
  79469. * Material Occlusion Texture Info
  79470. */
  79471. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79472. /**
  79473. * A scalar multiplier controlling the amount of occlusion applied
  79474. */
  79475. strength?: number;
  79476. }
  79477. /**
  79478. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79479. */
  79480. interface IMaterialPbrMetallicRoughness {
  79481. /**
  79482. * The material's base color factor
  79483. */
  79484. baseColorFactor?: number[];
  79485. /**
  79486. * The base color texture
  79487. */
  79488. baseColorTexture?: ITextureInfo;
  79489. /**
  79490. * The metalness of the material
  79491. */
  79492. metallicFactor?: number;
  79493. /**
  79494. * The roughness of the material
  79495. */
  79496. roughnessFactor?: number;
  79497. /**
  79498. * The metallic-roughness texture
  79499. */
  79500. metallicRoughnessTexture?: ITextureInfo;
  79501. }
  79502. /**
  79503. * The material appearance of a primitive
  79504. */
  79505. interface IMaterial extends IChildRootProperty {
  79506. /**
  79507. * 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
  79508. */
  79509. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79510. /**
  79511. * The normal map texture
  79512. */
  79513. normalTexture?: IMaterialNormalTextureInfo;
  79514. /**
  79515. * The occlusion map texture
  79516. */
  79517. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79518. /**
  79519. * The emissive map texture
  79520. */
  79521. emissiveTexture?: ITextureInfo;
  79522. /**
  79523. * 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
  79524. */
  79525. emissiveFactor?: number[];
  79526. /**
  79527. * The alpha rendering mode of the material
  79528. */
  79529. alphaMode?: MaterialAlphaMode;
  79530. /**
  79531. * The alpha cutoff value of the material
  79532. */
  79533. alphaCutoff?: number;
  79534. /**
  79535. * Specifies whether the material is double sided
  79536. */
  79537. doubleSided?: boolean;
  79538. }
  79539. /**
  79540. * Geometry to be rendered with the given material
  79541. */
  79542. interface IMeshPrimitive extends IProperty {
  79543. /**
  79544. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79545. */
  79546. attributes: {
  79547. [name: string]: number;
  79548. };
  79549. /**
  79550. * The index of the accessor that contains the indices
  79551. */
  79552. indices?: number;
  79553. /**
  79554. * The index of the material to apply to this primitive when rendering
  79555. */
  79556. material?: number;
  79557. /**
  79558. * The type of primitives to render. All valid values correspond to WebGL enums
  79559. */
  79560. mode?: MeshPrimitiveMode;
  79561. /**
  79562. * 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
  79563. */
  79564. targets?: {
  79565. [name: string]: number;
  79566. }[];
  79567. }
  79568. /**
  79569. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79570. */
  79571. interface IMesh extends IChildRootProperty {
  79572. /**
  79573. * An array of primitives, each defining geometry to be rendered with a material
  79574. */
  79575. primitives: IMeshPrimitive[];
  79576. /**
  79577. * Array of weights to be applied to the Morph Targets
  79578. */
  79579. weights?: number[];
  79580. }
  79581. /**
  79582. * A node in the node hierarchy
  79583. */
  79584. interface INode extends IChildRootProperty {
  79585. /**
  79586. * The index of the camera referenced by this node
  79587. */
  79588. camera?: number;
  79589. /**
  79590. * The indices of this node's children
  79591. */
  79592. children?: number[];
  79593. /**
  79594. * The index of the skin referenced by this node
  79595. */
  79596. skin?: number;
  79597. /**
  79598. * A floating-point 4x4 transformation matrix stored in column-major order
  79599. */
  79600. matrix?: number[];
  79601. /**
  79602. * The index of the mesh in this node
  79603. */
  79604. mesh?: number;
  79605. /**
  79606. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79607. */
  79608. rotation?: number[];
  79609. /**
  79610. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79611. */
  79612. scale?: number[];
  79613. /**
  79614. * The node's translation along the x, y, and z axes
  79615. */
  79616. translation?: number[];
  79617. /**
  79618. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79619. */
  79620. weights?: number[];
  79621. }
  79622. /**
  79623. * Texture sampler properties for filtering and wrapping modes
  79624. */
  79625. interface ISampler extends IChildRootProperty {
  79626. /**
  79627. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79628. */
  79629. magFilter?: TextureMagFilter;
  79630. /**
  79631. * Minification filter. All valid values correspond to WebGL enums
  79632. */
  79633. minFilter?: TextureMinFilter;
  79634. /**
  79635. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79636. */
  79637. wrapS?: TextureWrapMode;
  79638. /**
  79639. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79640. */
  79641. wrapT?: TextureWrapMode;
  79642. }
  79643. /**
  79644. * The root nodes of a scene
  79645. */
  79646. interface IScene extends IChildRootProperty {
  79647. /**
  79648. * The indices of each root node
  79649. */
  79650. nodes: number[];
  79651. }
  79652. /**
  79653. * Joints and matrices defining a skin
  79654. */
  79655. interface ISkin extends IChildRootProperty {
  79656. /**
  79657. * 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
  79658. */
  79659. inverseBindMatrices?: number;
  79660. /**
  79661. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79662. */
  79663. skeleton?: number;
  79664. /**
  79665. * 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)
  79666. */
  79667. joints: number[];
  79668. }
  79669. /**
  79670. * A texture and its sampler
  79671. */
  79672. interface ITexture extends IChildRootProperty {
  79673. /**
  79674. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79675. */
  79676. sampler?: number;
  79677. /**
  79678. * The index of the image used by this texture
  79679. */
  79680. source: number;
  79681. }
  79682. /**
  79683. * Reference to a texture
  79684. */
  79685. interface ITextureInfo extends IProperty {
  79686. /**
  79687. * The index of the texture
  79688. */
  79689. index: number;
  79690. /**
  79691. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79692. */
  79693. texCoord?: number;
  79694. }
  79695. /**
  79696. * The root object for a glTF asset
  79697. */
  79698. interface IGLTF extends IProperty {
  79699. /**
  79700. * An array of accessors. An accessor is a typed view into a bufferView
  79701. */
  79702. accessors?: IAccessor[];
  79703. /**
  79704. * An array of keyframe animations
  79705. */
  79706. animations?: IAnimation[];
  79707. /**
  79708. * Metadata about the glTF asset
  79709. */
  79710. asset: IAsset;
  79711. /**
  79712. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79713. */
  79714. buffers?: IBuffer[];
  79715. /**
  79716. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79717. */
  79718. bufferViews?: IBufferView[];
  79719. /**
  79720. * An array of cameras
  79721. */
  79722. cameras?: ICamera[];
  79723. /**
  79724. * Names of glTF extensions used somewhere in this asset
  79725. */
  79726. extensionsUsed?: string[];
  79727. /**
  79728. * Names of glTF extensions required to properly load this asset
  79729. */
  79730. extensionsRequired?: string[];
  79731. /**
  79732. * An array of images. An image defines data used to create a texture
  79733. */
  79734. images?: IImage[];
  79735. /**
  79736. * An array of materials. A material defines the appearance of a primitive
  79737. */
  79738. materials?: IMaterial[];
  79739. /**
  79740. * An array of meshes. A mesh is a set of primitives to be rendered
  79741. */
  79742. meshes?: IMesh[];
  79743. /**
  79744. * An array of nodes
  79745. */
  79746. nodes?: INode[];
  79747. /**
  79748. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79749. */
  79750. samplers?: ISampler[];
  79751. /**
  79752. * The index of the default scene
  79753. */
  79754. scene?: number;
  79755. /**
  79756. * An array of scenes
  79757. */
  79758. scenes?: IScene[];
  79759. /**
  79760. * An array of skins. A skin is defined by joints and matrices
  79761. */
  79762. skins?: ISkin[];
  79763. /**
  79764. * An array of textures
  79765. */
  79766. textures?: ITexture[];
  79767. }
  79768. /**
  79769. * The glTF validation results
  79770. * @ignore
  79771. */
  79772. interface IGLTFValidationResults {
  79773. info: {
  79774. generator: string;
  79775. hasAnimations: boolean;
  79776. hasDefaultScene: boolean;
  79777. hasMaterials: boolean;
  79778. hasMorphTargets: boolean;
  79779. hasSkins: boolean;
  79780. hasTextures: boolean;
  79781. maxAttributesUsed: number;
  79782. primitivesCount: number
  79783. };
  79784. issues: {
  79785. messages: Array<string>;
  79786. numErrors: number;
  79787. numHints: number;
  79788. numInfos: number;
  79789. numWarnings: number;
  79790. truncated: boolean
  79791. };
  79792. mimeType: string;
  79793. uri: string;
  79794. validatedAt: string;
  79795. validatorVersion: string;
  79796. }
  79797. /**
  79798. * The glTF validation options
  79799. */
  79800. interface IGLTFValidationOptions {
  79801. /** Uri to use */
  79802. uri?: string;
  79803. /** Function used to load external resources */
  79804. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79805. /** Boolean indicating that we need to validate accessor data */
  79806. validateAccessorData?: boolean;
  79807. /** max number of issues allowed */
  79808. maxIssues?: number;
  79809. /** Ignored issues */
  79810. ignoredIssues?: Array<string>;
  79811. /** Value to override severy settings */
  79812. severityOverrides?: Object;
  79813. }
  79814. /**
  79815. * The glTF validator object
  79816. * @ignore
  79817. */
  79818. interface IGLTFValidator {
  79819. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79820. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79821. }
  79822. }
  79823. declare module BABYLON {
  79824. /** @hidden */
  79825. export var cellPixelShader: {
  79826. name: string;
  79827. shader: string;
  79828. };
  79829. }
  79830. declare module BABYLON {
  79831. /** @hidden */
  79832. export var cellVertexShader: {
  79833. name: string;
  79834. shader: string;
  79835. };
  79836. }
  79837. declare module BABYLON {
  79838. export class CellMaterial extends BABYLON.PushMaterial {
  79839. private _diffuseTexture;
  79840. diffuseTexture: BABYLON.BaseTexture;
  79841. diffuseColor: BABYLON.Color3;
  79842. _computeHighLevel: boolean;
  79843. computeHighLevel: boolean;
  79844. private _disableLighting;
  79845. disableLighting: boolean;
  79846. private _maxSimultaneousLights;
  79847. maxSimultaneousLights: number;
  79848. constructor(name: string, scene: BABYLON.Scene);
  79849. needAlphaBlending(): boolean;
  79850. needAlphaTesting(): boolean;
  79851. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79852. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79853. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79854. getAnimatables(): BABYLON.IAnimatable[];
  79855. getActiveTextures(): BABYLON.BaseTexture[];
  79856. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79857. dispose(forceDisposeEffect?: boolean): void;
  79858. getClassName(): string;
  79859. clone(name: string): CellMaterial;
  79860. serialize(): any;
  79861. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79862. }
  79863. }
  79864. declare module BABYLON {
  79865. export class CustomShaderStructure {
  79866. FragmentStore: string;
  79867. VertexStore: string;
  79868. constructor();
  79869. }
  79870. export class ShaderSpecialParts {
  79871. constructor();
  79872. Fragment_Begin: string;
  79873. Fragment_Definitions: string;
  79874. Fragment_MainBegin: string;
  79875. Fragment_Custom_Diffuse: string;
  79876. Fragment_Before_Lights: string;
  79877. Fragment_Before_Fog: string;
  79878. Fragment_Custom_Alpha: string;
  79879. Fragment_Before_FragColor: string;
  79880. Vertex_Begin: string;
  79881. Vertex_Definitions: string;
  79882. Vertex_MainBegin: string;
  79883. Vertex_Before_PositionUpdated: string;
  79884. Vertex_Before_NormalUpdated: string;
  79885. Vertex_After_WorldPosComputed: string;
  79886. Vertex_MainEnd: string;
  79887. }
  79888. export class CustomMaterial extends BABYLON.StandardMaterial {
  79889. static ShaderIndexer: number;
  79890. CustomParts: ShaderSpecialParts;
  79891. _isCreatedShader: boolean;
  79892. _createdShaderName: string;
  79893. _customUniform: string[];
  79894. _newUniforms: string[];
  79895. _newUniformInstances: {
  79896. [name: string]: any;
  79897. };
  79898. _newSamplerInstances: {
  79899. [name: string]: BABYLON.Texture;
  79900. };
  79901. _customAttributes: string[];
  79902. FragmentShader: string;
  79903. VertexShader: string;
  79904. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79905. ReviewUniform(name: string, arr: string[]): string[];
  79906. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79907. constructor(name: string, scene: BABYLON.Scene);
  79908. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79909. AddAttribute(name: string): CustomMaterial;
  79910. Fragment_Begin(shaderPart: string): CustomMaterial;
  79911. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79912. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79913. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79914. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79915. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79916. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79917. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79918. Vertex_Begin(shaderPart: string): CustomMaterial;
  79919. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79920. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79921. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79922. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79923. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  79924. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79925. }
  79926. }
  79927. declare module BABYLON {
  79928. export class ShaderAlebdoParts {
  79929. constructor();
  79930. Fragment_Begin: string;
  79931. Fragment_Definitions: string;
  79932. Fragment_MainBegin: string;
  79933. Fragment_Custom_Albedo: string;
  79934. Fragment_Before_Lights: string;
  79935. Fragment_Custom_MetallicRoughness: string;
  79936. Fragment_Custom_MicroSurface: string;
  79937. Fragment_Before_Fog: string;
  79938. Fragment_Custom_Alpha: string;
  79939. Fragment_Before_FragColor: string;
  79940. Vertex_Begin: string;
  79941. Vertex_Definitions: string;
  79942. Vertex_MainBegin: string;
  79943. Vertex_Before_PositionUpdated: string;
  79944. Vertex_Before_NormalUpdated: string;
  79945. Vertex_After_WorldPosComputed: string;
  79946. Vertex_MainEnd: string;
  79947. }
  79948. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79949. static ShaderIndexer: number;
  79950. CustomParts: ShaderAlebdoParts;
  79951. _isCreatedShader: boolean;
  79952. _createdShaderName: string;
  79953. _customUniform: string[];
  79954. _newUniforms: string[];
  79955. _newUniformInstances: {
  79956. [name: string]: any;
  79957. };
  79958. _newSamplerInstances: {
  79959. [name: string]: BABYLON.Texture;
  79960. };
  79961. _customAttributes: string[];
  79962. FragmentShader: string;
  79963. VertexShader: string;
  79964. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79965. ReviewUniform(name: string, arr: string[]): string[];
  79966. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79967. constructor(name: string, scene: BABYLON.Scene);
  79968. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79969. AddAttribute(name: string): PBRCustomMaterial;
  79970. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79971. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79972. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79973. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79974. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79975. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79976. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79977. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79978. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79979. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79980. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79981. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79982. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79983. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79984. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79985. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  79986. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79987. }
  79988. }
  79989. declare module BABYLON {
  79990. /** @hidden */
  79991. export var firePixelShader: {
  79992. name: string;
  79993. shader: string;
  79994. };
  79995. }
  79996. declare module BABYLON {
  79997. /** @hidden */
  79998. export var fireVertexShader: {
  79999. name: string;
  80000. shader: string;
  80001. };
  80002. }
  80003. declare module BABYLON {
  80004. export class FireMaterial extends BABYLON.PushMaterial {
  80005. private _diffuseTexture;
  80006. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80007. private _distortionTexture;
  80008. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80009. private _opacityTexture;
  80010. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80011. diffuseColor: BABYLON.Color3;
  80012. speed: number;
  80013. private _scaledDiffuse;
  80014. private _lastTime;
  80015. constructor(name: string, scene: BABYLON.Scene);
  80016. needAlphaBlending(): boolean;
  80017. needAlphaTesting(): boolean;
  80018. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80019. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80020. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80021. getAnimatables(): BABYLON.IAnimatable[];
  80022. getActiveTextures(): BABYLON.BaseTexture[];
  80023. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80024. getClassName(): string;
  80025. dispose(forceDisposeEffect?: boolean): void;
  80026. clone(name: string): FireMaterial;
  80027. serialize(): any;
  80028. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  80029. }
  80030. }
  80031. declare module BABYLON {
  80032. /** @hidden */
  80033. export var furPixelShader: {
  80034. name: string;
  80035. shader: string;
  80036. };
  80037. }
  80038. declare module BABYLON {
  80039. /** @hidden */
  80040. export var furVertexShader: {
  80041. name: string;
  80042. shader: string;
  80043. };
  80044. }
  80045. declare module BABYLON {
  80046. export class FurMaterial extends BABYLON.PushMaterial {
  80047. private _diffuseTexture;
  80048. diffuseTexture: BABYLON.BaseTexture;
  80049. private _heightTexture;
  80050. heightTexture: BABYLON.BaseTexture;
  80051. diffuseColor: BABYLON.Color3;
  80052. furLength: number;
  80053. furAngle: number;
  80054. furColor: BABYLON.Color3;
  80055. furOffset: number;
  80056. furSpacing: number;
  80057. furGravity: BABYLON.Vector3;
  80058. furSpeed: number;
  80059. furDensity: number;
  80060. furOcclusion: number;
  80061. furTexture: BABYLON.DynamicTexture;
  80062. private _disableLighting;
  80063. disableLighting: boolean;
  80064. private _maxSimultaneousLights;
  80065. maxSimultaneousLights: number;
  80066. highLevelFur: boolean;
  80067. _meshes: BABYLON.AbstractMesh[];
  80068. private _furTime;
  80069. constructor(name: string, scene: BABYLON.Scene);
  80070. get furTime(): number;
  80071. set furTime(furTime: number);
  80072. needAlphaBlending(): boolean;
  80073. needAlphaTesting(): boolean;
  80074. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80075. updateFur(): void;
  80076. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80077. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80078. getAnimatables(): BABYLON.IAnimatable[];
  80079. getActiveTextures(): BABYLON.BaseTexture[];
  80080. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80081. dispose(forceDisposeEffect?: boolean): void;
  80082. clone(name: string): FurMaterial;
  80083. serialize(): any;
  80084. getClassName(): string;
  80085. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  80086. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  80087. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  80088. }
  80089. }
  80090. declare module BABYLON {
  80091. /** @hidden */
  80092. export var gradientPixelShader: {
  80093. name: string;
  80094. shader: string;
  80095. };
  80096. }
  80097. declare module BABYLON {
  80098. /** @hidden */
  80099. export var gradientVertexShader: {
  80100. name: string;
  80101. shader: string;
  80102. };
  80103. }
  80104. declare module BABYLON {
  80105. export class GradientMaterial extends BABYLON.PushMaterial {
  80106. private _maxSimultaneousLights;
  80107. maxSimultaneousLights: number;
  80108. topColor: BABYLON.Color3;
  80109. topColorAlpha: number;
  80110. bottomColor: BABYLON.Color3;
  80111. bottomColorAlpha: number;
  80112. offset: number;
  80113. scale: number;
  80114. smoothness: number;
  80115. private _disableLighting;
  80116. disableLighting: boolean;
  80117. constructor(name: string, scene: BABYLON.Scene);
  80118. needAlphaBlending(): boolean;
  80119. needAlphaTesting(): boolean;
  80120. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80121. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80122. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80123. getAnimatables(): BABYLON.IAnimatable[];
  80124. dispose(forceDisposeEffect?: boolean): void;
  80125. clone(name: string): GradientMaterial;
  80126. serialize(): any;
  80127. getClassName(): string;
  80128. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  80129. }
  80130. }
  80131. declare module BABYLON {
  80132. /** @hidden */
  80133. export var gridPixelShader: {
  80134. name: string;
  80135. shader: string;
  80136. };
  80137. }
  80138. declare module BABYLON {
  80139. /** @hidden */
  80140. export var gridVertexShader: {
  80141. name: string;
  80142. shader: string;
  80143. };
  80144. }
  80145. declare module BABYLON {
  80146. /**
  80147. * The grid materials allows you to wrap any shape with a grid.
  80148. * Colors are customizable.
  80149. */
  80150. export class GridMaterial extends BABYLON.PushMaterial {
  80151. /**
  80152. * Main color of the grid (e.g. between lines)
  80153. */
  80154. mainColor: BABYLON.Color3;
  80155. /**
  80156. * Color of the grid lines.
  80157. */
  80158. lineColor: BABYLON.Color3;
  80159. /**
  80160. * The scale of the grid compared to unit.
  80161. */
  80162. gridRatio: number;
  80163. /**
  80164. * Allows setting an offset for the grid lines.
  80165. */
  80166. gridOffset: BABYLON.Vector3;
  80167. /**
  80168. * The frequency of thicker lines.
  80169. */
  80170. majorUnitFrequency: number;
  80171. /**
  80172. * The visibility of minor units in the grid.
  80173. */
  80174. minorUnitVisibility: number;
  80175. /**
  80176. * The grid opacity outside of the lines.
  80177. */
  80178. opacity: number;
  80179. /**
  80180. * Determine RBG output is premultiplied by alpha value.
  80181. */
  80182. preMultiplyAlpha: boolean;
  80183. private _opacityTexture;
  80184. opacityTexture: BABYLON.BaseTexture;
  80185. private _gridControl;
  80186. /**
  80187. * constructor
  80188. * @param name The name given to the material in order to identify it afterwards.
  80189. * @param scene The scene the material is used in.
  80190. */
  80191. constructor(name: string, scene: BABYLON.Scene);
  80192. /**
  80193. * Returns wehter or not the grid requires alpha blending.
  80194. */
  80195. needAlphaBlending(): boolean;
  80196. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80197. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80198. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80199. /**
  80200. * Dispose the material and its associated resources.
  80201. * @param forceDisposeEffect will also dispose the used effect when true
  80202. */
  80203. dispose(forceDisposeEffect?: boolean): void;
  80204. clone(name: string): GridMaterial;
  80205. serialize(): any;
  80206. getClassName(): string;
  80207. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  80208. }
  80209. }
  80210. declare module BABYLON {
  80211. /** @hidden */
  80212. export var lavaPixelShader: {
  80213. name: string;
  80214. shader: string;
  80215. };
  80216. }
  80217. declare module BABYLON {
  80218. /** @hidden */
  80219. export var lavaVertexShader: {
  80220. name: string;
  80221. shader: string;
  80222. };
  80223. }
  80224. declare module BABYLON {
  80225. export class LavaMaterial extends BABYLON.PushMaterial {
  80226. private _diffuseTexture;
  80227. diffuseTexture: BABYLON.BaseTexture;
  80228. noiseTexture: BABYLON.BaseTexture;
  80229. fogColor: BABYLON.Color3;
  80230. speed: number;
  80231. movingSpeed: number;
  80232. lowFrequencySpeed: number;
  80233. fogDensity: number;
  80234. private _lastTime;
  80235. diffuseColor: BABYLON.Color3;
  80236. private _disableLighting;
  80237. disableLighting: boolean;
  80238. private _unlit;
  80239. unlit: boolean;
  80240. private _maxSimultaneousLights;
  80241. maxSimultaneousLights: number;
  80242. private _scaledDiffuse;
  80243. constructor(name: string, scene: BABYLON.Scene);
  80244. needAlphaBlending(): boolean;
  80245. needAlphaTesting(): boolean;
  80246. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80247. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80248. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80249. getAnimatables(): BABYLON.IAnimatable[];
  80250. getActiveTextures(): BABYLON.BaseTexture[];
  80251. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80252. dispose(forceDisposeEffect?: boolean): void;
  80253. clone(name: string): LavaMaterial;
  80254. serialize(): any;
  80255. getClassName(): string;
  80256. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80257. }
  80258. }
  80259. declare module BABYLON {
  80260. /** @hidden */
  80261. export var mixPixelShader: {
  80262. name: string;
  80263. shader: string;
  80264. };
  80265. }
  80266. declare module BABYLON {
  80267. /** @hidden */
  80268. export var mixVertexShader: {
  80269. name: string;
  80270. shader: string;
  80271. };
  80272. }
  80273. declare module BABYLON {
  80274. export class MixMaterial extends BABYLON.PushMaterial {
  80275. /**
  80276. * Mix textures
  80277. */
  80278. private _mixTexture1;
  80279. mixTexture1: BABYLON.BaseTexture;
  80280. private _mixTexture2;
  80281. mixTexture2: BABYLON.BaseTexture;
  80282. /**
  80283. * Diffuse textures
  80284. */
  80285. private _diffuseTexture1;
  80286. diffuseTexture1: BABYLON.Texture;
  80287. private _diffuseTexture2;
  80288. diffuseTexture2: BABYLON.Texture;
  80289. private _diffuseTexture3;
  80290. diffuseTexture3: BABYLON.Texture;
  80291. private _diffuseTexture4;
  80292. diffuseTexture4: BABYLON.Texture;
  80293. private _diffuseTexture5;
  80294. diffuseTexture5: BABYLON.Texture;
  80295. private _diffuseTexture6;
  80296. diffuseTexture6: BABYLON.Texture;
  80297. private _diffuseTexture7;
  80298. diffuseTexture7: BABYLON.Texture;
  80299. private _diffuseTexture8;
  80300. diffuseTexture8: BABYLON.Texture;
  80301. /**
  80302. * Uniforms
  80303. */
  80304. diffuseColor: BABYLON.Color3;
  80305. specularColor: BABYLON.Color3;
  80306. specularPower: number;
  80307. private _disableLighting;
  80308. disableLighting: boolean;
  80309. private _maxSimultaneousLights;
  80310. maxSimultaneousLights: number;
  80311. constructor(name: string, scene: BABYLON.Scene);
  80312. needAlphaBlending(): boolean;
  80313. needAlphaTesting(): boolean;
  80314. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80315. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80316. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80317. getAnimatables(): BABYLON.IAnimatable[];
  80318. getActiveTextures(): BABYLON.BaseTexture[];
  80319. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80320. dispose(forceDisposeEffect?: boolean): void;
  80321. clone(name: string): MixMaterial;
  80322. serialize(): any;
  80323. getClassName(): string;
  80324. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80325. }
  80326. }
  80327. declare module BABYLON {
  80328. /** @hidden */
  80329. export var normalPixelShader: {
  80330. name: string;
  80331. shader: string;
  80332. };
  80333. }
  80334. declare module BABYLON {
  80335. /** @hidden */
  80336. export var normalVertexShader: {
  80337. name: string;
  80338. shader: string;
  80339. };
  80340. }
  80341. declare module BABYLON {
  80342. export class NormalMaterial extends BABYLON.PushMaterial {
  80343. private _diffuseTexture;
  80344. diffuseTexture: BABYLON.BaseTexture;
  80345. diffuseColor: BABYLON.Color3;
  80346. private _disableLighting;
  80347. disableLighting: boolean;
  80348. private _maxSimultaneousLights;
  80349. maxSimultaneousLights: number;
  80350. constructor(name: string, scene: BABYLON.Scene);
  80351. needAlphaBlending(): boolean;
  80352. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80353. needAlphaTesting(): boolean;
  80354. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80355. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80356. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80357. getAnimatables(): BABYLON.IAnimatable[];
  80358. getActiveTextures(): BABYLON.BaseTexture[];
  80359. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80360. dispose(forceDisposeEffect?: boolean): void;
  80361. clone(name: string): NormalMaterial;
  80362. serialize(): any;
  80363. getClassName(): string;
  80364. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80365. }
  80366. }
  80367. declare module BABYLON {
  80368. /** @hidden */
  80369. export var shadowOnlyPixelShader: {
  80370. name: string;
  80371. shader: string;
  80372. };
  80373. }
  80374. declare module BABYLON {
  80375. /** @hidden */
  80376. export var shadowOnlyVertexShader: {
  80377. name: string;
  80378. shader: string;
  80379. };
  80380. }
  80381. declare module BABYLON {
  80382. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80383. private _activeLight;
  80384. constructor(name: string, scene: BABYLON.Scene);
  80385. shadowColor: BABYLON.Color3;
  80386. needAlphaBlending(): boolean;
  80387. needAlphaTesting(): boolean;
  80388. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80389. get activeLight(): BABYLON.IShadowLight;
  80390. set activeLight(light: BABYLON.IShadowLight);
  80391. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80392. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80393. clone(name: string): ShadowOnlyMaterial;
  80394. serialize(): any;
  80395. getClassName(): string;
  80396. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80397. }
  80398. }
  80399. declare module BABYLON {
  80400. /** @hidden */
  80401. export var simplePixelShader: {
  80402. name: string;
  80403. shader: string;
  80404. };
  80405. }
  80406. declare module BABYLON {
  80407. /** @hidden */
  80408. export var simpleVertexShader: {
  80409. name: string;
  80410. shader: string;
  80411. };
  80412. }
  80413. declare module BABYLON {
  80414. export class SimpleMaterial extends BABYLON.PushMaterial {
  80415. private _diffuseTexture;
  80416. diffuseTexture: BABYLON.BaseTexture;
  80417. diffuseColor: BABYLON.Color3;
  80418. private _disableLighting;
  80419. disableLighting: boolean;
  80420. private _maxSimultaneousLights;
  80421. maxSimultaneousLights: number;
  80422. constructor(name: string, scene: BABYLON.Scene);
  80423. needAlphaBlending(): boolean;
  80424. needAlphaTesting(): boolean;
  80425. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80426. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80427. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80428. getAnimatables(): BABYLON.IAnimatable[];
  80429. getActiveTextures(): BABYLON.BaseTexture[];
  80430. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80431. dispose(forceDisposeEffect?: boolean): void;
  80432. clone(name: string): SimpleMaterial;
  80433. serialize(): any;
  80434. getClassName(): string;
  80435. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80436. }
  80437. }
  80438. declare module BABYLON {
  80439. /** @hidden */
  80440. export var skyPixelShader: {
  80441. name: string;
  80442. shader: string;
  80443. };
  80444. }
  80445. declare module BABYLON {
  80446. /** @hidden */
  80447. export var skyVertexShader: {
  80448. name: string;
  80449. shader: string;
  80450. };
  80451. }
  80452. declare module BABYLON {
  80453. /**
  80454. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80455. * @see https://doc.babylonjs.com/extensions/sky
  80456. */
  80457. export class SkyMaterial extends BABYLON.PushMaterial {
  80458. /**
  80459. * Defines the overall luminance of sky in interval ]0, 1[.
  80460. */
  80461. luminance: number;
  80462. /**
  80463. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80464. */
  80465. turbidity: number;
  80466. /**
  80467. * Defines the sky appearance (light intensity).
  80468. */
  80469. rayleigh: number;
  80470. /**
  80471. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80472. */
  80473. mieCoefficient: number;
  80474. /**
  80475. * Defines the amount of haze particles following the Mie scattering theory.
  80476. */
  80477. mieDirectionalG: number;
  80478. /**
  80479. * Defines the distance of the sun according to the active scene camera.
  80480. */
  80481. distance: number;
  80482. /**
  80483. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80484. * "inclined".
  80485. */
  80486. inclination: number;
  80487. /**
  80488. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80489. * an object direction and a reference direction.
  80490. */
  80491. azimuth: number;
  80492. /**
  80493. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80494. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80495. */
  80496. sunPosition: BABYLON.Vector3;
  80497. /**
  80498. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80499. * .sunPosition property.
  80500. */
  80501. useSunPosition: boolean;
  80502. /**
  80503. * Defines an offset vector used to get a horizon offset.
  80504. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80505. */
  80506. cameraOffset: BABYLON.Vector3;
  80507. private _cameraPosition;
  80508. /**
  80509. * Instantiates a new sky material.
  80510. * This material allows to create dynamic and texture free
  80511. * effects for skyboxes by taking care of the atmosphere state.
  80512. * @see https://doc.babylonjs.com/extensions/sky
  80513. * @param name Define the name of the material in the scene
  80514. * @param scene Define the scene the material belong to
  80515. */
  80516. constructor(name: string, scene: BABYLON.Scene);
  80517. /**
  80518. * Specifies if the material will require alpha blending
  80519. * @returns a boolean specifying if alpha blending is needed
  80520. */
  80521. needAlphaBlending(): boolean;
  80522. /**
  80523. * Specifies if this material should be rendered in alpha test mode
  80524. * @returns false as the sky material doesn't need alpha testing.
  80525. */
  80526. needAlphaTesting(): boolean;
  80527. /**
  80528. * Get the texture used for alpha test purpose.
  80529. * @returns null as the sky material has no texture.
  80530. */
  80531. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80532. /**
  80533. * Get if the submesh is ready to be used and all its information available.
  80534. * Child classes can use it to update shaders
  80535. * @param mesh defines the mesh to check
  80536. * @param subMesh defines which submesh to check
  80537. * @param useInstances specifies that instances should be used
  80538. * @returns a boolean indicating that the submesh is ready or not
  80539. */
  80540. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80541. /**
  80542. * Binds the submesh to this material by preparing the effect and shader to draw
  80543. * @param world defines the world transformation matrix
  80544. * @param mesh defines the mesh containing the submesh
  80545. * @param subMesh defines the submesh to bind the material to
  80546. */
  80547. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80548. /**
  80549. * Get the list of animatables in the material.
  80550. * @returns the list of animatables object used in the material
  80551. */
  80552. getAnimatables(): BABYLON.IAnimatable[];
  80553. /**
  80554. * Disposes the material
  80555. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80556. */
  80557. dispose(forceDisposeEffect?: boolean): void;
  80558. /**
  80559. * Makes a duplicate of the material, and gives it a new name
  80560. * @param name defines the new name for the duplicated material
  80561. * @returns the cloned material
  80562. */
  80563. clone(name: string): SkyMaterial;
  80564. /**
  80565. * Serializes this material in a JSON representation
  80566. * @returns the serialized material object
  80567. */
  80568. serialize(): any;
  80569. /**
  80570. * Gets the current class name of the material e.g. "SkyMaterial"
  80571. * Mainly use in serialization.
  80572. * @returns the class name
  80573. */
  80574. getClassName(): string;
  80575. /**
  80576. * Creates a sky material from parsed material data
  80577. * @param source defines the JSON representation of the material
  80578. * @param scene defines the hosting scene
  80579. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80580. * @returns a new sky material
  80581. */
  80582. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80583. }
  80584. }
  80585. declare module BABYLON {
  80586. /** @hidden */
  80587. export var terrainPixelShader: {
  80588. name: string;
  80589. shader: string;
  80590. };
  80591. }
  80592. declare module BABYLON {
  80593. /** @hidden */
  80594. export var terrainVertexShader: {
  80595. name: string;
  80596. shader: string;
  80597. };
  80598. }
  80599. declare module BABYLON {
  80600. export class TerrainMaterial extends BABYLON.PushMaterial {
  80601. private _mixTexture;
  80602. mixTexture: BABYLON.BaseTexture;
  80603. private _diffuseTexture1;
  80604. diffuseTexture1: BABYLON.Texture;
  80605. private _diffuseTexture2;
  80606. diffuseTexture2: BABYLON.Texture;
  80607. private _diffuseTexture3;
  80608. diffuseTexture3: BABYLON.Texture;
  80609. private _bumpTexture1;
  80610. bumpTexture1: BABYLON.Texture;
  80611. private _bumpTexture2;
  80612. bumpTexture2: BABYLON.Texture;
  80613. private _bumpTexture3;
  80614. bumpTexture3: BABYLON.Texture;
  80615. diffuseColor: BABYLON.Color3;
  80616. specularColor: BABYLON.Color3;
  80617. specularPower: number;
  80618. private _disableLighting;
  80619. disableLighting: boolean;
  80620. private _maxSimultaneousLights;
  80621. maxSimultaneousLights: number;
  80622. constructor(name: string, scene: BABYLON.Scene);
  80623. needAlphaBlending(): boolean;
  80624. needAlphaTesting(): boolean;
  80625. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80626. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80627. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80628. getAnimatables(): BABYLON.IAnimatable[];
  80629. getActiveTextures(): BABYLON.BaseTexture[];
  80630. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80631. dispose(forceDisposeEffect?: boolean): void;
  80632. clone(name: string): TerrainMaterial;
  80633. serialize(): any;
  80634. getClassName(): string;
  80635. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80636. }
  80637. }
  80638. declare module BABYLON {
  80639. /** @hidden */
  80640. export var triplanarPixelShader: {
  80641. name: string;
  80642. shader: string;
  80643. };
  80644. }
  80645. declare module BABYLON {
  80646. /** @hidden */
  80647. export var triplanarVertexShader: {
  80648. name: string;
  80649. shader: string;
  80650. };
  80651. }
  80652. declare module BABYLON {
  80653. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80654. mixTexture: BABYLON.BaseTexture;
  80655. private _diffuseTextureX;
  80656. diffuseTextureX: BABYLON.BaseTexture;
  80657. private _diffuseTextureY;
  80658. diffuseTextureY: BABYLON.BaseTexture;
  80659. private _diffuseTextureZ;
  80660. diffuseTextureZ: BABYLON.BaseTexture;
  80661. private _normalTextureX;
  80662. normalTextureX: BABYLON.BaseTexture;
  80663. private _normalTextureY;
  80664. normalTextureY: BABYLON.BaseTexture;
  80665. private _normalTextureZ;
  80666. normalTextureZ: BABYLON.BaseTexture;
  80667. tileSize: number;
  80668. diffuseColor: BABYLON.Color3;
  80669. specularColor: BABYLON.Color3;
  80670. specularPower: number;
  80671. private _disableLighting;
  80672. disableLighting: boolean;
  80673. private _maxSimultaneousLights;
  80674. maxSimultaneousLights: number;
  80675. constructor(name: string, scene: BABYLON.Scene);
  80676. needAlphaBlending(): boolean;
  80677. needAlphaTesting(): boolean;
  80678. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80679. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80680. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80681. getAnimatables(): BABYLON.IAnimatable[];
  80682. getActiveTextures(): BABYLON.BaseTexture[];
  80683. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80684. dispose(forceDisposeEffect?: boolean): void;
  80685. clone(name: string): TriPlanarMaterial;
  80686. serialize(): any;
  80687. getClassName(): string;
  80688. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80689. }
  80690. }
  80691. declare module BABYLON {
  80692. /** @hidden */
  80693. export var waterPixelShader: {
  80694. name: string;
  80695. shader: string;
  80696. };
  80697. }
  80698. declare module BABYLON {
  80699. /** @hidden */
  80700. export var waterVertexShader: {
  80701. name: string;
  80702. shader: string;
  80703. };
  80704. }
  80705. declare module BABYLON {
  80706. export class WaterMaterial extends BABYLON.PushMaterial {
  80707. renderTargetSize: BABYLON.Vector2;
  80708. private _bumpTexture;
  80709. bumpTexture: BABYLON.BaseTexture;
  80710. diffuseColor: BABYLON.Color3;
  80711. specularColor: BABYLON.Color3;
  80712. specularPower: number;
  80713. private _disableLighting;
  80714. disableLighting: boolean;
  80715. private _maxSimultaneousLights;
  80716. maxSimultaneousLights: number;
  80717. /**
  80718. * @param {number}: Represents the wind force
  80719. */
  80720. windForce: number;
  80721. /**
  80722. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80723. */
  80724. windDirection: BABYLON.Vector2;
  80725. /**
  80726. * @param {number}: Wave height, represents the height of the waves
  80727. */
  80728. waveHeight: number;
  80729. /**
  80730. * @param {number}: Bump height, represents the bump height related to the bump map
  80731. */
  80732. bumpHeight: number;
  80733. /**
  80734. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80735. */
  80736. private _bumpSuperimpose;
  80737. bumpSuperimpose: boolean;
  80738. /**
  80739. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80740. */
  80741. private _fresnelSeparate;
  80742. fresnelSeparate: boolean;
  80743. /**
  80744. * @param {boolean}: bump Waves modify the reflection.
  80745. */
  80746. private _bumpAffectsReflection;
  80747. bumpAffectsReflection: boolean;
  80748. /**
  80749. * @param {number}: The water color blended with the refraction (near)
  80750. */
  80751. waterColor: BABYLON.Color3;
  80752. /**
  80753. * @param {number}: The blend factor related to the water color
  80754. */
  80755. colorBlendFactor: number;
  80756. /**
  80757. * @param {number}: The water color blended with the reflection (far)
  80758. */
  80759. waterColor2: BABYLON.Color3;
  80760. /**
  80761. * @param {number}: The blend factor related to the water color (reflection, far)
  80762. */
  80763. colorBlendFactor2: number;
  80764. /**
  80765. * @param {number}: Represents the maximum length of a wave
  80766. */
  80767. waveLength: number;
  80768. /**
  80769. * @param {number}: Defines the waves speed
  80770. */
  80771. waveSpeed: number;
  80772. /**
  80773. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80774. * will avoid calculating useless pixels in the pixel shader of the water material.
  80775. */
  80776. disableClipPlane: boolean;
  80777. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80778. private _mesh;
  80779. private _refractionRTT;
  80780. private _reflectionRTT;
  80781. private _reflectionTransform;
  80782. private _lastTime;
  80783. private _lastDeltaTime;
  80784. private _useLogarithmicDepth;
  80785. private _waitingRenderList;
  80786. private _imageProcessingConfiguration;
  80787. private _imageProcessingObserver;
  80788. /**
  80789. * Gets a boolean indicating that current material needs to register RTT
  80790. */
  80791. get hasRenderTargetTextures(): boolean;
  80792. /**
  80793. * Constructor
  80794. */
  80795. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80796. get useLogarithmicDepth(): boolean;
  80797. set useLogarithmicDepth(value: boolean);
  80798. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80799. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80800. addToRenderList(node: any): void;
  80801. enableRenderTargets(enable: boolean): void;
  80802. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80803. get renderTargetsEnabled(): boolean;
  80804. needAlphaBlending(): boolean;
  80805. needAlphaTesting(): boolean;
  80806. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80807. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80808. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80809. private _createRenderTargets;
  80810. getAnimatables(): BABYLON.IAnimatable[];
  80811. getActiveTextures(): BABYLON.BaseTexture[];
  80812. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80813. dispose(forceDisposeEffect?: boolean): void;
  80814. clone(name: string): WaterMaterial;
  80815. serialize(): any;
  80816. getClassName(): string;
  80817. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80818. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80819. }
  80820. }
  80821. declare module BABYLON {
  80822. /** @hidden */
  80823. export var asciiartPixelShader: {
  80824. name: string;
  80825. shader: string;
  80826. };
  80827. }
  80828. declare module BABYLON {
  80829. /**
  80830. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80831. *
  80832. * It basically takes care rendering the font front the given font size to a texture.
  80833. * This is used later on in the postprocess.
  80834. */
  80835. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80836. private _font;
  80837. private _text;
  80838. private _charSize;
  80839. /**
  80840. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80841. */
  80842. get charSize(): number;
  80843. /**
  80844. * Create a new instance of the Ascii Art FontTexture class
  80845. * @param name the name of the texture
  80846. * @param font the font to use, use the W3C CSS notation
  80847. * @param text the caracter set to use in the rendering.
  80848. * @param scene the scene that owns the texture
  80849. */
  80850. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80851. /**
  80852. * Gets the max char width of a font.
  80853. * @param font the font to use, use the W3C CSS notation
  80854. * @return the max char width
  80855. */
  80856. private getFontWidth;
  80857. /**
  80858. * Gets the max char height of a font.
  80859. * @param font the font to use, use the W3C CSS notation
  80860. * @return the max char height
  80861. */
  80862. private getFontHeight;
  80863. /**
  80864. * Clones the current AsciiArtTexture.
  80865. * @return the clone of the texture.
  80866. */
  80867. clone(): AsciiArtFontTexture;
  80868. /**
  80869. * Parses a json object representing the texture and returns an instance of it.
  80870. * @param source the source JSON representation
  80871. * @param scene the scene to create the texture for
  80872. * @return the parsed texture
  80873. */
  80874. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80875. }
  80876. /**
  80877. * Option available in the Ascii Art Post Process.
  80878. */
  80879. export interface IAsciiArtPostProcessOptions {
  80880. /**
  80881. * The font to use following the w3c font definition.
  80882. */
  80883. font?: string;
  80884. /**
  80885. * The character set to use in the postprocess.
  80886. */
  80887. characterSet?: string;
  80888. /**
  80889. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80890. * This number is defined between 0 and 1;
  80891. */
  80892. mixToTile?: number;
  80893. /**
  80894. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80895. * This number is defined between 0 and 1;
  80896. */
  80897. mixToNormal?: number;
  80898. }
  80899. /**
  80900. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80901. *
  80902. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80903. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80904. */
  80905. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80906. /**
  80907. * The font texture used to render the char in the post process.
  80908. */
  80909. private _asciiArtFontTexture;
  80910. /**
  80911. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80912. * This number is defined between 0 and 1;
  80913. */
  80914. mixToTile: number;
  80915. /**
  80916. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80917. * This number is defined between 0 and 1;
  80918. */
  80919. mixToNormal: number;
  80920. /**
  80921. * Instantiates a new Ascii Art Post Process.
  80922. * @param name the name to give to the postprocess
  80923. * @camera the camera to apply the post process to.
  80924. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80925. */
  80926. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80927. }
  80928. }
  80929. declare module BABYLON {
  80930. /** @hidden */
  80931. export var digitalrainPixelShader: {
  80932. name: string;
  80933. shader: string;
  80934. };
  80935. }
  80936. declare module BABYLON {
  80937. /**
  80938. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80939. *
  80940. * It basically takes care rendering the font front the given font size to a texture.
  80941. * This is used later on in the postprocess.
  80942. */
  80943. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80944. private _font;
  80945. private _text;
  80946. private _charSize;
  80947. /**
  80948. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80949. */
  80950. get charSize(): number;
  80951. /**
  80952. * Create a new instance of the Digital Rain FontTexture class
  80953. * @param name the name of the texture
  80954. * @param font the font to use, use the W3C CSS notation
  80955. * @param text the caracter set to use in the rendering.
  80956. * @param scene the scene that owns the texture
  80957. */
  80958. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80959. /**
  80960. * Gets the max char width of a font.
  80961. * @param font the font to use, use the W3C CSS notation
  80962. * @return the max char width
  80963. */
  80964. private getFontWidth;
  80965. /**
  80966. * Gets the max char height of a font.
  80967. * @param font the font to use, use the W3C CSS notation
  80968. * @return the max char height
  80969. */
  80970. private getFontHeight;
  80971. /**
  80972. * Clones the current DigitalRainFontTexture.
  80973. * @return the clone of the texture.
  80974. */
  80975. clone(): DigitalRainFontTexture;
  80976. /**
  80977. * Parses a json object representing the texture and returns an instance of it.
  80978. * @param source the source JSON representation
  80979. * @param scene the scene to create the texture for
  80980. * @return the parsed texture
  80981. */
  80982. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80983. }
  80984. /**
  80985. * Option available in the Digital Rain Post Process.
  80986. */
  80987. export interface IDigitalRainPostProcessOptions {
  80988. /**
  80989. * The font to use following the w3c font definition.
  80990. */
  80991. font?: string;
  80992. /**
  80993. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80994. * This number is defined between 0 and 1;
  80995. */
  80996. mixToTile?: number;
  80997. /**
  80998. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80999. * This number is defined between 0 and 1;
  81000. */
  81001. mixToNormal?: number;
  81002. }
  81003. /**
  81004. * DigitalRainPostProcess helps rendering everithing in digital rain.
  81005. *
  81006. * Simmply add it to your scene and let the nerd that lives in you have fun.
  81007. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  81008. */
  81009. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  81010. /**
  81011. * The font texture used to render the char in the post process.
  81012. */
  81013. private _digitalRainFontTexture;
  81014. /**
  81015. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  81016. * This number is defined between 0 and 1;
  81017. */
  81018. mixToTile: number;
  81019. /**
  81020. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  81021. * This number is defined between 0 and 1;
  81022. */
  81023. mixToNormal: number;
  81024. /**
  81025. * Instantiates a new Digital Rain Post Process.
  81026. * @param name the name to give to the postprocess
  81027. * @camera the camera to apply the post process to.
  81028. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  81029. */
  81030. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  81031. }
  81032. }
  81033. declare module BABYLON {
  81034. /** @hidden */
  81035. export var brickProceduralTexturePixelShader: {
  81036. name: string;
  81037. shader: string;
  81038. };
  81039. }
  81040. declare module BABYLON {
  81041. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  81042. private _numberOfBricksHeight;
  81043. private _numberOfBricksWidth;
  81044. private _jointColor;
  81045. private _brickColor;
  81046. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81047. updateShaderUniforms(): void;
  81048. get numberOfBricksHeight(): number;
  81049. set numberOfBricksHeight(value: number);
  81050. get numberOfBricksWidth(): number;
  81051. set numberOfBricksWidth(value: number);
  81052. get jointColor(): BABYLON.Color3;
  81053. set jointColor(value: BABYLON.Color3);
  81054. get brickColor(): BABYLON.Color3;
  81055. set brickColor(value: BABYLON.Color3);
  81056. /**
  81057. * Serializes this brick procedural texture
  81058. * @returns a serialized brick procedural texture object
  81059. */
  81060. serialize(): any;
  81061. /**
  81062. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  81063. * @param parsedTexture defines parsed texture data
  81064. * @param scene defines the current scene
  81065. * @param rootUrl defines the root URL containing brick procedural texture information
  81066. * @returns a parsed Brick Procedural BABYLON.Texture
  81067. */
  81068. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  81069. }
  81070. }
  81071. declare module BABYLON {
  81072. /** @hidden */
  81073. export var cloudProceduralTexturePixelShader: {
  81074. name: string;
  81075. shader: string;
  81076. };
  81077. }
  81078. declare module BABYLON {
  81079. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  81080. private _skyColor;
  81081. private _cloudColor;
  81082. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81083. updateShaderUniforms(): void;
  81084. get skyColor(): BABYLON.Color4;
  81085. set skyColor(value: BABYLON.Color4);
  81086. get cloudColor(): BABYLON.Color4;
  81087. set cloudColor(value: BABYLON.Color4);
  81088. /**
  81089. * Serializes this cloud procedural texture
  81090. * @returns a serialized cloud procedural texture object
  81091. */
  81092. serialize(): any;
  81093. /**
  81094. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  81095. * @param parsedTexture defines parsed texture data
  81096. * @param scene defines the current scene
  81097. * @param rootUrl defines the root URL containing cloud procedural texture information
  81098. * @returns a parsed Cloud Procedural BABYLON.Texture
  81099. */
  81100. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  81101. }
  81102. }
  81103. declare module BABYLON {
  81104. /** @hidden */
  81105. export var fireProceduralTexturePixelShader: {
  81106. name: string;
  81107. shader: string;
  81108. };
  81109. }
  81110. declare module BABYLON {
  81111. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  81112. private _time;
  81113. private _speed;
  81114. private _autoGenerateTime;
  81115. private _fireColors;
  81116. private _alphaThreshold;
  81117. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81118. updateShaderUniforms(): void;
  81119. render(useCameraPostProcess?: boolean): void;
  81120. static get PurpleFireColors(): BABYLON.Color3[];
  81121. static get GreenFireColors(): BABYLON.Color3[];
  81122. static get RedFireColors(): BABYLON.Color3[];
  81123. static get BlueFireColors(): BABYLON.Color3[];
  81124. get autoGenerateTime(): boolean;
  81125. set autoGenerateTime(value: boolean);
  81126. get fireColors(): BABYLON.Color3[];
  81127. set fireColors(value: BABYLON.Color3[]);
  81128. get time(): number;
  81129. set time(value: number);
  81130. get speed(): BABYLON.Vector2;
  81131. set speed(value: BABYLON.Vector2);
  81132. get alphaThreshold(): number;
  81133. set alphaThreshold(value: number);
  81134. /**
  81135. * Serializes this fire procedural texture
  81136. * @returns a serialized fire procedural texture object
  81137. */
  81138. serialize(): any;
  81139. /**
  81140. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  81141. * @param parsedTexture defines parsed texture data
  81142. * @param scene defines the current scene
  81143. * @param rootUrl defines the root URL containing fire procedural texture information
  81144. * @returns a parsed Fire Procedural BABYLON.Texture
  81145. */
  81146. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  81147. }
  81148. }
  81149. declare module BABYLON {
  81150. /** @hidden */
  81151. export var grassProceduralTexturePixelShader: {
  81152. name: string;
  81153. shader: string;
  81154. };
  81155. }
  81156. declare module BABYLON {
  81157. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  81158. private _grassColors;
  81159. private _groundColor;
  81160. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81161. updateShaderUniforms(): void;
  81162. get grassColors(): BABYLON.Color3[];
  81163. set grassColors(value: BABYLON.Color3[]);
  81164. get groundColor(): BABYLON.Color3;
  81165. set groundColor(value: BABYLON.Color3);
  81166. /**
  81167. * Serializes this grass procedural texture
  81168. * @returns a serialized grass procedural texture object
  81169. */
  81170. serialize(): any;
  81171. /**
  81172. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  81173. * @param parsedTexture defines parsed texture data
  81174. * @param scene defines the current scene
  81175. * @param rootUrl defines the root URL containing grass procedural texture information
  81176. * @returns a parsed Grass Procedural BABYLON.Texture
  81177. */
  81178. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  81179. }
  81180. }
  81181. declare module BABYLON {
  81182. /** @hidden */
  81183. export var marbleProceduralTexturePixelShader: {
  81184. name: string;
  81185. shader: string;
  81186. };
  81187. }
  81188. declare module BABYLON {
  81189. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  81190. private _numberOfTilesHeight;
  81191. private _numberOfTilesWidth;
  81192. private _amplitude;
  81193. private _jointColor;
  81194. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81195. updateShaderUniforms(): void;
  81196. get numberOfTilesHeight(): number;
  81197. set numberOfTilesHeight(value: number);
  81198. get amplitude(): number;
  81199. set amplitude(value: number);
  81200. get numberOfTilesWidth(): number;
  81201. set numberOfTilesWidth(value: number);
  81202. get jointColor(): BABYLON.Color3;
  81203. set jointColor(value: BABYLON.Color3);
  81204. /**
  81205. * Serializes this marble procedural texture
  81206. * @returns a serialized marble procedural texture object
  81207. */
  81208. serialize(): any;
  81209. /**
  81210. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  81211. * @param parsedTexture defines parsed texture data
  81212. * @param scene defines the current scene
  81213. * @param rootUrl defines the root URL containing marble procedural texture information
  81214. * @returns a parsed Marble Procedural BABYLON.Texture
  81215. */
  81216. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  81217. }
  81218. }
  81219. declare module BABYLON {
  81220. /** @hidden */
  81221. export var normalMapProceduralTexturePixelShader: {
  81222. name: string;
  81223. shader: string;
  81224. };
  81225. }
  81226. declare module BABYLON {
  81227. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  81228. private _baseTexture;
  81229. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81230. updateShaderUniforms(): void;
  81231. render(useCameraPostProcess?: boolean): void;
  81232. resize(size: any, generateMipMaps: any): void;
  81233. get baseTexture(): BABYLON.Texture;
  81234. set baseTexture(texture: BABYLON.Texture);
  81235. /**
  81236. * Serializes this normal map procedural texture
  81237. * @returns a serialized normal map procedural texture object
  81238. */
  81239. serialize(): any;
  81240. /**
  81241. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  81242. * @param parsedTexture defines parsed texture data
  81243. * @param scene defines the current scene
  81244. * @param rootUrl defines the root URL containing normal map procedural texture information
  81245. * @returns a parsed Normal Map Procedural BABYLON.Texture
  81246. */
  81247. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  81248. }
  81249. }
  81250. declare module BABYLON {
  81251. /** @hidden */
  81252. export var perlinNoiseProceduralTexturePixelShader: {
  81253. name: string;
  81254. shader: string;
  81255. };
  81256. }
  81257. declare module BABYLON {
  81258. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81259. time: number;
  81260. timeScale: number;
  81261. translationSpeed: number;
  81262. private _currentTranslation;
  81263. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81264. updateShaderUniforms(): void;
  81265. render(useCameraPostProcess?: boolean): void;
  81266. resize(size: any, generateMipMaps: any): void;
  81267. /**
  81268. * Serializes this perlin noise procedural texture
  81269. * @returns a serialized perlin noise procedural texture object
  81270. */
  81271. serialize(): any;
  81272. /**
  81273. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81274. * @param parsedTexture defines parsed texture data
  81275. * @param scene defines the current scene
  81276. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81277. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81278. */
  81279. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81280. }
  81281. }
  81282. declare module BABYLON {
  81283. /** @hidden */
  81284. export var roadProceduralTexturePixelShader: {
  81285. name: string;
  81286. shader: string;
  81287. };
  81288. }
  81289. declare module BABYLON {
  81290. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81291. private _roadColor;
  81292. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81293. updateShaderUniforms(): void;
  81294. get roadColor(): BABYLON.Color3;
  81295. set roadColor(value: BABYLON.Color3);
  81296. /**
  81297. * Serializes this road procedural texture
  81298. * @returns a serialized road procedural texture object
  81299. */
  81300. serialize(): any;
  81301. /**
  81302. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81303. * @param parsedTexture defines parsed texture data
  81304. * @param scene defines the current scene
  81305. * @param rootUrl defines the root URL containing road procedural texture information
  81306. * @returns a parsed Road Procedural BABYLON.Texture
  81307. */
  81308. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81309. }
  81310. }
  81311. declare module BABYLON {
  81312. /** @hidden */
  81313. export var starfieldProceduralTexturePixelShader: {
  81314. name: string;
  81315. shader: string;
  81316. };
  81317. }
  81318. declare module BABYLON {
  81319. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81320. private _time;
  81321. private _alpha;
  81322. private _beta;
  81323. private _zoom;
  81324. private _formuparam;
  81325. private _stepsize;
  81326. private _tile;
  81327. private _brightness;
  81328. private _darkmatter;
  81329. private _distfading;
  81330. private _saturation;
  81331. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81332. updateShaderUniforms(): void;
  81333. get time(): number;
  81334. set time(value: number);
  81335. get alpha(): number;
  81336. set alpha(value: number);
  81337. get beta(): number;
  81338. set beta(value: number);
  81339. get formuparam(): number;
  81340. set formuparam(value: number);
  81341. get stepsize(): number;
  81342. set stepsize(value: number);
  81343. get zoom(): number;
  81344. set zoom(value: number);
  81345. get tile(): number;
  81346. set tile(value: number);
  81347. get brightness(): number;
  81348. set brightness(value: number);
  81349. get darkmatter(): number;
  81350. set darkmatter(value: number);
  81351. get distfading(): number;
  81352. set distfading(value: number);
  81353. get saturation(): number;
  81354. set saturation(value: number);
  81355. /**
  81356. * Serializes this starfield procedural texture
  81357. * @returns a serialized starfield procedural texture object
  81358. */
  81359. serialize(): any;
  81360. /**
  81361. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81362. * @param parsedTexture defines parsed texture data
  81363. * @param scene defines the current scene
  81364. * @param rootUrl defines the root URL containing startfield procedural texture information
  81365. * @returns a parsed Starfield Procedural BABYLON.Texture
  81366. */
  81367. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81368. }
  81369. }
  81370. declare module BABYLON {
  81371. /** @hidden */
  81372. export var woodProceduralTexturePixelShader: {
  81373. name: string;
  81374. shader: string;
  81375. };
  81376. }
  81377. declare module BABYLON {
  81378. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81379. private _ampScale;
  81380. private _woodColor;
  81381. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81382. updateShaderUniforms(): void;
  81383. get ampScale(): number;
  81384. set ampScale(value: number);
  81385. get woodColor(): BABYLON.Color3;
  81386. set woodColor(value: BABYLON.Color3);
  81387. /**
  81388. * Serializes this wood procedural texture
  81389. * @returns a serialized wood procedural texture object
  81390. */
  81391. serialize(): any;
  81392. /**
  81393. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81394. * @param parsedTexture defines parsed texture data
  81395. * @param scene defines the current scene
  81396. * @param rootUrl defines the root URL containing wood procedural texture information
  81397. * @returns a parsed Wood Procedural BABYLON.Texture
  81398. */
  81399. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81400. }
  81401. }